@segment/analytics-browser-mixpanel-web-actions 1.4.0 → 1.4.1-staging-154441964.0
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/fields.js.map +1 -1
- package/dist/cjs/functions.js.map +1 -1
- package/dist/cjs/init-script.js +59 -15
- package/dist/cjs/init-script.js.map +1 -1
- package/dist/cjs/setting-fields.js +1 -1
- package/dist/cjs/setting-fields.js.map +1 -1
- package/dist/cjs/track/index.js.map +1 -1
- package/dist/cjs/trackPageView/index.js.map +1 -1
- package/dist/esm/fields.js.map +1 -1
- package/dist/esm/functions.js.map +1 -1
- package/dist/esm/init-script.js +59 -15
- package/dist/esm/init-script.js.map +1 -1
- package/dist/esm/setting-fields.js +1 -1
- package/dist/esm/setting-fields.js.map +1 -1
- package/dist/esm/track/index.js.map +1 -1
- package/dist/esm/trackPageView/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/alias/__tests__/index.test.ts +2 -3
- package/src/constants.ts +1 -1
- package/src/fields.ts +137 -134
- package/src/functions.ts +9 -14
- package/src/group/__tests__/index.test.ts +6 -7
- package/src/group/index.ts +2 -2
- package/src/identify/__tests__/index.test.ts +12 -13
- package/src/identify/index.ts +3 -3
- package/src/init-script.ts +60 -2
- package/src/setting-fields.ts +260 -260
- package/src/track/__tests__/index.test.ts +23 -24
- package/src/track/index.ts +8 -6
- package/src/trackPageView/__tests__/index.test.ts +36 -35
- package/src/trackPageView/index.ts +10 -8
package/src/setting-fields.ts
CHANGED
|
@@ -2,272 +2,272 @@ import { PAGE_VIEW_URL_CONFIG_OPTIONS, PERSISTENCE_OPTIONS, AUTOCAPTURE_OPTIONS
|
|
|
2
2
|
import { GlobalSetting } from '@segment/actions-core'
|
|
3
3
|
|
|
4
4
|
export const settingFields: Record<string, GlobalSetting> = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
]
|
|
5
|
+
projectToken: {
|
|
6
|
+
description: 'Your Mixpanel project token.',
|
|
7
|
+
label: 'Project Token',
|
|
8
|
+
type: 'string',
|
|
9
|
+
required: true
|
|
10
|
+
},
|
|
11
|
+
name: {
|
|
12
|
+
label: 'Mixpanel Instance Name',
|
|
13
|
+
description: 'The name for the new mixpanel instance that you want created.',
|
|
14
|
+
type: 'string'
|
|
15
|
+
},
|
|
16
|
+
api_host: {
|
|
17
|
+
description: 'The Mixpanel API host to send data to.',
|
|
18
|
+
label: 'API Host',
|
|
19
|
+
type: 'string',
|
|
20
|
+
format: 'uri',
|
|
21
|
+
required: true,
|
|
22
|
+
default: 'https://api-js.mixpanel.com'
|
|
23
|
+
},
|
|
24
|
+
autocapture: {
|
|
25
|
+
description:
|
|
26
|
+
'Enable or disable Mixpanel autocapture functionality. Select "Custom" to specify fine grained control over which events are autocaptured.',
|
|
27
|
+
label: 'Autocapture',
|
|
28
|
+
type: 'string',
|
|
29
|
+
choices: [
|
|
30
|
+
{ label: 'Enabled', value: AUTOCAPTURE_OPTIONS.ENABLED },
|
|
31
|
+
{ label: 'Disabled', value: AUTOCAPTURE_OPTIONS.DISABLED },
|
|
32
|
+
{ label: 'Custom', value: AUTOCAPTURE_OPTIONS.CUSTOM }
|
|
33
|
+
],
|
|
34
|
+
default: AUTOCAPTURE_OPTIONS.ENABLED
|
|
35
|
+
},
|
|
36
|
+
pageview: {
|
|
37
|
+
description: 'Capture pageview events automatically',
|
|
38
|
+
label: 'Autocapture Pageview',
|
|
39
|
+
type: 'string',
|
|
40
|
+
choices: [
|
|
41
|
+
{ label: 'Full URL', value: PAGE_VIEW_URL_CONFIG_OPTIONS.FULL_URL },
|
|
42
|
+
{ label: 'URL with Path and Query String', value: PAGE_VIEW_URL_CONFIG_OPTIONS.URL_WITH_PATH_AND_QUERY_STRING },
|
|
43
|
+
{ label: 'URL with Path', value: PAGE_VIEW_URL_CONFIG_OPTIONS.URL_WITH_PATH }
|
|
44
|
+
],
|
|
45
|
+
default: PAGE_VIEW_URL_CONFIG_OPTIONS.FULL_URL,
|
|
46
|
+
required: true,
|
|
47
|
+
depends_on: {
|
|
48
|
+
conditions: [
|
|
49
|
+
{
|
|
50
|
+
fieldKey: 'autocapture',
|
|
51
|
+
operator: 'is',
|
|
52
|
+
value: 'custom'
|
|
55
53
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
click: {
|
|
58
|
+
description: 'Capture click events automatically',
|
|
59
|
+
label: 'Autocapture Click',
|
|
60
|
+
type: 'boolean',
|
|
61
|
+
default: true,
|
|
62
|
+
required: true,
|
|
63
|
+
depends_on: {
|
|
64
|
+
conditions: [
|
|
65
|
+
{
|
|
66
|
+
fieldKey: 'autocapture',
|
|
67
|
+
operator: 'is',
|
|
68
|
+
value: 'custom'
|
|
71
69
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
dead_click: {
|
|
74
|
+
description: 'Capture dead click events automatically',
|
|
75
|
+
label: 'Autocapture Dead Click',
|
|
76
|
+
type: 'boolean',
|
|
77
|
+
default: true,
|
|
78
|
+
required: true,
|
|
79
|
+
depends_on: {
|
|
80
|
+
conditions: [
|
|
81
|
+
{
|
|
82
|
+
fieldKey: 'autocapture',
|
|
83
|
+
operator: 'is',
|
|
84
|
+
value: 'custom'
|
|
87
85
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
input: {
|
|
90
|
+
description: 'Capture input events automatically',
|
|
91
|
+
label: 'Autocapture Input',
|
|
92
|
+
type: 'boolean',
|
|
93
|
+
default: true,
|
|
94
|
+
required: true,
|
|
95
|
+
depends_on: {
|
|
96
|
+
conditions: [
|
|
97
|
+
{
|
|
98
|
+
fieldKey: 'autocapture',
|
|
99
|
+
operator: 'is',
|
|
100
|
+
value: 'custom'
|
|
103
101
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
rage_click: {
|
|
106
|
+
description: 'Capture rage click events automatically',
|
|
107
|
+
label: 'Autocapture Rage Click',
|
|
108
|
+
type: 'boolean',
|
|
109
|
+
default: true,
|
|
110
|
+
required: true,
|
|
111
|
+
depends_on: {
|
|
112
|
+
conditions: [
|
|
113
|
+
{
|
|
114
|
+
fieldKey: 'autocapture',
|
|
115
|
+
operator: 'is',
|
|
116
|
+
value: 'custom'
|
|
119
117
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
scroll: {
|
|
122
|
+
description: 'Capture scroll events automatically',
|
|
123
|
+
label: 'Autocapture Scroll',
|
|
124
|
+
type: 'boolean',
|
|
125
|
+
default: true,
|
|
126
|
+
required: true,
|
|
127
|
+
depends_on: {
|
|
128
|
+
conditions: [
|
|
129
|
+
{
|
|
130
|
+
fieldKey: 'autocapture',
|
|
131
|
+
operator: 'is',
|
|
132
|
+
value: 'custom'
|
|
135
133
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
submit: {
|
|
138
|
+
description: 'Capture form submit events automatically',
|
|
139
|
+
label: 'Autocapture Submit',
|
|
140
|
+
type: 'boolean',
|
|
141
|
+
default: true,
|
|
142
|
+
depends_on: {
|
|
143
|
+
conditions: [
|
|
144
|
+
{
|
|
145
|
+
fieldKey: 'autocapture',
|
|
146
|
+
operator: 'is',
|
|
147
|
+
value: 'custom'
|
|
150
148
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
capture_text_content: {
|
|
153
|
+
description: 'Capture text content of elements in autocaptured events',
|
|
154
|
+
label: 'Autocapture Capture Text Content',
|
|
155
|
+
type: 'boolean',
|
|
156
|
+
default: false,
|
|
157
|
+
required: true,
|
|
158
|
+
depends_on: {
|
|
159
|
+
conditions: [
|
|
160
|
+
{
|
|
161
|
+
fieldKey: 'autocapture',
|
|
162
|
+
operator: 'is',
|
|
163
|
+
value: 'custom'
|
|
166
164
|
}
|
|
167
|
-
|
|
168
|
-
cross_subdomain_cookie: {
|
|
169
|
-
description: 'Enable or disable cross subdomain cookies for Mixpanel.',
|
|
170
|
-
label: 'Cross Subdomain Cookie',
|
|
171
|
-
type: 'boolean',
|
|
172
|
-
default: true
|
|
173
|
-
},
|
|
174
|
-
persistence: {
|
|
175
|
-
description: 'Set the persistence method for Mixpanel (cookie or localStorage).',
|
|
176
|
-
label: 'Persistence Method',
|
|
177
|
-
type: 'string',
|
|
178
|
-
choices: [
|
|
179
|
-
{ label: 'Cookie', value: PERSISTENCE_OPTIONS.COOKIE },
|
|
180
|
-
{ label: 'Local Storage', value: PERSISTENCE_OPTIONS.LOCAL_STORAGE }
|
|
181
|
-
],
|
|
182
|
-
default: PERSISTENCE_OPTIONS.COOKIE
|
|
183
|
-
},
|
|
184
|
-
track_marketing: {
|
|
185
|
-
description:
|
|
186
|
-
'Enable or disable tracking of marketing campaigns in Mixpanel. Includes UTM parameters and click identifiers for various ad platforms.',
|
|
187
|
-
label: 'Track Marketing Campaigns',
|
|
188
|
-
type: 'boolean',
|
|
189
|
-
default: true
|
|
190
|
-
},
|
|
191
|
-
cookie_expiration: {
|
|
192
|
-
description: 'Set the cookie expiration time in days for Mixpanel cookies.',
|
|
193
|
-
label: 'Cookie Expiration (days)',
|
|
194
|
-
type: 'number',
|
|
195
|
-
default: 365
|
|
196
|
-
},
|
|
197
|
-
disable_persistence: {
|
|
198
|
-
description: 'Disable all persistence mechanisms for Mixpanel.',
|
|
199
|
-
label: 'Disable Persistence',
|
|
200
|
-
type: 'boolean',
|
|
201
|
-
default: false
|
|
202
|
-
},
|
|
203
|
-
ip: {
|
|
204
|
-
description: 'Enable or disable sending IP address information to Mixpanel.',
|
|
205
|
-
label: 'Send IP Address',
|
|
206
|
-
type: 'boolean',
|
|
207
|
-
default: true
|
|
208
|
-
},
|
|
209
|
-
record_block_class: {
|
|
210
|
-
description: 'CSS class to block elements from being recorded in session recordings.',
|
|
211
|
-
label: 'Record Block Class',
|
|
212
|
-
type: 'string',
|
|
213
|
-
default: 'mp-block'
|
|
214
|
-
},
|
|
215
|
-
record_block_selector: {
|
|
216
|
-
description: 'CSS selector to block elements from being recorded in session recordings.',
|
|
217
|
-
label: 'Record Block Selector',
|
|
218
|
-
type: 'string',
|
|
219
|
-
default: 'img, video, audio'
|
|
220
|
-
},
|
|
221
|
-
record_canvas: {
|
|
222
|
-
description: 'Enable or disable recording of canvas elements in session recordings.',
|
|
223
|
-
label: 'Record Canvas',
|
|
224
|
-
type: 'boolean',
|
|
225
|
-
default: false
|
|
226
|
-
},
|
|
227
|
-
record_heatmap_data: {
|
|
228
|
-
description: 'Enable or disable tracking of heatmap events in session recordings.',
|
|
229
|
-
label: 'Record Heatmap Data',
|
|
230
|
-
type: 'boolean',
|
|
231
|
-
default: false
|
|
232
|
-
},
|
|
233
|
-
record_idle_timeout_ms: {
|
|
234
|
-
description: 'Idle timeout in milliseconds for session recordings.',
|
|
235
|
-
label: 'Record Idle Timeout (ms)',
|
|
236
|
-
type: 'number',
|
|
237
|
-
default: 180_000
|
|
238
|
-
},
|
|
239
|
-
record_mask_text_class: {
|
|
240
|
-
description: 'CSS class to mask text elements in session recordings.',
|
|
241
|
-
label: 'Record Mask Text Class',
|
|
242
|
-
type: 'string',
|
|
243
|
-
default: 'mp-mask'
|
|
244
|
-
},
|
|
245
|
-
record_mask_text_selector: {
|
|
246
|
-
description: 'CSS selector to mask text elements in session recordings.',
|
|
247
|
-
label: 'Record Mask Text Selector',
|
|
248
|
-
type: 'string',
|
|
249
|
-
default: '*'
|
|
250
|
-
},
|
|
251
|
-
record_max_ms: {
|
|
252
|
-
description: 'Maximum recording time in milliseconds for session recordings.',
|
|
253
|
-
label: 'Record Max (ms)',
|
|
254
|
-
type: 'number',
|
|
255
|
-
default: 86_400_000
|
|
256
|
-
},
|
|
257
|
-
record_min_ms: {
|
|
258
|
-
description: 'Minimum recording time in milliseconds for session recordings.',
|
|
259
|
-
label: 'Record Min (ms)',
|
|
260
|
-
type: 'number',
|
|
261
|
-
default: 0,
|
|
262
|
-
minimum: 0,
|
|
263
|
-
maximum: 8_000
|
|
264
|
-
},
|
|
265
|
-
record_sessions_percent: {
|
|
266
|
-
description: 'Percentage of sessions to record for session recordings.',
|
|
267
|
-
label: 'Record Sessions Percent',
|
|
268
|
-
type: 'number',
|
|
269
|
-
default: 0,
|
|
270
|
-
minimum: 0,
|
|
271
|
-
maximum: 100
|
|
165
|
+
]
|
|
272
166
|
}
|
|
273
|
-
}
|
|
167
|
+
},
|
|
168
|
+
cross_subdomain_cookie: {
|
|
169
|
+
description: 'Enable or disable cross subdomain cookies for Mixpanel.',
|
|
170
|
+
label: 'Cross Subdomain Cookie',
|
|
171
|
+
type: 'boolean',
|
|
172
|
+
default: true
|
|
173
|
+
},
|
|
174
|
+
persistence: {
|
|
175
|
+
description: 'Set the persistence method for Mixpanel (cookie or localStorage).',
|
|
176
|
+
label: 'Persistence Method',
|
|
177
|
+
type: 'string',
|
|
178
|
+
choices: [
|
|
179
|
+
{ label: 'Cookie', value: PERSISTENCE_OPTIONS.COOKIE },
|
|
180
|
+
{ label: 'Local Storage', value: PERSISTENCE_OPTIONS.LOCAL_STORAGE }
|
|
181
|
+
],
|
|
182
|
+
default: PERSISTENCE_OPTIONS.COOKIE
|
|
183
|
+
},
|
|
184
|
+
track_marketing: {
|
|
185
|
+
description:
|
|
186
|
+
'Enable or disable tracking of marketing campaigns in Mixpanel. Includes UTM parameters and click identifiers for various ad platforms.',
|
|
187
|
+
label: 'Track Marketing Campaigns',
|
|
188
|
+
type: 'boolean',
|
|
189
|
+
default: true
|
|
190
|
+
},
|
|
191
|
+
cookie_expiration: {
|
|
192
|
+
description: 'Set the cookie expiration time in days for Mixpanel cookies.',
|
|
193
|
+
label: 'Cookie Expiration (days)',
|
|
194
|
+
type: 'number',
|
|
195
|
+
default: 365
|
|
196
|
+
},
|
|
197
|
+
disable_persistence: {
|
|
198
|
+
description: 'Disable all persistence mechanisms for Mixpanel.',
|
|
199
|
+
label: 'Disable Persistence',
|
|
200
|
+
type: 'boolean',
|
|
201
|
+
default: false
|
|
202
|
+
},
|
|
203
|
+
ip: {
|
|
204
|
+
description: 'Enable or disable sending IP address information to Mixpanel.',
|
|
205
|
+
label: 'Send IP Address',
|
|
206
|
+
type: 'boolean',
|
|
207
|
+
default: true
|
|
208
|
+
},
|
|
209
|
+
record_block_class: {
|
|
210
|
+
description: 'CSS class to block elements from being recorded in session recordings.',
|
|
211
|
+
label: 'Record Block Class',
|
|
212
|
+
type: 'string',
|
|
213
|
+
default: 'mp-block'
|
|
214
|
+
},
|
|
215
|
+
record_block_selector: {
|
|
216
|
+
description: 'CSS selector to block elements from being recorded in session recordings.',
|
|
217
|
+
label: 'Record Block Selector',
|
|
218
|
+
type: 'string',
|
|
219
|
+
default: 'img, video, audio'
|
|
220
|
+
},
|
|
221
|
+
record_canvas: {
|
|
222
|
+
description: 'Enable or disable recording of canvas elements in session recordings.',
|
|
223
|
+
label: 'Record Canvas',
|
|
224
|
+
type: 'boolean',
|
|
225
|
+
default: false
|
|
226
|
+
},
|
|
227
|
+
record_heatmap_data: {
|
|
228
|
+
description: 'Enable or disable tracking of heatmap events in session recordings.',
|
|
229
|
+
label: 'Record Heatmap Data',
|
|
230
|
+
type: 'boolean',
|
|
231
|
+
default: false
|
|
232
|
+
},
|
|
233
|
+
record_idle_timeout_ms: {
|
|
234
|
+
description: 'Idle timeout in milliseconds for session recordings.',
|
|
235
|
+
label: 'Record Idle Timeout (ms)',
|
|
236
|
+
type: 'number',
|
|
237
|
+
default: 180_000
|
|
238
|
+
},
|
|
239
|
+
record_mask_text_class: {
|
|
240
|
+
description: 'CSS class to mask text elements in session recordings.',
|
|
241
|
+
label: 'Record Mask Text Class',
|
|
242
|
+
type: 'string',
|
|
243
|
+
default: 'mp-mask'
|
|
244
|
+
},
|
|
245
|
+
record_mask_text_selector: {
|
|
246
|
+
description: 'CSS selector to mask text elements in session recordings.',
|
|
247
|
+
label: 'Record Mask Text Selector',
|
|
248
|
+
type: 'string',
|
|
249
|
+
default: '*'
|
|
250
|
+
},
|
|
251
|
+
record_max_ms: {
|
|
252
|
+
description: 'Maximum recording time in milliseconds for session recordings.',
|
|
253
|
+
label: 'Record Max (ms)',
|
|
254
|
+
type: 'number',
|
|
255
|
+
default: 86_400_000
|
|
256
|
+
},
|
|
257
|
+
record_min_ms: {
|
|
258
|
+
description: 'Minimum recording time in milliseconds for session recordings.',
|
|
259
|
+
label: 'Record Min (ms)',
|
|
260
|
+
type: 'number',
|
|
261
|
+
default: 0,
|
|
262
|
+
minimum: 0,
|
|
263
|
+
maximum: 8_000
|
|
264
|
+
},
|
|
265
|
+
record_sessions_percent: {
|
|
266
|
+
description: 'Percentage of sessions to record for session recordings.',
|
|
267
|
+
label: 'Record Sessions Percent',
|
|
268
|
+
type: 'number',
|
|
269
|
+
default: 0,
|
|
270
|
+
minimum: 0,
|
|
271
|
+
maximum: 100
|
|
272
|
+
}
|
|
273
|
+
}
|
|
@@ -36,7 +36,6 @@ describe('Mixpanel.track', () => {
|
|
|
36
36
|
beforeEach(async () => {
|
|
37
37
|
jest.restoreAllMocks()
|
|
38
38
|
jest.spyOn(destination, 'initialize').mockImplementation(() => {
|
|
39
|
-
|
|
40
39
|
mockGroup = {
|
|
41
40
|
set: jest.fn(),
|
|
42
41
|
set_once: jest.fn(),
|
|
@@ -71,32 +70,32 @@ describe('Mixpanel.track', () => {
|
|
|
71
70
|
mapping: {
|
|
72
71
|
event_name: { '@path': '$.event' },
|
|
73
72
|
properties: { '@path': '$.properties' },
|
|
74
|
-
unique_id:{ '@path': '$.userId' },
|
|
75
|
-
user_profile_properties_to_set: {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
73
|
+
unique_id: { '@path': '$.userId' },
|
|
74
|
+
user_profile_properties_to_set: {
|
|
75
|
+
name: { '@path': '$.context.traits.user.name' },
|
|
76
|
+
first_name: { '@path': '$.context.traits.user.first_name' },
|
|
77
|
+
last_name: { '@path': '$.context.traits.user.last_name' },
|
|
78
|
+
email: { '@path': '$.context.traits.user.email' },
|
|
79
|
+
phone: { '@path': '$.context.traits.user.phone' },
|
|
80
|
+
avatar: { '@path': '$.context.traits.user.avatar' },
|
|
81
|
+
created: { '@path': '$.context.traits.user.created' }
|
|
83
82
|
},
|
|
84
83
|
user_profile_properties_to_set_once: {
|
|
85
|
-
|
|
84
|
+
set_once_trait: { '@path': '$.context.traits.user.set_once_trait_1' }
|
|
86
85
|
},
|
|
87
86
|
user_profile_properties_to_increment: {
|
|
88
|
-
|
|
87
|
+
increment_property: { '@path': '$.context.traits.user.increment_property_1' }
|
|
89
88
|
},
|
|
90
89
|
group_details: {
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
group_key: { '@path': '$.context.traits.company.group_key' },
|
|
91
|
+
group_id: { '@path': '$.context.groupId' }
|
|
93
92
|
},
|
|
94
|
-
group_profile_properties_to_set: {
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
group_profile_properties_to_set: {
|
|
94
|
+
company_name: { '@path': '$.context.traits.company.company_name' },
|
|
95
|
+
number_employees: { '@path': '$.context.traits.company.number_employees' }
|
|
97
96
|
},
|
|
98
97
|
group_profile_properties_to_set_once: {
|
|
99
|
-
|
|
98
|
+
set_once_trait: { '@path': '$.context.traits.company.set_once_trait_1' }
|
|
100
99
|
},
|
|
101
100
|
group_profile_properties_to_union: { '@path': '$.context.traits.company.union_properties' }
|
|
102
101
|
}
|
|
@@ -106,7 +105,7 @@ describe('Mixpanel.track', () => {
|
|
|
106
105
|
const context = new Context({
|
|
107
106
|
messageId: 'ajs-71f386523ee5dfa90c7d0fda28b6b5c6',
|
|
108
107
|
type: 'track',
|
|
109
|
-
event:
|
|
108
|
+
event: 'Big Fat Test Event',
|
|
110
109
|
anonymousId: 'anonymousId',
|
|
111
110
|
userId: 'userId1',
|
|
112
111
|
properties: {
|
|
@@ -114,7 +113,7 @@ describe('Mixpanel.track', () => {
|
|
|
114
113
|
prop2: 2,
|
|
115
114
|
prop3: true,
|
|
116
115
|
prop4: [1, 2, 3],
|
|
117
|
-
prop5: { subprop1: 'subvalue1', subprop2: 22}
|
|
116
|
+
prop5: { subprop1: 'subvalue1', subprop2: 22 }
|
|
118
117
|
},
|
|
119
118
|
context: {
|
|
120
119
|
groupId: 'groupId1',
|
|
@@ -153,8 +152,8 @@ describe('Mixpanel.track', () => {
|
|
|
153
152
|
await event.load(Context.system(), {} as Analytics)
|
|
154
153
|
await event.group?.(context)
|
|
155
154
|
|
|
156
|
-
// Identify related calls
|
|
157
|
-
expect(mockMPP.identify).toHaveBeenCalledWith(
|
|
155
|
+
// Identify related calls
|
|
156
|
+
expect(mockMPP.identify).toHaveBeenCalledWith('userId1')
|
|
158
157
|
expect(mockMPP.people.set).toHaveBeenCalledWith({
|
|
159
158
|
$name: 'User Name',
|
|
160
159
|
$last_name: 'Last',
|
|
@@ -171,7 +170,7 @@ describe('Mixpanel.track', () => {
|
|
|
171
170
|
increment_property: 5
|
|
172
171
|
})
|
|
173
172
|
|
|
174
|
-
// Group related calls
|
|
173
|
+
// Group related calls
|
|
175
174
|
expect(mockMPP.set_group).toHaveBeenCalledWith('company', 'groupId1')
|
|
176
175
|
expect(mockMPP.get_group).toHaveBeenCalledWith('company', 'groupId1')
|
|
177
176
|
expect(mockGroup.set).toHaveBeenCalledWith({
|
|
@@ -191,7 +190,7 @@ describe('Mixpanel.track', () => {
|
|
|
191
190
|
prop2: 2,
|
|
192
191
|
prop3: true,
|
|
193
192
|
prop4: [1, 2, 3],
|
|
194
|
-
prop5: { subprop1: 'subvalue1', subprop2: 22}
|
|
193
|
+
prop5: { subprop1: 'subvalue1', subprop2: 22 }
|
|
195
194
|
})
|
|
196
195
|
})
|
|
197
196
|
})
|