mixpanel-browser 2.72.0 → 2.74.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.
Files changed (44) hide show
  1. package/.claude/settings.local.json +5 -2
  2. package/.eslintrc.json +7 -4
  3. package/.github/workflows/integration-tests.yml +52 -0
  4. package/.github/workflows/unit-tests.yml +40 -0
  5. package/CHANGELOG.md +12 -0
  6. package/README.md +1 -1
  7. package/build.sh +1 -5
  8. package/dist/mixpanel-core.cjs.d.ts +49 -4
  9. package/dist/mixpanel-core.cjs.js +244 -26
  10. package/dist/mixpanel-recorder.js +5258 -688
  11. package/dist/mixpanel-recorder.min.js +1 -1
  12. package/dist/mixpanel-recorder.min.js.map +1 -1
  13. package/dist/mixpanel-with-async-recorder.cjs.d.ts +49 -4
  14. package/dist/mixpanel-with-async-recorder.cjs.js +244 -26
  15. package/dist/mixpanel-with-recorder.d.ts +49 -4
  16. package/dist/mixpanel-with-recorder.js +6858 -2099
  17. package/dist/mixpanel-with-recorder.min.d.ts +49 -4
  18. package/dist/mixpanel-with-recorder.min.js +1 -1
  19. package/dist/mixpanel.amd.d.ts +49 -4
  20. package/dist/mixpanel.amd.js +6858 -2099
  21. package/dist/mixpanel.cjs.d.ts +49 -4
  22. package/dist/mixpanel.cjs.js +6858 -2099
  23. package/dist/mixpanel.globals.js +244 -26
  24. package/dist/mixpanel.min.js +175 -171
  25. package/dist/mixpanel.module.d.ts +49 -4
  26. package/dist/mixpanel.module.js +6858 -2099
  27. package/dist/mixpanel.umd.d.ts +49 -4
  28. package/dist/mixpanel.umd.js +6858 -2099
  29. package/dist/rrweb-bundled.js +4315 -591
  30. package/dist/rrweb-compiled.js +4962 -641
  31. package/package.json +30 -5
  32. package/rollup.config.mjs +254 -224
  33. package/src/autocapture/utils.js +15 -7
  34. package/src/config.js +1 -1
  35. package/src/index.d.ts +49 -4
  36. package/src/mixpanel-core.js +215 -15
  37. package/src/recorder/masking.js +197 -0
  38. package/src/recorder/rrweb-entrypoint.js +2 -1
  39. package/src/recorder/session-recording.js +43 -4
  40. package/src/recorder/utils.js +5 -1
  41. package/src/utils.js +11 -2
  42. package/src/window.js +3 -1
  43. package/testServer.js +51 -7
  44. package/.github/workflows/tests.yml +0 -25
@@ -2,10 +2,12 @@ export type Persistence = "cookie" | "localStorage";
2
2
 
3
3
  export type ApiPayloadFormat = "base64" | "json";
4
4
 
5
- export type PushItem = Array<string | Dict>;
5
+ export type PushItem = Array<string | Dict | ((this: Mixpanel) => void)>;
6
6
 
7
7
  export type Query = string | Element | Element[];
8
8
 
9
+ export type RemoteSettingType = "disabled" | "fallback" | "strict";
10
+
9
11
  export interface Dict {
10
12
  [key: string]: any;
11
13
  }
@@ -155,22 +157,32 @@ export interface FlagsConfig {
155
157
  context: Dict;
156
158
  }
157
159
 
160
+ export interface BeforeSendHookPayload {
161
+ event: string;
162
+ properties: Record<string, any>;
163
+ }
164
+
158
165
  export interface Config {
159
166
  api_host: string;
160
167
  api_routes: {
161
168
  track?: string;
162
169
  engage?: string;
163
170
  groups?: string;
171
+ record?: string;
172
+ flags?: string;
164
173
  };
165
174
  api_method: string;
166
175
  api_transport: string;
167
176
  app_host: string;
168
177
  api_payload_format: ApiPayloadFormat;
169
178
  autotrack: boolean;
179
+ batch_autostart: boolean;
180
+ batch_requests: boolean;
170
181
  cdn: string;
171
182
  cookie_domain: string;
172
183
  cross_site_cookie: boolean;
173
184
  cross_subdomain_cookie: boolean;
185
+ error_reporter: (msg: string, err?: Error) => void;
174
186
  flags: boolean | FlagsConfig;
175
187
  persistence: Persistence;
176
188
  persistence_name: string;
@@ -207,24 +219,54 @@ export interface Config {
207
219
  inapp_protocol: string;
208
220
  inapp_link_new_window: boolean;
209
221
  ignore_dnt: boolean;
210
- batch_requests: boolean;
211
222
  batch_size: number;
212
223
  batch_flush_interval_ms: number;
213
224
  batch_request_timeout_ms: number;
225
+ recorder_src: string;
214
226
  record_block_class: string | RegExp;
215
227
  record_block_selector: string;
216
228
  record_collect_fonts: boolean;
217
229
  record_idle_timeout_ms: number;
218
230
  record_inline_images: boolean;
219
231
  record_mask_text_class: string | RegExp;
220
- record_mask_text_selector: string;
232
+ record_mask_text_selector: string | string[];
233
+ record_unmask_text_selector: string | string[];
234
+ record_mask_all_text: boolean;
235
+ record_mask_input_selector: string | string[];
236
+ record_unmask_input_selector: string | string[];
237
+ record_mask_all_inputs: boolean;
221
238
  record_min_ms: number;
222
239
  record_max_ms: number;
223
240
  record_sessions_percent: number;
224
241
  record_canvas: boolean;
225
242
  record_heatmap_data: boolean;
243
+ remote_settings_mode: RemoteSettingType;
244
+ hooks: {
245
+ before_identify?: (new_distinct_id: string) => string | null;
246
+ before_register?: (
247
+ props: Dict,
248
+ days_or_options?: number | Partial<RegisterOptions>
249
+ ) => Dict | Array<Dict | number | Partial<RegisterOptions>> | null;
250
+ before_register_once?: (
251
+ props: Dict,
252
+ default_value?: any,
253
+ days_or_options?: number | Partial<RegisterOptions>
254
+ ) => Dict | Array<any | Dict | number | Partial<RegisterOptions>> | null;
255
+ before_send_events?: (
256
+ event: BeforeSendHookPayload
257
+ ) => BeforeSendHookPayload | null;
258
+ before_track?: (
259
+ event_name: string,
260
+ properties: Dict
261
+ ) => string | Array<string | Dict> | null;
262
+ before_unregister?: (
263
+ property: string,
264
+ options?: Partial<RegisterOptions>
265
+ ) => string | Partial<RegisterOptions> | null;
266
+ };
226
267
  }
227
268
 
269
+
228
270
  export type VerboseResponse =
229
271
  | {
230
272
  status: 1;
@@ -323,10 +365,11 @@ export interface Mixpanel {
323
365
  get_distinct_id(): any;
324
366
  get_group(group_key: string, group_id: string): Group;
325
367
  get_property(property_name: string): any;
368
+ get_session_replay_url(): string;
326
369
  has_opted_in_tracking(options?: Partial<HasOptedInOutOptions>): boolean;
327
370
  has_opted_out_tracking(options?: Partial<HasOptedInOutOptions>): boolean;
328
371
  identify(unique_id?: string): any;
329
- init(token: string, config: Partial<Config>, name: string): Mixpanel;
372
+ init(token: string, config: Partial<Config>, name?: string): Mixpanel;
330
373
  opt_in_tracking(options?: Partial<InTrackingOptions>): void;
331
374
  opt_out_tracking(options?: Partial<OutTrackingOptions>): void;
332
375
  push(item: PushItem): void;
@@ -351,6 +394,7 @@ export interface Mixpanel {
351
394
  group_ids: string | string[] | number | number[],
352
395
  callback?: Callback
353
396
  ): void;
397
+ start_batch_senders(): void;
354
398
  time_event(event_name: string): void;
355
399
  track(
356
400
  event_name: string,
@@ -380,6 +424,7 @@ export interface Mixpanel {
380
424
  ): void;
381
425
  unregister(property: string, options?: Partial<RegisterOptions>): void;
382
426
  people: People;
427
+ start_batch_senders(): void;
383
428
  start_session_recording(): void;
384
429
  stop_session_recording(): void;
385
430
  get_session_recording_properties(): { $mp_replay_id?: string } | {};