Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bugsnag event sent as an object for track call #2681

Merged
merged 6 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/v0/destinations/customerio/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ const defaultResponseBuilder = (message, evName, userId, evType, destination, me
// 100 - len(`Viewed Screen`) = 86
trimmedEvName = `Viewed ${truncate(message.event || message.properties.name, 86)} Screen`;
} else {
if (!evName) {
if (!evName || typeof evName !== 'string') {
logger.error(`Could not determine event name`);
throw new InstrumentationError(`Could not determine event name`);
}
Expand Down
4 changes: 2 additions & 2 deletions src/v0/destinations/freshsales/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ const identifyResponseBuilder = (message, { Config }) => {
* @returns
*/
const trackResponseBuilder = async (message, { Config }, event) => {
if (!event) {
throw new InstrumentationError('Event name is required for track call.');
if (!event || typeof event !== 'string') {
throw new InstrumentationError('String Event name is required for track call.');
}
let payload;

Expand Down
7 changes: 5 additions & 2 deletions src/v0/destinations/monday/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
const trackResponseBuilder = async (message, { Config }) => {
const { apiToken } = Config;
let boardId = getDestinationExternalID(message, 'boardId');
if (!message?.event || typeof message.event !== 'string') {
throw new InstrumentationError('Event name is required and it should be string');
}
if (!boardId) {
boardId = Config.boardId;
}
Expand All @@ -48,8 +51,8 @@
}
const event = get(message, 'event');

if (!event) {
throw new InstrumentationError('event is not present in the input payloads');
if (!event || typeof event !== 'string') {
throw new InstrumentationError('Event name is required and it should be string');

Check warning on line 55 in src/v0/destinations/monday/transform.js

View check run for this annotation

Codecov / codecov/patch

src/v0/destinations/monday/transform.js#L55

Added line #L55 was not covered by tests
}

if (!checkAllowedEventNameFromUI(event, Config)) {
Expand Down
2 changes: 1 addition & 1 deletion src/v0/destinations/monday/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ const checkAllowedEventNameFromUI = (event, Config) => {
let allowEvent;
if (whitelistedEvents && whitelistedEvents.length > 0) {
allowEvent = whitelistedEvents.some(
(whiteListedEvent) => whiteListedEvent.eventName.toLowerCase() === event.toLowerCase(),
(whiteListedEvent) => whiteListedEvent?.eventName?.toLowerCase() === event.toLowerCase(),
);
}
return !!allowEvent;
Expand Down
66 changes: 66 additions & 0 deletions test/__tests__/data/customerio_input.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,70 @@
[
{
"message": {
"type": "track",
"event": {
"Phone": "123456677",
"Lead ID": "abc",
"Lead URL": "https://simplisafe.com/admin/store/leads/19635101/view",
"firstName": "david tenenbaum",
"Pro Install": "Yes",
"Property Type": "Home",
"Last Lead Source": "uyfasauya ",
"Saved System URL": "ihguwivkbjc"
},
"userId": "",
"channel": "web",
"context": {
"os": {
"name": "",
"version": ""
},
"app": {
"name": "RudderLabs JavaScript SDK",
"version": "x.x.x",
"namespace": "com.rudderlabs.javascript"
},
"page": {
"path": "/rudderstack-sample-site/",
"title": "Keyboard Site",
"search": "",
"referrer": "$direct",
"initial_referrer": "$direct",
"referring_domain": "",
"initial_referring_domain": ""
},
"locale": "en-US",
"screen": {
"width": 1512,
"height": 982,
"density": 2,
"innerWidth": 347,
"innerHeight": 778
},
"traits": {
"name": "john ",
"lead_id": "abc",
"firstName": "doe "
},
"campaign": {},
"sessionId": 123456
},
"rudderId": "rudder_id",
"timestamp": "2022-12-03T18:37:57.755Z",
"properties": {},
"receivedAt": "2022-12-03T18:37:57.758Z",
"request_ip": "62.59.170.125",
"anonymousId": "149a7c9f-0778-45f6-b071-d92523cc8738",
"originalTimestamp": "2022-12-03T18:37:57.614Z"
},
"destination": {
"Config": {
"datacenter": "US",
"siteID": "46be54768e7d49ab2628",
"apiKey": "dummyApiKey"
}
}
},
{
"message": {
"channel": "web",
Expand Down
3 changes: 3 additions & 0 deletions test/__tests__/data/customerio_output.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[
{
"message": "Could not determine event name"
},
{
"body": {
"XML": {},
Expand Down
85 changes: 85 additions & 0 deletions test/__tests__/data/freshsales.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,89 @@
[
{
"description": "Track call, event is not supported.",
"input": {
"message": {
"channel": "web",
"context": {
"app": {
"build": "1.0.0",
"name": "RudderLabs JavaScript SDK",
"namespace": "com.rudderlabs.javascript",
"version": "1.1.5"
},
"traits": {
"name": "Shehan Study",
"category": "SampleIdentify",
"email": "[email protected]",
"plan": "Open source",
"logins": 5,
"createdAt": 1599264000
},
"library": {
"name": "RudderLabs JavaScript SDK",
"version": "1.1.5"
},
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36",
"locale": "en-US",
"os": {
"name": "",
"version": ""
},
"screen": {
"density": 0.8999999761581421
},
"campaign": {
"source": "google",
"medium": "medium",
"term": "keyword",
"content": "some content",
"name": "some campaign",
"test": "other value"
},
"page": {
"path": "/destinations/amplitude",
"referrer": "",
"search": "",
"title": "",
"url": "https://docs.rudderstack.com/destinations/amplitude",
"category": "destination",
"initial_referrer": "https://docs.rudderstack.com",
"initial_referring_domain": "docs.rudderstack.com"
}
},
"type": "track",
"messageId": "dd46338d-5f83-493b-bd28-3b48f55d0be8",
"originalTimestamp": "2020-10-20T08:14:28.778Z",
"anonymousId": "my-anonymous-id-new",
"userId": "newUserIdAlias",
"properties": {
"product_name": "Shirt",
"brand": "Wrogn"
},
"event": {
"name": "Add to Cart"
},
"previousId": "sampleusrRudder3",
"sentAt": "2020-10-20T08:14:28.778Z"
},
"destination": {
"Config": {
"apiKey": "dummyApiKey",
"domain": "domain-rudder"
}
}
},
"output": {
"statusCode": 400,
"error": "String Event name is required for track call.",
"statTags": {
"errorAt": "proc",
"destType": "FRESHMARKETER",
"stage": "transform",
"scope": "exception"
}
}
},
{
"description": "Identify call for creating new user",
"input": {
Expand Down
2 changes: 1 addition & 1 deletion test/__tests__/data/monday.json
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@
}
},
"output": {
"error": "event is not present in the input payloads"
"error": "Event name is required and it should be string"
}
},
{
Expand Down
Loading