From 784f34ab713a4af21b310078b1aa3c480d6589a4 Mon Sep 17 00:00:00 2001 From: mihir-4116 Date: Fri, 15 Sep 2023 15:28:39 +0530 Subject: [PATCH 1/3] feat(intercom): move intercom to new ui --- .../destinations/intercom/db-config.json | 30 +- .../destinations/intercom/schema.json | 105 ++++- .../destinations/intercom/ui-config.json | 417 +++++++++++------- 3 files changed, 392 insertions(+), 160 deletions(-) diff --git a/src/configurations/destinations/intercom/db-config.json b/src/configurations/destinations/intercom/db-config.json index 8b941737a..fa31e4c6b 100644 --- a/src/configurations/destinations/intercom/db-config.json +++ b/src/configurations/destinations/intercom/db-config.json @@ -14,8 +14,7 @@ "blacklistedEvents", "whitelistedEvents", "oneTrustCookieCategories", - "eventFilteringOption", - "updateLastRequestAt" + "eventFilteringOption" ], "excludeKeys": [], "supportedSourceTypes": [ @@ -32,21 +31,36 @@ "shopify" ], "supportedMessageTypes": ["identify", "track", "group"], + "supportedConnectionModes": { + "web": [ + "cloud", + "device" + ], + "android": [ + "cloud", + "device" + ], + "ios": [ + "cloud", + "device" + ] + }, "destConfig": { "defaultConfig": [ "apiKey", "appId", - "collectContext", + "apiServer", "sendAnonymousId", + "mobileApiKeyIOS", "blacklistedEvents", "whitelistedEvents", + "mobileApiKeyAndroid", "eventFilteringOption", - "oneTrustCookieCategories", - "updateLastRequestAt" + "oneTrustCookieCategories" ], - "android": ["useNativeSDK", "mobileApiKeyAndroid"], - "ios": ["useNativeSDK", "mobileApiKeyIOS"], - "web": ["useNativeSDK"] + "android": ["useNativeSDK", "mobileApiKeyAndroid", "connectionMode"], + "ios": ["useNativeSDK", "mobileApiKeyIOS", "connectionMode"], + "web": ["useNativeSDK","appId", "connectionMode"] }, "secretKeys": [] } diff --git a/src/configurations/destinations/intercom/schema.json b/src/configurations/destinations/intercom/schema.json index fddffa4cc..314e57301 100644 --- a/src/configurations/destinations/intercom/schema.json +++ b/src/configurations/destinations/intercom/schema.json @@ -1,3 +1,106 @@ { - "configSchema": null + "configSchema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "required": ["apiKey", "apiServer"], + "type": "object", + "properties": { + "apiKey": { + "type": "string", + "pattern": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{1,100})$" + }, + "apiServer": { + "type": "string", + "enum": ["standard", "eu", "au"], + "default": "standard" + }, + "appId": { + "type": "string", + "pattern": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{0,100})$" + }, + "mobileApiKeyAndroid": { + "type": "string", + "pattern": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{0,100})$" + }, + "mobileApiKeyIOS": { + "type": "string", + "pattern": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{0,100})$" + }, + "sendAnonymousId": { + "type": "boolean", + "default": false + }, + "eventFilteringOption": { + "type": "string", + "enum": ["disable", "whitelistedEvents", "blacklistedEvents"], + "default": "disable" + }, + "whitelistedEvents": { + "type": "array", + "items": { + "type": "object", + "properties": { + "eventName": { + "type": "string", + "pattern": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{0,100})$" + } + } + } + }, + "blacklistedEvents": { + "type": "array", + "items": { + "type": "object", + "properties": { + "eventName": { + "type": "string", + "pattern": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{0,100})$" + } + } + } + }, + "oneTrustCookieCategories": { + "type": "array", + "items": { + "type": "object", + "properties": { + "oneTrustCookieCategory": { + "type": "string", + "pattern": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{0,100})$" + } + } + } + }, + "useNativeSDK": { + "type": "object", + "properties": { + "android": { + "type": "boolean" + }, + "ios": { + "type": "boolean" + }, + "web": { + "type": "boolean" + } + } + }, + "connectionMode": { + "type": "object", + "properties": { + "android": { + "type": "string", + "enum": ["cloud", "device"] + }, + "ios": { + "type": "string", + "enum": ["cloud", "device"] + }, + "web": { + "type": "string", + "enum": ["cloud", "device"] + } + } + } + } + } } diff --git a/src/configurations/destinations/intercom/ui-config.json b/src/configurations/destinations/intercom/ui-config.json index 792619aff..5398d750e 100644 --- a/src/configurations/destinations/intercom/ui-config.json +++ b/src/configurations/destinations/intercom/ui-config.json @@ -1,154 +1,269 @@ { - "uiConfig": [ - { - "title": "1. Connection Settings", - "fields": [ - { - "type": "textInput", - "label": "Access Token", - "value": "apiKey", - "regex": "^(.{0,100})$", - "regexErrorMessage": "Invalid Access Token", - "required": true, - "placeholder": "e.g: FGHrOjU4ZDc0MjEyXzhjYmNfNDZmYl85ODUxX2RjZDk0Mzk1M2VlMDoxOjA=" - }, - { - "type": "textInput", - "label": "App Id", - "value": "appId", - "regex": "^(.{0,100})$", - "regexErrorMessage": "Invalid App Id", - "required": true, - "placeholder": "e.g: fll5vd90" - }, - { - "type": "textInput", - "label": "Android API Key", - "value": "mobileApiKeyAndroid", - "regex": "^(.{0,100})$", - "regexErrorMessage": "Invalid Android API Key", - "required": false, - "placeholder": "e.g: android_sdk-67f114561f2267e242466e6687bc7a9ba455cf90" - }, - { - "type": "textInput", - "label": "iOS API Key", - "value": "mobileApiKeyIOS", - "regex": "^(.{0,100})$", - "regexErrorMessage": "Invalid iOS API Key", - "required": false, - "placeholder": "e.g: ios_sdk-5fe73e0bb7fcae17a1a75fdbad227191a69f6c00" - } - ] - }, - { - "title": "2. Native SDK", - "fields": [ - { - "type": "checkbox", - "label": "Use device-mode to send events", - "value": "useNativeSDK", - "default": false - } - ] - }, - { - "title": "3. Other Setttings", - "fields": [ - { - "type": "checkbox", - "label": "Include Context with Identify Calls", - "value": "collectContext", - "required": false - }, - { - "type": "checkbox", - "label": "Send AnonymousId as Secondary UserId", - "value": "sendAnonymousId", - "default": false - }, - { - "type": "checkbox", - "label": "Enable this to update the last seen to the current time", - "value": "updateLastRequestAt", - "footerNote": "For more details refer update_last_request_at in this link https://developers.intercom.com/intercom-api-reference/v1.2/reference/updating-the-last-seen-time", - "default": true - } - ] - }, - { - "title": "Client-side Events Filtering", - "sectionNote": "Applicable only for device-mode integrations. If enabled, it works only with either allowlisted or denylisted events", - "fields": [ - { - "type": "singleSelect", - "value": "eventFilteringOption", - "required": false, - "options": [ - { - "name": "Disable", - "value": "disable" - }, - { - "name": "Allowlist", - "value": "whitelistedEvents" - }, - { - "name": "Denylist", - "value": "blacklistedEvents" - } - ], - "defaultOption": { - "name": "Disable", - "value": "disable" + "uiConfig": { + "baseTemplate": [ + { + "title": "Initial setup", + "note": "Review how this destination is set up", + "sections": [ + { + "groups": [ + { + "title": "Connection Settings", + "note": "Update your connection settings here", + "icon": "settings", + "fields": [ + { + "type": "textInput", + "label": "Access Token", + "configKey": "apiKey", + "regex": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{1,100})$", + "regexErrorMessage": "Invalid Access Token", + "placeholder": "e.g: FGHrOjU4ZDc0MjEyXzhjYmNfNDZmYl85ODUxX2RjZDk0Mzk1M2VlMDoxOjA=" + }, + { + "type": "singleSelect", + "label": "API Server", + "configKey": "apiServer", + "options": [ + { + "label": "Standard", + "value": "standard" + }, + { + "label": "EU", + "value": "eu" + }, + { + "label": "AU", + "value": "au" + } + ], + "default": "standard", + "note": "Select your Intercom API Server" + }, + { + "type": "textInput", + "label": "App Id", + "configKey": "appId", + "regex": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{0,100})$", + "regexErrorMessage": "Invalid App Id", + "note": "Intercom appId. Applicable to device mode only", + "placeholder": "e.g: fll5vd90", + "preRequisites": { + "fields": [ + { + "configKey": "connectionModes.webDevice", + "value": true + } + ] + } + }, + { + "type": "textInput", + "label": "Android API Key", + "configKey": "mobileApiKeyAndroid", + "regex": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{0,100})$", + "regexErrorMessage": "Invalid Android API Key", + "placeholder": "e.g: android_sdk-67f114561f2267e242466e6687bc7a9ba455cf90", + "preRequisites": { + "fields": [ + { + "configKey": "connectionModes.mobileDevice", + "value": true + } + ] + } + }, + { + "type": "textInput", + "label": "iOS API Key", + "configKey": "mobileApiKeyIOS", + "regex": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{0,100})$", + "regexErrorMessage": "Invalid iOS API Key", + "placeholder": "e.g: ios_sdk-5fe73e0bb7fcae17a1a75fdbad227191a69f6c00", + "preRequisites": { + "fields": [ + { + "configKey": "connectionModes.mobileDevice", + "value": true + } + ] + } + } + ] + } + ] + }, + { + "groups": [ + { + "title": "Connection mode", + "note": [ + "Update how you want to route events from your source to destination. ", + { + "text": "Get help deciding", + "link": "https://www.rudderstack.com/docs/destinations/rudderstack-connection-modes/" + } + ], + "icon": "sliders", + "fields": [] + } + ] } - }, - { - "type": "dynamicCustomForm", - "value": "whitelistedEvents", - "label": "Allowlist", - "customFields": [ - { - "type": "textInput", - "value": "eventName", - "required": false, - "placeholder": "e.g: Anonymous Page Visit" - } - ] - }, - { - "type": "dynamicCustomForm", - "value": "blacklistedEvents", - "label": "Denylist", - "customFields": [ - { - "type": "textInput", - "value": "eventName", - "required": false, - "placeholder": "e.g: Credit Card Added" - } - ] - } - ] - }, - { - "title": "Consent Settings", - "fields": [ - { - "type": "dynamicCustomForm", - "value": "oneTrustCookieCategories", - "label": "OneTrust Cookie Categories", - "customFields": [ - { - "type": "textInput", - "placeholder": "Marketing", - "value": "oneTrustCookieCategory", - "label": "Category Name/ID", - "required": false - } - ] - } - ] + ] + }, + { + "title": "Configuration settings", + "note": "Manage the settings for your destination", + "sections": [ + { + "title": "Destination settings", + "note": "Configure advanced destination-specific settings here", + "icon": "settings", + "groups": [ + { + "title": "Intercom IT", + "fields": [ + { + "type": "checkbox", + "label": "Send AnonymousId as Secondary UserId", + "configKey": "sendAnonymousId", + "default": false, + "preRequisites": { + "fields": [ + { + "configKey": "connectionModes.cloud", + "value": true + } + ] + } + } + ] + } + ] + }, + { + "title": "Other settings", + "note": "Configure advanced RudderStack features here", + "icon": "otherSettings", + "groups": [ + { + "title": "Client-side event filtering", + "note": "Decide what events are allowed (allowlisting) and blocked (denylisting)", + "preRequisites": { + "fields": [ + { + "configKey": "connectionModes.webDevice", + "value": true + }, + { + "configKey": "connectionModes.mobileDevice", + "value": true + } + ], + "condition": "or" + }, + "fields": [ + { + "type": "singleSelect", + "label": "Choose if you want to turn on events filtering:", + "configKey": "eventFilteringOption", + "note": "You must select either allowlist or denylist to enable events filtering", + "options": [ + { + "label": "No events filtering", + "value": "disable" + }, + { + "label": "Filter via allowlist", + "value": "whitelistedEvents" + }, + { + "label": "Filter via denylist", + "value": "blacklistedEvents" + } + ], + "default": "disable" + }, + { + "type": "tagInput", + "label": "Allowlisted events", + "note": "Input separate events by pressing ‘Enter’.\nInput the events you want to allowlist.", + "configKey": "whitelistedEvents", + "tagKey": "eventName", + "placeholder": "e.g: Anonymous page visit", + "default": [ + { + "eventName": "" + } + ], + "preRequisites": { + "fields": [ + { + "configKey": "eventFilteringOption", + "value": "whitelistedEvents" + } + ] + } + }, + { + "type": "tagInput", + "label": "Denylisted events", + "note": "Input separate events by pressing ‘Enter’.\nInput the events you want to denylist. ", + "configKey": "blacklistedEvents", + "tagKey": "eventName", + "placeholder": "e.g: Anonymous page visit", + "default": [ + { + "eventName": "" + } + ], + "preRequisites": { + "fields": [ + { + "configKey": "eventFilteringOption", + "value": "blacklistedEvents" + } + ] + } + } + ] + }, + { + "title": "OneTrust cookie consent settings", + "note": [ + "Enter your OneTrust category names if you have them configured. ", + { + "text": "Learn more ", + "link": "https://www.rudderstack.com/docs/sources/event-streams/sdks/rudderstack-javascript-sdk/onetrust-consent-manager/" + }, + "about RudderStack’s OneTrust Consent Manager feature." + ], + "fields": [ + { + "type": "tagInput", + "label": "Cookie category name", + "note": "Input your OneTrust category names by pressing ‘Enter’ after each entry", + "configKey": "oneTrustCookieCategories", + "tagKey": "oneTrustCookieCategory", + "placeholder": "e.g: Credit card visit", + "default": [ + { + "oneTrustCookieCategory": "" + } + ] + } + ] + } + ] + } + ] + } + ], + "sdkTemplate": { + "title": "Web SDK settings", + "note": "not visible in the ui", + "fields": [] } - ] -} + } +} \ No newline at end of file From 968af3628a1cff9a5b2d763eb2042a5dc6631cd5 Mon Sep 17 00:00:00 2001 From: mihir-4116 Date: Tue, 26 Sep 2023 14:27:48 +0530 Subject: [PATCH 2/3] chore: code review changes --- src/configurations/destinations/intercom/db-config.json | 2 +- src/configurations/destinations/intercom/schema.json | 4 ++-- src/configurations/destinations/intercom/ui-config.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/configurations/destinations/intercom/db-config.json b/src/configurations/destinations/intercom/db-config.json index fa31e4c6b..d65af37f9 100644 --- a/src/configurations/destinations/intercom/db-config.json +++ b/src/configurations/destinations/intercom/db-config.json @@ -47,7 +47,7 @@ }, "destConfig": { "defaultConfig": [ - "apiKey", + "accessToken", "appId", "apiServer", "sendAnonymousId", diff --git a/src/configurations/destinations/intercom/schema.json b/src/configurations/destinations/intercom/schema.json index 314e57301..02662375e 100644 --- a/src/configurations/destinations/intercom/schema.json +++ b/src/configurations/destinations/intercom/schema.json @@ -1,10 +1,10 @@ { "configSchema": { "$schema": "http://json-schema.org/draft-07/schema#", - "required": ["apiKey", "apiServer"], + "required": ["accessToken", "apiServer"], "type": "object", "properties": { - "apiKey": { + "accessToken": { "type": "string", "pattern": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{1,100})$" }, diff --git a/src/configurations/destinations/intercom/ui-config.json b/src/configurations/destinations/intercom/ui-config.json index 5398d750e..eb6fdb435 100644 --- a/src/configurations/destinations/intercom/ui-config.json +++ b/src/configurations/destinations/intercom/ui-config.json @@ -15,7 +15,7 @@ { "type": "textInput", "label": "Access Token", - "configKey": "apiKey", + "configKey": "accessToken", "regex": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{1,100})$", "regexErrorMessage": "Invalid Access Token", "placeholder": "e.g: FGHrOjU4ZDc0MjEyXzhjYmNfNDZmYl85ODUxX2RjZDk0Mzk1M2VlMDoxOjA=" From da2fa1dbcf9d2cc7a6171cd73c8cbbf71505c348 Mon Sep 17 00:00:00 2001 From: mihir-4116 Date: Tue, 26 Sep 2023 14:39:04 +0530 Subject: [PATCH 3/3] fix(intercom): test cases --- .../validation/destinations/intercom.json | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/test/data/validation/destinations/intercom.json b/test/data/validation/destinations/intercom.json index 7ccf2aba2..06566ceb5 100644 --- a/test/data/validation/destinations/intercom.json +++ b/test/data/validation/destinations/intercom.json @@ -1,22 +1,8 @@ [ - { - "config": { - "apiKey": "cdsfvgertefdvcdfgrtfvdgrfvd", - "useNativeSDK": { "web": false }, - "blacklistedEvents": [{ "eventName": "Pin Generated" }, { "eventName": "Pin Expired" }], - "whitelistedEvents": [{ "eventName": "" }], - "eventFilteringOption": "blacklistedEvents", - "oneTrustCookieCategories": [ - { "oneTrustCookieCategory": "Sales" }, - { "oneTrustCookieCategory": "Marketing" } - ] - }, - "result": false, - "err": [" must have required property 'appId'"] - }, { "config": { "appId": "bhjjknlmnbhjnklm", + "apiServer": "standard", "useNativeSDK": { "web": false }, "blacklistedEvents": [{ "eventName": "Pin Generated" }, { "eventName": "Pin Expired" }], "whitelistedEvents": [{ "eventName": "" }], @@ -28,8 +14,9 @@ }, { "config": { - "apiKey": "dfvgtbheygrefdbfgtyhrgfghtgrfdv", + "accessToken": "dfvgtbheygrefdbfgtyhrgfghtgrfdv", "appId": "bhjjknlmnbhjnklm", + "apiServer": "standard", "useNativeSDK": { "web": false }, "blacklistedEvents": [{ "eventName": "Pin Generated" }, { "eventName": "Pin Expired" }], "whitelistedEvents": [{ "eventName": "" }],