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
|
@@ -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.module.js
CHANGED
|
@@ -15,7 +15,9 @@ if (typeof(window) === 'undefined') {
|
|
|
15
15
|
screen: { width: 0, height: 0 },
|
|
16
16
|
location: loc,
|
|
17
17
|
addEventListener: function() {},
|
|
18
|
-
removeEventListener: function() {}
|
|
18
|
+
removeEventListener: function() {},
|
|
19
|
+
dispatchEvent: function() {},
|
|
20
|
+
CustomEvent: function () {}
|
|
19
21
|
};
|
|
20
22
|
} else {
|
|
21
23
|
win = window;
|
|
@@ -14530,7 +14532,7 @@ if (typeof Promise !== 'undefined' && Promise.toString().indexOf('[native code]'
|
|
|
14530
14532
|
|
|
14531
14533
|
var Config = {
|
|
14532
14534
|
DEBUG: false,
|
|
14533
|
-
LIB_VERSION: '2.
|
|
14535
|
+
LIB_VERSION: '2.73.0'
|
|
14534
14536
|
};
|
|
14535
14537
|
|
|
14536
14538
|
/* eslint camelcase: "off", eqeqeq: "off" */
|
|
@@ -21798,8 +21800,6 @@ var mixpanel_master; // main mixpanel instance / object
|
|
|
21798
21800
|
var INIT_MODULE = 0;
|
|
21799
21801
|
var INIT_SNIPPET = 1;
|
|
21800
21802
|
|
|
21801
|
-
var IDENTITY_FUNC = function(x) {return x;};
|
|
21802
|
-
|
|
21803
21803
|
/** @const */ var PRIMARY_INSTANCE_NAME = 'mixpanel';
|
|
21804
21804
|
/** @const */ var PAYLOAD_TYPE_BASE64 = 'base64';
|
|
21805
21805
|
/** @const */ var PAYLOAD_TYPE_JSON = 'json';
|
|
@@ -21965,6 +21965,17 @@ var create_mplib = function(token, config, name) {
|
|
|
21965
21965
|
// global debug to be true
|
|
21966
21966
|
Config.DEBUG = Config.DEBUG || instance.get_config('debug');
|
|
21967
21967
|
|
|
21968
|
+
var source = init_type === INIT_MODULE ? 'module' : 'snippet';
|
|
21969
|
+
win.dispatchEvent(new win.CustomEvent('$mp_sdk_to_extension_event', {
|
|
21970
|
+
'detail': {
|
|
21971
|
+
'instance': instance,
|
|
21972
|
+
'source': source,
|
|
21973
|
+
'token': token,
|
|
21974
|
+
'name': name,
|
|
21975
|
+
'info': _.info
|
|
21976
|
+
}
|
|
21977
|
+
}));
|
|
21978
|
+
|
|
21968
21979
|
// if target is not defined, we called init after the lib already
|
|
21969
21980
|
// loaded, so there won't be an array of things to execute
|
|
21970
21981
|
if (!_.isUndefined(target) && _.isArray(target)) {
|
|
@@ -22035,6 +22046,8 @@ MixpanelLib.prototype._init = function(token, config, name) {
|
|
|
22035
22046
|
}
|
|
22036
22047
|
}
|
|
22037
22048
|
|
|
22049
|
+
this.hooks = {};
|
|
22050
|
+
|
|
22038
22051
|
this.set_config(_.extend({}, DEFAULT_CONFIG, variable_features, config, {
|
|
22039
22052
|
'name': name,
|
|
22040
22053
|
'token': token,
|
|
@@ -22635,7 +22648,12 @@ MixpanelLib.prototype.init_batchers = function() {
|
|
|
22635
22648
|
);
|
|
22636
22649
|
}, this),
|
|
22637
22650
|
beforeSendHook: _.bind(function(item) {
|
|
22638
|
-
|
|
22651
|
+
var ret = this._run_hook('before_send_' + attrs.type, item);
|
|
22652
|
+
if (ret) {
|
|
22653
|
+
return ret[0];
|
|
22654
|
+
} else {
|
|
22655
|
+
return null;
|
|
22656
|
+
}
|
|
22639
22657
|
}, this),
|
|
22640
22658
|
stopAllBatchingFunc: _.bind(this.stop_batch_senders, this),
|
|
22641
22659
|
usePersistence: true,
|
|
@@ -22728,6 +22746,9 @@ MixpanelLib.prototype._track_or_batch = function(options, callback) {
|
|
|
22728
22746
|
var send_request_immediately = _.bind(function() {
|
|
22729
22747
|
if (!send_request_options.skip_hooks) {
|
|
22730
22748
|
truncated_data = this._run_hook('before_send_' + options.type, truncated_data);
|
|
22749
|
+
if (truncated_data) {
|
|
22750
|
+
truncated_data = truncated_data[0];
|
|
22751
|
+
}
|
|
22731
22752
|
}
|
|
22732
22753
|
if (truncated_data) {
|
|
22733
22754
|
console$1.log('MIXPANEL REQUEST:');
|
|
@@ -22782,6 +22803,17 @@ MixpanelLib.prototype._track_or_batch = function(options, callback) {
|
|
|
22782
22803
|
* with the tracking payload sent to the API server is returned; otherwise false.
|
|
22783
22804
|
*/
|
|
22784
22805
|
MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, properties, options, callback) {
|
|
22806
|
+
var ret;
|
|
22807
|
+
if (!(options && options.skip_hooks)) {
|
|
22808
|
+
ret = this._run_hook('before_track', event_name, properties);
|
|
22809
|
+
if (ret === null) {
|
|
22810
|
+
return;
|
|
22811
|
+
} else {
|
|
22812
|
+
event_name = ret[0];
|
|
22813
|
+
properties = ret[1];
|
|
22814
|
+
}
|
|
22815
|
+
}
|
|
22816
|
+
|
|
22785
22817
|
if (!callback && typeof options === 'function') {
|
|
22786
22818
|
callback = options;
|
|
22787
22819
|
options = null;
|
|
@@ -22851,7 +22883,7 @@ MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, pro
|
|
|
22851
22883
|
'event': event_name,
|
|
22852
22884
|
'properties': properties
|
|
22853
22885
|
};
|
|
22854
|
-
|
|
22886
|
+
ret = this._track_or_batch({
|
|
22855
22887
|
type: 'events',
|
|
22856
22888
|
data: data,
|
|
22857
22889
|
endpoint: this.get_api_host('events') + '/' + this.get_config('api_routes')['track'],
|
|
@@ -23197,6 +23229,14 @@ var options_for_register = function(days_or_options) {
|
|
|
23197
23229
|
* @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
|
|
23198
23230
|
*/
|
|
23199
23231
|
MixpanelLib.prototype.register = function(props, days_or_options) {
|
|
23232
|
+
var ret = this._run_hook('before_register', props, days_or_options);
|
|
23233
|
+
if (ret === null) {
|
|
23234
|
+
return;
|
|
23235
|
+
} else {
|
|
23236
|
+
props = ret[0];
|
|
23237
|
+
days_or_options = ret[1];
|
|
23238
|
+
}
|
|
23239
|
+
|
|
23200
23240
|
var options = options_for_register(days_or_options);
|
|
23201
23241
|
if (options['persistent']) {
|
|
23202
23242
|
this['persistence'].register(props, options['days']);
|
|
@@ -23233,6 +23273,15 @@ MixpanelLib.prototype.register = function(props, days_or_options) {
|
|
|
23233
23273
|
* @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
|
|
23234
23274
|
*/
|
|
23235
23275
|
MixpanelLib.prototype.register_once = function(props, default_value, days_or_options) {
|
|
23276
|
+
var ret = this._run_hook('before_register_once', props, default_value, days_or_options);
|
|
23277
|
+
if (ret === null) {
|
|
23278
|
+
return;
|
|
23279
|
+
} else {
|
|
23280
|
+
props = ret[0];
|
|
23281
|
+
default_value = ret[1];
|
|
23282
|
+
days_or_options = ret[2];
|
|
23283
|
+
}
|
|
23284
|
+
|
|
23236
23285
|
var options = options_for_register(days_or_options);
|
|
23237
23286
|
if (options['persistent']) {
|
|
23238
23287
|
this['persistence'].register_once(props, default_value, options['days']);
|
|
@@ -23256,6 +23305,14 @@ MixpanelLib.prototype.register_once = function(props, default_value, days_or_opt
|
|
|
23256
23305
|
* @param {boolean} [options.persistent=true] - whether to look in persistent storage (cookie/localStorage)
|
|
23257
23306
|
*/
|
|
23258
23307
|
MixpanelLib.prototype.unregister = function(property, options) {
|
|
23308
|
+
var ret = this._run_hook('before_unregister', property, options);
|
|
23309
|
+
if (ret === null) {
|
|
23310
|
+
return;
|
|
23311
|
+
} else {
|
|
23312
|
+
property = ret[0];
|
|
23313
|
+
options = ret[1];
|
|
23314
|
+
}
|
|
23315
|
+
|
|
23259
23316
|
options = options_for_register(options);
|
|
23260
23317
|
if (options['persistent']) {
|
|
23261
23318
|
this['persistence'].unregister(property);
|
|
@@ -23304,6 +23361,13 @@ MixpanelLib.prototype.identify = function(
|
|
|
23304
23361
|
// _set_once_callback:function A callback to be run if and when the People set_once queue is flushed
|
|
23305
23362
|
// _union_callback:function A callback to be run if and when the People union queue is flushed
|
|
23306
23363
|
// _unset_callback:function A callback to be run if and when the People unset queue is flushed
|
|
23364
|
+
var ret = this._run_hook('before_identify', new_distinct_id);
|
|
23365
|
+
|
|
23366
|
+
if (ret === null) {
|
|
23367
|
+
return -1;
|
|
23368
|
+
} else {
|
|
23369
|
+
new_distinct_id = ret[0];
|
|
23370
|
+
}
|
|
23307
23371
|
|
|
23308
23372
|
var previous_distinct_id = this.get_distinct_id();
|
|
23309
23373
|
if (new_distinct_id && previous_distinct_id !== new_distinct_id) {
|
|
@@ -23628,6 +23692,25 @@ MixpanelLib.prototype.set_config = function(config) {
|
|
|
23628
23692
|
if (('autocapture' in config || 'record_heatmap_data' in config) && this.autocapture) {
|
|
23629
23693
|
this.autocapture.init();
|
|
23630
23694
|
}
|
|
23695
|
+
|
|
23696
|
+
if (_.isObject(config['hooks'])) {
|
|
23697
|
+
this.hooks = {};
|
|
23698
|
+
_.each(config['hooks'], function(hook_value, hook_name) {
|
|
23699
|
+
if (_.isFunction(hook_value)) {
|
|
23700
|
+
this.hooks[hook_name] = [hook_value];
|
|
23701
|
+
} else if (_.isArray(hook_value)) {
|
|
23702
|
+
this.hooks[hook_name] = [];
|
|
23703
|
+
for (var i = 0; i < hook_value.length; i++) {
|
|
23704
|
+
if (!_.isFunction(hook_value[i])) {
|
|
23705
|
+
console$1.critical('Invalid hook added. Hook is not a function');
|
|
23706
|
+
}
|
|
23707
|
+
this.hooks[hook_name].push(hook_value[i]);
|
|
23708
|
+
}
|
|
23709
|
+
} else {
|
|
23710
|
+
console$1.critical('Invalid hooks added. Ensure that the hook values passed into config.hooks are functions or arrays of functions.');
|
|
23711
|
+
}
|
|
23712
|
+
}, this);
|
|
23713
|
+
}
|
|
23631
23714
|
}
|
|
23632
23715
|
};
|
|
23633
23716
|
|
|
@@ -23645,12 +23728,26 @@ MixpanelLib.prototype.get_config = function(prop_name) {
|
|
|
23645
23728
|
* @returns {any|null} return value of user-provided hook, or null if nothing was returned
|
|
23646
23729
|
*/
|
|
23647
23730
|
MixpanelLib.prototype._run_hook = function(hook_name) {
|
|
23648
|
-
var
|
|
23649
|
-
|
|
23650
|
-
|
|
23651
|
-
|
|
23652
|
-
|
|
23653
|
-
|
|
23731
|
+
var hook_data = slice.call(arguments, 1);
|
|
23732
|
+
_.each(this.hooks[hook_name], function(hook) {
|
|
23733
|
+
if (hook_data === null) {
|
|
23734
|
+
return null;
|
|
23735
|
+
}
|
|
23736
|
+
|
|
23737
|
+
var ret = hook.apply(this, hook_data);
|
|
23738
|
+
|
|
23739
|
+
if (typeof ret === 'undefined') {
|
|
23740
|
+
this.report_error(hook_name + ' hook did not return a valid value');
|
|
23741
|
+
hook_data = null;
|
|
23742
|
+
} else {
|
|
23743
|
+
if (!_.isArray(ret)) {
|
|
23744
|
+
ret = [ret];
|
|
23745
|
+
}
|
|
23746
|
+
hook_data.splice.apply(hook_data, [0, ret.length].concat(ret));
|
|
23747
|
+
}
|
|
23748
|
+
}, this);
|
|
23749
|
+
|
|
23750
|
+
return hook_data;
|
|
23654
23751
|
};
|
|
23655
23752
|
|
|
23656
23753
|
/**
|
|
@@ -23961,6 +24058,25 @@ MixpanelLib.prototype.report_error = function(msg, err) {
|
|
|
23961
24058
|
}
|
|
23962
24059
|
};
|
|
23963
24060
|
|
|
24061
|
+
MixpanelLib.prototype.add_hook = function(hook_name, hook_fn) {
|
|
24062
|
+
if (!this.hooks[hook_name]) {
|
|
24063
|
+
this.hooks[hook_name] = [];
|
|
24064
|
+
}
|
|
24065
|
+
this.hooks[hook_name].push(hook_fn);
|
|
24066
|
+
};
|
|
24067
|
+
|
|
24068
|
+
MixpanelLib.prototype.remove_hook = function(hook_name, hook_fn) {
|
|
24069
|
+
var fn_index;
|
|
24070
|
+
if (this.hooks[hook_name]) {
|
|
24071
|
+
fn_index = this.hooks[hook_name].indexOf(hook_fn);
|
|
24072
|
+
if (fn_index !== -1) {
|
|
24073
|
+
this.hooks[hook_name].splice(fn_index, 1);
|
|
24074
|
+
} else {
|
|
24075
|
+
console$1.log('remove_hook failed. Matching hook was not found');
|
|
24076
|
+
}
|
|
24077
|
+
}
|
|
24078
|
+
};
|
|
24079
|
+
|
|
23964
24080
|
// EXPORTS (for closure compiler)
|
|
23965
24081
|
|
|
23966
24082
|
// MixpanelLib Exports
|
|
@@ -23993,6 +24109,8 @@ MixpanelLib.prototype['get_group'] = MixpanelLib.protot
|
|
|
23993
24109
|
MixpanelLib.prototype['set_group'] = MixpanelLib.prototype.set_group;
|
|
23994
24110
|
MixpanelLib.prototype['add_group'] = MixpanelLib.prototype.add_group;
|
|
23995
24111
|
MixpanelLib.prototype['remove_group'] = MixpanelLib.prototype.remove_group;
|
|
24112
|
+
MixpanelLib.prototype['add_hook'] = MixpanelLib.prototype.add_hook;
|
|
24113
|
+
MixpanelLib.prototype['remove_hook'] = MixpanelLib.prototype.remove_hook;
|
|
23996
24114
|
MixpanelLib.prototype['track_with_groups'] = MixpanelLib.prototype.track_with_groups;
|
|
23997
24115
|
MixpanelLib.prototype['start_batch_senders'] = MixpanelLib.prototype.start_batch_senders;
|
|
23998
24116
|
MixpanelLib.prototype['stop_batch_senders'] = MixpanelLib.prototype.stop_batch_senders;
|
package/dist/mixpanel.umd.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 } | {};
|