From bc6ccfc0f236975e69887062a5bc9e02b7513d0c Mon Sep 17 00:00:00 2001 From: Jacopo Scrinzi Date: Mon, 7 Apr 2025 11:20:48 -0500 Subject: [PATCH 1/2] add intercom_user_jwt --- .../src/identifyUser/__tests__/index.test.ts | 47 +++++++++++++++++++ .../intercom/src/identifyUser/index.ts | 16 ++++++- 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/packages/browser-destinations/destinations/intercom/src/identifyUser/__tests__/index.test.ts b/packages/browser-destinations/destinations/intercom/src/identifyUser/__tests__/index.test.ts index 712f6e17c7..a9916062f9 100644 --- a/packages/browser-destinations/destinations/intercom/src/identifyUser/__tests__/index.test.ts +++ b/packages/browser-destinations/destinations/intercom/src/identifyUser/__tests__/index.test.ts @@ -38,6 +38,13 @@ const subscriptions: Subscription[] = [ else: { '@path': '$.context.Intercom.userHash' } } }, + intercom_user_jwt: { + '@if': { + exists: { '@path': '$.context.Intercom.intercom_user_jwt' }, + then: { '@path': '$.context.Intercom.intercom_user_jwt' }, + else: { '@path': '$.context.Intercom.intercomUserJwt' } + } + }, hide_default_launcher: { '@if': { exists: { '@path': '$.context.Intercom.hideDefaultLauncher' }, @@ -368,6 +375,46 @@ describe('Intercom.update (user)', () => { user_hash: 'x' }) }) + + test('allows passing a intercom user jwt', async () => { + const context = new Context({ + type: 'identify', + userId: 'id', + traits: {}, + context: { + Intercom: { + intercom_user_jwt: 'x' + } + } + }) + + await identifyUser.identify?.(context) + + expect(mockIntercom).toHaveBeenCalledWith('update', { + user_id: 'id', + intercom_user_jwt: 'x' + }) + }) + + test('accepts snake/camel case for intercom_user_jwt', async () => { + const context = new Context({ + type: 'identify', + userId: 'id', + traits: {}, + context: { + Intercom: { + intercomUserJwt: 'x' + } + } + }) + + await identifyUser.identify?.(context) + + expect(mockIntercom).toHaveBeenCalledWith('update', { + user_id: 'id', + intercom_user_jwt: 'x' + }) + }) }) describe('Intercom.update (user) widget options', () => { diff --git a/packages/browser-destinations/destinations/intercom/src/identifyUser/index.ts b/packages/browser-destinations/destinations/intercom/src/identifyUser/index.ts index 4384859222..bd407dd679 100644 --- a/packages/browser-destinations/destinations/intercom/src/identifyUser/index.ts +++ b/packages/browser-destinations/destinations/intercom/src/identifyUser/index.ts @@ -91,7 +91,7 @@ const action: BrowserActionDefinition = { }, user_hash: { description: - 'The user hash used for identity verification. See [Intercom docs](https://www.intercom.com/help/en/articles/183-enable-identity-verification-for-web-and-mobile) for more information on how to set this field.', + 'The user hash used for identity verification. See [Intercom docs](https://www.intercom.com/help/en/collections/12295815-messenger-security) for more information on how to set this field.', label: 'User Hash', type: 'string', required: false, @@ -103,6 +103,20 @@ const action: BrowserActionDefinition = { } } }, + intercom_user_jwt: { + description: + 'The intercom user JWT is used to secure your messenger for your users. See [Intercom docs](https://www.intercom.com/help/en/collections/12295815-messenger-security) for more information on how to set this field.', + label: 'Intercom User JWT', + type: 'string', + required: false, + default: { + '@if': { + exists: { '@path': '$.integrations.Intercom.intercom_user_jwt' }, + then: { '@path': '$.integrations.Intercom.intercom_user_jwt' }, + else: { '@path': '$.integrations.Intercom.intercomUserJwt' } + } + } + }, company: { description: "The user's company.", label: 'Company', From 3a59f17c10070939fc4b928a8448a576ea768f9f Mon Sep 17 00:00:00 2001 From: Jacopo Scrinzi Date: Fri, 2 May 2025 12:50:38 -0500 Subject: [PATCH 2/2] yarn types --- .../intercom/src/identifyUser/generated-types.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/browser-destinations/destinations/intercom/src/identifyUser/generated-types.ts b/packages/browser-destinations/destinations/intercom/src/identifyUser/generated-types.ts index e5e4bc4306..84993d51ca 100644 --- a/packages/browser-destinations/destinations/intercom/src/identifyUser/generated-types.ts +++ b/packages/browser-destinations/destinations/intercom/src/identifyUser/generated-types.ts @@ -40,9 +40,13 @@ export interface Payload { */ avatar_image_url?: string /** - * The user hash used for identity verification. See [Intercom docs](https://www.intercom.com/help/en/articles/183-enable-identity-verification-for-web-and-mobile) for more information on how to set this field. + * The user hash used for identity verification. See [Intercom docs](https://www.intercom.com/help/en/collections/12295815-messenger-security) for more information on how to set this field. */ user_hash?: string + /** + * The intercom user JWT is used to secure your messenger for your users. See [Intercom docs](https://www.intercom.com/help/en/collections/12295815-messenger-security) for more information on how to set this field. + */ + intercom_user_jwt?: string /** * The user's company. */