mixpanel-browser 2.39.0 → 2.42.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/.github/workflows/tests.yml +25 -0
- package/CHANGELOG.md +21 -0
- package/README.md +4 -2
- package/dist/mixpanel-jslib-snippet.min.js +3 -4
- package/dist/mixpanel-jslib-snippet.min.test.js +3 -4
- package/dist/mixpanel.amd.js +370 -704
- package/dist/mixpanel.cjs.js +370 -704
- package/dist/mixpanel.globals.js +373 -707
- package/dist/mixpanel.min.js +150 -158
- package/dist/mixpanel.umd.js +370 -704
- package/doc/build-docs.js +16 -0
- package/doc/readme.io/javascript-full-api-reference.md +44 -2
- package/mixpanel-jslib-snippet.js +1 -20
- package/package.json +3 -3
- package/src/config.js +1 -1
- package/src/gdpr-utils.js +7 -2
- package/src/mixpanel-core.js +201 -85
- package/src/mixpanel-group.js +6 -1
- package/src/mixpanel-people.js +3 -3
- package/src/request-batcher.js +27 -13
- package/src/request-queue.js +47 -0
- package/src/utils.js +48 -37
- package/tunnel.log +0 -0
- package/.travis.yml +0 -8
- package/src/autotrack-utils.js +0 -192
- package/src/autotrack.js +0 -355
package/doc/build-docs.js
CHANGED
|
@@ -97,6 +97,22 @@ function doxToMD(items) {
|
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
// Captures prototype bracket notation property assignment, e.g.:
|
|
101
|
+
// `MixpanelGroup.prototype['delete'] = addOptOutCheckMixpanelGroup(function(callback) {`
|
|
102
|
+
// Based on https://github.com/tj/dox/blob/9fe92e17dfcd31c9b6512f6e5bf0b52c2b6b84d4/lib/dox.js#L592
|
|
103
|
+
dox.contextPatternMatchers.push(function (str) {
|
|
104
|
+
if (/^\s*([\w$.]+)\s*\.\s*prototype\s*\['\s*([\w$]+)'\]\s*=\s*([^\n;]+)/.exec(str)) {
|
|
105
|
+
return {
|
|
106
|
+
type: 'property'
|
|
107
|
+
, constructor: RegExp.$1
|
|
108
|
+
, cons: RegExp.$1
|
|
109
|
+
, name: RegExp.$2
|
|
110
|
+
, value: RegExp.$3.trim()
|
|
111
|
+
, string: RegExp.$1 + '.prototype.' + RegExp.$2
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
100
116
|
const rawCode = fs.readFileSync(SOURCE_FILE).toString().trim();
|
|
101
117
|
const parsed = dox.parseComments(rawCode);
|
|
102
118
|
|
|
@@ -344,6 +344,9 @@ mixpanel.register({
|
|
|
344
344
|
'Email': 'jdoe@example.com',
|
|
345
345
|
'Account Type': 'Free'
|
|
346
346
|
});
|
|
347
|
+
|
|
348
|
+
// register only for the current pageload
|
|
349
|
+
mixpanel.register({'Name': 'Pat'}, {persistent: false});
|
|
347
350
|
```
|
|
348
351
|
|
|
349
352
|
|
|
@@ -351,7 +354,13 @@ mixpanel.register({
|
|
|
351
354
|
| Argument | Type | Description |
|
|
352
355
|
| ------------- | ------------- | ----- |
|
|
353
356
|
| **properties** | <span class="mp-arg-type">Object</span></br></span><span class="mp-arg-required">required</span> | An associative array of properties to store about the user |
|
|
354
|
-
| **
|
|
357
|
+
| **days_or_options** | <span class="mp-arg-type">Number or Object</span></br></span><span class="mp-arg-optional">optional</span> | Options object or number of days since the user's last visit to store the super properties (only valid for persisted props) |
|
|
358
|
+
| **days_or_options.days** | <span class="mp-arg-type">boolean</span></br></span><span class="mp-arg-optional">optional</span> | <ul>
|
|
359
|
+
<li>number of days since the user's last visit to store the super properties (only valid for persisted props)</li>
|
|
360
|
+
</ul> |
|
|
361
|
+
| **days_or_options.persistent=true** | <span class="mp-arg-type">boolean</span></br></span><span class="mp-arg-optional">optional</span> | <ul>
|
|
362
|
+
<li>whether to put in persistent storage (cookie/localStorage)</li>
|
|
363
|
+
</ul> |
|
|
355
364
|
|
|
356
365
|
|
|
357
366
|
___
|
|
@@ -367,6 +376,11 @@ mixpanel.register_once({
|
|
|
367
376
|
'First Login Date': new Date().toISOString()
|
|
368
377
|
});
|
|
369
378
|
|
|
379
|
+
// register once, only for the current pageload
|
|
380
|
+
mixpanel.register_once({
|
|
381
|
+
'First interaction time': new Date().toISOString()
|
|
382
|
+
}, 'None', {persistent: false});
|
|
383
|
+
|
|
370
384
|
```
|
|
371
385
|
|
|
372
386
|
|
|
@@ -378,7 +392,13 @@ If default_value is specified, current super properties with that value will be
|
|
|
378
392
|
| ------------- | ------------- | ----- |
|
|
379
393
|
| **properties** | <span class="mp-arg-type">Object</span></br></span><span class="mp-arg-required">required</span> | An associative array of properties to store about the user |
|
|
380
394
|
| **default_value** | <span class="mp-arg-type">any</span></br></span><span class="mp-arg-optional">optional</span> | Value to override if already set in super properties (ex: 'False') Default: 'None' |
|
|
381
|
-
| **
|
|
395
|
+
| **days_or_options** | <span class="mp-arg-type">Number or Object</span></br></span><span class="mp-arg-optional">optional</span> | Options object or number of days since the user's last visit to store the super properties (only valid for persisted props) |
|
|
396
|
+
| **days_or_options.days** | <span class="mp-arg-type">boolean</span></br></span><span class="mp-arg-optional">optional</span> | <ul>
|
|
397
|
+
<li>number of days since the user's last visit to store the super properties (only valid for persisted props)</li>
|
|
398
|
+
</ul> |
|
|
399
|
+
| **days_or_options.persistent=true** | <span class="mp-arg-type">boolean</span></br></span><span class="mp-arg-optional">optional</span> | <ul>
|
|
400
|
+
<li>whether to put in persistent storage (cookie/localStorage)</li>
|
|
401
|
+
</ul> |
|
|
382
402
|
|
|
383
403
|
|
|
384
404
|
___
|
|
@@ -703,6 +723,10 @@ Delete a super property stored with the current user.
|
|
|
703
723
|
| Argument | Type | Description |
|
|
704
724
|
| ------------- | ------------- | ----- |
|
|
705
725
|
| **property** | <span class="mp-arg-type">String</span></br></span><span class="mp-arg-required">required</span> | The name of the super property to remove |
|
|
726
|
+
| **options** | <span class="mp-arg-type">Object</span></br></span><span class="mp-arg-optional">optional</span> | |
|
|
727
|
+
| **options.persistent=true** | <span class="mp-arg-type">boolean</span></br></span><span class="mp-arg-optional">optional</span> | <ul>
|
|
728
|
+
<li>whether to look in persistent storage (cookie/localStorage)</li>
|
|
729
|
+
</ul> |
|
|
706
730
|
|
|
707
731
|
|
|
708
732
|
|
|
@@ -966,6 +990,24 @@ mixpanel.people.unset(['gender', 'Company']);
|
|
|
966
990
|
# mixpanel.group
|
|
967
991
|
|
|
968
992
|
|
|
993
|
+
___
|
|
994
|
+
## mixpanel.group.delete
|
|
995
|
+
Permanently delete a group.
|
|
996
|
+
|
|
997
|
+
|
|
998
|
+
### Usage:
|
|
999
|
+
|
|
1000
|
+
```javascript
|
|
1001
|
+
mixpanel.get_group('company', 'mixpanel').delete();
|
|
1002
|
+
```
|
|
1003
|
+
|
|
1004
|
+
|
|
1005
|
+
|
|
1006
|
+
| Argument | Type | Description |
|
|
1007
|
+
| ------------- | ------------- | ----- |
|
|
1008
|
+
| **callback** | <span class="mp-arg-type">Function</span></br></span><span class="mp-arg-optional">optional</span> | If provided, the callback will be called after the tracking event |
|
|
1009
|
+
|
|
1010
|
+
|
|
969
1011
|
___
|
|
970
1012
|
## mixpanel.group.remove
|
|
971
1013
|
Remove a property from a group. The value will be ignored if doesn't exist.
|
|
@@ -9,25 +9,6 @@ var MIXPANEL_LIB_URL = '//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js';
|
|
|
9
9
|
(function(document, mixpanel) {
|
|
10
10
|
// Only stub out if this is the first time running the snippet.
|
|
11
11
|
if (!mixpanel['__SV']) {
|
|
12
|
-
var win = window;
|
|
13
|
-
|
|
14
|
-
// grab the hash params for ce editor immediately in case
|
|
15
|
-
// host website changes hash after init
|
|
16
|
-
try {
|
|
17
|
-
var getHashParam, matches, state, loc = win.location, hash = loc.hash;
|
|
18
|
-
getHashParam = function(hash, param) {
|
|
19
|
-
matches = hash.match(new RegExp(param + '=([^&]*)'));
|
|
20
|
-
return matches ? matches[1] : null;
|
|
21
|
-
};
|
|
22
|
-
if (hash && getHashParam(hash, 'state')) {
|
|
23
|
-
state = JSON.parse(decodeURIComponent(getHashParam(hash, 'state')));
|
|
24
|
-
if (state['action'] === 'mpeditor') {
|
|
25
|
-
win.sessionStorage.setItem('_mpcehash', hash);
|
|
26
|
-
history.replaceState(state['desiredHash'] || '', document.title, loc.pathname + loc.search); // remove ce editor hash
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
} catch (e) {}
|
|
30
|
-
|
|
31
12
|
var script, first_script, gen_fn, functions, i, lib_name = "mixpanel";
|
|
32
13
|
window[lib_name] = mixpanel;
|
|
33
14
|
|
|
@@ -72,7 +53,7 @@ var MIXPANEL_LIB_URL = '//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js';
|
|
|
72
53
|
|
|
73
54
|
// create shallow clone of the public mixpanel interface
|
|
74
55
|
// Note: only supports 1 additional level atm, e.g. mixpanel.people.set, not mixpanel.people.set.do_something_else.
|
|
75
|
-
functions = "disable time_event track track_pageview track_links track_forms track_with_groups add_group set_group remove_group register register_once alias unregister identify name_tag set_config reset opt_in_tracking opt_out_tracking has_opted_in_tracking has_opted_out_tracking clear_opt_in_out_tracking people.set people.set_once people.unset people.increment people.append people.union people.track_charge people.clear_charges people.delete_user people.remove".split(' ');
|
|
56
|
+
functions = "disable time_event track track_pageview track_links track_forms track_with_groups add_group set_group remove_group register register_once alias unregister identify name_tag set_config reset opt_in_tracking opt_out_tracking has_opted_in_tracking has_opted_out_tracking clear_opt_in_out_tracking start_batch_senders people.set people.set_once people.unset people.increment people.append people.union people.track_charge people.clear_charges people.delete_user people.remove".split(' ');
|
|
76
57
|
for (i = 0; i < functions.length; i++) {
|
|
77
58
|
_set_and_defer(target, functions[i]);
|
|
78
59
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mixpanel-browser",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.42.0",
|
|
4
4
|
"description": "The official Mixpanel JavaScript browser client library",
|
|
5
5
|
"main": "dist/mixpanel.cjs.js",
|
|
6
6
|
"directories": {
|
|
@@ -46,10 +46,10 @@
|
|
|
46
46
|
"jsdom": "11.12.0",
|
|
47
47
|
"jsdom-global": "3.0.2",
|
|
48
48
|
"localStorage": "1.0.4",
|
|
49
|
-
"lodash": "4.17.
|
|
49
|
+
"lodash": "4.17.21",
|
|
50
50
|
"mocha": "7.1.1",
|
|
51
51
|
"morgan": "1.9.1",
|
|
52
|
-
"rdme": "
|
|
52
|
+
"rdme": "4.0.0",
|
|
53
53
|
"request": "2.88.0",
|
|
54
54
|
"rollup": "0.25.8",
|
|
55
55
|
"rollup-plugin-npm": "1.4.0",
|
package/src/config.js
CHANGED
package/src/gdpr-utils.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* These functions are used internally by the SDK and are not intended to be publicly exposed.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import { _, window } from './utils';
|
|
14
|
+
import { _, console, window } from './utils';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* A function used to track a Mixpanel event (e.g. MixpanelLib.track)
|
|
@@ -83,9 +83,14 @@ export function hasOptedIn(token, options) {
|
|
|
83
83
|
*/
|
|
84
84
|
export function hasOptedOut(token, options) {
|
|
85
85
|
if (_hasDoNotTrackFlagOn(options)) {
|
|
86
|
+
console.warn('This browser has "Do Not Track" enabled. This will prevent the Mixpanel SDK from sending any data. To ignore the "Do Not Track" browser setting, initialize the Mixpanel instance with the config "ignore_dnt: true"');
|
|
86
87
|
return true;
|
|
87
88
|
}
|
|
88
|
-
|
|
89
|
+
var optedOut = _getStorageValue(token, options) === '0';
|
|
90
|
+
if (optedOut) {
|
|
91
|
+
console.warn('You are opted out of Mixpanel tracking. This will prevent the Mixpanel SDK from sending any data.');
|
|
92
|
+
}
|
|
93
|
+
return optedOut;
|
|
89
94
|
}
|
|
90
95
|
|
|
91
96
|
/**
|