@segment/analytics-browser-actions-intercom 1.0.0 → 1.4.1-AudienceSettingsSupport.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/api.d.ts +9 -0
- package/dist/cjs/api.js +3 -0
- package/dist/cjs/api.js.map +1 -0
- package/dist/cjs/generated-types.d.ts +6 -0
- package/dist/cjs/generated-types.js +3 -0
- package/dist/cjs/generated-types.js.map +1 -0
- package/dist/cjs/identifyCompany/generated-types.d.ts +16 -0
- package/dist/cjs/identifyCompany/generated-types.js +3 -0
- package/dist/cjs/identifyCompany/generated-types.js.map +1 -0
- package/dist/cjs/identifyCompany/index.d.ts +6 -0
- package/dist/cjs/identifyCompany/index.js +65 -0
- package/dist/cjs/identifyCompany/index.js.map +1 -0
- package/dist/cjs/identifyUser/generated-types.d.ts +41 -0
- package/dist/cjs/identifyUser/generated-types.js +3 -0
- package/dist/cjs/identifyUser/generated-types.js.map +1 -0
- package/dist/cjs/identifyUser/index.d.ts +6 -0
- package/dist/cjs/identifyUser/index.js +213 -0
- package/dist/cjs/identifyUser/index.js.map +1 -0
- package/dist/cjs/index.d.ts +11 -0
- package/dist/cjs/index.js +95 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/init-script.d.ts +4 -0
- package/dist/cjs/init-script.js +53 -0
- package/dist/cjs/init-script.js.map +1 -0
- package/dist/cjs/sharedCompanyProperties.d.ts +2 -0
- package/dist/cjs/sharedCompanyProperties.js +62 -0
- package/dist/cjs/sharedCompanyProperties.js.map +1 -0
- package/dist/cjs/trackEvent/generated-types.d.ts +8 -0
- package/dist/cjs/trackEvent/generated-types.js +3 -0
- package/dist/cjs/trackEvent/generated-types.js.map +1 -0
- package/dist/cjs/trackEvent/index.d.ts +6 -0
- package/dist/cjs/trackEvent/index.js +77 -0
- package/dist/cjs/trackEvent/index.js.map +1 -0
- package/dist/cjs/utils.d.ts +10 -0
- package/dist/cjs/utils.js +48 -0
- package/dist/cjs/utils.js.map +1 -0
- package/dist/esm/api.d.ts +9 -0
- package/dist/esm/api.js +2 -0
- package/dist/esm/api.js.map +1 -0
- package/dist/esm/generated-types.d.ts +6 -0
- package/dist/esm/generated-types.js +2 -0
- package/dist/esm/generated-types.js.map +1 -0
- package/dist/esm/identifyCompany/generated-types.d.ts +16 -0
- package/dist/esm/identifyCompany/generated-types.js +2 -0
- package/dist/esm/identifyCompany/generated-types.js.map +1 -0
- package/dist/esm/identifyCompany/index.d.ts +6 -0
- package/dist/esm/identifyCompany/index.js +63 -0
- package/dist/esm/identifyCompany/index.js.map +1 -0
- package/dist/esm/identifyUser/generated-types.d.ts +41 -0
- package/dist/esm/identifyUser/generated-types.js +2 -0
- package/dist/esm/identifyUser/generated-types.js.map +1 -0
- package/dist/esm/identifyUser/index.d.ts +6 -0
- package/dist/esm/identifyUser/index.js +211 -0
- package/dist/esm/identifyUser/index.js.map +1 -0
- package/dist/esm/index.d.ts +11 -0
- package/dist/esm/index.js +91 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/init-script.d.ts +4 -0
- package/dist/esm/init-script.js +48 -0
- package/dist/esm/init-script.js.map +1 -0
- package/dist/esm/sharedCompanyProperties.d.ts +2 -0
- package/dist/esm/sharedCompanyProperties.js +58 -0
- package/dist/esm/sharedCompanyProperties.js.map +1 -0
- package/dist/esm/trackEvent/generated-types.d.ts +8 -0
- package/dist/esm/trackEvent/generated-types.js +2 -0
- package/dist/esm/trackEvent/generated-types.js.map +1 -0
- package/dist/esm/trackEvent/index.d.ts +6 -0
- package/dist/esm/trackEvent/index.js +75 -0
- package/dist/esm/trackEvent/index.js.map +1 -0
- package/dist/esm/utils.d.ts +10 -0
- package/dist/esm/utils.js +40 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +6 -5
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare type method = 'trackEvent' | 'update';
|
|
2
|
+
declare type IntercomApi = {
|
|
3
|
+
richLinkProperties: string[] | undefined;
|
|
4
|
+
appId: string;
|
|
5
|
+
activator: string | undefined;
|
|
6
|
+
};
|
|
7
|
+
declare type IntercomFunction = (method: method, ...args: unknown[]) => void;
|
|
8
|
+
export declare type Intercom = IntercomFunction & IntercomApi;
|
|
9
|
+
export {};
|
package/dist/cjs/api.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/api.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../src/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface Payload {
|
|
2
|
+
company: {
|
|
3
|
+
company_id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
created_at?: string | number;
|
|
6
|
+
plan?: string;
|
|
7
|
+
monthly_spend?: number;
|
|
8
|
+
size?: number;
|
|
9
|
+
website?: string;
|
|
10
|
+
industry?: string;
|
|
11
|
+
company_custom_traits?: {
|
|
12
|
+
[k: string]: unknown;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
hide_default_launcher?: boolean;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/identifyCompany/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BrowserActionDefinition } from '@segment/browser-destination-runtime/types';
|
|
2
|
+
import { Intercom } from '../api';
|
|
3
|
+
import type { Settings } from '../generated-types';
|
|
4
|
+
import type { Payload } from './generated-types';
|
|
5
|
+
declare const action: BrowserActionDefinition<Settings, Intercom, Payload>;
|
|
6
|
+
export default action;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const sharedCompanyProperties_1 = require("../sharedCompanyProperties");
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const companyProperties = sharedCompanyProperties_1.getCompanyProperties();
|
|
6
|
+
const action = {
|
|
7
|
+
title: 'Identify Company',
|
|
8
|
+
description: 'Create or update a company in Intercom.',
|
|
9
|
+
defaultSubscription: 'type = "group"',
|
|
10
|
+
platform: 'web',
|
|
11
|
+
fields: {
|
|
12
|
+
company: {
|
|
13
|
+
description: "The user's company.",
|
|
14
|
+
label: 'Company',
|
|
15
|
+
type: 'object',
|
|
16
|
+
required: true,
|
|
17
|
+
properties: companyProperties,
|
|
18
|
+
default: {
|
|
19
|
+
company_id: { '@path': '$.groupId' },
|
|
20
|
+
name: { '@path': '$.traits.name' },
|
|
21
|
+
created_at: {
|
|
22
|
+
'@if': {
|
|
23
|
+
exists: { '@path': '$.traits.createdAt' },
|
|
24
|
+
then: { '@path': '$.traits.createdAt' },
|
|
25
|
+
else: { '@path': '$.traits.created_at' }
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
plan: { '@path': '$.traits.plan' },
|
|
29
|
+
size: { '@path': '$.traits.size' },
|
|
30
|
+
website: { '@path': '$.traits.website' },
|
|
31
|
+
industry: { '@path': '$.traits.industry' },
|
|
32
|
+
monthly_spend: { '@path': '$.traits.monthly_spend' }
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
hide_default_launcher: {
|
|
36
|
+
description: 'Selectively show the chat widget. As per [Intercom docs](https://www.intercom.com/help/en/articles/189-turn-off-show-or-hide-the-intercom-messenger), you want to first hide the Messenger for all users inside the Intercom UI using Messenger settings. Then think about how you want to programmatically decide which users you would like to show the widget to.',
|
|
37
|
+
label: 'Hide Default Launcher',
|
|
38
|
+
type: 'boolean',
|
|
39
|
+
required: false,
|
|
40
|
+
default: {
|
|
41
|
+
'@if': {
|
|
42
|
+
exists: { '@path': '$.context.Intercom.hideDefaultLauncher' },
|
|
43
|
+
then: { '@path': '$.context.Intercom.hideDefaultLauncher' },
|
|
44
|
+
else: { '@path': '$.context.Intercom.hide_default_launcher' }
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
perform: (Intercom, event) => {
|
|
50
|
+
const { company_custom_traits, ...rest } = event.payload.company;
|
|
51
|
+
let company = { ...rest };
|
|
52
|
+
if (company?.created_at) {
|
|
53
|
+
company.created_at = utils_1.convertDateToUnix(company.created_at);
|
|
54
|
+
}
|
|
55
|
+
const filteredCustomTraits = utils_1.filterCustomTraits(company_custom_traits);
|
|
56
|
+
company = { ...company, ...filteredCustomTraits };
|
|
57
|
+
const widgetOptions = utils_1.getWidgetOptions(event.payload.hide_default_launcher, Intercom.activator);
|
|
58
|
+
Intercom('update', {
|
|
59
|
+
company,
|
|
60
|
+
...widgetOptions
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
exports.default = action;
|
|
65
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/identifyCompany/index.ts"],"names":[],"mappings":";;AAIA,wEAAiE;AACjE,oCAAkF;AAGlF,MAAM,iBAAiB,GAA+B,8CAAoB,EAAE,CAAA;AAE5E,MAAM,MAAM,GAAyD;IACnE,KAAK,EAAE,kBAAkB;IACzB,WAAW,EAAE,yCAAyC;IACtD,mBAAmB,EAAE,gBAAgB;IACrC,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE;QACN,OAAO,EAAE;YACP,WAAW,EAAE,qBAAqB;YAClC,KAAK,EAAE,SAAS;YAChB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,iBAAiB;YAC7B,OAAO,EAAE;gBACP,UAAU,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE;gBACpC,IAAI,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE;gBAClC,UAAU,EAAE;oBACV,KAAK,EAAE;wBACL,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,GAAG,wBAAgB,CAAC,KAAK,CAAC,OAAO,CAAC,qBAAqB,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAA;QAG/F,QAAQ,CAAC,QAAQ,EAAE;YACjB,OAAO;YACP,GAAG,aAAa;SACjB,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface Payload {
|
|
2
|
+
user_id?: string;
|
|
3
|
+
custom_traits?: {
|
|
4
|
+
[k: string]: unknown;
|
|
5
|
+
};
|
|
6
|
+
name?: string;
|
|
7
|
+
phone?: string;
|
|
8
|
+
unsubscribed_from_emails?: boolean;
|
|
9
|
+
language_override?: string;
|
|
10
|
+
email?: string;
|
|
11
|
+
created_at?: string | number;
|
|
12
|
+
avatar_image_url?: string;
|
|
13
|
+
user_hash?: string;
|
|
14
|
+
company?: {
|
|
15
|
+
company_id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
created_at?: string | number;
|
|
18
|
+
plan?: string;
|
|
19
|
+
monthly_spend?: number;
|
|
20
|
+
size?: number;
|
|
21
|
+
website?: string;
|
|
22
|
+
industry?: string;
|
|
23
|
+
company_custom_traits?: {
|
|
24
|
+
[k: string]: unknown;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
companies?: {
|
|
28
|
+
company_id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
created_at?: string | number;
|
|
31
|
+
plan?: string;
|
|
32
|
+
monthly_spend?: number;
|
|
33
|
+
size?: number;
|
|
34
|
+
website?: string;
|
|
35
|
+
industry?: string;
|
|
36
|
+
company_custom_traits?: {
|
|
37
|
+
[k: string]: unknown;
|
|
38
|
+
};
|
|
39
|
+
}[];
|
|
40
|
+
hide_default_launcher?: boolean;
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/identifyUser/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BrowserActionDefinition } from '@segment/browser-destination-runtime/types';
|
|
2
|
+
import { Intercom } from '../api';
|
|
3
|
+
import type { Settings } from '../generated-types';
|
|
4
|
+
import type { Payload } from './generated-types';
|
|
5
|
+
declare const action: BrowserActionDefinition<Settings, Intercom, Payload>;
|
|
6
|
+
export default action;
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const sharedCompanyProperties_1 = require("../sharedCompanyProperties");
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const companyProperties = sharedCompanyProperties_1.getCompanyProperties();
|
|
6
|
+
const action = {
|
|
7
|
+
title: 'Identify User',
|
|
8
|
+
description: 'Create or update a user in Intercom.',
|
|
9
|
+
defaultSubscription: 'type = "identify" or type = "page"',
|
|
10
|
+
platform: 'web',
|
|
11
|
+
fields: {
|
|
12
|
+
user_id: {
|
|
13
|
+
description: 'A unique identifier for the user.',
|
|
14
|
+
label: 'User ID',
|
|
15
|
+
type: 'string',
|
|
16
|
+
required: false,
|
|
17
|
+
default: {
|
|
18
|
+
'@path': '$.userId'
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
custom_traits: {
|
|
22
|
+
description: "The user's custom attributes.",
|
|
23
|
+
label: 'Custom Attributes',
|
|
24
|
+
type: 'object',
|
|
25
|
+
required: false,
|
|
26
|
+
defaultObjectUI: 'keyvalue'
|
|
27
|
+
},
|
|
28
|
+
name: {
|
|
29
|
+
description: "The user's name.",
|
|
30
|
+
label: 'Name',
|
|
31
|
+
type: 'string',
|
|
32
|
+
required: false,
|
|
33
|
+
default: {
|
|
34
|
+
'@path': '$.traits.name'
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
phone: {
|
|
38
|
+
description: "The user's phone number.",
|
|
39
|
+
label: 'Phone Number',
|
|
40
|
+
type: 'string',
|
|
41
|
+
required: false,
|
|
42
|
+
default: {
|
|
43
|
+
'@path': '$.traits.phone'
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
unsubscribed_from_emails: {
|
|
47
|
+
description: "The user's email unsubscribe status.",
|
|
48
|
+
label: 'Unsubscribed From Emails',
|
|
49
|
+
type: 'boolean',
|
|
50
|
+
required: false
|
|
51
|
+
},
|
|
52
|
+
language_override: {
|
|
53
|
+
description: "The user's messenger language (instead of relying on browser language settings).",
|
|
54
|
+
label: 'Language Override',
|
|
55
|
+
type: 'string',
|
|
56
|
+
required: false
|
|
57
|
+
},
|
|
58
|
+
email: {
|
|
59
|
+
description: "The user's email address.",
|
|
60
|
+
label: 'Email Address',
|
|
61
|
+
type: 'string',
|
|
62
|
+
required: false,
|
|
63
|
+
default: {
|
|
64
|
+
'@path': '$.traits.email'
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
created_at: {
|
|
68
|
+
description: 'The time the user was created in your system.',
|
|
69
|
+
label: 'User Creation Time',
|
|
70
|
+
type: 'datetime',
|
|
71
|
+
required: false,
|
|
72
|
+
default: {
|
|
73
|
+
'@if': {
|
|
74
|
+
exists: { '@path': '$.traits.createdAt' },
|
|
75
|
+
then: { '@path': '$.traits.createdAt' },
|
|
76
|
+
else: { '@path': '$.traits.created_at' }
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
avatar_image_url: {
|
|
81
|
+
description: "The URL for the user's avatar/profile image.",
|
|
82
|
+
label: 'Avatar',
|
|
83
|
+
type: 'string',
|
|
84
|
+
required: false,
|
|
85
|
+
default: { '@path': '$.traits.avatar' }
|
|
86
|
+
},
|
|
87
|
+
user_hash: {
|
|
88
|
+
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.',
|
|
89
|
+
label: 'User Hash',
|
|
90
|
+
type: 'string',
|
|
91
|
+
required: false,
|
|
92
|
+
default: {
|
|
93
|
+
'@if': {
|
|
94
|
+
exists: { '@path': '$.context.Intercom.user_hash' },
|
|
95
|
+
then: { '@path': '$.context.Intercom.user_hash' },
|
|
96
|
+
else: { '@path': '$.context.Intercom.userHash' }
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
company: {
|
|
101
|
+
description: "The user's company.",
|
|
102
|
+
label: 'Company',
|
|
103
|
+
type: 'object',
|
|
104
|
+
required: false,
|
|
105
|
+
properties: companyProperties,
|
|
106
|
+
default: {
|
|
107
|
+
company_id: { '@path': '$.traits.company.id' },
|
|
108
|
+
name: { '@path': '$.traits.company.name' },
|
|
109
|
+
created_at: {
|
|
110
|
+
'@if': {
|
|
111
|
+
exists: { '@path': '$.traits.company.createdAt' },
|
|
112
|
+
then: { '@path': '$.traits.company.createdAt' },
|
|
113
|
+
else: { '@path': '$.traits.company.created_at' }
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
plan: { '@path': '$.traits.company.plan' },
|
|
117
|
+
size: { '@path': '$.traits.company.size' },
|
|
118
|
+
website: { '@path': '$.traits.company.website' },
|
|
119
|
+
industry: { '@path': '$.traits.company.industry' },
|
|
120
|
+
monthly_spend: { '@path': '$.traits.company.monthly_spend' }
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
companies: {
|
|
124
|
+
description: 'The array of companies the user is associated to.',
|
|
125
|
+
label: 'Companies',
|
|
126
|
+
type: 'object',
|
|
127
|
+
multiple: true,
|
|
128
|
+
required: false,
|
|
129
|
+
properties: companyProperties,
|
|
130
|
+
default: {
|
|
131
|
+
'@arrayPath': [
|
|
132
|
+
'$.traits.companies',
|
|
133
|
+
{
|
|
134
|
+
company_id: { '@path': '$.id' },
|
|
135
|
+
name: { '@path': '$.name' },
|
|
136
|
+
created_at: {
|
|
137
|
+
'@if': {
|
|
138
|
+
exists: { '@path': '$.createdAt' },
|
|
139
|
+
then: { '@path': '$.createdAt' },
|
|
140
|
+
else: { '@path': '$.created_at' }
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
plan: { '@path': '$.plan' },
|
|
144
|
+
size: { '@path': '$.size' },
|
|
145
|
+
website: { '@path': '$.website' },
|
|
146
|
+
industry: { '@path': '$.industry' },
|
|
147
|
+
monthly_spend: { '@path': '$.monthly_spend' }
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
hide_default_launcher: {
|
|
153
|
+
description: 'Selectively show the chat widget. As per [Intercom docs](https://www.intercom.com/help/en/articles/189-turn-off-show-or-hide-the-intercom-messenger), you want to first hide the Messenger for all users inside the Intercom UI using Messenger settings. Then think about how you want to programmatically decide which users you would like to show the widget to.',
|
|
154
|
+
label: 'Hide Default Launcher',
|
|
155
|
+
type: 'boolean',
|
|
156
|
+
required: false,
|
|
157
|
+
default: {
|
|
158
|
+
'@if': {
|
|
159
|
+
exists: { '@path': '$.context.Intercom.hideDefaultLauncher' },
|
|
160
|
+
then: { '@path': '$.context.Intercom.hideDefaultLauncher' },
|
|
161
|
+
else: { '@path': '$.context.Intercom.hide_default_launcher' }
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
perform: (Intercom, event) => {
|
|
167
|
+
const { custom_traits, avatar_image_url, ...rest } = event.payload;
|
|
168
|
+
const payload = { ...rest };
|
|
169
|
+
if (utils_1.isEmpty(payload.company?.company_custom_traits)) {
|
|
170
|
+
delete payload.company?.company_custom_traits;
|
|
171
|
+
}
|
|
172
|
+
if (utils_1.isEmpty(payload.company)) {
|
|
173
|
+
delete payload.company;
|
|
174
|
+
}
|
|
175
|
+
const companies = Array.isArray(payload.companies) ? [...payload.companies] : [];
|
|
176
|
+
const datesToConvert = [payload, payload.company, ...companies];
|
|
177
|
+
for (const objectWithDateProp of datesToConvert) {
|
|
178
|
+
if (objectWithDateProp && objectWithDateProp?.created_at) {
|
|
179
|
+
objectWithDateProp.created_at = utils_1.convertDateToUnix(objectWithDateProp.created_at);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
const filteredCustomTraits = utils_1.filterCustomTraits(custom_traits);
|
|
183
|
+
if (payload.company) {
|
|
184
|
+
const { company_custom_traits, ...rest } = payload.company;
|
|
185
|
+
const companyFilteredCustomTraits = utils_1.filterCustomTraits(company_custom_traits);
|
|
186
|
+
payload.company = { ...rest, ...companyFilteredCustomTraits };
|
|
187
|
+
}
|
|
188
|
+
if (payload.companies) {
|
|
189
|
+
payload.companies = payload.companies.map((company) => {
|
|
190
|
+
const { company_custom_traits, ...rest } = company;
|
|
191
|
+
const companyFilteredCustomTraits = utils_1.filterCustomTraits(company_custom_traits);
|
|
192
|
+
company = { ...rest, ...companyFilteredCustomTraits };
|
|
193
|
+
return company;
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
const widgetOptions = utils_1.getWidgetOptions(payload.hide_default_launcher, Intercom.activator);
|
|
197
|
+
let avatar = {};
|
|
198
|
+
if (avatar_image_url) {
|
|
199
|
+
avatar = {
|
|
200
|
+
image_url: avatar_image_url,
|
|
201
|
+
type: 'avatar'
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
Intercom('update', {
|
|
205
|
+
...payload,
|
|
206
|
+
...filteredCustomTraits,
|
|
207
|
+
...widgetOptions,
|
|
208
|
+
...(!utils_1.isEmpty(avatar) && { avatar })
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
exports.default = action;
|
|
213
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/identifyUser/index.ts"],"names":[],"mappings":";;AAIA,wEAAiE;AACjE,oCAA2F;AAG3F,MAAM,iBAAiB,GAA+B,8CAAoB,EAAE,CAAA;AAE5E,MAAM,MAAM,GAAyD;IACnE,KAAK,EAAE,eAAe;IACtB,WAAW,EAAE,sCAAsC;IACnD,mBAAmB,EAAE,oCAAoC;IACzD,QAAQ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AAO,CAAC,OAAO,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,2BAA2B,EAAE,CAAA;SAC9D;QAGD,IAAI,OAAO,CAAC,SAAS,EAAE;YACrB,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;gBACpD,MAAM,EAAE,qBAAqB,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAA;gBAClD,MAAM,2BAA2B,GAAG,0BAAkB,CAAC,qBAAqB,CAAC,CAAA;gBAC7E,OAAO,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,2BAA2B,EAAE,CAAA;gBACrD,OAAO,OAAO,CAAA;YAChB,CAAC,CAAC,CAAA;SACH;QAGD,MAAM,aAAa,GAAG,wBAAgB,CAAC,OAAO,CAAC,qBAAqB,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAA;QAGzF,IAAI,MAAM,GAAG,EAAE,CAAA;QACf,IAAI,gBAAgB,EAAE;YACpB,MAAM,GAAG;gBACP,SAAS,EAAE,gBAAgB;gBAC3B,IAAI,EAAE,QAAQ;aACf,CAAA;SACF;QAGD,QAAQ,CAAC,QAAQ,EAAE;YACjB,GAAG,OAAO;YACV,GAAG,oBAAoB;YACvB,GAAG,aAAa;YAChB,GAAG,CAAC,CAAC,eAAO,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;SACpC,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Settings } from './generated-types';
|
|
2
|
+
import type { BrowserDestinationDefinition } from '@segment/browser-destination-runtime/types';
|
|
3
|
+
import { Intercom } from './api';
|
|
4
|
+
declare global {
|
|
5
|
+
interface Window {
|
|
6
|
+
Intercom: Intercom;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export declare const destination: BrowserDestinationDefinition<Settings, Intercom>;
|
|
10
|
+
declare const _default: import("@segment/browser-destination-runtime/types").PluginFactory;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.destination = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const shim_1 = require("@segment/browser-destination-runtime/shim");
|
|
6
|
+
const init_script_1 = require("./init-script");
|
|
7
|
+
const trackEvent_1 = tslib_1.__importDefault(require("./trackEvent"));
|
|
8
|
+
const identifyUser_1 = tslib_1.__importDefault(require("./identifyUser"));
|
|
9
|
+
const identifyCompany_1 = tslib_1.__importDefault(require("./identifyCompany"));
|
|
10
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
11
|
+
exports.destination = {
|
|
12
|
+
name: 'Intercom Web (Actions)',
|
|
13
|
+
slug: 'actions-intercom-web',
|
|
14
|
+
mode: 'device',
|
|
15
|
+
presets: [
|
|
16
|
+
{
|
|
17
|
+
name: 'Track Event',
|
|
18
|
+
subscribe: 'type = "track"',
|
|
19
|
+
partnerAction: 'trackEvent',
|
|
20
|
+
mapping: actions_core_1.defaultValues(trackEvent_1.default.fields)
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'Identify User',
|
|
24
|
+
subscribe: 'type = "identify" or type = "page"',
|
|
25
|
+
partnerAction: 'identifyUser',
|
|
26
|
+
mapping: actions_core_1.defaultValues(identifyUser_1.default.fields)
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'Identify Company',
|
|
30
|
+
subscribe: 'type = "group"',
|
|
31
|
+
partnerAction: 'identifyCompany',
|
|
32
|
+
mapping: actions_core_1.defaultValues(identifyCompany_1.default.fields)
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
settings: {
|
|
36
|
+
appId: {
|
|
37
|
+
description: 'The app_id of your Intercom app which will indicate where to store any data.',
|
|
38
|
+
label: 'App ID',
|
|
39
|
+
type: 'string',
|
|
40
|
+
required: true
|
|
41
|
+
},
|
|
42
|
+
activator: {
|
|
43
|
+
description: 'By default, Intercom will inject their own inbox button onto the page, but you can choose to use your own custom button instead by providing a CSS selector, e.g. #my-button. You must have the "Show the Intercom Inbox" setting enabled for this to work. The default value is #IntercomDefaultWidget.',
|
|
44
|
+
label: 'Custom Inbox Button Selector',
|
|
45
|
+
type: 'string',
|
|
46
|
+
required: false,
|
|
47
|
+
default: '#IntercomDefaultWidget'
|
|
48
|
+
},
|
|
49
|
+
richLinkProperties: {
|
|
50
|
+
description: 'A list of rich link property keys.',
|
|
51
|
+
label: 'Rich Link Properties',
|
|
52
|
+
type: 'string',
|
|
53
|
+
multiple: true,
|
|
54
|
+
required: false
|
|
55
|
+
},
|
|
56
|
+
apiBase: {
|
|
57
|
+
description: 'The regional API to use for processing the data',
|
|
58
|
+
label: 'Regional Data Hosting',
|
|
59
|
+
type: 'string',
|
|
60
|
+
choices: [
|
|
61
|
+
{
|
|
62
|
+
label: 'US',
|
|
63
|
+
value: 'https://api-iam.intercom.io'
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
label: 'EU',
|
|
67
|
+
value: 'https://api-iam.eu.intercom.io'
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
label: 'Australia',
|
|
71
|
+
value: 'https://api-iam.au.intercom.io'
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
default: 'https://api-iam.intercom.io',
|
|
75
|
+
required: false
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
initialize: async ({ settings }, deps) => {
|
|
79
|
+
init_script_1.initScript({ appId: settings.appId });
|
|
80
|
+
const preloadedIntercom = window.Intercom;
|
|
81
|
+
init_script_1.initialBoot(settings.appId, { api_base: settings.apiBase });
|
|
82
|
+
await deps.resolveWhen(() => window.Intercom !== preloadedIntercom, 100);
|
|
83
|
+
window.Intercom.richLinkProperties = settings.richLinkProperties;
|
|
84
|
+
window.Intercom.appId = settings.appId;
|
|
85
|
+
window.Intercom.activator = settings.activator;
|
|
86
|
+
return window.Intercom;
|
|
87
|
+
},
|
|
88
|
+
actions: {
|
|
89
|
+
trackEvent: trackEvent_1.default,
|
|
90
|
+
identifyUser: identifyUser_1.default,
|
|
91
|
+
identifyCompany: identifyCompany_1.default
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
exports.default = shim_1.browserDestination(exports.destination);
|
|
95
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAEA,oEAA8E;AAC9E,+CAAuD;AAGvD,sEAAqC;AACrC,0EAAyC;AACzC,gFAA+C;AAC/C,wDAAqD;AAQxC,QAAA,WAAW,GAAqD;IAC3E,IAAI,EAAE,wBAAwB;IAC9B,IAAI,EAAE,sBAAsB;IAC5B,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE;QACP;YACE,IAAI,EAAE,aAAa;YACnB,SAAS,EAAE,gBAAgB;YAC3B,aAAa,EAAE,YAAY;YAC3B,OAAO,EAAE,4BAAa,CAAC,oBAAU,CAAC,MAAM,CAAC;SAC1C;QACD;YACE,IAAI,EAAE,eAAe;YACrB,SAAS,EAAE,oCAAoC;YAC/C,aAAa,EAAE,cAAc;YAC7B,OAAO,EAAE,4BAAa,CAAC,sBAAY,CAAC,MAAM,CAAC;SAC5C;QACD;YACE,IAAI,EAAE,kBAAkB;YACxB,SAAS,EAAE,gBAAgB;YAC3B,aAAa,EAAE,iBAAiB;YAChC,OAAO,EAAE,4BAAa,CAAC,yBAAe,CAAC,MAAM,CAAC;SAC/C;KACF;IACD,QAAQ,EAAE;QACR,KAAK,EAAE;YACL,WAAW,EAAE,8EAA8E;YAC3F,KAAK,EAAE,QAAQ;YACf,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;SACf;QACD,SAAS,EAAE;YACT,WAAW,EACT,0SAA0S;YAC5S,KAAK,EAAE,8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AAA;QAE9C,OAAO,MAAM,CAAC,QAAQ,CAAA;IACxB,CAAC;IAED,OAAO,EAAE;QACP,UAAU,EAAV,oBAAU;QACV,YAAY,EAAZ,sBAAY;QACZ,eAAe,EAAf,yBAAe;KAChB;CACF,CAAA;AAED,kBAAe,yBAAkB,CAAC,mBAAW,CAAC,CAAA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initialBoot = exports.initScript = void 0;
|
|
4
|
+
function initScript({ appId }) {
|
|
5
|
+
var APP_ID = appId;
|
|
6
|
+
(function () {
|
|
7
|
+
var w = window;
|
|
8
|
+
var ic = w.Intercom;
|
|
9
|
+
if (typeof ic === 'function') {
|
|
10
|
+
ic('reattach_activator');
|
|
11
|
+
ic('update', w.intercomSettings);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
var d = document;
|
|
15
|
+
var i = function () {
|
|
16
|
+
i.c(arguments);
|
|
17
|
+
};
|
|
18
|
+
i.q = [];
|
|
19
|
+
i.c = function (args) {
|
|
20
|
+
i.q.push(args);
|
|
21
|
+
};
|
|
22
|
+
w.Intercom = i;
|
|
23
|
+
var l = function () {
|
|
24
|
+
var s = d.createElement('script');
|
|
25
|
+
s.type = 'text/javascript';
|
|
26
|
+
s.async = true;
|
|
27
|
+
s.src = 'https://widget.intercom.io/widget/' + APP_ID;
|
|
28
|
+
var x = d.getElementsByTagName('script')[0];
|
|
29
|
+
x.parentNode.insertBefore(s, x);
|
|
30
|
+
};
|
|
31
|
+
if (document.readyState === 'complete') {
|
|
32
|
+
l();
|
|
33
|
+
}
|
|
34
|
+
else if (w.attachEvent) {
|
|
35
|
+
w.attachEvent('onload', l);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
w.addEventListener('load', l, false);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
})();
|
|
42
|
+
}
|
|
43
|
+
exports.initScript = initScript;
|
|
44
|
+
function initialBoot(appId, options = {}) {
|
|
45
|
+
window &&
|
|
46
|
+
window.Intercom &&
|
|
47
|
+
window.Intercom('boot', {
|
|
48
|
+
app_id: appId,
|
|
49
|
+
...options
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
exports.initialBoot = initialBoot;
|
|
53
|
+
//# sourceMappingURL=init-script.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-script.js","sourceRoot":"","sources":["../../src/init-script.ts"],"names":[],"mappings":";;;AAGA,SAAgB,UAAU,CAAC,EAAE,KAAK,EAAE;IAElC,IAAI,MAAM,GAAG,KAAK,CACjB;IAAA,CAAC;QACA,IAAI,CAAC,GAAG,MAAM,CAAA;QACd,IAAI,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAA;QACnB,IAAI,OAAO,EAAE,KAAK,UAAU,EAAE;YAC5B,EAAE,CAAC,oBAAoB,CAAC,CAAA;YACxB,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,gBAAgB,CAAC,CAAA;SACjC;aAAM;YACL,IAAI,CAAC,GAAG,QAAQ,CAAA;YAChB,IAAI,CAAC,GAAG;gBACN,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;YAChB,CAAC,CAAA;YACD,CAAC,CAAC,CAAC,GAAG,EAAE,CAAA;YACR,CAAC,CAAC,CAAC,GAAG,UAAU,IAAI;gBAClB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAChB,CAAC,CAAA;YACD,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAA;YACd,IAAI,CAAC,GAAG;gBACN,IAAI,CAAC,GAAG,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;gBACjC,CAAC,CAAC,IAAI,GAAG,iBAAiB,CAAA;gBAC1B,CAAC,CAAC,KAAK,GAAG,IAAI,CAAA;gBACd,CAAC,CAAC,GAAG,GAAG,oCAAoC,GAAG,MAAM,CA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