mixpanel-browser 2.72.0 → 2.73.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/CHANGELOG.md +5 -0
- package/dist/mixpanel-core.cjs.d.ts +37 -3
- package/dist/mixpanel-core.cjs.js +130 -12
- package/dist/mixpanel-recorder.js +4 -2
- package/dist/mixpanel-recorder.min.js +1 -1
- package/dist/mixpanel-recorder.min.js.map +1 -1
- package/dist/mixpanel-with-async-recorder.cjs.d.ts +37 -3
- package/dist/mixpanel-with-async-recorder.cjs.js +130 -12
- package/dist/mixpanel-with-recorder.d.ts +37 -3
- package/dist/mixpanel-with-recorder.js +130 -12
- package/dist/mixpanel-with-recorder.min.d.ts +37 -3
- package/dist/mixpanel-with-recorder.min.js +1 -1
- package/dist/mixpanel.amd.d.ts +37 -3
- package/dist/mixpanel.amd.js +130 -12
- package/dist/mixpanel.cjs.d.ts +37 -3
- package/dist/mixpanel.cjs.js +130 -12
- package/dist/mixpanel.globals.js +130 -12
- package/dist/mixpanel.min.js +171 -169
- package/dist/mixpanel.module.d.ts +37 -3
- package/dist/mixpanel.module.js +130 -12
- package/dist/mixpanel.umd.d.ts +37 -3
- package/dist/mixpanel.umd.js +130 -12
- package/package.json +1 -1
- package/src/config.js +1 -1
- package/src/index.d.ts +37 -3
- package/src/mixpanel-core.js +126 -10
- package/src/window.js +3 -1
- package/.claude/settings.local.json +0 -9
package/dist/mixpanel.amd.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ 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
|
|
|
@@ -155,6 +155,11 @@ export interface FlagsConfig {
|
|
|
155
155
|
context: Dict;
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
export interface BeforeSendHookPayload {
|
|
159
|
+
event: string;
|
|
160
|
+
properties: Record<string, any>;
|
|
161
|
+
}
|
|
162
|
+
|
|
158
163
|
export interface Config {
|
|
159
164
|
api_host: string;
|
|
160
165
|
api_routes: {
|
|
@@ -167,10 +172,13 @@ export interface Config {
|
|
|
167
172
|
app_host: string;
|
|
168
173
|
api_payload_format: ApiPayloadFormat;
|
|
169
174
|
autotrack: boolean;
|
|
175
|
+
batch_autostart: boolean;
|
|
176
|
+
batch_requests: boolean;
|
|
170
177
|
cdn: string;
|
|
171
178
|
cookie_domain: string;
|
|
172
179
|
cross_site_cookie: boolean;
|
|
173
180
|
cross_subdomain_cookie: boolean;
|
|
181
|
+
error_reporter: (msg: string, err?: Error) => void;
|
|
174
182
|
flags: boolean | FlagsConfig;
|
|
175
183
|
persistence: Persistence;
|
|
176
184
|
persistence_name: string;
|
|
@@ -207,10 +215,10 @@ export interface Config {
|
|
|
207
215
|
inapp_protocol: string;
|
|
208
216
|
inapp_link_new_window: boolean;
|
|
209
217
|
ignore_dnt: boolean;
|
|
210
|
-
batch_requests: boolean;
|
|
211
218
|
batch_size: number;
|
|
212
219
|
batch_flush_interval_ms: number;
|
|
213
220
|
batch_request_timeout_ms: number;
|
|
221
|
+
recorder_src: string;
|
|
214
222
|
record_block_class: string | RegExp;
|
|
215
223
|
record_block_selector: string;
|
|
216
224
|
record_collect_fonts: boolean;
|
|
@@ -223,6 +231,29 @@ export interface Config {
|
|
|
223
231
|
record_sessions_percent: number;
|
|
224
232
|
record_canvas: boolean;
|
|
225
233
|
record_heatmap_data: boolean;
|
|
234
|
+
hooks: {
|
|
235
|
+
before_identify?: (new_distinct_id: string) => string | null;
|
|
236
|
+
before_register?: (
|
|
237
|
+
props: Dict,
|
|
238
|
+
days_or_options?: number | Partial<RegisterOptions>
|
|
239
|
+
) => Dict | Array<Dict | number | Partial<RegisterOptions>> | null;
|
|
240
|
+
before_register_once?: (
|
|
241
|
+
props: Dict,
|
|
242
|
+
default_value?: any,
|
|
243
|
+
days_or_options?: number | Partial<RegisterOptions>
|
|
244
|
+
) => Dict | Array<any | Dict | number | Partial<RegisterOptions>> | null;
|
|
245
|
+
before_send_events?: (
|
|
246
|
+
event: BeforeSendHookPayload
|
|
247
|
+
) => BeforeSendHookPayload | null;
|
|
248
|
+
before_track?: (
|
|
249
|
+
event_name: string,
|
|
250
|
+
properties: Dict
|
|
251
|
+
) => string | Array<string | Dict> | null;
|
|
252
|
+
before_unregister?: (
|
|
253
|
+
property: string,
|
|
254
|
+
options?: Partial<RegisterOptions>
|
|
255
|
+
) => string | Partial<RegisterOptions> | null;
|
|
256
|
+
};
|
|
226
257
|
}
|
|
227
258
|
|
|
228
259
|
export type VerboseResponse =
|
|
@@ -323,10 +354,11 @@ export interface Mixpanel {
|
|
|
323
354
|
get_distinct_id(): any;
|
|
324
355
|
get_group(group_key: string, group_id: string): Group;
|
|
325
356
|
get_property(property_name: string): any;
|
|
357
|
+
get_session_replay_url(): string;
|
|
326
358
|
has_opted_in_tracking(options?: Partial<HasOptedInOutOptions>): boolean;
|
|
327
359
|
has_opted_out_tracking(options?: Partial<HasOptedInOutOptions>): boolean;
|
|
328
360
|
identify(unique_id?: string): any;
|
|
329
|
-
init(token: string, config: Partial<Config>, name
|
|
361
|
+
init(token: string, config: Partial<Config>, name?: string): Mixpanel;
|
|
330
362
|
opt_in_tracking(options?: Partial<InTrackingOptions>): void;
|
|
331
363
|
opt_out_tracking(options?: Partial<OutTrackingOptions>): void;
|
|
332
364
|
push(item: PushItem): void;
|
|
@@ -351,6 +383,7 @@ export interface Mixpanel {
|
|
|
351
383
|
group_ids: string | string[] | number | number[],
|
|
352
384
|
callback?: Callback
|
|
353
385
|
): void;
|
|
386
|
+
start_batch_senders(): void;
|
|
354
387
|
time_event(event_name: string): void;
|
|
355
388
|
track(
|
|
356
389
|
event_name: string,
|
|
@@ -380,6 +413,7 @@ export interface Mixpanel {
|
|
|
380
413
|
): void;
|
|
381
414
|
unregister(property: string, options?: Partial<RegisterOptions>): void;
|
|
382
415
|
people: People;
|
|
416
|
+
start_batch_senders(): void;
|
|
383
417
|
start_session_recording(): void;
|
|
384
418
|
stop_session_recording(): void;
|
|
385
419
|
get_session_recording_properties(): { $mp_replay_id?: string } | {};
|
package/dist/mixpanel.amd.js
CHANGED
|
@@ -17,7 +17,9 @@ define((function () { 'use strict';
|
|
|
17
17
|
screen: { width: 0, height: 0 },
|
|
18
18
|
location: loc,
|
|
19
19
|
addEventListener: function() {},
|
|
20
|
-
removeEventListener: function() {}
|
|
20
|
+
removeEventListener: function() {},
|
|
21
|
+
dispatchEvent: function() {},
|
|
22
|
+
CustomEvent: function () {}
|
|
21
23
|
};
|
|
22
24
|
} else {
|
|
23
25
|
win = window;
|
|
@@ -14532,7 +14534,7 @@ define((function () { 'use strict';
|
|
|
14532
14534
|
|
|
14533
14535
|
var Config = {
|
|
14534
14536
|
DEBUG: false,
|
|
14535
|
-
LIB_VERSION: '2.
|
|
14537
|
+
LIB_VERSION: '2.73.0'
|
|
14536
14538
|
};
|
|
14537
14539
|
|
|
14538
14540
|
/* eslint camelcase: "off", eqeqeq: "off" */
|
|
@@ -21800,8 +21802,6 @@ define((function () { 'use strict';
|
|
|
21800
21802
|
var INIT_MODULE = 0;
|
|
21801
21803
|
var INIT_SNIPPET = 1;
|
|
21802
21804
|
|
|
21803
|
-
var IDENTITY_FUNC = function(x) {return x;};
|
|
21804
|
-
|
|
21805
21805
|
/** @const */ var PRIMARY_INSTANCE_NAME = 'mixpanel';
|
|
21806
21806
|
/** @const */ var PAYLOAD_TYPE_BASE64 = 'base64';
|
|
21807
21807
|
/** @const */ var PAYLOAD_TYPE_JSON = 'json';
|
|
@@ -21967,6 +21967,17 @@ define((function () { 'use strict';
|
|
|
21967
21967
|
// global debug to be true
|
|
21968
21968
|
Config.DEBUG = Config.DEBUG || instance.get_config('debug');
|
|
21969
21969
|
|
|
21970
|
+
var source = init_type === INIT_MODULE ? 'module' : 'snippet';
|
|
21971
|
+
win.dispatchEvent(new win.CustomEvent('$mp_sdk_to_extension_event', {
|
|
21972
|
+
'detail': {
|
|
21973
|
+
'instance': instance,
|
|
21974
|
+
'source': source,
|
|
21975
|
+
'token': token,
|
|
21976
|
+
'name': name,
|
|
21977
|
+
'info': _.info
|
|
21978
|
+
}
|
|
21979
|
+
}));
|
|
21980
|
+
|
|
21970
21981
|
// if target is not defined, we called init after the lib already
|
|
21971
21982
|
// loaded, so there won't be an array of things to execute
|
|
21972
21983
|
if (!_.isUndefined(target) && _.isArray(target)) {
|
|
@@ -22037,6 +22048,8 @@ define((function () { 'use strict';
|
|
|
22037
22048
|
}
|
|
22038
22049
|
}
|
|
22039
22050
|
|
|
22051
|
+
this.hooks = {};
|
|
22052
|
+
|
|
22040
22053
|
this.set_config(_.extend({}, DEFAULT_CONFIG, variable_features, config, {
|
|
22041
22054
|
'name': name,
|
|
22042
22055
|
'token': token,
|
|
@@ -22637,7 +22650,12 @@ define((function () { 'use strict';
|
|
|
22637
22650
|
);
|
|
22638
22651
|
}, this),
|
|
22639
22652
|
beforeSendHook: _.bind(function(item) {
|
|
22640
|
-
|
|
22653
|
+
var ret = this._run_hook('before_send_' + attrs.type, item);
|
|
22654
|
+
if (ret) {
|
|
22655
|
+
return ret[0];
|
|
22656
|
+
} else {
|
|
22657
|
+
return null;
|
|
22658
|
+
}
|
|
22641
22659
|
}, this),
|
|
22642
22660
|
stopAllBatchingFunc: _.bind(this.stop_batch_senders, this),
|
|
22643
22661
|
usePersistence: true,
|
|
@@ -22730,6 +22748,9 @@ define((function () { 'use strict';
|
|
|
22730
22748
|
var send_request_immediately = _.bind(function() {
|
|
22731
22749
|
if (!send_request_options.skip_hooks) {
|
|
22732
22750
|
truncated_data = this._run_hook('before_send_' + options.type, truncated_data);
|
|
22751
|
+
if (truncated_data) {
|
|
22752
|
+
truncated_data = truncated_data[0];
|
|
22753
|
+
}
|
|
22733
22754
|
}
|
|
22734
22755
|
if (truncated_data) {
|
|
22735
22756
|
console$1.log('MIXPANEL REQUEST:');
|
|
@@ -22784,6 +22805,17 @@ define((function () { 'use strict';
|
|
|
22784
22805
|
* with the tracking payload sent to the API server is returned; otherwise false.
|
|
22785
22806
|
*/
|
|
22786
22807
|
MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, properties, options, callback) {
|
|
22808
|
+
var ret;
|
|
22809
|
+
if (!(options && options.skip_hooks)) {
|
|
22810
|
+
ret = this._run_hook('before_track', event_name, properties);
|
|
22811
|
+
if (ret === null) {
|
|
22812
|
+
return;
|
|
22813
|
+
} else {
|
|
22814
|
+
event_name = ret[0];
|
|
22815
|
+
properties = ret[1];
|
|
22816
|
+
}
|
|
22817
|
+
}
|
|
22818
|
+
|
|
22787
22819
|
if (!callback && typeof options === 'function') {
|
|
22788
22820
|
callback = options;
|
|
22789
22821
|
options = null;
|
|
@@ -22853,7 +22885,7 @@ define((function () { 'use strict';
|
|
|
22853
22885
|
'event': event_name,
|
|
22854
22886
|
'properties': properties
|
|
22855
22887
|
};
|
|
22856
|
-
|
|
22888
|
+
ret = this._track_or_batch({
|
|
22857
22889
|
type: 'events',
|
|
22858
22890
|
data: data,
|
|
22859
22891
|
endpoint: this.get_api_host('events') + '/' + this.get_config('api_routes')['track'],
|
|
@@ -23199,6 +23231,14 @@ define((function () { 'use strict';
|
|
|
23199
23231
|
* @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
|
|
23200
23232
|
*/
|
|
23201
23233
|
MixpanelLib.prototype.register = function(props, days_or_options) {
|
|
23234
|
+
var ret = this._run_hook('before_register', props, days_or_options);
|
|
23235
|
+
if (ret === null) {
|
|
23236
|
+
return;
|
|
23237
|
+
} else {
|
|
23238
|
+
props = ret[0];
|
|
23239
|
+
days_or_options = ret[1];
|
|
23240
|
+
}
|
|
23241
|
+
|
|
23202
23242
|
var options = options_for_register(days_or_options);
|
|
23203
23243
|
if (options['persistent']) {
|
|
23204
23244
|
this['persistence'].register(props, options['days']);
|
|
@@ -23235,6 +23275,15 @@ define((function () { 'use strict';
|
|
|
23235
23275
|
* @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
|
|
23236
23276
|
*/
|
|
23237
23277
|
MixpanelLib.prototype.register_once = function(props, default_value, days_or_options) {
|
|
23278
|
+
var ret = this._run_hook('before_register_once', props, default_value, days_or_options);
|
|
23279
|
+
if (ret === null) {
|
|
23280
|
+
return;
|
|
23281
|
+
} else {
|
|
23282
|
+
props = ret[0];
|
|
23283
|
+
default_value = ret[1];
|
|
23284
|
+
days_or_options = ret[2];
|
|
23285
|
+
}
|
|
23286
|
+
|
|
23238
23287
|
var options = options_for_register(days_or_options);
|
|
23239
23288
|
if (options['persistent']) {
|
|
23240
23289
|
this['persistence'].register_once(props, default_value, options['days']);
|
|
@@ -23258,6 +23307,14 @@ define((function () { 'use strict';
|
|
|
23258
23307
|
* @param {boolean} [options.persistent=true] - whether to look in persistent storage (cookie/localStorage)
|
|
23259
23308
|
*/
|
|
23260
23309
|
MixpanelLib.prototype.unregister = function(property, options) {
|
|
23310
|
+
var ret = this._run_hook('before_unregister', property, options);
|
|
23311
|
+
if (ret === null) {
|
|
23312
|
+
return;
|
|
23313
|
+
} else {
|
|
23314
|
+
property = ret[0];
|
|
23315
|
+
options = ret[1];
|
|
23316
|
+
}
|
|
23317
|
+
|
|
23261
23318
|
options = options_for_register(options);
|
|
23262
23319
|
if (options['persistent']) {
|
|
23263
23320
|
this['persistence'].unregister(property);
|
|
@@ -23306,6 +23363,13 @@ define((function () { 'use strict';
|
|
|
23306
23363
|
// _set_once_callback:function A callback to be run if and when the People set_once queue is flushed
|
|
23307
23364
|
// _union_callback:function A callback to be run if and when the People union queue is flushed
|
|
23308
23365
|
// _unset_callback:function A callback to be run if and when the People unset queue is flushed
|
|
23366
|
+
var ret = this._run_hook('before_identify', new_distinct_id);
|
|
23367
|
+
|
|
23368
|
+
if (ret === null) {
|
|
23369
|
+
return -1;
|
|
23370
|
+
} else {
|
|
23371
|
+
new_distinct_id = ret[0];
|
|
23372
|
+
}
|
|
23309
23373
|
|
|
23310
23374
|
var previous_distinct_id = this.get_distinct_id();
|
|
23311
23375
|
if (new_distinct_id && previous_distinct_id !== new_distinct_id) {
|
|
@@ -23630,6 +23694,25 @@ define((function () { 'use strict';
|
|
|
23630
23694
|
if (('autocapture' in config || 'record_heatmap_data' in config) && this.autocapture) {
|
|
23631
23695
|
this.autocapture.init();
|
|
23632
23696
|
}
|
|
23697
|
+
|
|
23698
|
+
if (_.isObject(config['hooks'])) {
|
|
23699
|
+
this.hooks = {};
|
|
23700
|
+
_.each(config['hooks'], function(hook_value, hook_name) {
|
|
23701
|
+
if (_.isFunction(hook_value)) {
|
|
23702
|
+
this.hooks[hook_name] = [hook_value];
|
|
23703
|
+
} else if (_.isArray(hook_value)) {
|
|
23704
|
+
this.hooks[hook_name] = [];
|
|
23705
|
+
for (var i = 0; i < hook_value.length; i++) {
|
|
23706
|
+
if (!_.isFunction(hook_value[i])) {
|
|
23707
|
+
console$1.critical('Invalid hook added. Hook is not a function');
|
|
23708
|
+
}
|
|
23709
|
+
this.hooks[hook_name].push(hook_value[i]);
|
|
23710
|
+
}
|
|
23711
|
+
} else {
|
|
23712
|
+
console$1.critical('Invalid hooks added. Ensure that the hook values passed into config.hooks are functions or arrays of functions.');
|
|
23713
|
+
}
|
|
23714
|
+
}, this);
|
|
23715
|
+
}
|
|
23633
23716
|
}
|
|
23634
23717
|
};
|
|
23635
23718
|
|
|
@@ -23647,12 +23730,26 @@ define((function () { 'use strict';
|
|
|
23647
23730
|
* @returns {any|null} return value of user-provided hook, or null if nothing was returned
|
|
23648
23731
|
*/
|
|
23649
23732
|
MixpanelLib.prototype._run_hook = function(hook_name) {
|
|
23650
|
-
var
|
|
23651
|
-
|
|
23652
|
-
|
|
23653
|
-
|
|
23654
|
-
|
|
23655
|
-
|
|
23733
|
+
var hook_data = slice.call(arguments, 1);
|
|
23734
|
+
_.each(this.hooks[hook_name], function(hook) {
|
|
23735
|
+
if (hook_data === null) {
|
|
23736
|
+
return null;
|
|
23737
|
+
}
|
|
23738
|
+
|
|
23739
|
+
var ret = hook.apply(this, hook_data);
|
|
23740
|
+
|
|
23741
|
+
if (typeof ret === 'undefined') {
|
|
23742
|
+
this.report_error(hook_name + ' hook did not return a valid value');
|
|
23743
|
+
hook_data = null;
|
|
23744
|
+
} else {
|
|
23745
|
+
if (!_.isArray(ret)) {
|
|
23746
|
+
ret = [ret];
|
|
23747
|
+
}
|
|
23748
|
+
hook_data.splice.apply(hook_data, [0, ret.length].concat(ret));
|
|
23749
|
+
}
|
|
23750
|
+
}, this);
|
|
23751
|
+
|
|
23752
|
+
return hook_data;
|
|
23656
23753
|
};
|
|
23657
23754
|
|
|
23658
23755
|
/**
|
|
@@ -23963,6 +24060,25 @@ define((function () { 'use strict';
|
|
|
23963
24060
|
}
|
|
23964
24061
|
};
|
|
23965
24062
|
|
|
24063
|
+
MixpanelLib.prototype.add_hook = function(hook_name, hook_fn) {
|
|
24064
|
+
if (!this.hooks[hook_name]) {
|
|
24065
|
+
this.hooks[hook_name] = [];
|
|
24066
|
+
}
|
|
24067
|
+
this.hooks[hook_name].push(hook_fn);
|
|
24068
|
+
};
|
|
24069
|
+
|
|
24070
|
+
MixpanelLib.prototype.remove_hook = function(hook_name, hook_fn) {
|
|
24071
|
+
var fn_index;
|
|
24072
|
+
if (this.hooks[hook_name]) {
|
|
24073
|
+
fn_index = this.hooks[hook_name].indexOf(hook_fn);
|
|
24074
|
+
if (fn_index !== -1) {
|
|
24075
|
+
this.hooks[hook_name].splice(fn_index, 1);
|
|
24076
|
+
} else {
|
|
24077
|
+
console$1.log('remove_hook failed. Matching hook was not found');
|
|
24078
|
+
}
|
|
24079
|
+
}
|
|
24080
|
+
};
|
|
24081
|
+
|
|
23966
24082
|
// EXPORTS (for closure compiler)
|
|
23967
24083
|
|
|
23968
24084
|
// MixpanelLib Exports
|
|
@@ -23995,6 +24111,8 @@ define((function () { 'use strict';
|
|
|
23995
24111
|
MixpanelLib.prototype['set_group'] = MixpanelLib.prototype.set_group;
|
|
23996
24112
|
MixpanelLib.prototype['add_group'] = MixpanelLib.prototype.add_group;
|
|
23997
24113
|
MixpanelLib.prototype['remove_group'] = MixpanelLib.prototype.remove_group;
|
|
24114
|
+
MixpanelLib.prototype['add_hook'] = MixpanelLib.prototype.add_hook;
|
|
24115
|
+
MixpanelLib.prototype['remove_hook'] = MixpanelLib.prototype.remove_hook;
|
|
23998
24116
|
MixpanelLib.prototype['track_with_groups'] = MixpanelLib.prototype.track_with_groups;
|
|
23999
24117
|
MixpanelLib.prototype['start_batch_senders'] = MixpanelLib.prototype.start_batch_senders;
|
|
24000
24118
|
MixpanelLib.prototype['stop_batch_senders'] = MixpanelLib.prototype.stop_batch_senders;
|
package/dist/mixpanel.cjs.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ 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
|
|
|
@@ -155,6 +155,11 @@ export interface FlagsConfig {
|
|
|
155
155
|
context: Dict;
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
export interface BeforeSendHookPayload {
|
|
159
|
+
event: string;
|
|
160
|
+
properties: Record<string, any>;
|
|
161
|
+
}
|
|
162
|
+
|
|
158
163
|
export interface Config {
|
|
159
164
|
api_host: string;
|
|
160
165
|
api_routes: {
|
|
@@ -167,10 +172,13 @@ export interface Config {
|
|
|
167
172
|
app_host: string;
|
|
168
173
|
api_payload_format: ApiPayloadFormat;
|
|
169
174
|
autotrack: boolean;
|
|
175
|
+
batch_autostart: boolean;
|
|
176
|
+
batch_requests: boolean;
|
|
170
177
|
cdn: string;
|
|
171
178
|
cookie_domain: string;
|
|
172
179
|
cross_site_cookie: boolean;
|
|
173
180
|
cross_subdomain_cookie: boolean;
|
|
181
|
+
error_reporter: (msg: string, err?: Error) => void;
|
|
174
182
|
flags: boolean | FlagsConfig;
|
|
175
183
|
persistence: Persistence;
|
|
176
184
|
persistence_name: string;
|
|
@@ -207,10 +215,10 @@ export interface Config {
|
|
|
207
215
|
inapp_protocol: string;
|
|
208
216
|
inapp_link_new_window: boolean;
|
|
209
217
|
ignore_dnt: boolean;
|
|
210
|
-
batch_requests: boolean;
|
|
211
218
|
batch_size: number;
|
|
212
219
|
batch_flush_interval_ms: number;
|
|
213
220
|
batch_request_timeout_ms: number;
|
|
221
|
+
recorder_src: string;
|
|
214
222
|
record_block_class: string | RegExp;
|
|
215
223
|
record_block_selector: string;
|
|
216
224
|
record_collect_fonts: boolean;
|
|
@@ -223,6 +231,29 @@ export interface Config {
|
|
|
223
231
|
record_sessions_percent: number;
|
|
224
232
|
record_canvas: boolean;
|
|
225
233
|
record_heatmap_data: boolean;
|
|
234
|
+
hooks: {
|
|
235
|
+
before_identify?: (new_distinct_id: string) => string | null;
|
|
236
|
+
before_register?: (
|
|
237
|
+
props: Dict,
|
|
238
|
+
days_or_options?: number | Partial<RegisterOptions>
|
|
239
|
+
) => Dict | Array<Dict | number | Partial<RegisterOptions>> | null;
|
|
240
|
+
before_register_once?: (
|
|
241
|
+
props: Dict,
|
|
242
|
+
default_value?: any,
|
|
243
|
+
days_or_options?: number | Partial<RegisterOptions>
|
|
244
|
+
) => Dict | Array<any | Dict | number | Partial<RegisterOptions>> | null;
|
|
245
|
+
before_send_events?: (
|
|
246
|
+
event: BeforeSendHookPayload
|
|
247
|
+
) => BeforeSendHookPayload | null;
|
|
248
|
+
before_track?: (
|
|
249
|
+
event_name: string,
|
|
250
|
+
properties: Dict
|
|
251
|
+
) => string | Array<string | Dict> | null;
|
|
252
|
+
before_unregister?: (
|
|
253
|
+
property: string,
|
|
254
|
+
options?: Partial<RegisterOptions>
|
|
255
|
+
) => string | Partial<RegisterOptions> | null;
|
|
256
|
+
};
|
|
226
257
|
}
|
|
227
258
|
|
|
228
259
|
export type VerboseResponse =
|
|
@@ -323,10 +354,11 @@ export interface Mixpanel {
|
|
|
323
354
|
get_distinct_id(): any;
|
|
324
355
|
get_group(group_key: string, group_id: string): Group;
|
|
325
356
|
get_property(property_name: string): any;
|
|
357
|
+
get_session_replay_url(): string;
|
|
326
358
|
has_opted_in_tracking(options?: Partial<HasOptedInOutOptions>): boolean;
|
|
327
359
|
has_opted_out_tracking(options?: Partial<HasOptedInOutOptions>): boolean;
|
|
328
360
|
identify(unique_id?: string): any;
|
|
329
|
-
init(token: string, config: Partial<Config>, name
|
|
361
|
+
init(token: string, config: Partial<Config>, name?: string): Mixpanel;
|
|
330
362
|
opt_in_tracking(options?: Partial<InTrackingOptions>): void;
|
|
331
363
|
opt_out_tracking(options?: Partial<OutTrackingOptions>): void;
|
|
332
364
|
push(item: PushItem): void;
|
|
@@ -351,6 +383,7 @@ export interface Mixpanel {
|
|
|
351
383
|
group_ids: string | string[] | number | number[],
|
|
352
384
|
callback?: Callback
|
|
353
385
|
): void;
|
|
386
|
+
start_batch_senders(): void;
|
|
354
387
|
time_event(event_name: string): void;
|
|
355
388
|
track(
|
|
356
389
|
event_name: string,
|
|
@@ -380,6 +413,7 @@ export interface Mixpanel {
|
|
|
380
413
|
): void;
|
|
381
414
|
unregister(property: string, options?: Partial<RegisterOptions>): void;
|
|
382
415
|
people: People;
|
|
416
|
+
start_batch_senders(): void;
|
|
383
417
|
start_session_recording(): void;
|
|
384
418
|
stop_session_recording(): void;
|
|
385
419
|
get_session_recording_properties(): { $mp_replay_id?: string } | {};
|