mixpanel-browser 2.64.0 → 2.66.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/src/index.d.ts ADDED
@@ -0,0 +1,408 @@
1
+ export type Persistence = "cookie" | "localStorage";
2
+
3
+ export type ApiPayloadFormat = "base64" | "json";
4
+
5
+ export type PushItem = Array<string | Dict>;
6
+
7
+ export type Query = string | Element | Element[];
8
+
9
+ export interface Dict {
10
+ [key: string]: any;
11
+ }
12
+
13
+ export interface RequestOptions {
14
+ transport?: "xhr" | "sendBeacon" | undefined;
15
+ send_immediately?: boolean | undefined;
16
+ }
17
+
18
+ export interface XhrHeadersDef {
19
+ [header: string]: any;
20
+ }
21
+
22
+ export interface HasOptedInOutOptions {
23
+ persistence_type: Persistence;
24
+ cookie_prefix: string;
25
+ }
26
+
27
+ export interface ClearOptOutInOutOptions extends HasOptedInOutOptions {
28
+ cookie_expiration: number;
29
+ cross_subdomain_cookie: boolean;
30
+ secure_cookie: boolean;
31
+ }
32
+
33
+ export interface InTrackingOptions extends ClearOptOutInOutOptions {
34
+ track: () => void;
35
+ track_event_name: string;
36
+ track_properties: Dict;
37
+ }
38
+
39
+ export interface OutTrackingOptions extends ClearOptOutInOutOptions {
40
+ delete_user: boolean;
41
+ }
42
+
43
+ export interface RegisterOptions {
44
+ persistent: boolean;
45
+ }
46
+
47
+ export type TrackPageView =
48
+ | boolean
49
+ | "url-with-path"
50
+ | "url-with-path-and-query-string"
51
+ | "full-url";
52
+
53
+ export interface AutocaptureConfig {
54
+ /**
55
+ * When set to `true`, Mixpanel will track element clicks. It will not track textContent unless `capture_text_content` is also set to `true`.
56
+ * @default true
57
+ */
58
+ click?: boolean;
59
+ /**
60
+ * When set to `true`, Mixpanel will track when an input is provided. It will not capture input content.
61
+ * @default true
62
+ */
63
+ input?: boolean;
64
+ /**
65
+ * When set, Mixpanel will collect pageviews when some components of the URL change — including UTM parameters.
66
+ * @default 'full-url'
67
+ */
68
+ pageview?: TrackPageView;
69
+ /**
70
+ * When set, Mixpanel will collect page scrolls at specified scroll intervals.
71
+ * @default true
72
+ */
73
+ scroll?: boolean;
74
+ /**
75
+ * When set to `true`, Mixpanel will track form submissions (but not submission content).
76
+ * @default true
77
+ */
78
+ submit?: boolean;
79
+ /**
80
+ * When set to `true`, Mixpanel will capture the textContent of any element.
81
+ * @default false
82
+ */
83
+ capture_text_content?: boolean;
84
+ /** Enables specification of additional attributes to track. */
85
+ capture_extra_attrs?: string[];
86
+ /**
87
+ * Establishes the scroll depth intervals which trigger `Page Scroll` event.
88
+ * @default [25, 50, 75, 100]
89
+ */
90
+ scroll_depth_percent_checkpoints?: number[];
91
+ /**
92
+ * When set to true, overrides `scroll_depth_percentage_checkpoints` and captures all scroll events.
93
+ * @default false
94
+ */
95
+ scroll_capture_all?: boolean;
96
+ /** Opts out specific pages from Autocapture. */
97
+ block_url_regexes?: RegExp[];
98
+ /** Opts in specific pages to Autocapture. */
99
+ allow_url_regexes?: RegExp[];
100
+ /** Opts out specific classes from Autocapture. */
101
+ block_selectors?: string[];
102
+ /** Opts in specific classes to Autocapture. */
103
+ allow_selectors?: string[];
104
+ /** Opts out specific attributes from Autocapture. */
105
+ block_attrs?: string[];
106
+ /**
107
+ * A user-provided function that determines whether a specific element should be
108
+ * tracked via Autocapture or not. The function receives the element as its first
109
+ * argument, and the DOM event as its second argument, and should return `true` if
110
+ * the element should be tracked (otherwise the element will NOT be tracked).
111
+ */
112
+ allow_element_callback?: (element: Element, event: Event) => boolean;
113
+ /**
114
+ * A user-provided function that determines whether a specific element should be
115
+ * blocked from tracking via Autocapture or not. The function receives the element
116
+ * as its first argument, and the DOM event as its second argument, and should
117
+ * return `true` if the element should be blocked.
118
+ */
119
+ block_element_callback?: (element: Element, event: Event) => boolean;
120
+ }
121
+
122
+ export interface Config {
123
+ api_host: string;
124
+ api_routes: {
125
+ track?: string;
126
+ engage?: string;
127
+ groups?: string;
128
+ };
129
+ api_method: string;
130
+ api_transport: string;
131
+ app_host: string;
132
+ api_payload_format: ApiPayloadFormat;
133
+ autotrack: boolean;
134
+ cdn: string;
135
+ cookie_domain: string;
136
+ cross_site_cookie: boolean;
137
+ cross_subdomain_cookie: boolean;
138
+ persistence: Persistence;
139
+ persistence_name: string;
140
+ cookie_name: string;
141
+ loaded: (mixpanel: Mixpanel) => void;
142
+ store_google: boolean;
143
+ stop_utm_persistence: boolean;
144
+ save_referrer: boolean;
145
+ test: boolean;
146
+ verbose: boolean;
147
+ img: boolean;
148
+ /**
149
+ * @default false
150
+ * @see https://github.com/mixpanel/mixpanel-js/blob/master/doc/readme.io/javascript-full-api-reference.md#mixpanelset_config
151
+ */
152
+ debug: boolean;
153
+ track_links_timeout: number;
154
+ track_pageview: TrackPageView;
155
+ autocapture: boolean | AutocaptureConfig;
156
+ skip_first_touch_marketing: boolean;
157
+ cookie_expiration: number;
158
+ upgrade: boolean;
159
+ disable_persistence: boolean;
160
+ disable_cookie: boolean;
161
+ disable_notifications: boolean;
162
+ secure_cookie: boolean;
163
+ ip: boolean;
164
+ property_blacklist: string[];
165
+ xhr_headers: XhrHeadersDef;
166
+ opt_out_tracking_by_default: boolean;
167
+ opt_out_persistence_by_default: boolean;
168
+ opt_out_tracking_persistence_type: Persistence;
169
+ opt_out_tracking_cookie_prefix: string;
170
+ inapp_protocol: string;
171
+ inapp_link_new_window: boolean;
172
+ ignore_dnt: boolean;
173
+ batch_requests: boolean;
174
+ batch_size: number;
175
+ batch_flush_interval_ms: number;
176
+ batch_request_timeout_ms: number;
177
+ record_block_class: string;
178
+ record_block_selector: string;
179
+ record_collect_fonts: boolean;
180
+ record_idle_timeout_ms: number;
181
+ record_inline_images: boolean;
182
+ record_mask_text_class: string;
183
+ record_mask_text_selector: string;
184
+ record_max_ms: number;
185
+ record_sessions_percent: number;
186
+ record_canvas: boolean;
187
+ }
188
+
189
+ export type VerboseResponse =
190
+ | {
191
+ status: 1;
192
+ error: null;
193
+ }
194
+ | {
195
+ status: 0;
196
+ error: string;
197
+ };
198
+
199
+ export type NormalResponse = 1 | 0;
200
+
201
+ export type Response = VerboseResponse | NormalResponse;
202
+
203
+ export type Callback = (response: Response) => void;
204
+
205
+ export interface People {
206
+ set(prop: string, to: any, callback?: Callback): void;
207
+ set(prop: Dict, callback?: Callback): void;
208
+ set_once(prop: string, to: any, callback?: Callback): void;
209
+ set_once(prop: Dict, callback?: Callback): void;
210
+ unset(prop: string[] | string, callback?: Callback): void;
211
+ increment(prop: string | Dict, callback?: Callback): void;
212
+ increment(prop: string, by: number, callback?: Callback): void;
213
+ remove(prop: string, value: any, callback?: Callback): void;
214
+ remove(prop: Dict, callback?: Callback): void;
215
+ append(prop: string, value: any, callback?: Callback): void;
216
+ append(prop: Dict, callback?: Callback): void;
217
+ union(prop: string, value: any, callback?: Callback): void;
218
+ union(prop: Dict, callback?: Callback): void;
219
+ track_charge(
220
+ amount: number,
221
+ propertiesOrCallback?: Dict | Callback,
222
+ callback?: Callback
223
+ ): void;
224
+ clear_charges(callback?: Callback): void;
225
+ delete_user(): void;
226
+ }
227
+
228
+ export interface Group {
229
+ remove(list_name: string, value: string, callback?: Callback): Group;
230
+ set<Prop extends string | Dict>(
231
+ prop: Prop,
232
+ to?: Prop extends string ? string : undefined,
233
+ callback?: Callback
234
+ ): Group;
235
+ set_once<Prop extends string | Dict>(
236
+ prop: Prop,
237
+ to?: Prop extends string ? string : undefined,
238
+ callback?: Callback
239
+ ): Group;
240
+ union(
241
+ list_name: string,
242
+ values: Array<string | number>,
243
+ callback?: Callback
244
+ ): Group;
245
+ unset(prop: string, callback?: Callback): void;
246
+ }
247
+
248
+ export interface Mixpanel {
249
+ add_group(group_key: string, group_id: string, callback?: Callback): void;
250
+ alias(alias: string, original?: string): void;
251
+ clear_opt_in_out_tracking(options?: Partial<ClearOptOutInOutOptions>): void;
252
+ disable(events?: string[]): void;
253
+ get_config(prop_name?: string): any;
254
+ get_distinct_id(): any;
255
+ get_group(group_key: string, group_id: string): Group;
256
+ get_property(property_name: string): any;
257
+ has_opted_in_tracking(options?: Partial<HasOptedInOutOptions>): boolean;
258
+ has_opted_out_tracking(options?: Partial<HasOptedInOutOptions>): boolean;
259
+ identify(unique_id?: string): any;
260
+ init(token: string, config: Partial<Config>, name: string): Mixpanel;
261
+ opt_in_tracking(options?: Partial<InTrackingOptions>): void;
262
+ opt_out_tracking(options?: Partial<OutTrackingOptions>): void;
263
+ push(item: PushItem): void;
264
+ register(
265
+ props: Dict,
266
+ days_or_options?: number | Partial<RegisterOptions>
267
+ ): void;
268
+ register_once(
269
+ props: Dict,
270
+ default_value?: any,
271
+ days_or_options?: number | Partial<RegisterOptions>
272
+ ): void;
273
+ remove_group(
274
+ group_key: string,
275
+ group_ids: string | string[] | number | number[],
276
+ callback?: Callback
277
+ ): void;
278
+ reset(): void;
279
+ set_config(config: Partial<Config>): void;
280
+ set_group(
281
+ group_key: string,
282
+ group_ids: string | string[] | number | number[],
283
+ callback?: Callback
284
+ ): void;
285
+ time_event(event_name: string): void;
286
+ track(
287
+ event_name: string,
288
+ properties?: Dict,
289
+ optionsOrCallback?: RequestOptions | Callback,
290
+ callback?: Callback
291
+ ): void;
292
+ track_forms(
293
+ query: Query,
294
+ event_name: string,
295
+ properties?: Dict | (() => void)
296
+ ): void;
297
+ track_links(
298
+ query: Query,
299
+ event_name: string,
300
+ properties?: Dict | (() => void)
301
+ ): void;
302
+ track_pageview(
303
+ properties?: Dict,
304
+ options?: { event_name?: string | undefined }
305
+ ): void;
306
+ track_with_groups(
307
+ event_name: string,
308
+ properties: Dict,
309
+ groups: Dict,
310
+ callback?: Callback
311
+ ): void;
312
+ unregister(property: string, options?: Partial<RegisterOptions>): void;
313
+ people: People;
314
+ start_session_recording(): void;
315
+ stop_session_recording(): void;
316
+ get_session_recording_properties(): { $mp_replay_id?: string } | {};
317
+ }
318
+
319
+ export interface OverridedMixpanel extends Mixpanel {
320
+ init(token: string, config: Partial<Config>, name: string): Mixpanel;
321
+ init(token: string, config?: Partial<Config>): undefined;
322
+ }
323
+
324
+ export function add_group(
325
+ group_key: string,
326
+ group_id: string,
327
+ callback?: Callback
328
+ ): void;
329
+ export function alias(alias: string, original?: string): void;
330
+ export function clear_opt_in_out_tracking(
331
+ options?: Partial<ClearOptOutInOutOptions>
332
+ ): void;
333
+ export function disable(events?: string[]): void;
334
+ export function get_config(prop_name?: string): any;
335
+ export function get_distinct_id(): any;
336
+ export function get_group(group_key: string, group_id: string): Group;
337
+ export function get_property(property_name: string): any;
338
+ export function has_opted_in_tracking(
339
+ options?: Partial<HasOptedInOutOptions>
340
+ ): boolean;
341
+ export function has_opted_out_tracking(
342
+ options?: Partial<HasOptedInOutOptions>
343
+ ): boolean;
344
+ export function identify(unique_id?: string): any;
345
+ export function init(
346
+ token: string,
347
+ config: Partial<Config>,
348
+ name: string
349
+ ): Mixpanel;
350
+ export function init(token: string, config?: Partial<Config>): undefined;
351
+ export function opt_in_tracking(options?: Partial<InTrackingOptions>): void;
352
+ export function opt_out_tracking(options?: Partial<OutTrackingOptions>): void;
353
+ export function push(item: PushItem): void;
354
+ export function register(
355
+ props: Dict,
356
+ days_or_options?: number | Partial<RegisterOptions>
357
+ ): void;
358
+ export function register_once(
359
+ props: Dict,
360
+ default_value?: any,
361
+ days_or_options?: number | Partial<RegisterOptions>
362
+ ): void;
363
+ export function remove_group(
364
+ group_key: string,
365
+ group_ids: string | string[] | number | number[],
366
+ callback?: Callback
367
+ ): void;
368
+ export function reset(): void;
369
+ export function set_config(config: Partial<Config>): void;
370
+ export function set_group(
371
+ group_key: string,
372
+ group_ids: string | string[] | number | number[],
373
+ callback?: Callback
374
+ ): void;
375
+ export function time_event(event_name: string): void;
376
+ export function track(
377
+ event_name: string,
378
+ properties?: Dict,
379
+ optionsOrCallback?: RequestOptions | Callback,
380
+ callback?: Callback
381
+ ): void;
382
+ export function track_forms(
383
+ query: Query,
384
+ event_name: string,
385
+ properties?: Dict | (() => void)
386
+ ): void;
387
+ export function track_links(
388
+ query: Query,
389
+ event_name: string,
390
+ properties?: Dict | (() => void)
391
+ ): void;
392
+ export function track_with_groups(
393
+ event_name: string,
394
+ properties: Dict,
395
+ groups: Dict,
396
+ callback?: Callback
397
+ ): void;
398
+ export function unregister(
399
+ property: string,
400
+ options?: Partial<RegisterOptions>
401
+ ): void;
402
+ export const people: People;
403
+ export function get_session_recording_properties():
404
+ | { $mp_replay_id?: string }
405
+ | {};
406
+
407
+ declare const mixpanel: OverridedMixpanel;
408
+ export default mixpanel;
@@ -99,7 +99,9 @@ var DEFAULT_API_ROUTES = {
99
99
  */
100
100
  var DEFAULT_CONFIG = {
101
101
  'api_host': 'https://api-js.mixpanel.com',
102
+ 'api_hosts': {},
102
103
  'api_routes': DEFAULT_API_ROUTES,
104
+ 'api_extra_query_params': {},
103
105
  'api_method': 'POST',
104
106
  'api_transport': 'XHR',
105
107
  'api_payload_format': PAYLOAD_TYPE_BASE64,
@@ -483,20 +485,23 @@ MixpanelLib.prototype.start_session_recording = function () {
483
485
 
484
486
  MixpanelLib.prototype.stop_session_recording = function () {
485
487
  if (this._recorder) {
486
- this._recorder['stopRecording']();
488
+ return this._recorder['stopRecording']();
487
489
  }
490
+ return Promise.resolve();
488
491
  };
489
492
 
490
493
  MixpanelLib.prototype.pause_session_recording = function () {
491
494
  if (this._recorder) {
492
- this._recorder['pauseRecording']();
495
+ return this._recorder['pauseRecording']();
493
496
  }
497
+ return Promise.resolve();
494
498
  };
495
499
 
496
500
  MixpanelLib.prototype.resume_session_recording = function () {
497
501
  if (this._recorder) {
498
- this._recorder['resumeRecording']();
502
+ return this._recorder['resumeRecording']();
499
503
  }
504
+ return Promise.resolve();
500
505
  };
501
506
 
502
507
  MixpanelLib.prototype.is_recording_heatmap_data = function () {
@@ -687,6 +692,8 @@ MixpanelLib.prototype._send_request = function(url, data, options, callback) {
687
692
  delete data['data'];
688
693
  }
689
694
 
695
+ _.extend(data, this.get_config('api_extra_query_params'));
696
+
690
697
  url += '?' + _.HTTPBuildQuery(data);
691
698
 
692
699
  var lib = this;
@@ -1094,7 +1101,7 @@ MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, pro
1094
1101
  var ret = this._track_or_batch({
1095
1102
  type: 'events',
1096
1103
  data: data,
1097
- endpoint: this.get_config('api_host') + '/' + this.get_config('api_routes')['track'],
1104
+ endpoint: this.get_api_host('events') + '/' + this.get_config('api_routes')['track'],
1098
1105
  batcher: this.request_batchers.events,
1099
1106
  should_send_immediately: should_send_immediately,
1100
1107
  send_request_options: options
@@ -1596,13 +1603,31 @@ MixpanelLib.prototype.identify = function(
1596
1603
  * Useful for clearing data when a user logs out.
1597
1604
  */
1598
1605
  MixpanelLib.prototype.reset = function() {
1599
- this['persistence'].clear();
1600
- this._flags.identify_called = false;
1601
- var uuid = _.UUID();
1602
- this.register_once({
1603
- 'distinct_id': DEVICE_ID_PREFIX + uuid,
1604
- '$device_id': uuid
1605
- }, '');
1606
+ var self = this;
1607
+
1608
+ var reset = function () {
1609
+ self['persistence'].clear();
1610
+ self._flags.identify_called = false;
1611
+ var uuid = _.UUID();
1612
+ self.register_once({
1613
+ 'distinct_id': DEVICE_ID_PREFIX + uuid,
1614
+ '$device_id': uuid
1615
+ }, '');
1616
+ };
1617
+
1618
+ if (self._recorder) {
1619
+ self.stop_session_recording()
1620
+ .then(function () {
1621
+ reset();
1622
+ self._check_and_start_session_recording();
1623
+ })
1624
+ .catch(_.bind(function (err) {
1625
+ reset();
1626
+ this.report_error('Error restarting recording session', err);
1627
+ }, this));
1628
+ } else {
1629
+ reset();
1630
+ }
1606
1631
  };
1607
1632
 
1608
1633
  /**
@@ -1913,6 +1938,16 @@ MixpanelLib.prototype.get_property = function(property_name) {
1913
1938
  return this['persistence'].load_prop([property_name]);
1914
1939
  };
1915
1940
 
1941
+ /**
1942
+ * Get the API host for a specific endpoint type, falling back to the default api_host if not specified
1943
+ *
1944
+ * @param {String} endpoint_type The type of endpoint (e.g., "events", "people", "groups")
1945
+ * @returns {String} The API host to use for this endpoint
1946
+ */
1947
+ MixpanelLib.prototype.get_api_host = function(endpoint_type) {
1948
+ return this.get_config('api_hosts')[endpoint_type] || this.get_config('api_host');
1949
+ };
1950
+
1916
1951
  MixpanelLib.prototype.toString = function() {
1917
1952
  var name = this.get_config('name');
1918
1953
  if (name !== PRIMARY_INSTANCE_NAME) {
@@ -2208,6 +2243,7 @@ MixpanelLib.prototype['alias'] = MixpanelLib.protot
2208
2243
  MixpanelLib.prototype['name_tag'] = MixpanelLib.prototype.name_tag;
2209
2244
  MixpanelLib.prototype['set_config'] = MixpanelLib.prototype.set_config;
2210
2245
  MixpanelLib.prototype['get_config'] = MixpanelLib.prototype.get_config;
2246
+ MixpanelLib.prototype['get_api_host'] = MixpanelLib.prototype.get_api_host;
2211
2247
  MixpanelLib.prototype['get_property'] = MixpanelLib.prototype.get_property;
2212
2248
  MixpanelLib.prototype['get_distinct_id'] = MixpanelLib.prototype.get_distinct_id;
2213
2249
  MixpanelLib.prototype['toString'] = MixpanelLib.prototype.toString;
@@ -146,7 +146,7 @@ MixpanelGroup.prototype._send_request = function(data, callback) {
146
146
  return this._mixpanel._track_or_batch({
147
147
  type: 'groups',
148
148
  data: date_encoded_data,
149
- endpoint: this._get_config('api_host') + '/' + this._get_config('api_routes')['groups'],
149
+ endpoint: this._mixpanel.get_api_host('groups') + '/' + this._get_config('api_routes')['groups'],
150
150
  batcher: this._mixpanel.request_batchers.groups
151
151
  }, callback);
152
152
  };
@@ -262,18 +262,8 @@ MixpanelPeople.prototype.union = addOptOutCheckMixpanelPeople(function(list_name
262
262
  * @param {Function} [callback] If provided, the callback will be called when the server responds
263
263
  * @deprecated
264
264
  */
265
- MixpanelPeople.prototype.track_charge = addOptOutCheckMixpanelPeople(function(amount, properties, callback) {
266
- if (!_.isNumber(amount)) {
267
- amount = parseFloat(amount);
268
- if (isNaN(amount)) {
269
- console.error('Invalid value passed to mixpanel.people.track_charge - must be a number');
270
- return;
271
- }
272
- }
273
-
274
- return this.append('$transactions', _.extend({
275
- '$amount': amount
276
- }, properties), callback);
265
+ MixpanelPeople.prototype.track_charge = addOptOutCheckMixpanelPeople(function() {
266
+ console.error('mixpanel.people.track_charge() is deprecated and no longer has any effect.');
277
267
  });
278
268
 
279
269
  /*
@@ -347,7 +337,7 @@ MixpanelPeople.prototype._send_request = function(data, callback) {
347
337
  return this._mixpanel._track_or_batch({
348
338
  type: 'people',
349
339
  data: date_encoded_data,
350
- endpoint: this._get_config('api_host') + '/' + this._get_config('api_routes')['engage'],
340
+ endpoint: this._mixpanel.get_api_host('people') + '/' + this._get_config('api_routes')['engage'],
351
341
  batcher: this._mixpanel.request_batchers.people
352
342
  }, callback);
353
343
  };
@@ -27,6 +27,7 @@ var MixpanelRecorder = function(mixpanelInstance, rrwebRecord, sharedLockStorage
27
27
  this._flushInactivePromise = this.recordingRegistry.flushInactiveRecordings();
28
28
 
29
29
  this.activeRecording = null;
30
+ this.stopRecordingInProgress = false;
30
31
  };
31
32
 
32
33
  MixpanelRecorder.prototype.startRecording = function(options) {
@@ -75,19 +76,26 @@ MixpanelRecorder.prototype.startRecording = function(options) {
75
76
  };
76
77
 
77
78
  MixpanelRecorder.prototype.stopRecording = function() {
78
- var stopPromise = this._stopCurrentRecording(false);
79
- this.recordingRegistry.clearActiveRecording();
80
- this.activeRecording = null;
81
- return stopPromise;
79
+ // Prevents activeSerializedRecording from being reused when stopping the recording.
80
+ this.stopRecordingInProgress = true;
81
+ return this._stopCurrentRecording(false, true).then(function() {
82
+ return this.recordingRegistry.clearActiveRecording();
83
+ }.bind(this)).then(function() {
84
+ this.stopRecordingInProgress = false;
85
+ }.bind(this));
82
86
  };
83
87
 
84
88
  MixpanelRecorder.prototype.pauseRecording = function() {
85
89
  return this._stopCurrentRecording(false);
86
90
  };
87
91
 
88
- MixpanelRecorder.prototype._stopCurrentRecording = function(skipFlush) {
92
+ MixpanelRecorder.prototype._stopCurrentRecording = function(skipFlush, disableActiveRecording) {
89
93
  if (this.activeRecording) {
90
- return this.activeRecording.stopRecording(skipFlush);
94
+ var stopRecordingPromise = this.activeRecording.stopRecording(skipFlush);
95
+ if (disableActiveRecording) {
96
+ this.activeRecording = null;
97
+ }
98
+ return stopRecordingPromise;
91
99
  }
92
100
  return Promise.resolve();
93
101
  };
@@ -100,7 +108,7 @@ MixpanelRecorder.prototype.resumeRecording = function (startNewIfInactive) {
100
108
 
101
109
  return this.recordingRegistry.getActiveRecording()
102
110
  .then(function (activeSerializedRecording) {
103
- if (activeSerializedRecording) {
111
+ if (activeSerializedRecording && !this.stopRecordingInProgress) {
104
112
  return this.startRecording({activeSerializedRecording: activeSerializedRecording});
105
113
  } else if (startNewIfInactive) {
106
114
  return this.startRecording({shouldStopBatcher: false});
@@ -352,8 +352,8 @@ SessionRecording.prototype._sendRequest = function(currentReplayId, reqParams, r
352
352
  retryAfter: response.headers.get('Retry-After')
353
353
  });
354
354
  }.bind(this);
355
-
356
- window['fetch'](this.getConfig('api_host') + '/' + this.getConfig('api_routes')['record'] + '?' + new URLSearchParams(reqParams), {
355
+ var apiHost = (this._mixpanel.get_api_host && this._mixpanel.get_api_host('record')) || this.getConfig('api_host');
356
+ window['fetch'](apiHost + '/' + this.getConfig('api_routes')['record'] + '?' + new URLSearchParams(reqParams), {
357
357
  'method': 'POST',
358
358
  'headers': {
359
359
  'Authorization': 'Basic ' + btoa(this.getConfig('token') + ':'),
package/src/utils.js CHANGED
@@ -1483,6 +1483,9 @@ _.info = {
1483
1483
  return 'Microsoft Edge';
1484
1484
  } else if (_.includes(user_agent, 'FBIOS')) {
1485
1485
  return 'Facebook Mobile';
1486
+ } else if (_.includes(user_agent, 'Whale/')) {
1487
+ // https://user-agents.net/browsers/whale-browser
1488
+ return 'Whale Browser';
1486
1489
  } else if (_.includes(user_agent, 'Chrome')) {
1487
1490
  return 'Chrome';
1488
1491
  } else if (_.includes(user_agent, 'CriOS')) {
@@ -1534,7 +1537,8 @@ _.info = {
1534
1537
  'Android Mobile': /android\s(\d+(\.\d+)?)/,
1535
1538
  'Samsung Internet': /SamsungBrowser\/(\d+(\.\d+)?)/,
1536
1539
  'Internet Explorer': /(rv:|MSIE )(\d+(\.\d+)?)/,
1537
- 'Mozilla': /rv:(\d+(\.\d+)?)/
1540
+ 'Mozilla': /rv:(\d+(\.\d+)?)/,
1541
+ 'Whale Browser': /Whale\/(\d+(\.\d+)?)/
1538
1542
  };
1539
1543
  var regex = versionRegexs[browser];
1540
1544
  if (regex === undefined) {
package/tunnel.log DELETED
File without changes