diff --git a/src/v0/destinations/slack/transform.js b/src/v0/destinations/slack/transform.js index ee58b63dff..b56ebfbc48 100644 --- a/src/v0/destinations/slack/transform.js +++ b/src/v0/destinations/slack/transform.js @@ -16,25 +16,38 @@ const { defaultRequestConfig, getFieldValueFromMessage, simpleProcessRouterDest, + isDefinedAndNotNull, } = require('../../util'); const { InstrumentationError, ConfigurationError } = require('../../util/errorTypes'); // build the response to be sent to backend, url encoded header is required as slack accepts payload in this format // add the username and image for Rudder // image currently served from prod CDN -const buildResponse = (payloadJSON, message, destination) => { - const endpoint = destination.Config.webhookUrl; +const buildResponse = ( + payloadJSON, + message, + destination, + channelWebhook = null, + sendAppNameAndIcon = true, +) => { + const endpoint = channelWebhook || destination.Config.webhookUrl; const response = defaultRequestConfig(); response.endpoint = endpoint; response.method = defaultPostRequestConfig.requestMethod; response.headers = { 'Content-Type': 'application/x-www-form-urlencoded' }; response.userId = message.userId ? message.userId : message.anonymousId; + const payload = + sendAppNameAndIcon === true + ? JSON.stringify({ + ...payloadJSON, + username: SLACK_USER_NAME, + icon_url: SLACK_RUDDER_IMAGE_URL, + }) + : JSON.stringify({ + ...payloadJSON, + }); response.body.FORM = { - payload: JSON.stringify({ - ...payloadJSON, - username: SLACK_USER_NAME, - icon_url: SLACK_RUDDER_IMAGE_URL, - }), + payload, }; response.statusCode = 200; logger.debug(response); @@ -42,21 +55,15 @@ const buildResponse = (payloadJSON, message, destination) => { }; const processIdentify = (message, destination) => { - // debug(JSON.stringify(destination)); const identifyTemplateConfig = destination.Config.identifyTemplate; const traitsList = getWhiteListedTraits(destination); const defaultIdentifyTemplate = 'Identified {{name}}'; logger.debug('defaulTraitsList:: ', traitsList); const uName = getName(message); - // required traitlist ?? - /* if (!traitsList || traitsList.length == 0) { - throw Error("traits list in config not present"); - } */ - const template = Handlebars.compile( (identifyTemplateConfig - ? identifyTemplateConfig.trim().length === 0 + ? identifyTemplateConfig.trim()?.length === 0 ? undefined : identifyTemplateConfig : undefined) || @@ -69,7 +76,7 @@ const processIdentify = (message, destination) => { logger.debug( 'identifyTemplateConfig: ', (identifyTemplateConfig - ? identifyTemplateConfig.trim().length === 0 + ? identifyTemplateConfig.trim()?.length === 0 ? undefined : identifyTemplateConfig : undefined) || @@ -95,18 +102,40 @@ const processIdentify = (message, destination) => { return buildResponse({ text: resultText }, message, destination); }; -function buildChannelList(channelListToSendThisEvent, eventChannelConfig, eventName) { - eventChannelConfig.forEach((channelConfig) => { - const configEventName = channelConfig.eventName - ? channelConfig.eventName.trim().length > 0 - ? channelConfig.eventName - : undefined - : undefined; - const configEventChannel = channelConfig.eventChannel - ? channelConfig.eventChannel.trim().length > 0 - ? channelConfig.eventChannel - : undefined - : undefined; +const isEventNameMatchesRegex = (eventName, regex) => eventName.match(regex)?.length > 0; + +const getChannelForEventName = (eventChannelSettings, eventName) => { + for (const channelConfig of eventChannelSettings) { + const configEventName = + channelConfig?.eventName?.trim()?.length > 0 ? channelConfig.eventName : null; + const channelWebhook = + channelConfig?.eventChannelWebhook?.length > 0 ? channelConfig.eventChannelWebhook : null; + + if (configEventName && isDefinedAndNotNull(channelWebhook)) { + if (channelConfig.eventRegex) { + logger.debug('regex: ', `${configEventName} trying to match with ${eventName}`); + logger.debug( + 'match:: ', + configEventName, + eventName, + eventName.match(new RegExp(configEventName, 'g')), + ); + if (isEventNameMatchesRegex(eventName, new RegExp(configEventName, 'g'))) { + return channelWebhook; + } + } else if (channelConfig.eventName === eventName) { + return channelWebhook; + } + } + } + return null; +}; +const getChannelNameForEvent = (eventChannelSettings, eventName) => { + for (const channelConfig of eventChannelSettings) { + const configEventName = + channelConfig?.eventName?.trim()?.length > 0 ? channelConfig.eventName : null; + const configEventChannel = + channelConfig?.eventChannel?.trim()?.length > 0 ? channelConfig.eventChannel : null; if (configEventName && configEventChannel) { if (channelConfig.eventRegex) { logger.debug('regex: ', `${configEventName} trying to match with ${eventName}`); @@ -116,37 +145,29 @@ function buildChannelList(channelListToSendThisEvent, eventChannelConfig, eventN eventName, eventName.match(new RegExp(configEventName, 'g')), ); - if ( - eventName.match(new RegExp(configEventName, 'g')) && - eventName.match(new RegExp(configEventName, 'g')).length > 0 - ) { - channelListToSendThisEvent.add(configEventChannel); + if (isEventNameMatchesRegex(eventName, new RegExp(configEventName, 'g'))) { + return configEventChannel; } } else if (configEventName === eventName) { - channelListToSendThisEvent.add(configEventChannel); + return configEventChannel; } } - }); -} + } + return null; +}; -function buildtemplateList(templateListForThisEvent, eventTemplateConfig, eventName) { - eventTemplateConfig.forEach((templateConfig) => { - const configEventName = templateConfig.eventName - ? templateConfig.eventName.trim().length > 0 - ? templateConfig.eventName - : undefined - : undefined; +const buildtemplateList = (templateListForThisEvent, eventTemplateSettings, eventName) => { + eventTemplateSettings.forEach((templateConfig) => { + const configEventName = + templateConfig?.eventName?.trim()?.length > 0 ? templateConfig.eventName : undefined; const configEventTemplate = templateConfig.eventTemplate - ? templateConfig.eventTemplate.trim().length > 0 + ? templateConfig.eventTemplate.trim()?.length > 0 ? templateConfig.eventTemplate : undefined : undefined; if (configEventName && configEventTemplate) { if (templateConfig.eventRegex) { - if ( - eventName.match(new RegExp(configEventName, 'g')) && - eventName.match(new RegExp(configEventName, 'g')).length > 0 - ) { + if (isEventNameMatchesRegex(eventName, new RegExp(configEventName, 'g'))) { templateListForThisEvent.add(configEventTemplate); } } else if (configEventName === eventName) { @@ -154,32 +175,47 @@ function buildtemplateList(templateListForThisEvent, eventTemplateConfig, eventN } } }); -} +}; const processTrack = (message, destination) => { // logger.debug(JSON.stringify(destination)); - const eventChannelConfig = destination.Config.eventChannelSettings; - const eventTemplateConfig = destination.Config.eventTemplateSettings; + const { Config } = destination; + const { eventChannelSettings, eventTemplateSettings, incomingWebhooksType, blacklistedEvents } = + Config; + const eventName = message.event; - if (!message.event) { + if (!eventName) { throw new InstrumentationError('Event name is required'); } - const eventName = message.event; - const channelListToSendThisEvent = new Set(); + if (blacklistedEvents?.length > 0) { + const blackListedEvents = blacklistedEvents.map((item) => item.eventName); + if (blackListedEvents.includes(eventName)) { + throw new ConfigurationError('Event is blacklisted. Please check configuration.'); + } + } + const templateListForThisEvent = new Set(); const traitsList = getWhiteListedTraits(destination); - // Add global context to regex always - // build the channel list and templatelist for the event, pick the first in case of multiple - // using set to filter out - // document this behaviour + /* Add global context to regex always + * build the channel list and template list for the event, pick the first in case of multiple + * using set to filter out + * document this behaviour + */ - // building channel list - buildChannelList(channelListToSendThisEvent, eventChannelConfig, eventName); - const channelListArray = Array.from(channelListToSendThisEvent); + // getting specific channel for event if available + + let channelWebhook; + let channelName; + if (incomingWebhooksType && incomingWebhooksType === 'modern') { + channelWebhook = getChannelForEventName(eventChannelSettings, eventName); + } else { + // default + channelName = getChannelNameForEvent(eventChannelSettings, eventName); + } // building templatelist - buildtemplateList(templateListForThisEvent, eventTemplateConfig, eventName); + buildtemplateList(templateListForThisEvent, eventTemplateSettings, eventName); const templateListArray = Array.from(templateListForThisEvent); logger.debug( @@ -187,8 +223,6 @@ const processTrack = (message, destination) => { templateListArray, templateListArray.length > 0 ? templateListArray[0] : undefined, ); - logger.debug('channelListToSendThisEvent: ', channelListArray); - // track event default handlebar expression const defaultTemplate = '{{name}} did {{event}}'; const template = templateListArray @@ -219,9 +253,16 @@ const processTrack = (message, destination) => { } catch (err) { throw new ConfigurationError(`Something is wrong with the event template: '${template}'`); } - - if (channelListArray && channelListArray.length > 0) { - return buildResponse({ channel: channelListArray[0], text: resultText }, message, destination); + if (incomingWebhooksType === 'modern' && channelWebhook) { + return buildResponse({ text: resultText }, message, destination, channelWebhook, false); + } + if (channelName) { + return buildResponse( + { channel: channelName, text: resultText }, + message, + destination, + channelWebhook, + ); } return buildResponse({ text: resultText }, message, destination); }; diff --git a/src/v0/destinations/slack/util.js b/src/v0/destinations/slack/util.js index b327d1d867..658ffe4d37 100644 --- a/src/v0/destinations/slack/util.js +++ b/src/v0/destinations/slack/util.js @@ -72,8 +72,10 @@ const stringifyJSON = (json, whiteListedTraits) => { return output; }; -// build default identify template -// if whitelisted traits are present build on it else build the entire traits object +/* build default identify template + * if whitelisted traits are present build on it + * else build the entire traits object + */ const buildDefaultTraitTemplate = (traitsList, traits, template) => { let generatedStringFromTemplate = template; // build template with whitelisted traits diff --git a/test/__tests__/data/slack_input.json b/test/__tests__/data/slack_input.json index 4e6195a37d..9b1ec52664 100644 --- a/test/__tests__/data/slack_input.json +++ b/test/__tests__/data/slack_input.json @@ -7,17 +7,130 @@ "ID": "1ZQUiJVMlmF7lfsdfXg7KXQnlLV", "Name": "SLACK", "DisplayName": "Slack", - "Config": { "excludeKeys": [], "includeKeys": [] } + "Config": { + "excludeKeys": [], + "includeKeys": [] + } }, "Config": { "eventChannelSettings": [ { - "eventChannel": "#slack_integration", + "eventChannelWebhook": "https://hooks.slack.com/services/example/test/demo", "eventName": "is", "eventRegex": true + } + ], + "eventTemplateSettings": [ + { + "eventName": "is", + "eventRegex": true, + "eventTemplate": "{{name}} performed {{event}} with {{properties.key1}} {{properties.key2}}" + }, + { + "eventName": "", + "eventRegex": false, + "eventTemplate": "" + } + ], + "webhookUrl": "https://hooks.slack.com/services/THZM86VSS/BV9HZ2UN6/demo", + "whitelistedTraitsSettings": [ + { + "trait": "hiji" }, - { "eventChannel": "", "eventName": "", "eventRegex": false }, - { "eventChannel": "", "eventName": "", "eventRegex": false } + { + "trait": "" + } + ] + }, + "Enabled": true, + "Transformations": [], + "IsProcessorEnabled": true + }, + "message": { + "anonymousId": "4de817fb-7f8e-4e23-b9be-f6736dbda20f", + "channel": "web", + "context": { + "app": { + "build": "1.0.0", + "name": "RudderLabs JavaScript SDK", + "namespace": "com.rudderlabs.javascript", + "version": "1.1.1-rc.1" + }, + "library": { + "name": "RudderLabs JavaScript SDK", + "version": "1.1.1-rc.1" + }, + "locale": "en-US", + "os": { + "name": "", + "version": "" + }, + "page": { + "path": "/tests/html/script-test.html", + "referrer": "http://localhost:1111/tests/html/", + "search": "", + "title": "", + "url": "http://localhost:1111/tests/html/script-test.html" + }, + "screen": { + "density": 1.7999999523162842 + }, + "traits": { + "country": "India", + "email": "name@domain.com", + "hiji": "hulala", + "name": "my-name" + }, + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36" + }, + "integrations": { + "All": true + }, + "messageId": "9ecc0183-89ed-48bd-87eb-b2d8e1ca6780", + "originalTimestamp": "2020-03-23T03:46:30.916Z", + "properties": { + "path": "/tests/html/script-test.html", + "referrer": "http://localhost:1111/tests/html/", + "search": "", + "title": "", + "url": "http://localhost:1111/tests/html/script-test.html" + }, + "receivedAt": "2020-03-23T09:16:31.041+05:30", + "request_ip": "[::1]:52056", + "sentAt": "2020-03-23T03:46:30.916Z", + "timestamp": "2020-03-23T09:16:31.041+05:30", + "type": "identify", + "userId": "12345" + }, + "metadata": { + "anonymousId": "4de817fb-7f8e-4e23-b9be-f6736dbda20f", + "destinationId": "1ZQVSU9SXNg6KYgZALaqjAO3PIL", + "destinationType": "SLACK", + "jobId": 126, + "messageId": "9ecc0183-89ed-48bd-87eb-b2d8e1ca6780", + "sourceId": "1YhwKyDcKstudlGxkeN5p2wgsrp" + } + }, + { + "destination": { + "ID": "1ZQVSU9SXNg6KYgZALaqjAO3PIL", + "Name": "test-slack", + "DestinationDefinition": { + "ID": "1ZQUiJVMlmF7lfsdfXg7KXQnlLV", + "Name": "SLACK", + "DisplayName": "Slack", + "Config": { + "excludeKeys": [], + "includeKeys": [] + } + }, + "Config": { + "eventChannelSettings": [ + { + "eventChannelWebhook": "https://hooks.slack.com/services/example/test/demo", + "eventName": "is", + "eventRegex": true + } ], "eventTemplateSettings": [ { @@ -25,11 +138,27 @@ "eventRegex": true, "eventTemplate": "{{name}} performed {{event}} with {{properties.key1}} {{properties.key2}}" }, - { "eventName": "", "eventRegex": false, "eventTemplate": "" } + { + "eventName": "", + "eventRegex": false, + "eventTemplate": "" + } ], "identifyTemplate": "identified {{name}} with {{traits}}", "webhookUrl": "https://hooks.slack.com/services/THZM86VSS/BV9HZ2UN6/demo", - "whitelistedTraitsSettings": [{ "trait": "hiji" }, { "trait": "" }] + "whitelistedTraitsSettings": [ + { + "trait": "hiji" + }, + { + "trait": "" + } + ], + "blacklistedEvents": [ + { + "eventName": "black_event" + } + ] }, "Enabled": true, "Transformations": [], @@ -50,7 +179,10 @@ "version": "1.1.1-rc.1" }, "locale": "en-US", - "os": { "name": "", "version": "" }, + "os": { + "name": "", + "version": "" + }, "page": { "path": "/tests/html/script-test.html", "referrer": "http://localhost:1111/tests/html/", @@ -58,7 +190,9 @@ "title": "", "url": "http://localhost:1111/tests/html/script-test.html" }, - "screen": { "density": 1.7999999523162842 }, + "screen": { + "density": 1.7999999523162842 + }, "traits": { "country": "India", "email": "name@domain.com", @@ -67,7 +201,9 @@ }, "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36" }, - "integrations": { "All": true }, + "integrations": { + "All": true + }, "messageId": "9ecc0183-89ed-48bd-87eb-b2d8e1ca6780", "originalTimestamp": "2020-03-23T03:46:30.916Z", "properties": { @@ -101,17 +237,18 @@ "ID": "1ZQUiJVMlmF7lfsdfXg7KXQnlLV", "Name": "SLACK", "DisplayName": "Slack", - "Config": { "excludeKeys": [], "includeKeys": [] } + "Config": { + "excludeKeys": [], + "includeKeys": [] + } }, "Config": { "eventChannelSettings": [ { - "eventChannel": "#slack_integration", + "eventChannelWebhook": "https://hooks.slack.com/services/id1/id2/example", "eventName": "is", "eventRegex": true - }, - { "eventChannel": "", "eventName": "", "eventRegex": false }, - { "eventChannel": "", "eventName": "", "eventRegex": false } + } ], "eventTemplateSettings": [ { @@ -119,11 +256,22 @@ "eventRegex": true, "eventTemplate": "{{name}} performed {{event}} with {{properties.key1}} {{properties.key2}}" }, - { "eventName": "", "eventRegex": false, "eventTemplate": "" } + { + "eventName": "", + "eventRegex": false, + "eventTemplate": "" + } ], "identifyTemplate": "identified {{name}} with {{traits}}", "webhookUrl": "https://hooks.slack.com/services/THZM86VSS/BV9HZ2UN6/demo", - "whitelistedTraitsSettings": [{ "trait": "hiji" }, { "trait": "" }] + "whitelistedTraitsSettings": [ + { + "trait": "hiji" + }, + { + "trait": "" + } + ] }, "Enabled": true, "Transformations": [], @@ -144,7 +292,10 @@ "version": "1.1.1-rc.1" }, "locale": "en-US", - "os": { "name": "", "version": "" }, + "os": { + "name": "", + "version": "" + }, "page": { "path": "", "referrer": "", @@ -152,7 +303,389 @@ "title": "", "url": "" }, - "screen": { "density": 1.7999999523162842 }, + "screen": { + "density": 1.7999999523162842 + }, + "traits": { + "country": "India", + "email": "name@domain.com", + "hiji": "hulala", + "name": "my-name" + }, + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36" + }, + "traits": { + "country": "USA", + "email": "test@domain.com", + "hiji": "hulala-1", + "name": "my-name-1" + }, + "integrations": { + "All": true + }, + "messageId": "4aaecff2-a513-4bbf-9824-c471f4ac9777", + "originalTimestamp": "2020-03-23T03:41:46.122Z", + "receivedAt": "2020-03-23T09:11:46.244+05:30", + "request_ip": "[::1]:52055", + "sentAt": "2020-03-23T03:41:46.123Z", + "timestamp": "2020-03-23T09:11:46.243+05:30", + "type": "identify", + "userId": "12345" + }, + "metadata": { + "anonymousId": "12345", + "destinationId": "1ZQVSU9SXNg6KYgZALaqjAO3PIL", + "destinationType": "SLACK", + "jobId": 123, + "messageId": "4aaecff2-a513-4bbf-9824-c471f4ac9777", + "sourceId": "1YhwKyDcKstudlGxkeN5p2wgsrp" + } + }, + { + "destination": { + "ID": "1ZQVSU9SXNg6KYgZALaqjAO3PIL", + "Name": "test-slack", + "DestinationDefinition": { + "ID": "1ZQUiJVMlmF7lfsdfXg7KXQnlLV", + "Name": "SLACK", + "DisplayName": "Slack", + "Config": { + "excludeKeys": [], + "includeKeys": [] + } + }, + "Config": { + "incomingWebhooksType": "modern", + "eventChannelSettings": [ + { + "eventChannelWebhook": "https://hooks.slack.com/services/id1/id2/demo", + "eventName": "is", + "eventRegex": true + }, + { + "eventChannelWebhook": "https://hooks.slack.com/services/id1/id2/example+1", + "eventName": "is", + "eventRegex": true + } + ], + "eventTemplateSettings": [ + { + "eventName": "is", + "eventRegex": true, + "eventTemplate": "{{name}} performed {{event}} with {{properties.key1}} {{properties.key2}} and traits {{traitsList.hiji}}" + }, + { + "eventName": "", + "eventRegex": false, + "eventTemplate": "" + } + ], + "identifyTemplate": "identified {{name}} with {{traits}}", + "webhookUrl": "https://hooks.slack.com/services/THZM86VSS/BV9HZ2UN6/demo", + "whitelistedTraitsSettings": [ + { + "trait": "hiji" + }, + { + "trait": "" + } + ], + "blacklistedEvents": [ + { + "eventName": "black_event" + } + ] + }, + "Enabled": true, + "Transformations": [], + "IsProcessorEnabled": true + }, + "message": { + "anonymousId": "00000000000000000000000000", + "channel": "web", + "context": { + "app": { + "build": "1.0.0", + "name": "RudderLabs JavaScript SDK", + "namespace": "com.rudderlabs.javascript", + "version": "1.1.1-rc.1" + }, + "ip": "0.0.0.0", + "library": { + "name": "RudderLabs JavaScript SDK", + "version": "1.1.1-rc.1" + }, + "locale": "en-US", + "os": { + "name": "", + "version": "" + }, + "page": { + "path": "/tests/html/script-test.html", + "referrer": "http://localhost:1111/tests/html/", + "search": "", + "title": "", + "url": "http://localhost:1111/tests/html/script-test.html" + }, + "screen": { + "density": 1.7999999523162842 + }, + "traits": { + "country": "India", + "email": "name@domain.com", + "hiji": "hulala", + "name": "my-name" + }, + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36" + }, + "event": "test_isent1", + "integrations": { + "All": true + }, + "messageId": "78102118-56ac-4c5a-a495-8cd7c8f71cc2", + "originalTimestamp": "2020-03-23T03:46:30.921Z", + "properties": { + "currency": "USD", + "key1": "test_val1", + "key2": "test_val2", + "revenue": 30, + "user_actual_id": 12345 + }, + "receivedAt": "2020-03-23T09:16:31.064+05:30", + "request_ip": "[::1]:52057", + "sentAt": "2020-03-23T03:46:30.921Z", + "timestamp": "2020-03-23T09:16:31.064+05:30", + "type": "track", + "userId": "12345" + }, + "metadata": { + "anonymousId": "00000000000000000000000000", + "destinationId": "1ZQVSU9SXNg6KYgZALaqjAO3PIL", + "destinationType": "SLACK", + "jobId": 128, + "messageId": "78102118-56ac-4c5a-a495-8cd7c8f71cc2", + "sourceId": "1YhwKyDcKstudlGxkeN5p2wgsrp" + } + }, + { + "destination": { + "ID": "1ZQVSU9SXNg6KYgZALaqjAO3PIL", + "Name": "test-slack", + "DestinationDefinition": { + "ID": "1ZQUiJVMlmF7lfsdfXg7KXQnlLV", + "Name": "SLACK", + "DisplayName": "Slack", + "Config": { + "excludeKeys": [], + "includeKeys": [] + } + }, + "Config": { + "incomingWebhooksType": "modern", + "eventChannelSettings": [ + { + "eventChannelWebhook": "https://hooks.slack.com/services/id1/id2/example", + "eventName": "is", + "eventChannel": "example_channel", + "eventRegex": true + }, + { + "eventChannelWebhook": "https://hooks.slack.com/services/id1/id2/example+1", + "eventName": "is", + "eventChannel": "example_channel", + "eventRegex": true + } + ], + "eventTemplateSettings": [ + { + "eventName": "is", + "eventRegex": true, + "eventTemplate": "{{name}} performed {{event}} with {{properties.key1}} {{properties.key2}}" + }, + { + "eventName": "", + "eventRegex": false, + "eventTemplate": "" + } + ], + "identifyTemplate": "identified {{name}} with {{traits}}", + "webhookUrl": "https://hooks.slack.com/services/THZM86VSS/BV9HZ2UN6/demo", + "whitelistedTraitsSettings": [ + { + "trait": "hiji" + }, + { + "trait": "" + } + ], + "blacklistedEvents": [ + { + "eventName": "black_event" + } + ] + }, + "Enabled": true, + "Transformations": [], + "IsProcessorEnabled": true + }, + "message": { + "anonymousId": "00000000000000000000000000", + "channel": "web", + "context": { + "app": { + "build": "1.0.0", + "name": "RudderLabs JavaScript SDK", + "namespace": "com.rudderlabs.javascript", + "version": "1.1.1-rc.1" + }, + "ip": "0.0.0.0", + "library": { + "name": "RudderLabs JavaScript SDK", + "version": "1.1.1-rc.1" + }, + "locale": "en-US", + "os": { + "name": "", + "version": "" + }, + "page": { + "path": "/tests/html/script-test.html", + "referrer": "http://localhost:1111/tests/html/", + "search": "", + "title": "", + "url": "http://localhost:1111/tests/html/script-test.html" + }, + "screen": { + "density": 1.7999999523162842 + }, + "traits": { + "country": "India", + "email": "name@domain.com", + "hiji": "hulala", + "name": "my-name" + }, + "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36" + }, + "event": "test_eventing_testis", + "integrations": { + "All": true + }, + "messageId": "8b8d5937-09bc-49dc-a35e-8cd6370575f8", + "originalTimestamp": "2020-03-23T03:46:30.922Z", + "properties": { + "currency": "USD", + "key1": "test_val1", + "key2": "test_val2", + "revenue": 30, + "user_actual_id": 12345 + }, + "receivedAt": "2020-03-23T09:16:31.064+05:30", + "request_ip": "[::1]:52054", + "sentAt": "2020-03-23T03:46:30.923Z", + "timestamp": "2020-03-23T09:16:31.063+05:30", + "type": "track", + "userId": "12345" + }, + "metadata": { + "anonymousId": "00000000000000000000000000", + "destinationId": "1ZQVSU9SXNg6KYgZALaqjAO3PIL", + "destinationType": "SLACK", + "jobId": 129, + "messageId": "8b8d5937-09bc-49dc-a35e-8cd6370575f8", + "sourceId": "1YhwKyDcKstudlGxkeN5p2wgsrp" + } + }, + { + "destination": { + "ID": "1ZQVSU9SXNg6KYgZALaqjAO3PIL", + "Name": "test-slack", + "DestinationDefinition": { + "ID": "1ZQUiJVMlmF7lfsdfXg7KXQnlLV", + "Name": "SLACK", + "DisplayName": "Slack", + "Config": { + "excludeKeys": [], + "includeKeys": [] + } + }, + "Config": { + "incomingWebhooksType": "modern", + "eventChannelSettings": [ + { + "eventChannelWebhook": "https://hooks.slack.com/services/id1/id2/example", + "eventName": "test_eventing_test", + "eventChannel": "example_channel", + "eventRegex": false + }, + { + "eventChannelWebhook": "https://hooks.slack.com/services/id1/id2/example+1", + "eventName": "", + "eventChannel": "example_channel", + "eventRegex": true + } + ], + "eventTemplateSettings": [ + { + "eventName": "is", + "eventRegex": true, + "eventTemplate": "{{name}} performed {{event}} with {{properties.key1}} {{properties.key2}}" + }, + { + "eventName": "", + "eventRegex": false, + "eventTemplate": "" + } + ], + "identifyTemplate": "identified {{name}} with {{traits}}", + "webhookUrl": "https://hooks.slack.com/services/THZM86VSS/BV9HZ2UN6/demo", + "whitelistedTraitsSettings": [ + { + "trait": "hiji" + }, + { + "trait": "" + } + ], + "blacklistedEvents": [ + { + "eventName": "black_event" + } + ] + }, + "Enabled": true, + "Transformations": [], + "IsProcessorEnabled": true + }, + "message": { + "anonymousId": "00000000000000000000000000", + "channel": "web", + "context": { + "app": { + "build": "1.0.0", + "name": "RudderLabs JavaScript SDK", + "namespace": "com.rudderlabs.javascript", + "version": "1.1.1-rc.1" + }, + "ip": "0.0.0.0", + "library": { + "name": "RudderLabs JavaScript SDK", + "version": "1.1.1-rc.1" + }, + "locale": "en-US", + "os": { + "name": "", + "version": "" + }, + "page": { + "path": "/tests/html/script-test.html", + "referrer": "http://localhost:1111/tests/html/", + "search": "", + "title": "", + "url": "http://localhost:1111/tests/html/script-test.html" + }, + "screen": { + "density": 1.7999999523162842 + }, "traits": { "country": "India", "email": "name@domain.com", @@ -161,28 +694,32 @@ }, "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36" }, - "traits": { - "country": "USA", - "email": "test@domain.com", - "hiji": "hulala-1", - "name": "my-name-1" + "event": "test_eventing_test", + "integrations": { + "All": true }, - "integrations": { "All": true }, - "messageId": "4aaecff2-a513-4bbf-9824-c471f4ac9777", - "originalTimestamp": "2020-03-23T03:41:46.122Z", - "receivedAt": "2020-03-23T09:11:46.244+05:30", - "request_ip": "[::1]:52055", - "sentAt": "2020-03-23T03:41:46.123Z", - "timestamp": "2020-03-23T09:11:46.243+05:30", - "type": "identify", + "messageId": "8b8d5937-09bc-49dc-a35e-8cd6370575f8", + "originalTimestamp": "2020-03-23T03:46:30.922Z", + "properties": { + "currency": "USD", + "key1": "test_val1", + "key2": "test_val2", + "revenue": 30, + "user_actual_id": 12345 + }, + "receivedAt": "2020-03-23T09:16:31.064+05:30", + "request_ip": "[::1]:52054", + "sentAt": "2020-03-23T03:46:30.923Z", + "timestamp": "2020-03-23T09:16:31.063+05:30", + "type": "track", "userId": "12345" }, "metadata": { - "anonymousId": "12345", + "anonymousId": "00000000000000000000000000", "destinationId": "1ZQVSU9SXNg6KYgZALaqjAO3PIL", "destinationType": "SLACK", - "jobId": 123, - "messageId": "4aaecff2-a513-4bbf-9824-c471f4ac9777", + "jobId": 129, + "messageId": "8b8d5937-09bc-49dc-a35e-8cd6370575f8", "sourceId": "1YhwKyDcKstudlGxkeN5p2wgsrp" } }, @@ -194,17 +731,24 @@ "ID": "1ZQUiJVMlmF7lfsdfXg7KXQnlLV", "Name": "SLACK", "DisplayName": "Slack", - "Config": { "excludeKeys": [], "includeKeys": [] } + "Config": { + "excludeKeys": [], + "includeKeys": [] + } }, "Config": { + "incomingWebhooksType": "legacy", "eventChannelSettings": [ { - "eventChannel": "#slack_integration", + "eventChannelWebhook": "https://hooks.slack.com/services/id1/id2/demo", "eventName": "is", "eventRegex": true }, - { "eventChannel": "", "eventName": "", "eventRegex": false }, - { "eventChannel": "", "eventName": "", "eventRegex": false } + { + "eventChannelWebhook": "https://hooks.slack.com/services/id1/id2/example+1", + "eventName": "is", + "eventRegex": true + } ], "eventTemplateSettings": [ { @@ -212,11 +756,27 @@ "eventRegex": true, "eventTemplate": "{{name}} performed {{event}} with {{properties.key1}} {{properties.key2}} and traits {{traitsList.hiji}}" }, - { "eventName": "", "eventRegex": false, "eventTemplate": "" } + { + "eventName": "", + "eventRegex": false, + "eventTemplate": "" + } ], "identifyTemplate": "identified {{name}} with {{traits}}", "webhookUrl": "https://hooks.slack.com/services/THZM86VSS/BV9HZ2UN6/demo", - "whitelistedTraitsSettings": [{ "trait": "hiji" }, { "trait": "" }] + "whitelistedTraitsSettings": [ + { + "trait": "hiji" + }, + { + "trait": "" + } + ], + "blacklistedEvents": [ + { + "eventName": "black_event" + } + ] }, "Enabled": true, "Transformations": [], @@ -238,7 +798,10 @@ "version": "1.1.1-rc.1" }, "locale": "en-US", - "os": { "name": "", "version": "" }, + "os": { + "name": "", + "version": "" + }, "page": { "path": "/tests/html/script-test.html", "referrer": "http://localhost:1111/tests/html/", @@ -246,7 +809,9 @@ "title": "", "url": "http://localhost:1111/tests/html/script-test.html" }, - "screen": { "density": 1.7999999523162842 }, + "screen": { + "density": 1.7999999523162842 + }, "traits": { "country": "India", "email": "name@domain.com", @@ -256,7 +821,9 @@ "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36" }, "event": "test_isent1", - "integrations": { "All": true }, + "integrations": { + "All": true + }, "messageId": "78102118-56ac-4c5a-a495-8cd7c8f71cc2", "originalTimestamp": "2020-03-23T03:46:30.921Z", "properties": { @@ -290,17 +857,25 @@ "ID": "1ZQUiJVMlmF7lfsdfXg7KXQnlLV", "Name": "SLACK", "DisplayName": "Slack", - "Config": { "excludeKeys": [], "includeKeys": [] } + "Config": { + "excludeKeys": [], + "includeKeys": [] + } }, "Config": { + "incomingWebhooksType": "legacy", "eventChannelSettings": [ { - "eventChannel": "#slack_integration", + "eventChannelWebhook": "https://hooks.slack.com/services/id1/id2/example", "eventName": "is", "eventRegex": true }, - { "eventChannel": "", "eventName": "", "eventRegex": false }, - { "eventChannel": "", "eventName": "", "eventRegex": false } + { + "eventChannelWebhook": "https://hooks.slack.com/services/id1/id2/example+1", + "eventChannel": "example-of-legacy", + "eventName": "is", + "eventRegex": true + } ], "eventTemplateSettings": [ { @@ -308,11 +883,27 @@ "eventRegex": true, "eventTemplate": "{{name}} performed {{event}} with {{properties.key1}} {{properties.key2}}" }, - { "eventName": "", "eventRegex": false, "eventTemplate": "" } + { + "eventName": "", + "eventRegex": false, + "eventTemplate": "" + } ], "identifyTemplate": "identified {{name}} with {{traits}}", "webhookUrl": "https://hooks.slack.com/services/THZM86VSS/BV9HZ2UN6/demo", - "whitelistedTraitsSettings": [{ "trait": "hiji" }, { "trait": "" }] + "whitelistedTraitsSettings": [ + { + "trait": "hiji" + }, + { + "trait": "" + } + ], + "blacklistedEvents": [ + { + "eventName": "black_event" + } + ] }, "Enabled": true, "Transformations": [], @@ -334,7 +925,10 @@ "version": "1.1.1-rc.1" }, "locale": "en-US", - "os": { "name": "", "version": "" }, + "os": { + "name": "", + "version": "" + }, "page": { "path": "/tests/html/script-test.html", "referrer": "http://localhost:1111/tests/html/", @@ -342,7 +936,9 @@ "title": "", "url": "http://localhost:1111/tests/html/script-test.html" }, - "screen": { "density": 1.7999999523162842 }, + "screen": { + "density": 1.7999999523162842 + }, "traits": { "country": "India", "email": "name@domain.com", @@ -352,7 +948,9 @@ "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36" }, "event": "test_eventing_testis", - "integrations": { "All": true }, + "integrations": { + "All": true + }, "messageId": "8b8d5937-09bc-49dc-a35e-8cd6370575f8", "originalTimestamp": "2020-03-23T03:46:30.922Z", "properties": { @@ -394,19 +992,9 @@ "Config": { "eventChannelSettings": [ { - "eventChannel": "#slack_integration", + "eventChannelWebhook": "https://hooks.slack.com/services/example/test/demo", "eventName": "is", "eventRegex": true - }, - { - "eventChannel": "", - "eventName": "", - "eventRegex": false - }, - { - "eventChannel": "", - "eventName": "", - "eventRegex": false } ], "eventTemplateSettings": [ @@ -510,17 +1098,18 @@ "ID": "1ZQUiJVMlmF7lfsdfXg7KXQnlLV", "Name": "SLACK", "DisplayName": "Slack", - "Config": { "excludeKeys": [], "includeKeys": [] } + "Config": { + "excludeKeys": [], + "includeKeys": [] + } }, "Config": { "eventChannelSettings": [ { - "eventChannel": "#slack_integration", + "eventChannelWebhook": "https://hooks.slack.com/services/example/test/demo", "eventName": "is", "eventRegex": true - }, - { "eventChannel": "", "eventName": "", "eventRegex": false }, - { "eventChannel": "", "eventName": "", "eventRegex": false } + } ], "eventTemplateSettings": [ { @@ -528,11 +1117,22 @@ "eventRegex": true, "eventTemplate": "{{name}} performed {{event}} with {{properties.key1}} {{properties.key2}}" }, - { "eventName": "", "eventRegex": false, "eventTemplate": "" } + { + "eventName": "", + "eventRegex": false, + "eventTemplate": "" + } ], "identifyTemplate": "identified {{name}} with {{traits}}", "webhookUrl": "https://hooks.slack.com/services/THZM86VSS/BV9HZ2UN6/demo", - "whitelistedTraitsSettings": [{ "trait": "hiji" }, { "trait": "" }] + "whitelistedTraitsSettings": [ + { + "trait": "hiji" + }, + { + "trait": "" + } + ] }, "Enabled": true, "Transformations": [], @@ -554,7 +1154,10 @@ "version": "1.1.1-rc.1" }, "locale": "en-US", - "os": { "name": "", "version": "" }, + "os": { + "name": "", + "version": "" + }, "page": { "path": "/tests/html/script-test.html", "referrer": "http://localhost:1111/tests/html/", @@ -562,7 +1165,9 @@ "title": "", "url": "http://localhost:1111/tests/html/script-test.html" }, - "screen": { "density": 1.7999999523162842 }, + "screen": { + "density": 1.7999999523162842 + }, "traits": { "country": "India", "email": "name@domain.com", @@ -571,7 +1176,9 @@ }, "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36" }, - "integrations": { "All": true }, + "integrations": { + "All": true + }, "messageId": "8b8d5937-09bc-49dc-a35e-8cd6370575f8", "originalTimestamp": "2020-03-23T03:46:30.922Z", "properties": { @@ -605,17 +1212,18 @@ "ID": "1ZQUiJVMlmF7lfsdfXg7KXQnlLV", "Name": "SLACK", "DisplayName": "Slack", - "Config": { "excludeKeys": [], "includeKeys": [] } + "Config": { + "excludeKeys": [], + "includeKeys": [] + } }, "Config": { "eventChannelSettings": [ { - "eventChannel": "#slack_integration", + "eventChannelWebhook": "https://hooks.slack.com/services/example/test/demo", "eventName": "is", "eventRegex": true - }, - { "eventChannel": "", "eventName": "", "eventRegex": false }, - { "eventChannel": "", "eventName": "", "eventRegex": false } + } ], "eventTemplateSettings": [ { @@ -623,11 +1231,22 @@ "eventRegex": true, "eventTemplate": "{{name}} performed {{event}} with {{properties. key1}} {{properties.key2}} and traits {{traitsList.hiji}}" }, - { "eventName": "", "eventRegex": false, "eventTemplate": "" } + { + "eventName": "", + "eventRegex": false, + "eventTemplate": "" + } ], "identifyTemplate": "identified {{name}} with {{traits}}", "webhookUrl": "https://hooks.slack.com/services/THZM86VSS/BV9HZ2UN6/demo", - "whitelistedTraitsSettings": [{ "trait": "hiji" }, { "trait": "" }] + "whitelistedTraitsSettings": [ + { + "trait": "hiji" + }, + { + "trait": "" + } + ] }, "Enabled": true, "Transformations": [], @@ -649,7 +1268,10 @@ "version": "1.1.1-rc.1" }, "locale": "en-US", - "os": { "name": "", "version": "" }, + "os": { + "name": "", + "version": "" + }, "page": { "path": "/tests/html/script-test.html", "referrer": "http://localhost:1111/tests/html/", @@ -657,7 +1279,9 @@ "title": "", "url": "http://localhost:1111/tests/html/script-test.html" }, - "screen": { "density": 1.7999999523162842 }, + "screen": { + "density": 1.7999999523162842 + }, "traits": { "country": "India", "email": "name@domain.com", @@ -667,7 +1291,9 @@ "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36" }, "event": "test_isent1", - "integrations": { "All": true }, + "integrations": { + "All": true + }, "messageId": "78102118-56ac-4c5a-a495-8cd7c8f71cc2", "originalTimestamp": "2020-03-23T03:46:30.921Z", "properties": { @@ -692,5 +1318,98 @@ "messageId": "78102118-56ac-4c5a-a495-8cd7c8f71cc2", "sourceId": "1YhwKyDcKstudlGxkeN5p2wgsrp" } + }, + { + "destination": { + "ID": "1ZQVSU9SXNg6KYgZALaqjAO3PIL", + "Name": "test-slack", + "DestinationDefinition": { + "ID": "1ZQUiJVMlmF7lfsdfXg7KXQnlLV", + "Name": "SLACK", + "DisplayName": "Slack", + "Config": { + "excludeKeys": [], + "includeKeys": [] + } + }, + "Config": { + "incomingWebhooksType": "legacy", + "eventChannelSettings": [ + { + "eventChannelWebhook": "https://hooks.slack.com/services/id1/id2/example", + "eventName": "is", + "eventRegex": true + }, + { + "eventChannelWebhook": "https://hooks.slack.com/services/id1/id2/example+1", + "eventChannel": "example-of-legacy", + "eventName": "is", + "eventRegex": true + } + ], + "eventTemplateSettings": [ + { + "eventName": "is", + "eventRegex": true, + "eventTemplate": "{{name}} performed {{event}} with {{properties.key1}} {{properties.key2}}" + }, + { + "eventName": "", + "eventRegex": false, + "eventTemplate": "" + } + ], + "identifyTemplate": "identified {{name}} with {{traits}}", + "webhookUrl": "https://hooks.slack.com/services/THZM86VSS/BV9HZ2UN6/demo", + "whitelistedTraitsSettings": [ + { + "trait": "hiji" + }, + { + "trait": "" + } + ], + "blacklistedEvents": [ + { + "eventName": "black_event" + } + ] + }, + "Enabled": true, + "Transformations": [], + "IsProcessorEnabled": true + }, + "message": { + "anonymousId": "00000000000000000000000000", + "channel": "web", + "context": {}, + "event": "black_event", + "integrations": { + "All": true + }, + "messageId": "8b8d5937-09bc-49dc-a35e-8cd6370575f8", + "originalTimestamp": "2020-03-23T03:46:30.922Z", + "properties": { + "currency": "USD", + "key1": "test_val1", + "key2": "test_val2", + "revenue": 30, + "user_actual_id": 12345 + }, + "receivedAt": "2020-03-23T09:16:31.064+05:30", + "request_ip": "[::1]:52054", + "sentAt": "2020-03-23T03:46:30.923Z", + "timestamp": "2020-03-23T09:16:31.063+05:30", + "type": "track", + "userId": "12345" + }, + "metadata": { + "anonymousId": "00000000000000000000000000", + "destinationId": "1ZQVSU9SXNg6KYgZALaqjAO3PIL", + "destinationType": "SLACK", + "jobId": 129, + "messageId": "8b8d5937-09bc-49dc-a35e-8cd6370575f8", + "sourceId": "1YhwKyDcKstudlGxkeN5p2wgsrp" + } } -] +] \ No newline at end of file diff --git a/test/__tests__/data/slack_output.json b/test/__tests__/data/slack_output.json index 5c8495c757..853daf7801 100644 --- a/test/__tests__/data/slack_output.json +++ b/test/__tests__/data/slack_output.json @@ -1,4 +1,25 @@ [ + { + "version": "1", + "type": "REST", + "method": "POST", + "endpoint": "https://hooks.slack.com/services/THZM86VSS/BV9HZ2UN6/demo", + "headers": { + "Content-Type": "application/x-www-form-urlencoded" + }, + "params": {}, + "body": { + "JSON": {}, + "XML": {}, + "JSON_ARRAY": {}, + "FORM": { + "payload": "{\"text\":\"Identified my-namehiji: hulala \",\"username\":\"RudderStack\",\"icon_url\":\"https://cdn.rudderlabs.com/rudderstack.png\"}" + } + }, + "files": {}, + "userId": "12345", + "statusCode": 200 + }, { "error": "Event type page is not supported" }, @@ -7,7 +28,9 @@ "type": "REST", "method": "POST", "endpoint": "https://hooks.slack.com/services/THZM86VSS/BV9HZ2UN6/demo", - "headers": { "Content-Type": "application/x-www-form-urlencoded" }, + "headers": { + "Content-Type": "application/x-www-form-urlencoded" + }, "params": {}, "body": { "JSON": {}, @@ -21,19 +44,84 @@ "userId": "12345", "statusCode": 200 }, + { + "version": "1", + "type": "REST", + "method": "POST", + "endpoint": "https://hooks.slack.com/services/id1/id2/demo", + "headers": { + "Content-Type": "application/x-www-form-urlencoded" + }, + "params": {}, + "body": { + "JSON": {}, + "XML": {}, + "JSON_ARRAY": {}, + "FORM": { + "payload": "{\"text\":\"my-name performed test_isent1 with test_val1 test_val2 and traits hulala\"}" + } + }, + "files": {}, + "userId": "12345", + "statusCode": 200 + }, + { + "version": "1", + "type": "REST", + "method": "POST", + "endpoint": "https://hooks.slack.com/services/id1/id2/example", + "headers": { + "Content-Type": "application/x-www-form-urlencoded" + }, + "params": {}, + "body": { + "JSON": {}, + "XML": {}, + "JSON_ARRAY": {}, + "FORM": { + "payload": "{\"text\":\"my-name performed test_eventing_testis with test_val1 test_val2\"}" + } + }, + "files": {}, + "userId": "12345", + "statusCode": 200 + }, + { + "version": "1", + "type": "REST", + "method": "POST", + "endpoint": "https://hooks.slack.com/services/id1/id2/example", + "headers": { + "Content-Type": "application/x-www-form-urlencoded" + }, + "params": {}, + "body": { + "JSON": {}, + "XML": {}, + "JSON_ARRAY": {}, + "FORM": { + "payload": "{\"text\":\"my-name did test_eventing_test\"}" + } + }, + "files": {}, + "userId": "12345", + "statusCode": 200 + }, { "version": "1", "type": "REST", "method": "POST", "endpoint": "https://hooks.slack.com/services/THZM86VSS/BV9HZ2UN6/demo", - "headers": { "Content-Type": "application/x-www-form-urlencoded" }, + "headers": { + "Content-Type": "application/x-www-form-urlencoded" + }, "params": {}, "body": { "JSON": {}, "XML": {}, "JSON_ARRAY": {}, "FORM": { - "payload": "{\"channel\":\"#slack_integration\",\"text\":\"my-name performed test_isent1 with test_val1 test_val2 and traits hulala\",\"username\":\"RudderStack\",\"icon_url\":\"https://cdn.rudderlabs.com/rudderstack.png\"}" + "payload": "{\"text\":\"my-name performed test_isent1 with test_val1 test_val2 and traits hulala\",\"username\":\"RudderStack\",\"icon_url\":\"https://cdn.rudderlabs.com/rudderstack.png\"}" } }, "files": {}, @@ -45,14 +133,16 @@ "type": "REST", "method": "POST", "endpoint": "https://hooks.slack.com/services/THZM86VSS/BV9HZ2UN6/demo", - "headers": { "Content-Type": "application/x-www-form-urlencoded" }, + "headers": { + "Content-Type": "application/x-www-form-urlencoded" + }, "params": {}, "body": { "JSON": {}, "XML": {}, "JSON_ARRAY": {}, "FORM": { - "payload": "{\"channel\":\"#slack_integration\",\"text\":\"my-name performed test_eventing_testis with test_val1 test_val2\",\"username\":\"RudderStack\",\"icon_url\":\"https://cdn.rudderlabs.com/rudderstack.png\"}" + "payload": "{\"channel\":\"example-of-legacy\",\"text\":\"my-name performed test_eventing_testis with test_val1 test_val2\",\"username\":\"RudderStack\",\"icon_url\":\"https://cdn.rudderlabs.com/rudderstack.png\"}" } }, "files": {}, @@ -67,5 +157,8 @@ }, { "error": "Something is wrong with the event template: '{{name}} performed {{event}} with {{properties. key1}} {{properties.key2}} and traits {{traitsList.hiji}}'" + }, + { + "error": "Event is blacklisted. Please check configuration." } -] +] \ No newline at end of file diff --git a/test/__tests__/slack.test.js b/test/__tests__/slack.test.js index c2b5b91ede..eec0f4054f 100644 --- a/test/__tests__/slack.test.js +++ b/test/__tests__/slack.test.js @@ -29,7 +29,7 @@ const inputRouterData = JSON.parse(inputRouterDataFile); const expectedRouterData = JSON.parse(outputRouterDataFile); inputData.forEach((input, index) => { - test(`${name} Tests - payload: %{index}`, () => { + test(`${name} Tests - payload: ${index}`, () => { try { const output = transformer.process(input); expect(output).toEqual([expectedData[index]]);