@shrfe/assets 1.0.70-staging.1 → 1.0.70-staging.2
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/css/ds/component.css +21 -21
- package/css/ds/semantics/color/color.css +27 -10
- package/css/ds/semantics/sizing/sizing.css +105 -0
- package/css/ds/semantics/typography/typography.css +5 -0
- package/css/sfe-styles.css +2 -2
- package/css/shrfe-styles.css +3 -3
- package/js/shrfe-core-umd.js +2108 -1066
- package/package.json +1 -1
- package/wc-lib/p-174301fb.entry.js +1 -0
- package/wc-lib/p-2c4876fa.entry.js +1 -0
- package/wc-lib/p-2e791a55.entry.js +1 -0
- package/wc-lib/p-31519e7f.entry.js +1 -0
- package/wc-lib/p-3e4a8ef5.entry.js +6 -0
- package/wc-lib/{p-cc5249f0.js → p-3e6d1904.js} +1 -1
- package/wc-lib/p-3eec282c.entry.js +1 -0
- package/wc-lib/p-4173382e.entry.js +1 -0
- package/wc-lib/p-675661f0.entry.js +1 -0
- package/wc-lib/p-6c03fed1.entry.js +1 -0
- package/wc-lib/p-6c47c21d.entry.js +1 -0
- package/wc-lib/p-7313607b.entry.js +1 -0
- package/wc-lib/p-7724ee26.entry.js +1 -0
- package/wc-lib/p-8b4ed5bd.entry.js +1 -0
- package/wc-lib/p-9012cefb.entry.js +1 -0
- package/wc-lib/p-BoRgucbk.js +3 -0
- package/wc-lib/p-af56e6b9.entry.js +1 -0
- package/wc-lib/p-be8b915e.entry.js +1 -0
- package/wc-lib/p-c6a60e55.entry.js +1 -0
- package/wc-lib/p-ead33561.entry.js +1 -0
- package/wc-lib/p-f9397a52.entry.js +1 -0
- package/wc-lib/wc-lib.esm.js +1 -1
- package/wc-lib/p-0b72ab12.entry.js +0 -1
- package/wc-lib/p-0cc19352.entry.js +0 -1
- package/wc-lib/p-10c23c12.entry.js +0 -1
- package/wc-lib/p-11d9c6ab.entry.js +0 -1
- package/wc-lib/p-2eac5d59.entry.js +0 -1
- package/wc-lib/p-372a4b08.entry.js +0 -1
- package/wc-lib/p-3b9cba49.entry.js +0 -1
- package/wc-lib/p-434962b3.entry.js +0 -1
- package/wc-lib/p-4b90088d.entry.js +0 -1
- package/wc-lib/p-5a39bffb.entry.js +0 -1
- package/wc-lib/p-5ec334e6.entry.js +0 -6
- package/wc-lib/p-6e7ee60b.entry.js +0 -1
- package/wc-lib/p-7799bd4f.entry.js +0 -1
- package/wc-lib/p-9af28040.entry.js +0 -1
- package/wc-lib/p-9c20ecd6.entry.js +0 -1
- package/wc-lib/p-9oFec6fH.js +0 -3
- package/wc-lib/p-abd9b780.entry.js +0 -1
- package/wc-lib/p-c117222e.entry.js +0 -1
- package/wc-lib/p-dcca5e23.entry.js +0 -1
- package/wc-lib/p-e96984e8.entry.js +0 -1
package/js/shrfe-core-umd.js
CHANGED
|
@@ -25990,16 +25990,16 @@ class HTTPBaseService {
|
|
|
25990
25990
|
processQueue(err, null);
|
|
25991
25991
|
refreshState.isRefreshing = false;
|
|
25992
25992
|
refreshState.accessToken = null;
|
|
25993
|
+
// Capture the destination before logout removes the persisted login URL.
|
|
25994
|
+
let loginUrl = this.authService.getLoginUrl();
|
|
25995
|
+
if (!loginUrl) {
|
|
25996
|
+
loginUrl = typeof this.loginUrl === 'function' ? this.loginUrl() : this.loginUrl;
|
|
25997
|
+
}
|
|
25993
25998
|
// Refresh failed — log out and redirect
|
|
25994
25999
|
const { showMessage, defaultMessage } = this.resolveError(error, 'Your session has expired, you need to sign in again.');
|
|
25995
26000
|
if (showMessage) {
|
|
25996
26001
|
alert_service_toast('error', 'Error', defaultMessage);
|
|
25997
26002
|
setTimeout(()=>{
|
|
25998
|
-
let loginUrl = this.authService.getLoginUrl();
|
|
25999
|
-
// Remove this once Login URL is set
|
|
26000
|
-
if (!loginUrl) {
|
|
26001
|
-
loginUrl = typeof this.loginUrl === 'function' ? this.loginUrl() : this.loginUrl;
|
|
26002
|
-
}
|
|
26003
26003
|
if (loginUrl) location.href = loginUrl;
|
|
26004
26004
|
}, 1000);
|
|
26005
26005
|
}
|
|
@@ -26050,7 +26050,7 @@ class HTTPService extends (/* unused pure expression or super */ null && (HTTPBa
|
|
|
26050
26050
|
|
|
26051
26051
|
;// CONCATENATED MODULE: ../../node_modules/@vue/shared/dist/shared.esm-bundler.js
|
|
26052
26052
|
/**
|
|
26053
|
-
* @vue/shared v3.5.
|
|
26053
|
+
* @vue/shared v3.5.45
|
|
26054
26054
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
26055
26055
|
* @license MIT
|
|
26056
26056
|
**/
|
|
@@ -26112,24 +26112,20 @@ const cacheStringFunction = (fn) => {
|
|
|
26112
26112
|
});
|
|
26113
26113
|
};
|
|
26114
26114
|
const camelizeRE = /-\w/g;
|
|
26115
|
-
const camelize = (/* unused pure expression or super */ null && (cacheStringFunction(
|
|
26116
|
-
(
|
|
26117
|
-
|
|
26118
|
-
}
|
|
26119
|
-
)));
|
|
26115
|
+
const camelize = /* @__PURE__ */ (/* unused pure expression or super */ null && (cacheStringFunction((str) => {
|
|
26116
|
+
return str.replace(camelizeRE, (c) => c.slice(1).toUpperCase());
|
|
26117
|
+
})));
|
|
26120
26118
|
const hyphenateRE = /\B([A-Z])/g;
|
|
26121
|
-
const hyphenate = (/* unused pure expression or super */ null && (cacheStringFunction(
|
|
26119
|
+
const hyphenate = /* @__PURE__ */ (/* unused pure expression or super */ null && (cacheStringFunction(
|
|
26122
26120
|
(str) => str.replace(hyphenateRE, "-$1").toLowerCase()
|
|
26123
26121
|
)));
|
|
26124
|
-
const capitalize = (/* unused pure expression or super */ null && (cacheStringFunction((str) => {
|
|
26122
|
+
const capitalize = /* @__PURE__ */ (/* unused pure expression or super */ null && (cacheStringFunction((str) => {
|
|
26125
26123
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
26126
26124
|
})));
|
|
26127
|
-
const toHandlerKey = (/* unused pure expression or super */ null && (cacheStringFunction(
|
|
26128
|
-
(str)
|
|
26129
|
-
|
|
26130
|
-
|
|
26131
|
-
}
|
|
26132
|
-
)));
|
|
26125
|
+
const toHandlerKey = /* @__PURE__ */ (/* unused pure expression or super */ null && (cacheStringFunction((str) => {
|
|
26126
|
+
const s = str ? `on${capitalize(str)}` : ``;
|
|
26127
|
+
return s;
|
|
26128
|
+
})));
|
|
26133
26129
|
const shared_esm_bundler_hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
|
26134
26130
|
const invokeArrayFns = (fns, ...arg) => {
|
|
26135
26131
|
for (let i = 0; i < fns.length; i++) {
|
|
@@ -26383,7 +26379,7 @@ const isSVGTag = /* @__PURE__ */ (/* unused pure expression or super */ null &&
|
|
|
26383
26379
|
const isMathMLTag = /* @__PURE__ */ (/* unused pure expression or super */ null && (makeMap(MATH_TAGS)));
|
|
26384
26380
|
const isVoidTag = /* @__PURE__ */ (/* unused pure expression or super */ null && (makeMap(VOID_TAGS)));
|
|
26385
26381
|
|
|
26386
|
-
const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
|
|
26382
|
+
const specialBooleanAttrs = `itemscope,allowfullscreen,disablepictureinpicture,disableremoteplayback,formnovalidate,ismap,nomodule,novalidate,playsinline,readonly`;
|
|
26387
26383
|
const isSpecialBooleanAttr = /* @__PURE__ */ (/* unused pure expression or super */ null && (makeMap(specialBooleanAttrs)));
|
|
26388
26384
|
const isBooleanAttr = /* @__PURE__ */ makeMap(
|
|
26389
26385
|
specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`
|
|
@@ -26634,7 +26630,7 @@ function normalizeCssVarValue(value) {
|
|
|
26634
26630
|
|
|
26635
26631
|
;// CONCATENATED MODULE: ../../node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js
|
|
26636
26632
|
/**
|
|
26637
|
-
* @vue/reactivity v3.5.
|
|
26633
|
+
* @vue/reactivity v3.5.45
|
|
26638
26634
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
26639
26635
|
* @license MIT
|
|
26640
26636
|
**/
|
|
@@ -26799,7 +26795,11 @@ function getCurrentScope() {
|
|
|
26799
26795
|
}
|
|
26800
26796
|
function onScopeDispose(fn, failSilently = false) {
|
|
26801
26797
|
if (activeEffectScope) {
|
|
26802
|
-
activeEffectScope.
|
|
26798
|
+
if (activeEffectScope.active) {
|
|
26799
|
+
activeEffectScope.cleanups.push(fn);
|
|
26800
|
+
} else {
|
|
26801
|
+
fn();
|
|
26802
|
+
}
|
|
26803
26803
|
} else if (false) {}
|
|
26804
26804
|
}
|
|
26805
26805
|
|
|
@@ -27266,7 +27266,7 @@ const MAP_KEY_ITERATE_KEY = /* @__PURE__ */ Symbol(
|
|
|
27266
27266
|
const ARRAY_ITERATE_KEY = /* @__PURE__ */ Symbol(
|
|
27267
27267
|
false ? 0 : ""
|
|
27268
27268
|
);
|
|
27269
|
-
function
|
|
27269
|
+
function reactivity_esm_bundler_track(target, type, key) {
|
|
27270
27270
|
if (reactivity_esm_bundler_shouldTrack && activeSub) {
|
|
27271
27271
|
let depsMap = targetMap.get(target);
|
|
27272
27272
|
if (!depsMap) {
|
|
@@ -27353,13 +27353,13 @@ function getDepFromReactive(object, key) {
|
|
|
27353
27353
|
function reactiveReadArray(array) {
|
|
27354
27354
|
const raw = toRaw(array);
|
|
27355
27355
|
if (raw === array) return raw;
|
|
27356
|
-
|
|
27356
|
+
reactivity_esm_bundler_track(raw, "iterate", ARRAY_ITERATE_KEY);
|
|
27357
27357
|
if (isShallow(array)) return raw;
|
|
27358
27358
|
if (!isReadonly(array)) return raw.map(toReactive);
|
|
27359
27359
|
return isReactive(array) ? raw.map((item) => toReadonly(toReactive(item))) : raw.map(toReadonly);
|
|
27360
27360
|
}
|
|
27361
27361
|
function shallowReadArray(arr) {
|
|
27362
|
-
|
|
27362
|
+
reactivity_esm_bundler_track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
|
|
27363
27363
|
return arr;
|
|
27364
27364
|
}
|
|
27365
27365
|
function toWrapped(target, item) {
|
|
@@ -27483,19 +27483,41 @@ const arrayInstrumentations = {
|
|
|
27483
27483
|
};
|
|
27484
27484
|
function reactivity_esm_bundler_iterator(self, method, wrapValue) {
|
|
27485
27485
|
const arr = shallowReadArray(self);
|
|
27486
|
-
const
|
|
27486
|
+
const methodFn = arr[method];
|
|
27487
|
+
const iter = methodFn.call(arr);
|
|
27487
27488
|
if (arr !== self && !isShallow(self)) {
|
|
27488
|
-
iter.
|
|
27489
|
-
|
|
27490
|
-
|
|
27491
|
-
if (
|
|
27492
|
-
|
|
27489
|
+
if (iter[Symbol.toStringTag] === "Array Iterator") {
|
|
27490
|
+
const wrapped = Object.create(Object.getPrototypeOf(iter));
|
|
27491
|
+
wrapped.next = () => wrapResult(iter.next(), wrapValue);
|
|
27492
|
+
if (methodFn !== reactivity_esm_bundler_arrayProto[method]) {
|
|
27493
|
+
Object.defineProperties(wrapped, {
|
|
27494
|
+
return: {
|
|
27495
|
+
get() {
|
|
27496
|
+
const fn = iter.return;
|
|
27497
|
+
return typeof fn === "function" ? fn.bind(iter) : fn;
|
|
27498
|
+
}
|
|
27499
|
+
},
|
|
27500
|
+
throw: {
|
|
27501
|
+
get() {
|
|
27502
|
+
const fn = iter.throw;
|
|
27503
|
+
return typeof fn === "function" ? fn.bind(iter) : fn;
|
|
27504
|
+
}
|
|
27505
|
+
}
|
|
27506
|
+
});
|
|
27493
27507
|
}
|
|
27494
|
-
return
|
|
27495
|
-
}
|
|
27508
|
+
return wrapped;
|
|
27509
|
+
}
|
|
27510
|
+
iter._next = iter.next;
|
|
27511
|
+
iter.next = () => wrapResult(iter._next(), wrapValue);
|
|
27496
27512
|
}
|
|
27497
27513
|
return iter;
|
|
27498
27514
|
}
|
|
27515
|
+
function wrapResult(result, wrapValue) {
|
|
27516
|
+
if (!result.done) {
|
|
27517
|
+
result.value = wrapValue(result.value);
|
|
27518
|
+
}
|
|
27519
|
+
return result;
|
|
27520
|
+
}
|
|
27499
27521
|
const reactivity_esm_bundler_arrayProto = Array.prototype;
|
|
27500
27522
|
function reactivity_esm_bundler_apply(self, method, fn, thisArg, wrappedRetFn, args) {
|
|
27501
27523
|
const arr = shallowReadArray(self);
|
|
@@ -27546,7 +27568,7 @@ function reduce(self, method, fn, args) {
|
|
|
27546
27568
|
}
|
|
27547
27569
|
function searchProxy(self, method, args) {
|
|
27548
27570
|
const arr = toRaw(self);
|
|
27549
|
-
|
|
27571
|
+
reactivity_esm_bundler_track(arr, "iterate", ARRAY_ITERATE_KEY);
|
|
27550
27572
|
const res = arr[method](...args);
|
|
27551
27573
|
if ((res === -1 || res === false) && isProxy(args[0])) {
|
|
27552
27574
|
args[0] = toRaw(args[0]);
|
|
@@ -27564,13 +27586,13 @@ function noTracking(self, method, args = []) {
|
|
|
27564
27586
|
}
|
|
27565
27587
|
|
|
27566
27588
|
const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
|
|
27567
|
-
const builtInSymbols = new Set(
|
|
27589
|
+
const builtInSymbols = /* @__PURE__ */ new Set(
|
|
27568
27590
|
/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(shared_esm_bundler_isSymbol)
|
|
27569
27591
|
);
|
|
27570
27592
|
function reactivity_esm_bundler_hasOwnProperty(key) {
|
|
27571
27593
|
if (!shared_esm_bundler_isSymbol(key)) key = String(key);
|
|
27572
27594
|
const obj = toRaw(this);
|
|
27573
|
-
|
|
27595
|
+
reactivity_esm_bundler_track(obj, "has", key);
|
|
27574
27596
|
return obj.hasOwnProperty(key);
|
|
27575
27597
|
}
|
|
27576
27598
|
class BaseReactiveHandler {
|
|
@@ -27617,7 +27639,7 @@ class BaseReactiveHandler {
|
|
|
27617
27639
|
return res;
|
|
27618
27640
|
}
|
|
27619
27641
|
if (!isReadonly2) {
|
|
27620
|
-
|
|
27642
|
+
reactivity_esm_bundler_track(target, "get", key);
|
|
27621
27643
|
}
|
|
27622
27644
|
if (isShallow2) {
|
|
27623
27645
|
return res;
|
|
@@ -27683,12 +27705,12 @@ class MutableReactiveHandler extends BaseReactiveHandler {
|
|
|
27683
27705
|
has(target, key) {
|
|
27684
27706
|
const result = Reflect.has(target, key);
|
|
27685
27707
|
if (!shared_esm_bundler_isSymbol(key) || !builtInSymbols.has(key)) {
|
|
27686
|
-
|
|
27708
|
+
reactivity_esm_bundler_track(target, "has", key);
|
|
27687
27709
|
}
|
|
27688
27710
|
return result;
|
|
27689
27711
|
}
|
|
27690
27712
|
ownKeys(target) {
|
|
27691
|
-
|
|
27713
|
+
reactivity_esm_bundler_track(
|
|
27692
27714
|
target,
|
|
27693
27715
|
"iterate",
|
|
27694
27716
|
shared_esm_bundler_isArray(target) ? "length" : ITERATE_KEY
|
|
@@ -27725,7 +27747,7 @@ function createIterableMethod(method, isReadonly2, isShallow2) {
|
|
|
27725
27747
|
const isKeyOnly = method === "keys" && targetIsMap;
|
|
27726
27748
|
const innerIterator = target[method](...args);
|
|
27727
27749
|
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
27728
|
-
!isReadonly2 &&
|
|
27750
|
+
!isReadonly2 && reactivity_esm_bundler_track(
|
|
27729
27751
|
rawTarget,
|
|
27730
27752
|
"iterate",
|
|
27731
27753
|
isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
|
|
@@ -27760,9 +27782,9 @@ function createInstrumentations(readonly, shallow) {
|
|
|
27760
27782
|
const rawKey = toRaw(key);
|
|
27761
27783
|
if (!readonly) {
|
|
27762
27784
|
if (shared_esm_bundler_hasChanged(key, rawKey)) {
|
|
27763
|
-
|
|
27785
|
+
reactivity_esm_bundler_track(rawTarget, "get", key);
|
|
27764
27786
|
}
|
|
27765
|
-
|
|
27787
|
+
reactivity_esm_bundler_track(rawTarget, "get", rawKey);
|
|
27766
27788
|
}
|
|
27767
27789
|
const { has } = getProto(rawTarget);
|
|
27768
27790
|
const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
|
|
@@ -27776,7 +27798,7 @@ function createInstrumentations(readonly, shallow) {
|
|
|
27776
27798
|
},
|
|
27777
27799
|
get size() {
|
|
27778
27800
|
const target = this["__v_raw"];
|
|
27779
|
-
!readonly &&
|
|
27801
|
+
!readonly && reactivity_esm_bundler_track(toRaw(target), "iterate", ITERATE_KEY);
|
|
27780
27802
|
return target.size;
|
|
27781
27803
|
},
|
|
27782
27804
|
has(key) {
|
|
@@ -27785,9 +27807,9 @@ function createInstrumentations(readonly, shallow) {
|
|
|
27785
27807
|
const rawKey = toRaw(key);
|
|
27786
27808
|
if (!readonly) {
|
|
27787
27809
|
if (shared_esm_bundler_hasChanged(key, rawKey)) {
|
|
27788
|
-
|
|
27810
|
+
reactivity_esm_bundler_track(rawTarget, "has", key);
|
|
27789
27811
|
}
|
|
27790
|
-
|
|
27812
|
+
reactivity_esm_bundler_track(rawTarget, "has", rawKey);
|
|
27791
27813
|
}
|
|
27792
27814
|
return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
|
|
27793
27815
|
},
|
|
@@ -27796,7 +27818,7 @@ function createInstrumentations(readonly, shallow) {
|
|
|
27796
27818
|
const target = observed["__v_raw"];
|
|
27797
27819
|
const rawTarget = toRaw(target);
|
|
27798
27820
|
const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
|
|
27799
|
-
!readonly &&
|
|
27821
|
+
!readonly && reactivity_esm_bundler_track(rawTarget, "iterate", ITERATE_KEY);
|
|
27800
27822
|
return target.forEach((value, key) => {
|
|
27801
27823
|
return callback.call(thisArg, wrap(value), wrap(key), observed);
|
|
27802
27824
|
});
|
|
@@ -27893,6 +27915,8 @@ function createInstrumentationGetter(isReadonly2, shallow) {
|
|
|
27893
27915
|
return !isReadonly2;
|
|
27894
27916
|
} else if (key === "__v_isReadonly") {
|
|
27895
27917
|
return isReadonly2;
|
|
27918
|
+
} else if (key === "__v_isShallow") {
|
|
27919
|
+
return shallow;
|
|
27896
27920
|
} else if (key === "__v_raw") {
|
|
27897
27921
|
return target;
|
|
27898
27922
|
}
|
|
@@ -28418,9 +28442,11 @@ function watch(source, cb, options = EMPTY_OBJ) {
|
|
|
28418
28442
|
if (once && cb) {
|
|
28419
28443
|
const _cb = cb;
|
|
28420
28444
|
cb = (...args) => {
|
|
28421
|
-
|
|
28422
|
-
|
|
28423
|
-
|
|
28445
|
+
try {
|
|
28446
|
+
return _cb(...args);
|
|
28447
|
+
} finally {
|
|
28448
|
+
watchHandle();
|
|
28449
|
+
}
|
|
28424
28450
|
};
|
|
28425
28451
|
}
|
|
28426
28452
|
let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
|
|
@@ -28431,12 +28457,13 @@ function watch(source, cb, options = EMPTY_OBJ) {
|
|
|
28431
28457
|
if (cb) {
|
|
28432
28458
|
const newValue = effect.run();
|
|
28433
28459
|
if (immediateFirstRun || deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
|
|
28434
|
-
if (cleanup) {
|
|
28435
|
-
cleanup();
|
|
28436
|
-
}
|
|
28437
28460
|
const currentWatcher = activeWatcher;
|
|
28438
|
-
|
|
28461
|
+
pauseTracking();
|
|
28439
28462
|
try {
|
|
28463
|
+
if (cleanup) {
|
|
28464
|
+
cleanup();
|
|
28465
|
+
}
|
|
28466
|
+
activeWatcher = effect;
|
|
28440
28467
|
const args = [
|
|
28441
28468
|
newValue,
|
|
28442
28469
|
// pass undefined as the old value when it's changed for the first time
|
|
@@ -28450,6 +28477,7 @@ function watch(source, cb, options = EMPTY_OBJ) {
|
|
|
28450
28477
|
);
|
|
28451
28478
|
} finally {
|
|
28452
28479
|
activeWatcher = currentWatcher;
|
|
28480
|
+
resetTracking();
|
|
28453
28481
|
}
|
|
28454
28482
|
}
|
|
28455
28483
|
} else {
|
|
@@ -28744,7 +28772,7 @@ if (typeof(window) === 'undefined') {
|
|
|
28744
28772
|
|
|
28745
28773
|
var Config = {
|
|
28746
28774
|
DEBUG: false,
|
|
28747
|
-
LIB_VERSION: '2.
|
|
28775
|
+
LIB_VERSION: '2.85.0'
|
|
28748
28776
|
};
|
|
28749
28777
|
|
|
28750
28778
|
// Window global names for async modules
|
|
@@ -47984,14 +48012,18 @@ mixpanel_module_.isElement = function(obj) {
|
|
|
47984
48012
|
};
|
|
47985
48013
|
|
|
47986
48014
|
mixpanel_module_.encodeDates = function(obj) {
|
|
48015
|
+
// build a copy so the caller's object (and any nested objects) are not mutated
|
|
48016
|
+
var encoded = mixpanel_module_.isArray(obj) ? [] : {};
|
|
47987
48017
|
mixpanel_module_.each(obj, function(v, k) {
|
|
47988
48018
|
if (mixpanel_module_.isDate(v)) {
|
|
47989
|
-
|
|
48019
|
+
encoded[k] = mixpanel_module_.formatDate(v);
|
|
47990
48020
|
} else if (mixpanel_module_.isObject(v)) {
|
|
47991
|
-
|
|
48021
|
+
encoded[k] = mixpanel_module_.encodeDates(v); // recurse
|
|
48022
|
+
} else {
|
|
48023
|
+
encoded[k] = v;
|
|
47992
48024
|
}
|
|
47993
48025
|
});
|
|
47994
|
-
return
|
|
48026
|
+
return encoded;
|
|
47995
48027
|
};
|
|
47996
48028
|
|
|
47997
48029
|
mixpanel_module_.timestamp = function() {
|
|
@@ -49208,7 +49240,7 @@ mixpanel_module_.info = {
|
|
|
49208
49240
|
'Firefox iOS': /FxiOS\/(\d+(\.\d+)?)/,
|
|
49209
49241
|
'Konqueror': /Konqueror:(\d+(\.\d+)?)/,
|
|
49210
49242
|
'BlackBerry': /BlackBerry (\d+(\.\d+)?)/,
|
|
49211
|
-
'Android Mobile': /
|
|
49243
|
+
'Android Mobile': /Android\s(\d+(\.\d+)?)/,
|
|
49212
49244
|
'Samsung Internet': /SamsungBrowser\/(\d+(\.\d+)?)/,
|
|
49213
49245
|
'Internet Explorer': /(rv:|MSIE )(\d+(\.\d+)?)/,
|
|
49214
49246
|
'Mozilla': /rv:(\d+(\.\d+)?)/,
|
|
@@ -49462,11 +49494,13 @@ mixpanel_module_['NPO'] = NpoPromise;
|
|
|
49462
49494
|
/**
|
|
49463
49495
|
* @type {import('./wrapper').StorageWrapper}
|
|
49464
49496
|
*/
|
|
49465
|
-
var IDBStorageWrapper = function (dbName, storeName, versionData) {
|
|
49497
|
+
var IDBStorageWrapper = function (dbName, storeName, versionData, options) {
|
|
49466
49498
|
this.dbName = dbName;
|
|
49467
49499
|
this.storeName = storeName;
|
|
49468
49500
|
this.version = versionData.version;
|
|
49469
49501
|
this.storeNamesInDb = versionData.storeNames;
|
|
49502
|
+
// false to only open a database the device already has, for cleanup that mustn't create one
|
|
49503
|
+
this.createIfMissing = !options || options.createIfMissing !== false;
|
|
49470
49504
|
/**
|
|
49471
49505
|
* @type {Promise<IDBDatabase>|null}
|
|
49472
49506
|
*/
|
|
@@ -49477,25 +49511,47 @@ IDBStorageWrapper.prototype._openDb = function () {
|
|
|
49477
49511
|
var dbName = this.dbName;
|
|
49478
49512
|
var version = this.version;
|
|
49479
49513
|
var storeNamesInDb = this.storeNamesInDb;
|
|
49480
|
-
|
|
49481
|
-
|
|
49482
|
-
|
|
49483
|
-
|
|
49484
|
-
|
|
49485
|
-
|
|
49486
|
-
|
|
49487
|
-
resolve(openRequest.result);
|
|
49488
|
-
};
|
|
49514
|
+
var createIfMissing = this.createIfMissing;
|
|
49515
|
+
var open = function () {
|
|
49516
|
+
return new PromisePolyfill(function (resolve, reject) {
|
|
49517
|
+
var openRequest = mixpanel_module_win.indexedDB.open(dbName, version);
|
|
49518
|
+
openRequest['onerror'] = function () {
|
|
49519
|
+
reject(openRequest.error);
|
|
49520
|
+
};
|
|
49489
49521
|
|
|
49490
|
-
|
|
49491
|
-
|
|
49522
|
+
openRequest['onsuccess'] = function () {
|
|
49523
|
+
resolve(openRequest.result);
|
|
49524
|
+
};
|
|
49492
49525
|
|
|
49493
|
-
|
|
49494
|
-
if (!
|
|
49495
|
-
|
|
49526
|
+
openRequest['onupgradeneeded'] = function (ev) {
|
|
49527
|
+
if (!createIfMissing && ev['oldVersion'] === 0) {
|
|
49528
|
+
// aborting fails the open; the new database stays at version 0, which
|
|
49529
|
+
// databases() doesn't list
|
|
49530
|
+
openRequest['transaction']['abort']();
|
|
49531
|
+
return;
|
|
49496
49532
|
}
|
|
49497
|
-
|
|
49498
|
-
|
|
49533
|
+
var db = ev.target.result;
|
|
49534
|
+
|
|
49535
|
+
storeNamesInDb.forEach(function (storeName) {
|
|
49536
|
+
if (!db.objectStoreNames.contains(storeName)) {
|
|
49537
|
+
db.createObjectStore(storeName);
|
|
49538
|
+
}
|
|
49539
|
+
});
|
|
49540
|
+
};
|
|
49541
|
+
});
|
|
49542
|
+
};
|
|
49543
|
+
|
|
49544
|
+
// where the browser lists its databases, a missing one isn't even opened
|
|
49545
|
+
if (createIfMissing || !mixpanel_module_win.indexedDB['databases']) {
|
|
49546
|
+
return open();
|
|
49547
|
+
}
|
|
49548
|
+
return mixpanel_module_win.indexedDB['databases']().then(function (databases) {
|
|
49549
|
+
for (var i = 0; i < databases.length; i++) {
|
|
49550
|
+
if (databases[i]['name'] === dbName) {
|
|
49551
|
+
return open();
|
|
49552
|
+
}
|
|
49553
|
+
}
|
|
49554
|
+
return PromisePolyfill.reject(dbName + ' does not exist');
|
|
49499
49555
|
});
|
|
49500
49556
|
};
|
|
49501
49557
|
|
|
@@ -49595,306 +49651,6 @@ var RECORDER_VERSION_DATA = {
|
|
|
49595
49651
|
storeNames: [RECORDING_EVENTS_STORE_NAME, RECORDING_REGISTRY_STORE_NAME]
|
|
49596
49652
|
};
|
|
49597
49653
|
|
|
49598
|
-
/**
|
|
49599
|
-
* GDPR utils
|
|
49600
|
-
*
|
|
49601
|
-
* The General Data Protection Regulation (GDPR) is a regulation in EU law on data protection
|
|
49602
|
-
* and privacy for all individuals within the European Union. It addresses the export of personal
|
|
49603
|
-
* data outside the EU. The GDPR aims primarily to give control back to citizens and residents
|
|
49604
|
-
* over their personal data and to simplify the regulatory environment for international business
|
|
49605
|
-
* by unifying the regulation within the EU.
|
|
49606
|
-
*
|
|
49607
|
-
* This set of utilities is intended to enable opt in/out functionality in the Mixpanel JS SDK.
|
|
49608
|
-
* These functions are used internally by the SDK and are not intended to be publicly exposed.
|
|
49609
|
-
*/
|
|
49610
|
-
|
|
49611
|
-
|
|
49612
|
-
/**
|
|
49613
|
-
* A function used to track a Mixpanel event (e.g. MixpanelLib.track)
|
|
49614
|
-
* @callback trackFunction
|
|
49615
|
-
* @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
|
|
49616
|
-
* @param {Object} [properties] A set of properties to include with the event you're sending. These describe the user who did the event or details about the event itself.
|
|
49617
|
-
* @param {Function} [callback] If provided, the callback function will be called after tracking the event.
|
|
49618
|
-
*/
|
|
49619
|
-
|
|
49620
|
-
/** Public **/
|
|
49621
|
-
|
|
49622
|
-
var GDPR_DEFAULT_PERSISTENCE_PREFIX = '__mp_opt_in_out_';
|
|
49623
|
-
|
|
49624
|
-
/**
|
|
49625
|
-
* Opt the user in to data tracking and cookies/localstorage for the given token
|
|
49626
|
-
* @param {string} token - Mixpanel project tracking token
|
|
49627
|
-
* @param {Object} [options]
|
|
49628
|
-
* @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
|
|
49629
|
-
* @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
|
|
49630
|
-
* @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
|
|
49631
|
-
* @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
|
|
49632
|
-
* @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
|
|
49633
|
-
* @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
|
|
49634
|
-
* @param {string} [options.cookieDomain] - custom cookie domain
|
|
49635
|
-
* @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
|
|
49636
|
-
* @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
|
|
49637
|
-
* @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
|
|
49638
|
-
*/
|
|
49639
|
-
function optIn(token, options) {
|
|
49640
|
-
_optInOut(true, token, options);
|
|
49641
|
-
}
|
|
49642
|
-
|
|
49643
|
-
/**
|
|
49644
|
-
* Opt the user out of data tracking and cookies/localstorage for the given token
|
|
49645
|
-
* @param {string} token - Mixpanel project tracking token
|
|
49646
|
-
* @param {Object} [options]
|
|
49647
|
-
* @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
|
|
49648
|
-
* @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
|
|
49649
|
-
* @param {Number} [options.cookieExpiration] - number of days until the opt-out cookie expires
|
|
49650
|
-
* @param {string} [options.cookieDomain] - custom cookie domain
|
|
49651
|
-
* @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
|
|
49652
|
-
* @param {boolean} [options.crossSubdomainCookie] - whether the opt-out cookie is set as cross-subdomain or not
|
|
49653
|
-
* @param {boolean} [options.secureCookie] - whether the opt-out cookie is set as secure or not
|
|
49654
|
-
*/
|
|
49655
|
-
function optOut(token, options) {
|
|
49656
|
-
_optInOut(false, token, options);
|
|
49657
|
-
}
|
|
49658
|
-
|
|
49659
|
-
/**
|
|
49660
|
-
* Check whether the user has opted in to data tracking and cookies/localstorage for the given token
|
|
49661
|
-
* @param {string} token - Mixpanel project tracking token
|
|
49662
|
-
* @param {Object} [options]
|
|
49663
|
-
* @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
|
|
49664
|
-
* @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
|
|
49665
|
-
* @returns {boolean} whether the user has opted in to the given opt type
|
|
49666
|
-
*/
|
|
49667
|
-
function hasOptedIn(token, options) {
|
|
49668
|
-
return _getStorageValue(token, options) === '1';
|
|
49669
|
-
}
|
|
49670
|
-
|
|
49671
|
-
/**
|
|
49672
|
-
* Check whether the user has opted out of data tracking and cookies/localstorage for the given token
|
|
49673
|
-
* @param {string} token - Mixpanel project tracking token
|
|
49674
|
-
* @param {Object} [options]
|
|
49675
|
-
* @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
|
|
49676
|
-
* @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
|
|
49677
|
-
* @param {boolean} [options.ignoreDnt] - flag to ignore browser DNT settings and always return false
|
|
49678
|
-
* @returns {boolean} whether the user has opted out of the given opt type
|
|
49679
|
-
*/
|
|
49680
|
-
function hasOptedOut(token, options) {
|
|
49681
|
-
if (_hasDoNotTrackFlagOn(options)) {
|
|
49682
|
-
console$1.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"');
|
|
49683
|
-
return true;
|
|
49684
|
-
}
|
|
49685
|
-
var optedOut = _getStorageValue(token, options) === '0';
|
|
49686
|
-
if (optedOut) {
|
|
49687
|
-
console$1.warn('You are opted out of Mixpanel tracking. This will prevent the Mixpanel SDK from sending any data.');
|
|
49688
|
-
}
|
|
49689
|
-
return optedOut;
|
|
49690
|
-
}
|
|
49691
|
-
|
|
49692
|
-
/**
|
|
49693
|
-
* Wrap a MixpanelLib method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
|
|
49694
|
-
* If the user has opted out, return early instead of executing the method.
|
|
49695
|
-
* If a callback argument was provided, execute it passing the 0 error code.
|
|
49696
|
-
* @param {function} method - wrapped method to be executed if the user has not opted out
|
|
49697
|
-
* @returns {*} the result of executing method OR undefined if the user has opted out
|
|
49698
|
-
*/
|
|
49699
|
-
function addOptOutCheckMixpanelLib(method) {
|
|
49700
|
-
return _addOptOutCheck(method, function(name) {
|
|
49701
|
-
return this.get_config(name);
|
|
49702
|
-
});
|
|
49703
|
-
}
|
|
49704
|
-
|
|
49705
|
-
/**
|
|
49706
|
-
* Wrap a MixpanelPeople method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
|
|
49707
|
-
* If the user has opted out, return early instead of executing the method.
|
|
49708
|
-
* If a callback argument was provided, execute it passing the 0 error code.
|
|
49709
|
-
* @param {function} method - wrapped method to be executed if the user has not opted out
|
|
49710
|
-
* @returns {*} the result of executing method OR undefined if the user has opted out
|
|
49711
|
-
*/
|
|
49712
|
-
function addOptOutCheckMixpanelPeople(method) {
|
|
49713
|
-
return _addOptOutCheck(method, function(name) {
|
|
49714
|
-
return this._get_config(name);
|
|
49715
|
-
});
|
|
49716
|
-
}
|
|
49717
|
-
|
|
49718
|
-
/**
|
|
49719
|
-
* Wrap a MixpanelGroup method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
|
|
49720
|
-
* If the user has opted out, return early instead of executing the method.
|
|
49721
|
-
* If a callback argument was provided, execute it passing the 0 error code.
|
|
49722
|
-
* @param {function} method - wrapped method to be executed if the user has not opted out
|
|
49723
|
-
* @returns {*} the result of executing method OR undefined if the user has opted out
|
|
49724
|
-
*/
|
|
49725
|
-
function addOptOutCheckMixpanelGroup(method) {
|
|
49726
|
-
return _addOptOutCheck(method, function(name) {
|
|
49727
|
-
return this._get_config(name);
|
|
49728
|
-
});
|
|
49729
|
-
}
|
|
49730
|
-
|
|
49731
|
-
/**
|
|
49732
|
-
* Clear the user's opt in/out status of data tracking and cookies/localstorage for the given token
|
|
49733
|
-
* @param {string} token - Mixpanel project tracking token
|
|
49734
|
-
* @param {Object} [options]
|
|
49735
|
-
* @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
|
|
49736
|
-
* @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
|
|
49737
|
-
* @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
|
|
49738
|
-
* @param {string} [options.cookieDomain] - custom cookie domain
|
|
49739
|
-
* @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
|
|
49740
|
-
* @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
|
|
49741
|
-
* @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
|
|
49742
|
-
*/
|
|
49743
|
-
function clearOptInOut(token, options) {
|
|
49744
|
-
options = options || {};
|
|
49745
|
-
_getStorage(options).remove(
|
|
49746
|
-
_getStorageKey(token, options), !!options.crossSubdomainCookie, options.cookieDomain
|
|
49747
|
-
);
|
|
49748
|
-
}
|
|
49749
|
-
|
|
49750
|
-
/** Private **/
|
|
49751
|
-
|
|
49752
|
-
/**
|
|
49753
|
-
* Get storage util
|
|
49754
|
-
* @param {Object} [options]
|
|
49755
|
-
* @param {string} [options.persistenceType]
|
|
49756
|
-
* @returns {object} either _.cookie or _.localstorage
|
|
49757
|
-
*/
|
|
49758
|
-
function _getStorage(options) {
|
|
49759
|
-
options = options || {};
|
|
49760
|
-
return options.persistenceType === 'localStorage' ? mixpanel_module_.localStorage : mixpanel_module_.cookie;
|
|
49761
|
-
}
|
|
49762
|
-
|
|
49763
|
-
/**
|
|
49764
|
-
* Get the name of the cookie that is used for the given opt type (tracking, cookie, etc.)
|
|
49765
|
-
* @param {string} token - Mixpanel project tracking token
|
|
49766
|
-
* @param {Object} [options]
|
|
49767
|
-
* @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
|
|
49768
|
-
* @returns {string} the name of the cookie for the given opt type
|
|
49769
|
-
*/
|
|
49770
|
-
function _getStorageKey(token, options) {
|
|
49771
|
-
options = options || {};
|
|
49772
|
-
return (options.persistencePrefix || GDPR_DEFAULT_PERSISTENCE_PREFIX) + token;
|
|
49773
|
-
}
|
|
49774
|
-
|
|
49775
|
-
/**
|
|
49776
|
-
* Get the value of the cookie that is used for the given opt type (tracking, cookie, etc.)
|
|
49777
|
-
* @param {string} token - Mixpanel project tracking token
|
|
49778
|
-
* @param {Object} [options]
|
|
49779
|
-
* @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
|
|
49780
|
-
* @returns {string} the value of the cookie for the given opt type
|
|
49781
|
-
*/
|
|
49782
|
-
function _getStorageValue(token, options) {
|
|
49783
|
-
return _getStorage(options).get(_getStorageKey(token, options));
|
|
49784
|
-
}
|
|
49785
|
-
|
|
49786
|
-
/**
|
|
49787
|
-
* Check whether the user has set the DNT/doNotTrack setting to true in their browser
|
|
49788
|
-
* @param {Object} [options]
|
|
49789
|
-
* @param {string} [options.window] - alternate window object to check; used to force various DNT settings in browser tests
|
|
49790
|
-
* @param {boolean} [options.ignoreDnt] - flag to ignore browser DNT settings and always return false
|
|
49791
|
-
* @returns {boolean} whether the DNT setting is true
|
|
49792
|
-
*/
|
|
49793
|
-
function _hasDoNotTrackFlagOn(options) {
|
|
49794
|
-
if (options && options.ignoreDnt) {
|
|
49795
|
-
return false;
|
|
49796
|
-
}
|
|
49797
|
-
var win$1 = (options && options.window) || mixpanel_module_win;
|
|
49798
|
-
var nav = win$1['navigator'] || {};
|
|
49799
|
-
var hasDntOn = false;
|
|
49800
|
-
|
|
49801
|
-
mixpanel_module_.each([
|
|
49802
|
-
nav['doNotTrack'], // standard
|
|
49803
|
-
nav['msDoNotTrack'],
|
|
49804
|
-
win$1['doNotTrack']
|
|
49805
|
-
], function(dntValue) {
|
|
49806
|
-
if (mixpanel_module_.includes([true, 1, '1', 'yes'], dntValue)) {
|
|
49807
|
-
hasDntOn = true;
|
|
49808
|
-
}
|
|
49809
|
-
});
|
|
49810
|
-
|
|
49811
|
-
return hasDntOn;
|
|
49812
|
-
}
|
|
49813
|
-
|
|
49814
|
-
/**
|
|
49815
|
-
* Set cookie/localstorage for the user indicating that they are opted in or out for the given opt type
|
|
49816
|
-
* @param {boolean} optValue - whether to opt the user in or out for the given opt type
|
|
49817
|
-
* @param {string} token - Mixpanel project tracking token
|
|
49818
|
-
* @param {Object} [options]
|
|
49819
|
-
* @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
|
|
49820
|
-
* @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
|
|
49821
|
-
* @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
|
|
49822
|
-
* @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
|
|
49823
|
-
* @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
|
|
49824
|
-
* @param {string} [options.cookieDomain] - custom cookie domain
|
|
49825
|
-
* @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
|
|
49826
|
-
* @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
|
|
49827
|
-
* @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
|
|
49828
|
-
*/
|
|
49829
|
-
function _optInOut(optValue, token, options) {
|
|
49830
|
-
if (!mixpanel_module_.isString(token) || !token.length) {
|
|
49831
|
-
console$1.error('gdpr.' + (optValue ? 'optIn' : 'optOut') + ' called with an invalid token');
|
|
49832
|
-
return;
|
|
49833
|
-
}
|
|
49834
|
-
|
|
49835
|
-
options = options || {};
|
|
49836
|
-
|
|
49837
|
-
_getStorage(options).set(
|
|
49838
|
-
_getStorageKey(token, options),
|
|
49839
|
-
optValue ? 1 : 0,
|
|
49840
|
-
mixpanel_module_.isNumber(options.cookieExpiration) ? options.cookieExpiration : null,
|
|
49841
|
-
!!options.crossSubdomainCookie,
|
|
49842
|
-
!!options.secureCookie,
|
|
49843
|
-
!!options.crossSiteCookie,
|
|
49844
|
-
options.cookieDomain
|
|
49845
|
-
);
|
|
49846
|
-
|
|
49847
|
-
if (options.track && optValue) { // only track event if opting in (optValue=true)
|
|
49848
|
-
options.track(options.trackEventName || '$opt_in', options.trackProperties, {
|
|
49849
|
-
'send_immediately': true
|
|
49850
|
-
});
|
|
49851
|
-
}
|
|
49852
|
-
}
|
|
49853
|
-
|
|
49854
|
-
/**
|
|
49855
|
-
* Wrap a method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
|
|
49856
|
-
* If the user has opted out, return early instead of executing the method.
|
|
49857
|
-
* If a callback argument was provided, execute it passing the 0 error code.
|
|
49858
|
-
* @param {function} method - wrapped method to be executed if the user has not opted out
|
|
49859
|
-
* @param {function} getConfigValue - getter function for the Mixpanel API token and other options to be used with opt-out check
|
|
49860
|
-
* @returns {*} the result of executing method OR undefined if the user has opted out
|
|
49861
|
-
*/
|
|
49862
|
-
function _addOptOutCheck(method, getConfigValue) {
|
|
49863
|
-
return function() {
|
|
49864
|
-
var optedOut = false;
|
|
49865
|
-
|
|
49866
|
-
try {
|
|
49867
|
-
var token = getConfigValue.call(this, 'token');
|
|
49868
|
-
var ignoreDnt = getConfigValue.call(this, 'ignore_dnt');
|
|
49869
|
-
var persistenceType = getConfigValue.call(this, 'opt_out_tracking_persistence_type');
|
|
49870
|
-
var persistencePrefix = getConfigValue.call(this, 'opt_out_tracking_cookie_prefix');
|
|
49871
|
-
var win = getConfigValue.call(this, 'window'); // used to override window during browser tests
|
|
49872
|
-
|
|
49873
|
-
if (token) { // if there was an issue getting the token, continue method execution as normal
|
|
49874
|
-
optedOut = hasOptedOut(token, {
|
|
49875
|
-
ignoreDnt: ignoreDnt,
|
|
49876
|
-
persistenceType: persistenceType,
|
|
49877
|
-
persistencePrefix: persistencePrefix,
|
|
49878
|
-
window: win
|
|
49879
|
-
});
|
|
49880
|
-
}
|
|
49881
|
-
} catch(err) {
|
|
49882
|
-
console$1.error('Unexpected error when checking tracking opt-out status: ' + err);
|
|
49883
|
-
}
|
|
49884
|
-
|
|
49885
|
-
if (!optedOut) {
|
|
49886
|
-
return method.apply(this, arguments);
|
|
49887
|
-
}
|
|
49888
|
-
|
|
49889
|
-
var callback = arguments[arguments.length - 1];
|
|
49890
|
-
if (typeof(callback) === 'function') {
|
|
49891
|
-
callback(0);
|
|
49892
|
-
}
|
|
49893
|
-
|
|
49894
|
-
return;
|
|
49895
|
-
};
|
|
49896
|
-
}
|
|
49897
|
-
|
|
49898
49654
|
var logger$9 = console_with_prefix('lock');
|
|
49899
49655
|
|
|
49900
49656
|
/**
|
|
@@ -50127,6 +49883,7 @@ var RequestQueue = function (storageKey, options) {
|
|
|
50127
49883
|
});
|
|
50128
49884
|
}
|
|
50129
49885
|
this.reportError = options.errorReporter || mixpanel_module_.bind(logger$8.error, logger$8);
|
|
49886
|
+
this.consentGate = options.consentGate;
|
|
50130
49887
|
|
|
50131
49888
|
this.pid = options.pid || null; // pass pid to test out storage lock contention scenarios
|
|
50132
49889
|
|
|
@@ -50178,7 +49935,7 @@ RequestQueue.prototype.enqueue = function (item, flushInterval) {
|
|
|
50178
49935
|
'payload': item
|
|
50179
49936
|
};
|
|
50180
49937
|
|
|
50181
|
-
if (!this.
|
|
49938
|
+
if (!this._persists()) {
|
|
50182
49939
|
this.memQueue.push(queueEntry);
|
|
50183
49940
|
return PromisePolyfill.resolve(true);
|
|
50184
49941
|
} else {
|
|
@@ -50186,7 +49943,20 @@ RequestQueue.prototype.enqueue = function (item, flushInterval) {
|
|
|
50186
49943
|
}
|
|
50187
49944
|
};
|
|
50188
49945
|
|
|
49946
|
+
/**
|
|
49947
|
+
* Whether the queue is kept in storage now: with persistence, and while consent allows storing.
|
|
49948
|
+
* The lock writes storage keys too, so nothing that takes it runs without this.
|
|
49949
|
+
* @returns {boolean}
|
|
49950
|
+
*/
|
|
49951
|
+
RequestQueue.prototype._persists = function () {
|
|
49952
|
+
return this.usePersistence && this.consentGate.allowsStoring();
|
|
49953
|
+
};
|
|
49954
|
+
|
|
50189
49955
|
RequestQueue.prototype._enqueuePersisted = function (queueEntries) {
|
|
49956
|
+
// a throttled enqueue can run after consent stops storage; its items are dropped
|
|
49957
|
+
if (!this._persists()) {
|
|
49958
|
+
return PromisePolyfill.resolve(false);
|
|
49959
|
+
}
|
|
50190
49960
|
var enqueueItem = mixpanel_module_.bind(function () {
|
|
50191
49961
|
return this.ensureInit()
|
|
50192
49962
|
.then(mixpanel_module_.bind(function () {
|
|
@@ -50286,7 +50056,7 @@ RequestQueue.prototype.removeItemsByID = function (ids) {
|
|
|
50286
50056
|
});
|
|
50287
50057
|
|
|
50288
50058
|
this.memQueue = filterOutIDsAndInvalid(this.memQueue, idSet);
|
|
50289
|
-
if (!this.
|
|
50059
|
+
if (!this._persists()) {
|
|
50290
50060
|
return PromisePolyfill.resolve(true);
|
|
50291
50061
|
} else {
|
|
50292
50062
|
var removeFromStorage = mixpanel_module_.bind(function () {
|
|
@@ -50374,7 +50144,7 @@ var updatePayloads = function (existingItems, itemsToUpdate) {
|
|
|
50374
50144
|
*/
|
|
50375
50145
|
RequestQueue.prototype.updatePayloads = function (itemsToUpdate) {
|
|
50376
50146
|
this.memQueue = updatePayloads(this.memQueue, itemsToUpdate);
|
|
50377
|
-
if (!this.
|
|
50147
|
+
if (!this._persists()) {
|
|
50378
50148
|
return PromisePolyfill.resolve(true);
|
|
50379
50149
|
} else {
|
|
50380
50150
|
return this.lock
|
|
@@ -50429,11 +50199,14 @@ RequestQueue.prototype.readFromStorage = function () {
|
|
|
50429
50199
|
RequestQueue.prototype.saveToStorage = function (queue) {
|
|
50430
50200
|
return this.ensureInit()
|
|
50431
50201
|
.then(mixpanel_module_.bind(function () {
|
|
50432
|
-
|
|
50202
|
+
// a save that started before consent stopped storage writes nothing
|
|
50203
|
+
if (!this._persists()) {
|
|
50204
|
+
return false;
|
|
50205
|
+
}
|
|
50206
|
+
return this.queueStorage.setItem(this.storageKey, queue).then(function () {
|
|
50207
|
+
return true;
|
|
50208
|
+
});
|
|
50433
50209
|
}, this))
|
|
50434
|
-
.then(function () {
|
|
50435
|
-
return true;
|
|
50436
|
-
})
|
|
50437
50210
|
.catch(mixpanel_module_.bind(function (err) {
|
|
50438
50211
|
this.reportError('Error saving queue', err);
|
|
50439
50212
|
return false;
|
|
@@ -50450,6 +50223,9 @@ RequestQueue.prototype.clear = function () {
|
|
|
50450
50223
|
return this.ensureInit()
|
|
50451
50224
|
.then(mixpanel_module_.bind(function () {
|
|
50452
50225
|
return this.queueStorage.removeItem(this.storageKey);
|
|
50226
|
+
}, this))
|
|
50227
|
+
.catch(mixpanel_module_.bind(function (err) {
|
|
50228
|
+
this.reportError('Error clearing queue', err);
|
|
50453
50229
|
}, this));
|
|
50454
50230
|
} else {
|
|
50455
50231
|
return PromisePolyfill.resolve();
|
|
@@ -50475,7 +50251,8 @@ var RequestBatcher = function(storageKey, options) {
|
|
|
50475
50251
|
sharedLockStorage: options.sharedLockStorage,
|
|
50476
50252
|
sharedLockTimeoutMS: options.sharedLockTimeoutMS,
|
|
50477
50253
|
usePersistence: options.usePersistence,
|
|
50478
|
-
enqueueThrottleMs: options.enqueueThrottleMs
|
|
50254
|
+
enqueueThrottleMs: options.enqueueThrottleMs,
|
|
50255
|
+
consentGate: options.consentGate
|
|
50479
50256
|
});
|
|
50480
50257
|
|
|
50481
50258
|
this.libConfig = options.libConfig;
|
|
@@ -52507,6 +52284,8 @@ function isUserEvent(ev) {
|
|
|
52507
52284
|
/**
|
|
52508
52285
|
* @typedef {Object} SessionRecordingOptions
|
|
52509
52286
|
* @property {Object} [options.mixpanelInstance] - reference to the core MixpanelLib
|
|
52287
|
+
* @property {import('../consent-gate').ConsentGate} options.consentGate - what the recording asks
|
|
52288
|
+
* before it stores or sends
|
|
52510
52289
|
* @property {String} [options.replayId] - unique uuid for a single replay
|
|
52511
52290
|
* @property {Function} [options.onIdleTimeout] - callback when a recording reaches idle timeout
|
|
52512
52291
|
* @property {Function} [options.onMaxLengthReached] - callback when a recording reaches its maximum length
|
|
@@ -52537,6 +52316,7 @@ function isUserEvent(ev) {
|
|
|
52537
52316
|
*/
|
|
52538
52317
|
var SessionRecording = function(options) {
|
|
52539
52318
|
this._mixpanel = options.mixpanelInstance;
|
|
52319
|
+
this.consentGate = options.consentGate;
|
|
52540
52320
|
this._onIdleTimeout = options.onIdleTimeout || NOOP_FUNC;
|
|
52541
52321
|
this._onMaxLengthReached = options.onMaxLengthReached || NOOP_FUNC;
|
|
52542
52322
|
this._onBatchSent = options.onBatchSent || NOOP_FUNC;
|
|
@@ -52563,7 +52343,7 @@ var SessionRecording = function(options) {
|
|
|
52563
52343
|
|
|
52564
52344
|
// disable persistence if localStorage is not supported
|
|
52565
52345
|
// request-queue will automatically disable persistence if indexedDB fails to initialize
|
|
52566
|
-
var usePersistence = localStorageSupported(options.sharedLockStorage || getLocalStorage(), true) &&
|
|
52346
|
+
var usePersistence = localStorageSupported(options.sharedLockStorage || getLocalStorage(), true) && this.consentGate.allowsPersistence();
|
|
52567
52347
|
|
|
52568
52348
|
// each replay has its own batcher key to avoid conflicts between rrweb events of different recordings
|
|
52569
52349
|
this.batcherKey = '__mprec_' + this.getConfig('name') + '_' + this.getConfig('token') + '_' + this.replayId;
|
|
@@ -52577,6 +52357,7 @@ var SessionRecording = function(options) {
|
|
|
52577
52357
|
sharedLockStorage: options.sharedLockStorage,
|
|
52578
52358
|
usePersistence: usePersistence,
|
|
52579
52359
|
stopAllBatchingFunc: this.stopRecording.bind(this),
|
|
52360
|
+
consentGate: this.consentGate,
|
|
52580
52361
|
|
|
52581
52362
|
// increased throttle and shared lock timeout because recording events are very high frequency.
|
|
52582
52363
|
// this will minimize the amount of lock contention between enqueued events.
|
|
@@ -52632,13 +52413,6 @@ SessionRecording.prototype.getConfig = function(configVar) {
|
|
|
52632
52413
|
return this._mixpanel.get_config(configVar);
|
|
52633
52414
|
};
|
|
52634
52415
|
|
|
52635
|
-
// Alias for getConfig, used by the common addOptOutCheckMixpanelLib function which
|
|
52636
|
-
// reaches into this class instance and expects the snake case version of the function.
|
|
52637
|
-
// eslint-disable-next-line camelcase
|
|
52638
|
-
SessionRecording.prototype.get_config = function(configVar) {
|
|
52639
|
-
return this.getConfig(configVar);
|
|
52640
|
-
};
|
|
52641
|
-
|
|
52642
52416
|
SessionRecording.prototype.startRecording = function (shouldStopBatcher) {
|
|
52643
52417
|
if (this._rrwebRecord === null) {
|
|
52644
52418
|
this.reportError('rrweb record function not provided. ');
|
|
@@ -52813,19 +52587,15 @@ SessionRecording.prototype.isRrwebStopped = function () {
|
|
|
52813
52587
|
|
|
52814
52588
|
|
|
52815
52589
|
/**
|
|
52816
|
-
* Flushes the current batch of events to the server,
|
|
52817
|
-
* we stop recording and dump any queued events if the user has opted out.
|
|
52590
|
+
* Flushes the current batch of events to the server, or stops recording if consent stops the calls.
|
|
52818
52591
|
*/
|
|
52819
52592
|
SessionRecording.prototype.flushEventsWithOptOut = function (data, options, cb) {
|
|
52820
|
-
|
|
52821
|
-
|
|
52822
|
-
|
|
52823
|
-
|
|
52824
|
-
|
|
52825
|
-
|
|
52826
|
-
}.bind(this);
|
|
52827
|
-
|
|
52828
|
-
this._flushEvents(data, options, cb, onOptOut);
|
|
52593
|
+
if (!this.consentGate.allowsApiCalls()) {
|
|
52594
|
+
this.stopRecording();
|
|
52595
|
+
cb({error: 'Tracking has been opted out, stopping recording.'});
|
|
52596
|
+
return;
|
|
52597
|
+
}
|
|
52598
|
+
this._flushEvents(data, options, cb);
|
|
52829
52599
|
};
|
|
52830
52600
|
|
|
52831
52601
|
/**
|
|
@@ -52881,7 +52651,12 @@ SessionRecording.prototype._getApiRoute = function () {
|
|
|
52881
52651
|
return this.getConfig('api_routes')['record'];
|
|
52882
52652
|
};
|
|
52883
52653
|
|
|
52654
|
+
// consent can be withdrawn while the batch is compressed, so it is checked again before sending
|
|
52884
52655
|
SessionRecording.prototype._sendRequest = function(currentReplayId, reqParams, reqBody, callback) {
|
|
52656
|
+
if (!this.consentGate.allowsApiCalls()) {
|
|
52657
|
+
callback(0);
|
|
52658
|
+
return;
|
|
52659
|
+
}
|
|
52885
52660
|
var onSuccess = function (response, responseBody) {
|
|
52886
52661
|
// Update batch specific props only if the request was successful to guarantee ordering.
|
|
52887
52662
|
// RequestBatcher will always flush the next batch after the previous one succeeds.
|
|
@@ -52918,7 +52693,7 @@ SessionRecording.prototype._sendRequest = function(currentReplayId, reqParams, r
|
|
|
52918
52693
|
});
|
|
52919
52694
|
};
|
|
52920
52695
|
|
|
52921
|
-
SessionRecording.prototype._flushEvents =
|
|
52696
|
+
SessionRecording.prototype._flushEvents = function(data, options, callback) {
|
|
52922
52697
|
var numEvents = data.length;
|
|
52923
52698
|
|
|
52924
52699
|
if (numEvents > 0) {
|
|
@@ -52964,6 +52739,11 @@ SessionRecording.prototype._flushEvents = addOptOutCheckMixpanelLib(function (da
|
|
|
52964
52739
|
var eventsJson = JSON.stringify(data);
|
|
52965
52740
|
Object.assign(reqParams, this.getUserIdInfo());
|
|
52966
52741
|
|
|
52742
|
+
var sendUncompressed = function() {
|
|
52743
|
+
reqParams['format'] = 'body';
|
|
52744
|
+
this._sendRequest(replayId, reqParams, eventsJson, callback);
|
|
52745
|
+
}.bind(this);
|
|
52746
|
+
|
|
52967
52747
|
if (canUseCompressionStream(mixpanel_module_userAgent, mixpanel_module_navigator.vendor, windowOpera)) {
|
|
52968
52748
|
var jsonStream = new Blob([eventsJson], {type: 'application/json'}).stream();
|
|
52969
52749
|
var gzipStream = jsonStream.pipeThrough(new CompressionStream('gzip'));
|
|
@@ -52972,13 +52752,15 @@ SessionRecording.prototype._flushEvents = addOptOutCheckMixpanelLib(function (da
|
|
|
52972
52752
|
.then(function(compressedBlob) {
|
|
52973
52753
|
reqParams['format'] = 'gzip';
|
|
52974
52754
|
this._sendRequest(replayId, reqParams, compressedBlob, callback);
|
|
52755
|
+
}.bind(this), function(err) {
|
|
52756
|
+
this.reportError('Error compressing session recording batch; sending uncompressed', err);
|
|
52757
|
+
sendUncompressed();
|
|
52975
52758
|
}.bind(this));
|
|
52976
52759
|
} else {
|
|
52977
|
-
|
|
52978
|
-
this._sendRequest(replayId, reqParams, eventsJson, callback);
|
|
52760
|
+
sendUncompressed();
|
|
52979
52761
|
}
|
|
52980
52762
|
}
|
|
52981
|
-
}
|
|
52763
|
+
};
|
|
52982
52764
|
|
|
52983
52765
|
|
|
52984
52766
|
SessionRecording.prototype.reportError = function(msg, err) {
|
|
@@ -53033,9 +52815,10 @@ SessionRecording.prototype._getRecordMinMs = function() {
|
|
|
53033
52815
|
*/
|
|
53034
52816
|
SessionRecording.prototype._getMaskFn = function(shouldMaskFn, privacyConfig) {
|
|
53035
52817
|
return function(text, element) {
|
|
53036
|
-
//
|
|
52818
|
+
// whitespace-only text has nothing to mask, and dropping it would join adjacent words
|
|
52819
|
+
// (e.g. a space text node between two inline elements)
|
|
53037
52820
|
if (!text.trim().length) {
|
|
53038
|
-
return
|
|
52821
|
+
return text;
|
|
53039
52822
|
}
|
|
53040
52823
|
|
|
53041
52824
|
var shouldMask = true;
|
|
@@ -53063,11 +52846,12 @@ var RecordingRegistry = function (options) {
|
|
|
53063
52846
|
this.idb = new IDBStorageWrapper(MIXPANEL_BROWSER_DB_NAME, RECORDING_REGISTRY_STORE_NAME, RECORDER_VERSION_DATA);
|
|
53064
52847
|
this.errorReporter = options.errorReporter;
|
|
53065
52848
|
this.mixpanelInstance = options.mixpanelInstance;
|
|
52849
|
+
this.consentGate = options.consentGate;
|
|
53066
52850
|
this.sharedLockStorage = options.sharedLockStorage;
|
|
53067
52851
|
};
|
|
53068
52852
|
|
|
53069
52853
|
RecordingRegistry.prototype.isPersistenceEnabled = function() {
|
|
53070
|
-
return
|
|
52854
|
+
return this.consentGate.allowsPersistence();
|
|
53071
52855
|
};
|
|
53072
52856
|
|
|
53073
52857
|
RecordingRegistry.prototype.handleError = function (err) {
|
|
@@ -53078,6 +52862,7 @@ RecordingRegistry.prototype.handleError = function (err) {
|
|
|
53078
52862
|
* @param {import('./session-recording').SerializedRecording} serializedRecording
|
|
53079
52863
|
*/
|
|
53080
52864
|
RecordingRegistry.prototype.setActiveRecording = function (serializedRecording) {
|
|
52865
|
+
// a recording that resumes after consent stops storage writes nothing
|
|
53081
52866
|
if (!this.isPersistenceEnabled()) {
|
|
53082
52867
|
return PromisePolyfill.resolve();
|
|
53083
52868
|
}
|
|
@@ -53114,13 +52899,10 @@ RecordingRegistry.prototype.getActiveRecording = function () {
|
|
|
53114
52899
|
};
|
|
53115
52900
|
|
|
53116
52901
|
RecordingRegistry.prototype.clearActiveRecording = function () {
|
|
53117
|
-
|
|
53118
|
-
|
|
53119
|
-
|
|
53120
|
-
|
|
53121
|
-
} else {
|
|
53122
|
-
return this.deleteActiveRecording();
|
|
53123
|
-
}
|
|
52902
|
+
// mark recording as expired instead of deleting it in case the page unloads mid-flush and doesn't make it to ingestion.
|
|
52903
|
+
// this will ensure the next pageload will flush the remaining events, but not try to continue the recording.
|
|
52904
|
+
// without persistence the entry is left as it is, and its unsent events wait for a load that allows them.
|
|
52905
|
+
return this.markActiveRecordingExpired();
|
|
53124
52906
|
};
|
|
53125
52907
|
|
|
53126
52908
|
RecordingRegistry.prototype.markActiveRecordingExpired = function () {
|
|
@@ -53134,16 +52916,6 @@ RecordingRegistry.prototype.markActiveRecordingExpired = function () {
|
|
|
53134
52916
|
.catch(this.handleError.bind(this));
|
|
53135
52917
|
};
|
|
53136
52918
|
|
|
53137
|
-
RecordingRegistry.prototype.deleteActiveRecording = function () {
|
|
53138
|
-
// avoid initializing IDB if this registry instance hasn't already written a recording
|
|
53139
|
-
if (this.idb.isInitialized()) {
|
|
53140
|
-
return this.idb.removeItem(this.mixpanelInstance.get_tab_id())
|
|
53141
|
-
.catch(this.handleError.bind(this));
|
|
53142
|
-
} else {
|
|
53143
|
-
return PromisePolyfill.resolve();
|
|
53144
|
-
}
|
|
53145
|
-
};
|
|
53146
|
-
|
|
53147
52919
|
/**
|
|
53148
52920
|
* Flush any inactive recordings from the registry to minimize data loss.
|
|
53149
52921
|
* The main idea here is that we can flush remaining rrweb events on the next page load if a tab is closed mid-batch.
|
|
@@ -53166,6 +52938,7 @@ RecordingRegistry.prototype.flushInactiveRecordings = function () {
|
|
|
53166
52938
|
.map(function (serializedRecording) {
|
|
53167
52939
|
var sessionRecording = SessionRecording.deserialize(serializedRecording, {
|
|
53168
52940
|
mixpanelInstance: this.mixpanelInstance,
|
|
52941
|
+
consentGate: this.consentGate,
|
|
53169
52942
|
sharedLockStorage: this.sharedLockStorage
|
|
53170
52943
|
});
|
|
53171
52944
|
return sessionRecording.unloadPersistedData()
|
|
@@ -53181,6 +52954,79 @@ RecordingRegistry.prototype.flushInactiveRecordings = function () {
|
|
|
53181
52954
|
.catch(this.handleError.bind(this));
|
|
53182
52955
|
};
|
|
53183
52956
|
|
|
52957
|
+
/**
|
|
52958
|
+
* What the services ask before they store or send on their own. A ConsentManager is one; a new
|
|
52959
|
+
* storage write or network send must ask it too.
|
|
52960
|
+
* @typedef {Object} ConsentGate
|
|
52961
|
+
* @property {function(): boolean} allowsApiCalls whether the public tracking, people, group and
|
|
52962
|
+
* replay methods run
|
|
52963
|
+
* @property {function(): boolean} allowsSending whether tracking requests go out
|
|
52964
|
+
* @property {function(): boolean} allowsFetching whether feature flags and remote settings are
|
|
52965
|
+
* fetched
|
|
52966
|
+
* @property {function(): boolean} allowsStoring whether consent allows storing data about the
|
|
52967
|
+
* visitor; identify() and alias() ask this, since disable_persistence doesn't stop them
|
|
52968
|
+
* @property {function(): boolean} allowsPersistence whether the services may write to browser
|
|
52969
|
+
* storage: consent allows storing, and disable_persistence is off. Without it they keep their data
|
|
52970
|
+
* in memory.
|
|
52971
|
+
*/
|
|
52972
|
+
|
|
52973
|
+
|
|
52974
|
+
/**
|
|
52975
|
+
* @param {function(string): boolean} allowsFunc whether consent allows 'api_calls', 'send',
|
|
52976
|
+
* 'fetch' or 'store' now
|
|
52977
|
+
* @param {function(string): *} getConfigFunc
|
|
52978
|
+
* @returns {ConsentGate}
|
|
52979
|
+
*/
|
|
52980
|
+
function buildConsentGate(allowsFunc, getConfigFunc) {
|
|
52981
|
+
var gate = {
|
|
52982
|
+
// if asking throws, the call runs
|
|
52983
|
+
allowsApiCalls: function() {
|
|
52984
|
+
try {
|
|
52985
|
+
return allowsFunc('api_calls');
|
|
52986
|
+
} catch (err) {
|
|
52987
|
+
console$1.error('Unexpected error when checking tracking opt-out status: ' + err);
|
|
52988
|
+
return true;
|
|
52989
|
+
}
|
|
52990
|
+
},
|
|
52991
|
+
allowsSending: function() {
|
|
52992
|
+
return allowsFunc('send');
|
|
52993
|
+
},
|
|
52994
|
+
allowsFetching: function() {
|
|
52995
|
+
return allowsFunc('fetch');
|
|
52996
|
+
},
|
|
52997
|
+
allowsStoring: function() {
|
|
52998
|
+
return allowsFunc('store');
|
|
52999
|
+
},
|
|
53000
|
+
allowsPersistence: function() {
|
|
53001
|
+
return gate.allowsStoring() && !getConfigFunc('disable_persistence');
|
|
53002
|
+
}
|
|
53003
|
+
};
|
|
53004
|
+
return gate;
|
|
53005
|
+
}
|
|
53006
|
+
|
|
53007
|
+
/**
|
|
53008
|
+
* The consent gate the recorder bundle builds when it starts, and hands to its services. The core
|
|
53009
|
+
* passes the bundle only its instance, so this asks the core's _consent_allows by its quoted name,
|
|
53010
|
+
* the bundle being built separately. A core without it only knows the opt-out, through
|
|
53011
|
+
* has_opted_out_tracking().
|
|
53012
|
+
* @param {Object} mixpanelInstance
|
|
53013
|
+
* @returns {ConsentGate}
|
|
53014
|
+
*/
|
|
53015
|
+
function consentGateFor(mixpanelInstance) {
|
|
53016
|
+
return buildConsentGate(
|
|
53017
|
+
function(capability) {
|
|
53018
|
+
var consentAllows = mixpanelInstance['_consent_allows'];
|
|
53019
|
+
if (typeof consentAllows === 'function') {
|
|
53020
|
+
return !!consentAllows.call(mixpanelInstance, capability);
|
|
53021
|
+
}
|
|
53022
|
+
return capability !== 'api_calls' || !mixpanelInstance.has_opted_out_tracking();
|
|
53023
|
+
},
|
|
53024
|
+
function(key) {
|
|
53025
|
+
return mixpanelInstance.get_config(key);
|
|
53026
|
+
}
|
|
53027
|
+
);
|
|
53028
|
+
}
|
|
53029
|
+
|
|
53184
53030
|
var logger$3 = console_with_prefix('recorder');
|
|
53185
53031
|
|
|
53186
53032
|
/**
|
|
@@ -53191,12 +53037,14 @@ var MixpanelRecorder = function(mixpanelInstance, rrwebRecord, sharedLockStorage
|
|
|
53191
53037
|
this.mixpanelInstance = mixpanelInstance;
|
|
53192
53038
|
this.rrwebRecord = rrwebRecord || record;
|
|
53193
53039
|
this.sharedLockStorage = sharedLockStorage;
|
|
53040
|
+
this.consentGate = consentGateFor(mixpanelInstance);
|
|
53194
53041
|
|
|
53195
53042
|
/**
|
|
53196
53043
|
* @member {import('./registry').RecordingRegistry}
|
|
53197
53044
|
*/
|
|
53198
53045
|
this.recordingRegistry = new RecordingRegistry({
|
|
53199
53046
|
mixpanelInstance: this.mixpanelInstance,
|
|
53047
|
+
consentGate: this.consentGate,
|
|
53200
53048
|
errorReporter: logger$3.error,
|
|
53201
53049
|
sharedLockStorage: sharedLockStorage
|
|
53202
53050
|
});
|
|
@@ -53233,6 +53081,7 @@ MixpanelRecorder.prototype.startRecording = function(options) {
|
|
|
53233
53081
|
*/
|
|
53234
53082
|
var sessionRecordingOptions = {
|
|
53235
53083
|
mixpanelInstance: this.mixpanelInstance,
|
|
53084
|
+
consentGate: this.consentGate,
|
|
53236
53085
|
onBatchSent: onBatchSent,
|
|
53237
53086
|
onIdleTimeout: onIdleTimeout,
|
|
53238
53087
|
onMaxLengthReached: onMaxLengthReached,
|
|
@@ -55254,16 +55103,23 @@ FeatureFlagPersistence.prototype.save = function(context, flagsMap, pendingFirst
|
|
|
55254
55103
|
});
|
|
55255
55104
|
};
|
|
55256
55105
|
|
|
55106
|
+
/**
|
|
55107
|
+
* Remove the persisted variants, without creating the database.
|
|
55108
|
+
* @returns {Promise}
|
|
55109
|
+
*/
|
|
55257
55110
|
FeatureFlagPersistence.prototype.clear = function() {
|
|
55258
55111
|
if (this.isGloballyDisabled()) {
|
|
55259
55112
|
return Promise.resolve();
|
|
55260
55113
|
}
|
|
55261
|
-
|
|
55262
|
-
|
|
55263
|
-
|
|
55114
|
+
var variantsKey = this.persistedVariantsKey;
|
|
55115
|
+
var existingIdb = new IDBStorageWrapper(MIXPANEL_FLAGS_DB_NAME, FLAGS_STORE_NAME, FLAGS_VERSION_DATA, {createIfMissing: false});
|
|
55116
|
+
return existingIdb.init().then(function() {
|
|
55117
|
+
return existingIdb.removeItem(variantsKey);
|
|
55118
|
+
}).then(function() {
|
|
55264
55119
|
logger$2.log('Cleared persisted variants from IndexedDB');
|
|
55265
55120
|
}).catch(function(error) {
|
|
55266
|
-
|
|
55121
|
+
// usually the device has no database, so there's nothing to clear
|
|
55122
|
+
logger$2.log('No persisted variants cleared from IndexedDB:', error);
|
|
55267
55123
|
});
|
|
55268
55124
|
};
|
|
55269
55125
|
|
|
@@ -55326,11 +55182,15 @@ var FeatureFlagManager = function(initOptions) {
|
|
|
55326
55182
|
this.setMpConfig = initOptions.setConfigFunc;
|
|
55327
55183
|
this.getMpProperty = initOptions.getPropertyFunc;
|
|
55328
55184
|
this.track = initOptions.trackingFunc;
|
|
55185
|
+
this.consentGate = initOptions.consentGate;
|
|
55329
55186
|
this.loadExtraBundle = initOptions.loadExtraBundle || function() {};
|
|
55330
55187
|
this.targetingSrc = initOptions.targetingSrc || '';
|
|
55331
55188
|
};
|
|
55332
55189
|
|
|
55333
55190
|
FeatureFlagManager.prototype.init = function() {
|
|
55191
|
+
if (!this.consentGate.allowsFetching()) {
|
|
55192
|
+
return;
|
|
55193
|
+
}
|
|
55334
55194
|
if (!this.minApisSupported()) {
|
|
55335
55195
|
logger$1.critical('Feature Flags unavailable: missing minimum required APIs');
|
|
55336
55196
|
return;
|
|
@@ -55346,7 +55206,7 @@ FeatureFlagManager.prototype.init = function() {
|
|
|
55346
55206
|
this.persistence = new FeatureFlagPersistence(
|
|
55347
55207
|
this.getConfig(CONFIG_PERSISTENCE),
|
|
55348
55208
|
this.getMpConfig('token'),
|
|
55349
|
-
mixpanel_module_.bind(function() { return this.
|
|
55209
|
+
mixpanel_module_.bind(function() { return !this.consentGate.allowsPersistence(); }, this)
|
|
55350
55210
|
);
|
|
55351
55211
|
|
|
55352
55212
|
this.persistenceLoadedPromise = this.persistence.loadFlagsFromStorage(this._buildContext())
|
|
@@ -55414,7 +55274,7 @@ FeatureFlagManager.prototype.getConfig = function(key) {
|
|
|
55414
55274
|
};
|
|
55415
55275
|
|
|
55416
55276
|
FeatureFlagManager.prototype.isSystemEnabled = function() {
|
|
55417
|
-
return !!this.getMpConfig(FLAGS_CONFIG_KEY);
|
|
55277
|
+
return !!this.getMpConfig(FLAGS_CONFIG_KEY) && this.consentGate.allowsFetching();
|
|
55418
55278
|
};
|
|
55419
55279
|
|
|
55420
55280
|
FeatureFlagManager.prototype.updateContext = function(newContext, options) {
|
|
@@ -55445,6 +55305,14 @@ FeatureFlagManager.prototype.areFlagsReady = function() {
|
|
|
55445
55305
|
return !!this.flags;
|
|
55446
55306
|
};
|
|
55447
55307
|
|
|
55308
|
+
/**
|
|
55309
|
+
* Delete this token's persisted variants, also before init() and when persistence isn't allowed.
|
|
55310
|
+
* @returns {Promise}
|
|
55311
|
+
*/
|
|
55312
|
+
FeatureFlagManager.prototype.clearPersistedVariants = function() {
|
|
55313
|
+
return new FeatureFlagPersistence(null, this.getMpConfig('token')).clear();
|
|
55314
|
+
};
|
|
55315
|
+
|
|
55448
55316
|
FeatureFlagManager.prototype.fetchFlags = function() {
|
|
55449
55317
|
if (!this.isSystemEnabled()) {
|
|
55450
55318
|
return Promise.resolve();
|
|
@@ -55740,6 +55608,9 @@ FeatureFlagManager.prototype.getFirstTimeEventApiRoute = function(flagId) {
|
|
|
55740
55608
|
};
|
|
55741
55609
|
|
|
55742
55610
|
FeatureFlagManager.prototype.recordFirstTimeEvent = function(flagId, projectId, firstTimeEventHash) {
|
|
55611
|
+
if (!this.consentGate.allowsFetching()) {
|
|
55612
|
+
return Promise.resolve();
|
|
55613
|
+
}
|
|
55743
55614
|
var distinctId = this.getMpProperty('distinct_id');
|
|
55744
55615
|
var traceparent = generateTraceparent();
|
|
55745
55616
|
|
|
@@ -56020,6 +55891,8 @@ var RecorderManager = function(initOptions) {
|
|
|
56020
55891
|
this.getTabId = initOptions.getTabIdFunc;
|
|
56021
55892
|
this.reportError = initOptions.reportErrorFunc;
|
|
56022
55893
|
this.getDistinctId = initOptions.getDistinctIdFunc;
|
|
55894
|
+
// recording stores the session before it sends it
|
|
55895
|
+
this.consentGate = initOptions.consentGate;
|
|
56023
55896
|
this.loadExtraBundle = initOptions.loadExtraBundle;
|
|
56024
55897
|
this.recorderSrc = initOptions.recorderSrc;
|
|
56025
55898
|
this.targetingSrc = initOptions.targetingSrc;
|
|
@@ -56031,8 +55904,8 @@ var RecorderManager = function(initOptions) {
|
|
|
56031
55904
|
};
|
|
56032
55905
|
|
|
56033
55906
|
RecorderManager.prototype.shouldLoadRecorder = function() {
|
|
56034
|
-
if (this.
|
|
56035
|
-
console$1.log('Load recorder check skipped
|
|
55907
|
+
if (!this.consentGate.allowsPersistence()) {
|
|
55908
|
+
console$1.log('Load recorder check skipped without persistence');
|
|
56036
55909
|
return PromisePolyfill.resolve(false);
|
|
56037
55910
|
}
|
|
56038
55911
|
|
|
@@ -56059,6 +55932,10 @@ RecorderManager.prototype.shouldLoadRecorder = function() {
|
|
|
56059
55932
|
};
|
|
56060
55933
|
|
|
56061
55934
|
RecorderManager.prototype.checkAndStartSessionRecording = function(force_start, rate) {
|
|
55935
|
+
if (!this.consentGate.allowsStoring()) {
|
|
55936
|
+
console$1.log('Session recording skipped without consent');
|
|
55937
|
+
return PromisePolyfill.resolve();
|
|
55938
|
+
}
|
|
56062
55939
|
if (!mixpanel_module_win['MutationObserver']) {
|
|
56063
55940
|
console$1.critical('Browser does not support MutationObserver; skipping session recording');
|
|
56064
55941
|
return PromisePolyfill.resolve();
|
|
@@ -56067,6 +55944,11 @@ RecorderManager.prototype.checkAndStartSessionRecording = function(force_start,
|
|
|
56067
55944
|
var loadRecorder = mixpanel_module_.bind(function(startNewIfInactive) {
|
|
56068
55945
|
return new PromisePolyfill(mixpanel_module_.bind(function(resolve) {
|
|
56069
55946
|
var handleLoadedRecorder = safewrap(mixpanel_module_.bind(function() {
|
|
55947
|
+
// consent can be withdrawn while the bundle loads
|
|
55948
|
+
if (!this.consentGate.allowsStoring()) {
|
|
55949
|
+
resolve();
|
|
55950
|
+
return;
|
|
55951
|
+
}
|
|
56070
55952
|
this._recorder = this._recorder || new mixpanel_module_win[RECORDER_GLOBAL_NAME](this.mixpanelInstance);
|
|
56071
55953
|
this._recorder['resumeRecording'](startNewIfInactive);
|
|
56072
55954
|
resolve();
|
|
@@ -56590,137 +56472,186 @@ var apiActions = {
|
|
|
56590
56472
|
|
|
56591
56473
|
/**
|
|
56592
56474
|
* Mixpanel Group Object
|
|
56593
|
-
* @
|
|
56475
|
+
* @class
|
|
56594
56476
|
*/
|
|
56595
|
-
|
|
56477
|
+
function MixpanelGroup() {}
|
|
56596
56478
|
|
|
56597
56479
|
mixpanel_module_.extend(MixpanelGroup.prototype, apiActions);
|
|
56598
56480
|
|
|
56599
|
-
|
|
56481
|
+
/**
|
|
56482
|
+
* @param {Object} mixpanel_instance
|
|
56483
|
+
* @param {string} group_key
|
|
56484
|
+
* @param {*} group_id
|
|
56485
|
+
* @param {import('./consent-gate').ConsentGate} consentGate
|
|
56486
|
+
*/
|
|
56487
|
+
MixpanelGroup.prototype._init = function(mixpanel_instance, group_key, group_id, consentGate) {
|
|
56600
56488
|
this._mixpanel = mixpanel_instance;
|
|
56601
56489
|
this._group_key = group_key;
|
|
56602
56490
|
this._group_id = group_id;
|
|
56491
|
+
this.consentGate = consentGate;
|
|
56603
56492
|
};
|
|
56604
56493
|
|
|
56605
56494
|
/**
|
|
56606
56495
|
* Set properties on a group.
|
|
56607
56496
|
*
|
|
56608
|
-
*
|
|
56609
|
-
*
|
|
56610
|
-
*
|
|
56497
|
+
* @example
|
|
56498
|
+
* ```js
|
|
56499
|
+
* mixpanel.get_group('company', 'mixpanel').set('Location', '405 Howard');
|
|
56611
56500
|
*
|
|
56612
|
-
*
|
|
56613
|
-
*
|
|
56614
|
-
*
|
|
56615
|
-
*
|
|
56616
|
-
*
|
|
56617
|
-
*
|
|
56501
|
+
* // or set multiple properties at once
|
|
56502
|
+
* mixpanel.get_group('company', 'mixpanel').set({
|
|
56503
|
+
* 'Location': '405 Howard',
|
|
56504
|
+
* 'Founded' : 2009,
|
|
56505
|
+
* });
|
|
56506
|
+
* // properties can be strings, integers, dates, or lists
|
|
56507
|
+
* ```
|
|
56618
56508
|
*
|
|
56619
56509
|
* @param {Object|String} prop If a string, this is the name of the property. If an object, this is an associative array of names and values.
|
|
56620
56510
|
* @param {*} [to] A value to set on the given property name
|
|
56621
56511
|
* @param {Function} [callback] If provided, the callback will be called after the tracking event
|
|
56622
56512
|
*/
|
|
56623
|
-
MixpanelGroup.prototype.set =
|
|
56624
|
-
var data = this.set_action(prop, to);
|
|
56513
|
+
MixpanelGroup.prototype.set = function(prop, to, callback) {
|
|
56625
56514
|
if (mixpanel_module_.isObject(prop)) {
|
|
56626
56515
|
callback = to;
|
|
56627
56516
|
}
|
|
56517
|
+
if (!this.consentGate.allowsApiCalls()) {
|
|
56518
|
+
if (mixpanel_module_.isFunction(callback)) {
|
|
56519
|
+
callback(0);
|
|
56520
|
+
}
|
|
56521
|
+
return;
|
|
56522
|
+
}
|
|
56523
|
+
var data = this.set_action(prop, to);
|
|
56628
56524
|
return this._send_request(data, callback);
|
|
56629
|
-
}
|
|
56525
|
+
};
|
|
56630
56526
|
|
|
56631
56527
|
/**
|
|
56632
56528
|
* Set properties on a group, only if they do not yet exist.
|
|
56633
56529
|
* This will not overwrite previous group property values, unlike
|
|
56634
56530
|
* group.set().
|
|
56635
56531
|
*
|
|
56636
|
-
*
|
|
56637
|
-
*
|
|
56638
|
-
*
|
|
56532
|
+
* @example
|
|
56533
|
+
* ```js
|
|
56534
|
+
* mixpanel.get_group('company', 'mixpanel').set_once('Location', '405 Howard');
|
|
56639
56535
|
*
|
|
56640
|
-
*
|
|
56641
|
-
*
|
|
56642
|
-
*
|
|
56643
|
-
*
|
|
56644
|
-
*
|
|
56645
|
-
*
|
|
56536
|
+
* // or set multiple properties at once
|
|
56537
|
+
* mixpanel.get_group('company', 'mixpanel').set_once({
|
|
56538
|
+
* 'Location': '405 Howard',
|
|
56539
|
+
* 'Founded' : 2009,
|
|
56540
|
+
* });
|
|
56541
|
+
* // properties can be strings, integers, lists or dates
|
|
56542
|
+
* ```
|
|
56646
56543
|
*
|
|
56647
56544
|
* @param {Object|String} prop If a string, this is the name of the property. If an object, this is an associative array of names and values.
|
|
56648
56545
|
* @param {*} [to] A value to set on the given property name
|
|
56649
56546
|
* @param {Function} [callback] If provided, the callback will be called after the tracking event
|
|
56650
56547
|
*/
|
|
56651
|
-
MixpanelGroup.prototype.set_once =
|
|
56652
|
-
var data = this.set_once_action(prop, to);
|
|
56548
|
+
MixpanelGroup.prototype.set_once = function(prop, to, callback) {
|
|
56653
56549
|
if (mixpanel_module_.isObject(prop)) {
|
|
56654
56550
|
callback = to;
|
|
56655
56551
|
}
|
|
56552
|
+
if (!this.consentGate.allowsApiCalls()) {
|
|
56553
|
+
if (mixpanel_module_.isFunction(callback)) {
|
|
56554
|
+
callback(0);
|
|
56555
|
+
}
|
|
56556
|
+
return;
|
|
56557
|
+
}
|
|
56558
|
+
var data = this.set_once_action(prop, to);
|
|
56656
56559
|
return this._send_request(data, callback);
|
|
56657
|
-
}
|
|
56560
|
+
};
|
|
56658
56561
|
|
|
56659
56562
|
/**
|
|
56660
56563
|
* Unset properties on a group permanently.
|
|
56661
56564
|
*
|
|
56662
|
-
*
|
|
56663
|
-
*
|
|
56664
|
-
*
|
|
56565
|
+
* @example
|
|
56566
|
+
* ```js
|
|
56567
|
+
* mixpanel.get_group('company', 'mixpanel').unset('Founded');
|
|
56568
|
+
* ```
|
|
56665
56569
|
*
|
|
56666
56570
|
* @param {String} prop The name of the property.
|
|
56667
56571
|
* @param {Function} [callback] If provided, the callback will be called after the tracking event
|
|
56668
56572
|
*/
|
|
56669
|
-
MixpanelGroup.prototype.unset =
|
|
56573
|
+
MixpanelGroup.prototype.unset = function(prop, callback) {
|
|
56574
|
+
if (!this.consentGate.allowsApiCalls()) {
|
|
56575
|
+
if (mixpanel_module_.isFunction(callback)) {
|
|
56576
|
+
callback(0);
|
|
56577
|
+
}
|
|
56578
|
+
return;
|
|
56579
|
+
}
|
|
56670
56580
|
var data = this.unset_action(prop);
|
|
56671
56581
|
return this._send_request(data, callback);
|
|
56672
|
-
}
|
|
56582
|
+
};
|
|
56673
56583
|
|
|
56674
56584
|
/**
|
|
56675
56585
|
* Merge a given list with a list-valued group property, excluding duplicate values.
|
|
56676
56586
|
*
|
|
56677
|
-
*
|
|
56678
|
-
*
|
|
56679
|
-
*
|
|
56680
|
-
*
|
|
56587
|
+
* @example
|
|
56588
|
+
* ```js
|
|
56589
|
+
* // merge a value to a list, creating it if needed
|
|
56590
|
+
* mixpanel.get_group('company', 'mixpanel').union('Location', ['San Francisco', 'London']);
|
|
56591
|
+
* ```
|
|
56681
56592
|
*
|
|
56682
56593
|
* @param {String} list_name Name of the property.
|
|
56683
56594
|
* @param {Array} values Values to merge with the given property
|
|
56684
56595
|
* @param {Function} [callback] If provided, the callback will be called after the tracking event
|
|
56685
56596
|
*/
|
|
56686
|
-
MixpanelGroup.prototype.union =
|
|
56597
|
+
MixpanelGroup.prototype.union = function(list_name, values, callback) {
|
|
56687
56598
|
if (mixpanel_module_.isObject(list_name)) {
|
|
56688
56599
|
callback = values;
|
|
56689
56600
|
}
|
|
56601
|
+
if (!this.consentGate.allowsApiCalls()) {
|
|
56602
|
+
if (mixpanel_module_.isFunction(callback)) {
|
|
56603
|
+
callback(0);
|
|
56604
|
+
}
|
|
56605
|
+
return;
|
|
56606
|
+
}
|
|
56690
56607
|
var data = this.union_action(list_name, values);
|
|
56691
56608
|
return this._send_request(data, callback);
|
|
56692
|
-
}
|
|
56609
|
+
};
|
|
56693
56610
|
|
|
56694
56611
|
/**
|
|
56695
56612
|
* Permanently delete a group.
|
|
56696
56613
|
*
|
|
56697
|
-
*
|
|
56698
|
-
*
|
|
56699
|
-
*
|
|
56614
|
+
* @example
|
|
56615
|
+
* ```js
|
|
56616
|
+
* mixpanel.get_group('company', 'mixpanel').delete();
|
|
56617
|
+
* ```
|
|
56700
56618
|
*
|
|
56701
56619
|
* @param {Function} [callback] If provided, the callback will be called after the tracking event
|
|
56702
56620
|
*/
|
|
56703
|
-
MixpanelGroup.prototype['delete'] =
|
|
56621
|
+
MixpanelGroup.prototype['delete'] = function(callback) {
|
|
56622
|
+
if (!this.consentGate.allowsApiCalls()) {
|
|
56623
|
+
if (mixpanel_module_.isFunction(callback)) {
|
|
56624
|
+
callback(0);
|
|
56625
|
+
}
|
|
56626
|
+
return;
|
|
56627
|
+
}
|
|
56704
56628
|
// bracket notation above prevents a minification error related to reserved words
|
|
56705
56629
|
var data = this.delete_action();
|
|
56706
56630
|
return this._send_request(data, callback);
|
|
56707
|
-
}
|
|
56631
|
+
};
|
|
56708
56632
|
|
|
56709
56633
|
/**
|
|
56710
56634
|
* Remove a property from a group. The value will be ignored if doesn't exist.
|
|
56711
56635
|
*
|
|
56712
|
-
*
|
|
56713
|
-
*
|
|
56714
|
-
*
|
|
56636
|
+
* @example
|
|
56637
|
+
* ```js
|
|
56638
|
+
* mixpanel.get_group('company', 'mixpanel').remove('Location', 'London');
|
|
56639
|
+
* ```
|
|
56715
56640
|
*
|
|
56716
56641
|
* @param {String} list_name Name of the property.
|
|
56717
56642
|
* @param {Object} value Value to remove from the given group property
|
|
56718
56643
|
* @param {Function} [callback] If provided, the callback will be called after the tracking event
|
|
56719
56644
|
*/
|
|
56720
|
-
MixpanelGroup.prototype.remove =
|
|
56645
|
+
MixpanelGroup.prototype.remove = function(list_name, value, callback) {
|
|
56646
|
+
if (!this.consentGate.allowsApiCalls()) {
|
|
56647
|
+
if (mixpanel_module_.isFunction(callback)) {
|
|
56648
|
+
callback(0);
|
|
56649
|
+
}
|
|
56650
|
+
return;
|
|
56651
|
+
}
|
|
56721
56652
|
var data = this.remove_action(list_name, value);
|
|
56722
56653
|
return this._send_request(data, callback);
|
|
56723
|
-
}
|
|
56654
|
+
};
|
|
56724
56655
|
|
|
56725
56656
|
MixpanelGroup.prototype._send_request = function(data, callback) {
|
|
56726
56657
|
data['$group_key'] = this._group_key;
|
|
@@ -56749,51 +56680,66 @@ MixpanelGroup.prototype.toString = function() {
|
|
|
56749
56680
|
};
|
|
56750
56681
|
|
|
56751
56682
|
// MixpanelGroup Exports
|
|
56752
|
-
MixpanelGroup.prototype[
|
|
56753
|
-
|
|
56754
|
-
|
|
56755
|
-
|
|
56756
|
-
|
|
56683
|
+
// (assigned through an alias: a second `MixpanelGroup.prototype[...]` declaration of each method would
|
|
56684
|
+
// make TypeScript type them as `any`, which breaks the generated API docs)
|
|
56685
|
+
var MixpanelGroupProto = MixpanelGroup.prototype;
|
|
56686
|
+
MixpanelGroupProto['remove'] = MixpanelGroupProto.remove;
|
|
56687
|
+
MixpanelGroupProto['set'] = MixpanelGroupProto.set;
|
|
56688
|
+
MixpanelGroupProto['set_once'] = MixpanelGroupProto.set_once;
|
|
56689
|
+
MixpanelGroupProto['union'] = MixpanelGroupProto.union;
|
|
56690
|
+
MixpanelGroupProto['unset'] = MixpanelGroupProto.unset;
|
|
56757
56691
|
MixpanelGroup.prototype['toString'] = MixpanelGroup.prototype.toString;
|
|
56758
56692
|
|
|
56759
56693
|
/* eslint camelcase: "off" */
|
|
56760
56694
|
|
|
56761
56695
|
/**
|
|
56762
56696
|
* Mixpanel People Object
|
|
56763
|
-
* @
|
|
56697
|
+
* @class
|
|
56764
56698
|
*/
|
|
56765
|
-
|
|
56699
|
+
function MixpanelPeople() {}
|
|
56766
56700
|
|
|
56767
56701
|
mixpanel_module_.extend(MixpanelPeople.prototype, apiActions);
|
|
56768
56702
|
|
|
56769
|
-
|
|
56703
|
+
/**
|
|
56704
|
+
* @param {Object} mixpanel_instance
|
|
56705
|
+
* @param {import('./consent-gate').ConsentGate} consentGate
|
|
56706
|
+
*/
|
|
56707
|
+
MixpanelPeople.prototype._init = function(mixpanel_instance, consentGate) {
|
|
56770
56708
|
this._mixpanel = mixpanel_instance;
|
|
56709
|
+
this.consentGate = consentGate;
|
|
56771
56710
|
};
|
|
56772
56711
|
|
|
56773
|
-
|
|
56712
|
+
/**
|
|
56774
56713
|
* Set properties on a user record.
|
|
56775
56714
|
*
|
|
56776
|
-
*
|
|
56715
|
+
* @example
|
|
56716
|
+
* ```js
|
|
56717
|
+
* mixpanel.people.set('gender', 'm');
|
|
56777
56718
|
*
|
|
56778
|
-
*
|
|
56779
|
-
*
|
|
56780
|
-
*
|
|
56781
|
-
*
|
|
56782
|
-
*
|
|
56783
|
-
*
|
|
56784
|
-
*
|
|
56785
|
-
*
|
|
56786
|
-
* // properties can be strings, integers, dates, or lists
|
|
56719
|
+
* // or set multiple properties at once
|
|
56720
|
+
* mixpanel.people.set({
|
|
56721
|
+
* 'Company': 'Acme',
|
|
56722
|
+
* 'Plan': 'Premium',
|
|
56723
|
+
* 'Upgrade date': new Date()
|
|
56724
|
+
* });
|
|
56725
|
+
* // properties can be strings, integers, dates, or lists
|
|
56726
|
+
* ```
|
|
56787
56727
|
*
|
|
56788
56728
|
* @param {Object|String} prop If a string, this is the name of the property. If an object, this is an associative array of names and values.
|
|
56789
56729
|
* @param {*} [to] A value to set on the given property name
|
|
56790
56730
|
* @param {Function} [callback] If provided, the callback will be called after tracking the event.
|
|
56791
56731
|
*/
|
|
56792
|
-
MixpanelPeople.prototype.set =
|
|
56793
|
-
var data = this.set_action(prop, to);
|
|
56732
|
+
MixpanelPeople.prototype.set = function(prop, to, callback) {
|
|
56794
56733
|
if (mixpanel_module_.isObject(prop)) {
|
|
56795
56734
|
callback = to;
|
|
56796
56735
|
}
|
|
56736
|
+
if (!this.consentGate.allowsApiCalls()) {
|
|
56737
|
+
if (mixpanel_module_.isFunction(callback)) {
|
|
56738
|
+
callback(0);
|
|
56739
|
+
}
|
|
56740
|
+
return;
|
|
56741
|
+
}
|
|
56742
|
+
var data = this.set_action(prop, to);
|
|
56797
56743
|
// make sure that the referrer info has been updated and saved
|
|
56798
56744
|
if (this._get_config('save_referrer')) {
|
|
56799
56745
|
this._mixpanel['persistence'].update_referrer_info(document.referrer);
|
|
@@ -56806,81 +56752,105 @@ MixpanelPeople.prototype.set = addOptOutCheckMixpanelPeople(function(prop, to, c
|
|
|
56806
56752
|
data[SET_ACTION]
|
|
56807
56753
|
);
|
|
56808
56754
|
return this._send_request(data, callback);
|
|
56809
|
-
}
|
|
56755
|
+
};
|
|
56810
56756
|
|
|
56811
|
-
|
|
56757
|
+
/**
|
|
56812
56758
|
* Set properties on a user record, only if they do not yet exist.
|
|
56813
56759
|
* This will not overwrite previous people property values, unlike
|
|
56814
56760
|
* people.set().
|
|
56815
56761
|
*
|
|
56816
|
-
*
|
|
56762
|
+
* @example
|
|
56763
|
+
* ```js
|
|
56764
|
+
* mixpanel.people.set_once('First Login Date', new Date());
|
|
56817
56765
|
*
|
|
56818
|
-
*
|
|
56766
|
+
* // or set multiple properties at once
|
|
56767
|
+
* mixpanel.people.set_once({
|
|
56768
|
+
* 'First Login Date': new Date(),
|
|
56769
|
+
* 'Starting Plan': 'Premium'
|
|
56770
|
+
* });
|
|
56819
56771
|
*
|
|
56820
|
-
*
|
|
56821
|
-
*
|
|
56822
|
-
* 'First Login Date': new Date(),
|
|
56823
|
-
* 'Starting Plan': 'Premium'
|
|
56824
|
-
* });
|
|
56825
|
-
*
|
|
56826
|
-
* // properties can be strings, integers or dates
|
|
56772
|
+
* // properties can be strings, integers or dates
|
|
56773
|
+
* ```
|
|
56827
56774
|
*
|
|
56828
56775
|
* @param {Object|String} prop If a string, this is the name of the property. If an object, this is an associative array of names and values.
|
|
56829
56776
|
* @param {*} [to] A value to set on the given property name
|
|
56830
56777
|
* @param {Function} [callback] If provided, the callback will be called after tracking the event.
|
|
56831
56778
|
*/
|
|
56832
|
-
MixpanelPeople.prototype.set_once =
|
|
56833
|
-
var data = this.set_once_action(prop, to);
|
|
56779
|
+
MixpanelPeople.prototype.set_once = function(prop, to, callback) {
|
|
56834
56780
|
if (mixpanel_module_.isObject(prop)) {
|
|
56835
56781
|
callback = to;
|
|
56836
56782
|
}
|
|
56783
|
+
if (!this.consentGate.allowsApiCalls()) {
|
|
56784
|
+
if (mixpanel_module_.isFunction(callback)) {
|
|
56785
|
+
callback(0);
|
|
56786
|
+
}
|
|
56787
|
+
return;
|
|
56788
|
+
}
|
|
56789
|
+
var data = this.set_once_action(prop, to);
|
|
56837
56790
|
return this._send_request(data, callback);
|
|
56838
|
-
}
|
|
56791
|
+
};
|
|
56839
56792
|
|
|
56840
|
-
|
|
56793
|
+
/**
|
|
56841
56794
|
* Unset properties on a user record (permanently removes the properties and their values from a profile).
|
|
56842
56795
|
*
|
|
56843
|
-
*
|
|
56844
|
-
*
|
|
56845
|
-
*
|
|
56796
|
+
* @example
|
|
56797
|
+
* ```js
|
|
56798
|
+
* mixpanel.people.unset('gender');
|
|
56846
56799
|
*
|
|
56847
|
-
*
|
|
56848
|
-
*
|
|
56800
|
+
* // or unset multiple properties at once
|
|
56801
|
+
* mixpanel.people.unset(['gender', 'Company']);
|
|
56802
|
+
* ```
|
|
56849
56803
|
*
|
|
56850
56804
|
* @param {Array|String} prop If a string, this is the name of the property. If an array, this is a list of property names.
|
|
56851
56805
|
* @param {Function} [callback] If provided, the callback will be called after tracking the event.
|
|
56852
56806
|
*/
|
|
56853
|
-
MixpanelPeople.prototype.unset =
|
|
56807
|
+
MixpanelPeople.prototype.unset = function(prop, callback) {
|
|
56808
|
+
if (!this.consentGate.allowsApiCalls()) {
|
|
56809
|
+
if (mixpanel_module_.isFunction(callback)) {
|
|
56810
|
+
callback(0);
|
|
56811
|
+
}
|
|
56812
|
+
return;
|
|
56813
|
+
}
|
|
56854
56814
|
var data = this.unset_action(prop);
|
|
56855
56815
|
return this._send_request(data, callback);
|
|
56856
|
-
}
|
|
56816
|
+
};
|
|
56857
56817
|
|
|
56858
|
-
|
|
56818
|
+
/**
|
|
56859
56819
|
* Increment/decrement numeric people analytics properties.
|
|
56860
56820
|
*
|
|
56861
|
-
*
|
|
56821
|
+
* @example
|
|
56822
|
+
* ```js
|
|
56823
|
+
* mixpanel.people.increment('page_views', 1);
|
|
56862
56824
|
*
|
|
56863
|
-
*
|
|
56825
|
+
* // or, for convenience, if you're just incrementing a counter by
|
|
56826
|
+
* // 1, you can simply do
|
|
56827
|
+
* mixpanel.people.increment('page_views');
|
|
56864
56828
|
*
|
|
56865
|
-
*
|
|
56866
|
-
*
|
|
56867
|
-
* mixpanel.people.increment('page_views');
|
|
56829
|
+
* // to decrement a counter, pass a negative number
|
|
56830
|
+
* mixpanel.people.increment('credits_left', -1);
|
|
56868
56831
|
*
|
|
56869
|
-
*
|
|
56870
|
-
*
|
|
56871
|
-
*
|
|
56872
|
-
*
|
|
56873
|
-
*
|
|
56874
|
-
*
|
|
56875
|
-
*
|
|
56876
|
-
* counter2: 6
|
|
56877
|
-
* });
|
|
56832
|
+
* // like mixpanel.people.set(), you can increment multiple
|
|
56833
|
+
* // properties at once:
|
|
56834
|
+
* mixpanel.people.increment({
|
|
56835
|
+
* counter1: 1,
|
|
56836
|
+
* counter2: 6
|
|
56837
|
+
* });
|
|
56838
|
+
* ```
|
|
56878
56839
|
*
|
|
56879
56840
|
* @param {Object|String} prop If a string, this is the name of the property. If an object, this is an associative array of names and numeric values.
|
|
56880
56841
|
* @param {Number} [by] An amount to increment the given property
|
|
56881
56842
|
* @param {Function} [callback] If provided, the callback will be called after tracking the event.
|
|
56882
56843
|
*/
|
|
56883
|
-
MixpanelPeople.prototype.increment =
|
|
56844
|
+
MixpanelPeople.prototype.increment = function(prop, by, callback) {
|
|
56845
|
+
if (mixpanel_module_.isObject(prop)) {
|
|
56846
|
+
callback = by;
|
|
56847
|
+
}
|
|
56848
|
+
if (!this.consentGate.allowsApiCalls()) {
|
|
56849
|
+
if (mixpanel_module_.isFunction(callback)) {
|
|
56850
|
+
callback(0);
|
|
56851
|
+
}
|
|
56852
|
+
return;
|
|
56853
|
+
}
|
|
56884
56854
|
var data = {};
|
|
56885
56855
|
var $add = {};
|
|
56886
56856
|
if (mixpanel_module_.isObject(prop)) {
|
|
@@ -56894,7 +56864,6 @@ MixpanelPeople.prototype.increment = addOptOutCheckMixpanelPeople(function(prop,
|
|
|
56894
56864
|
}
|
|
56895
56865
|
}
|
|
56896
56866
|
}, this);
|
|
56897
|
-
callback = by;
|
|
56898
56867
|
} else {
|
|
56899
56868
|
// convenience: mixpanel.people.increment('property'); will
|
|
56900
56869
|
// increment 'property' by 1
|
|
@@ -56906,119 +56875,148 @@ MixpanelPeople.prototype.increment = addOptOutCheckMixpanelPeople(function(prop,
|
|
|
56906
56875
|
data[ADD_ACTION] = $add;
|
|
56907
56876
|
|
|
56908
56877
|
return this._send_request(data, callback);
|
|
56909
|
-
}
|
|
56878
|
+
};
|
|
56910
56879
|
|
|
56911
|
-
|
|
56880
|
+
/**
|
|
56912
56881
|
* Append a value to a list-valued people analytics property.
|
|
56913
56882
|
*
|
|
56914
|
-
*
|
|
56883
|
+
* @example
|
|
56884
|
+
* ```js
|
|
56885
|
+
* // append a value to a list, creating it if needed
|
|
56886
|
+
* mixpanel.people.append('pages_visited', 'homepage');
|
|
56915
56887
|
*
|
|
56916
|
-
*
|
|
56917
|
-
*
|
|
56918
|
-
*
|
|
56919
|
-
*
|
|
56920
|
-
*
|
|
56921
|
-
*
|
|
56922
|
-
*
|
|
56923
|
-
* list2: 123
|
|
56924
|
-
* });
|
|
56888
|
+
* // like mixpanel.people.set(), you can append multiple
|
|
56889
|
+
* // properties at once:
|
|
56890
|
+
* mixpanel.people.append({
|
|
56891
|
+
* list1: 'bob',
|
|
56892
|
+
* list2: 123
|
|
56893
|
+
* });
|
|
56894
|
+
* ```
|
|
56925
56895
|
*
|
|
56926
56896
|
* @param {Object|String} list_name If a string, this is the name of the property. If an object, this is an associative array of names and values.
|
|
56927
56897
|
* @param {*} [value] value An item to append to the list
|
|
56928
56898
|
* @param {Function} [callback] If provided, the callback will be called after tracking the event.
|
|
56929
56899
|
*/
|
|
56930
|
-
MixpanelPeople.prototype.append =
|
|
56900
|
+
MixpanelPeople.prototype.append = function(list_name, value, callback) {
|
|
56931
56901
|
if (mixpanel_module_.isObject(list_name)) {
|
|
56932
56902
|
callback = value;
|
|
56933
56903
|
}
|
|
56904
|
+
if (!this.consentGate.allowsApiCalls()) {
|
|
56905
|
+
if (mixpanel_module_.isFunction(callback)) {
|
|
56906
|
+
callback(0);
|
|
56907
|
+
}
|
|
56908
|
+
return;
|
|
56909
|
+
}
|
|
56934
56910
|
var data = this.append_action(list_name, value);
|
|
56935
56911
|
return this._send_request(data, callback);
|
|
56936
|
-
}
|
|
56912
|
+
};
|
|
56937
56913
|
|
|
56938
|
-
|
|
56914
|
+
/**
|
|
56939
56915
|
* Remove a value from a list-valued people analytics property.
|
|
56940
56916
|
*
|
|
56941
|
-
*
|
|
56942
|
-
*
|
|
56943
|
-
*
|
|
56917
|
+
* @example
|
|
56918
|
+
* ```js
|
|
56919
|
+
* mixpanel.people.remove('School', 'UCB');
|
|
56920
|
+
* ```
|
|
56944
56921
|
*
|
|
56945
56922
|
* @param {Object|String} list_name If a string, this is the name of the property. If an object, this is an associative array of names and values.
|
|
56946
56923
|
* @param {*} [value] value Item to remove from the list
|
|
56947
56924
|
* @param {Function} [callback] If provided, the callback will be called after tracking the event.
|
|
56948
56925
|
*/
|
|
56949
|
-
MixpanelPeople.prototype.remove =
|
|
56926
|
+
MixpanelPeople.prototype.remove = function(list_name, value, callback) {
|
|
56950
56927
|
if (mixpanel_module_.isObject(list_name)) {
|
|
56951
56928
|
callback = value;
|
|
56952
56929
|
}
|
|
56930
|
+
if (!this.consentGate.allowsApiCalls()) {
|
|
56931
|
+
if (mixpanel_module_.isFunction(callback)) {
|
|
56932
|
+
callback(0);
|
|
56933
|
+
}
|
|
56934
|
+
return;
|
|
56935
|
+
}
|
|
56953
56936
|
var data = this.remove_action(list_name, value);
|
|
56954
56937
|
return this._send_request(data, callback);
|
|
56955
|
-
}
|
|
56938
|
+
};
|
|
56956
56939
|
|
|
56957
|
-
|
|
56940
|
+
/**
|
|
56958
56941
|
* Merge a given list with a list-valued people analytics property,
|
|
56959
56942
|
* excluding duplicate values.
|
|
56960
56943
|
*
|
|
56961
|
-
*
|
|
56962
|
-
*
|
|
56963
|
-
*
|
|
56964
|
-
*
|
|
56944
|
+
* @example
|
|
56945
|
+
* ```js
|
|
56946
|
+
* // merge a value to a list, creating it if needed
|
|
56947
|
+
* mixpanel.people.union('pages_visited', 'homepage');
|
|
56965
56948
|
*
|
|
56966
|
-
*
|
|
56967
|
-
*
|
|
56968
|
-
*
|
|
56969
|
-
*
|
|
56970
|
-
*
|
|
56971
|
-
*
|
|
56949
|
+
* // like mixpanel.people.set(), you can append multiple
|
|
56950
|
+
* // properties at once:
|
|
56951
|
+
* mixpanel.people.union({
|
|
56952
|
+
* list1: 'bob',
|
|
56953
|
+
* list2: 123
|
|
56954
|
+
* });
|
|
56972
56955
|
*
|
|
56973
|
-
*
|
|
56974
|
-
*
|
|
56975
|
-
*
|
|
56976
|
-
*
|
|
56977
|
-
*
|
|
56956
|
+
* // like mixpanel.people.append(), you can append multiple
|
|
56957
|
+
* // values to the same list:
|
|
56958
|
+
* mixpanel.people.union({
|
|
56959
|
+
* list1: ['bob', 'billy']
|
|
56960
|
+
* });
|
|
56961
|
+
* ```
|
|
56978
56962
|
*
|
|
56979
56963
|
* @param {Object|String} list_name If a string, this is the name of the property. If an object, this is an associative array of names and values.
|
|
56980
|
-
* @param {*} [
|
|
56964
|
+
* @param {*} [values] Value / values to merge with the given property
|
|
56981
56965
|
* @param {Function} [callback] If provided, the callback will be called after tracking the event.
|
|
56982
56966
|
*/
|
|
56983
|
-
MixpanelPeople.prototype.union =
|
|
56967
|
+
MixpanelPeople.prototype.union = function(list_name, values, callback) {
|
|
56984
56968
|
if (mixpanel_module_.isObject(list_name)) {
|
|
56985
56969
|
callback = values;
|
|
56986
56970
|
}
|
|
56971
|
+
if (!this.consentGate.allowsApiCalls()) {
|
|
56972
|
+
if (mixpanel_module_.isFunction(callback)) {
|
|
56973
|
+
callback(0);
|
|
56974
|
+
}
|
|
56975
|
+
return;
|
|
56976
|
+
}
|
|
56987
56977
|
var data = this.union_action(list_name, values);
|
|
56988
56978
|
return this._send_request(data, callback);
|
|
56989
|
-
}
|
|
56979
|
+
};
|
|
56990
56980
|
|
|
56991
|
-
|
|
56981
|
+
/**
|
|
56992
56982
|
* Record that you have charged the current user a certain amount
|
|
56993
56983
|
* of money. Charges recorded with track_charge() will appear in the
|
|
56994
56984
|
* Mixpanel revenue report.
|
|
56995
56985
|
*
|
|
56996
|
-
*
|
|
56997
|
-
*
|
|
56998
|
-
*
|
|
56999
|
-
*
|
|
56986
|
+
* @example
|
|
56987
|
+
* ```js
|
|
56988
|
+
* // charge a user $50
|
|
56989
|
+
* mixpanel.people.track_charge(50);
|
|
57000
56990
|
*
|
|
57001
|
-
*
|
|
57002
|
-
*
|
|
57003
|
-
*
|
|
57004
|
-
*
|
|
56991
|
+
* // charge a user $30.50 on the 2nd of january
|
|
56992
|
+
* mixpanel.people.track_charge(30.50, {
|
|
56993
|
+
* '$time': new Date('jan 1 2012')
|
|
56994
|
+
* });
|
|
56995
|
+
* ```
|
|
57005
56996
|
*
|
|
57006
56997
|
* @param {Number} amount The amount of money charged to the current user
|
|
57007
56998
|
* @param {Object} [properties] An associative array of properties associated with the charge
|
|
57008
56999
|
* @param {Function} [callback] If provided, the callback will be called when the server responds
|
|
57009
57000
|
* @deprecated
|
|
57010
57001
|
*/
|
|
57011
|
-
MixpanelPeople.prototype.track_charge =
|
|
57002
|
+
MixpanelPeople.prototype.track_charge = function(amount, properties, callback) { // eslint-disable-line no-unused-vars
|
|
57003
|
+
if (!this.consentGate.allowsApiCalls()) {
|
|
57004
|
+
if (mixpanel_module_.isFunction(callback)) {
|
|
57005
|
+
callback(0);
|
|
57006
|
+
}
|
|
57007
|
+
return;
|
|
57008
|
+
}
|
|
57012
57009
|
console$1.error('mixpanel.people.track_charge() is deprecated and no longer has any effect.');
|
|
57013
|
-
}
|
|
57010
|
+
};
|
|
57014
57011
|
|
|
57015
|
-
|
|
57012
|
+
/**
|
|
57016
57013
|
* Permanently clear all revenue report transactions from the
|
|
57017
57014
|
* current user's people analytics profile.
|
|
57018
57015
|
*
|
|
57019
|
-
*
|
|
57020
|
-
*
|
|
57021
|
-
*
|
|
57016
|
+
* @example
|
|
57017
|
+
* ```js
|
|
57018
|
+
* mixpanel.people.clear_charges();
|
|
57019
|
+
* ```
|
|
57022
57020
|
*
|
|
57023
57021
|
* @param {Function} [callback] If provided, the callback will be called after tracking the event.
|
|
57024
57022
|
* @deprecated
|
|
@@ -57027,14 +57025,15 @@ MixpanelPeople.prototype.clear_charges = function(callback) {
|
|
|
57027
57025
|
return this.set('$transactions', [], callback);
|
|
57028
57026
|
};
|
|
57029
57027
|
|
|
57030
|
-
|
|
57028
|
+
/**
|
|
57031
57029
|
* Permanently deletes the current people analytics profile from
|
|
57032
57030
|
* Mixpanel (using the current distinct_id).
|
|
57033
57031
|
*
|
|
57034
|
-
*
|
|
57035
|
-
*
|
|
57036
|
-
*
|
|
57037
|
-
*
|
|
57032
|
+
* @example
|
|
57033
|
+
* ```js
|
|
57034
|
+
* // remove the all data you have stored about the current user
|
|
57035
|
+
* mixpanel.people.delete_user();
|
|
57036
|
+
* ```
|
|
57038
57037
|
*
|
|
57039
57038
|
*/
|
|
57040
57039
|
MixpanelPeople.prototype.delete_user = function() {
|
|
@@ -57069,7 +57068,7 @@ MixpanelPeople.prototype._send_request = function(data, callback) {
|
|
|
57069
57068
|
var date_encoded_data = mixpanel_module_.encodeDates(data);
|
|
57070
57069
|
|
|
57071
57070
|
if (!this._identify_called()) {
|
|
57072
|
-
this._enqueue(
|
|
57071
|
+
this._enqueue(date_encoded_data);
|
|
57073
57072
|
if (!mixpanel_module_.isUndefined(callback)) {
|
|
57074
57073
|
if (this._get_config('verbose')) {
|
|
57075
57074
|
callback({status: -1, error: null});
|
|
@@ -57204,16 +57203,19 @@ MixpanelPeople.prototype._is_reserved_property = function(prop) {
|
|
|
57204
57203
|
};
|
|
57205
57204
|
|
|
57206
57205
|
// MixpanelPeople Exports
|
|
57207
|
-
MixpanelPeople.prototype[
|
|
57208
|
-
|
|
57209
|
-
|
|
57210
|
-
|
|
57211
|
-
|
|
57212
|
-
|
|
57213
|
-
|
|
57214
|
-
|
|
57215
|
-
|
|
57216
|
-
|
|
57206
|
+
// (assigned through an alias: a second `MixpanelPeople.prototype[...]` declaration of each method would
|
|
57207
|
+
// make TypeScript type them as `any`, which breaks the generated API docs)
|
|
57208
|
+
var MixpanelPeopleProto = MixpanelPeople.prototype;
|
|
57209
|
+
MixpanelPeopleProto['set'] = MixpanelPeopleProto.set;
|
|
57210
|
+
MixpanelPeopleProto['set_once'] = MixpanelPeopleProto.set_once;
|
|
57211
|
+
MixpanelPeopleProto['unset'] = MixpanelPeopleProto.unset;
|
|
57212
|
+
MixpanelPeopleProto['increment'] = MixpanelPeopleProto.increment;
|
|
57213
|
+
MixpanelPeopleProto['append'] = MixpanelPeopleProto.append;
|
|
57214
|
+
MixpanelPeopleProto['remove'] = MixpanelPeopleProto.remove;
|
|
57215
|
+
MixpanelPeopleProto['union'] = MixpanelPeopleProto.union;
|
|
57216
|
+
MixpanelPeopleProto['track_charge'] = MixpanelPeopleProto.track_charge;
|
|
57217
|
+
MixpanelPeopleProto['clear_charges'] = MixpanelPeopleProto.clear_charges;
|
|
57218
|
+
MixpanelPeopleProto['delete_user'] = MixpanelPeopleProto.delete_user;
|
|
57217
57219
|
MixpanelPeople.prototype['toString'] = MixpanelPeople.prototype.toString;
|
|
57218
57220
|
|
|
57219
57221
|
/* eslint camelcase: "off" */
|
|
@@ -57246,11 +57248,21 @@ MixpanelPeople.prototype['toString'] = MixpanelPeople.prototype.toString;
|
|
|
57246
57248
|
EVENT_TIMERS_KEY
|
|
57247
57249
|
];
|
|
57248
57250
|
|
|
57251
|
+
// the store while persistence is off: nothing is read or written
|
|
57252
|
+
/** @const */ var NULL_STORAGE = {
|
|
57253
|
+
parse: function() { return null; },
|
|
57254
|
+
set: function() {}
|
|
57255
|
+
};
|
|
57256
|
+
|
|
57249
57257
|
/**
|
|
57250
57258
|
* Mixpanel Persistence Object
|
|
57251
57259
|
* @constructor
|
|
57260
|
+
* @param {Object} config
|
|
57261
|
+
* @param {Object} [options]
|
|
57262
|
+
* @param {boolean} [options.closed] start closed, keeping props in memory without reading, writing
|
|
57263
|
+
* or probing storage until open()
|
|
57252
57264
|
*/
|
|
57253
|
-
var MixpanelPersistence = function(config) {
|
|
57265
|
+
var MixpanelPersistence = function(config, options) {
|
|
57254
57266
|
this['props'] = {};
|
|
57255
57267
|
this.campaign_params_saved = false;
|
|
57256
57268
|
|
|
@@ -57263,19 +57275,25 @@ var MixpanelPersistence = function(config) {
|
|
|
57263
57275
|
var storage_type = config['persistence'];
|
|
57264
57276
|
if (storage_type !== 'cookie' && storage_type !== 'localStorage') {
|
|
57265
57277
|
console$1.critical('Unknown persistence type ' + storage_type + '; falling back to cookie');
|
|
57266
|
-
|
|
57278
|
+
config['persistence'] = 'cookie';
|
|
57267
57279
|
}
|
|
57280
|
+
this.storage_type = config['persistence'];
|
|
57268
57281
|
|
|
57269
|
-
|
|
57270
|
-
|
|
57271
|
-
|
|
57272
|
-
|
|
57282
|
+
this.closed = true;
|
|
57283
|
+
this.storage = NULL_STORAGE;
|
|
57284
|
+
this.update_config(config);
|
|
57285
|
+
if (!(options && options.closed)) {
|
|
57286
|
+
this.open();
|
|
57273
57287
|
}
|
|
57288
|
+
};
|
|
57274
57289
|
|
|
57275
|
-
|
|
57276
|
-
this.
|
|
57277
|
-
|
|
57278
|
-
|
|
57290
|
+
MixpanelPersistence.prototype._choose_backend = function() {
|
|
57291
|
+
if (this.storage_type === 'localStorage' && mixpanel_module_.localStorage.is_supported()) {
|
|
57292
|
+
this.backend = mixpanel_module_.localStorage;
|
|
57293
|
+
} else {
|
|
57294
|
+
this.backend = mixpanel_module_.cookie;
|
|
57295
|
+
}
|
|
57296
|
+
this.storage = this.backend;
|
|
57279
57297
|
};
|
|
57280
57298
|
|
|
57281
57299
|
MixpanelPersistence.prototype.properties = function() {
|
|
@@ -57293,8 +57311,6 @@ MixpanelPersistence.prototype.properties = function() {
|
|
|
57293
57311
|
};
|
|
57294
57312
|
|
|
57295
57313
|
MixpanelPersistence.prototype.load = function() {
|
|
57296
|
-
if (this.disabled) { return; }
|
|
57297
|
-
|
|
57298
57314
|
var entry = this.storage.parse(this.name);
|
|
57299
57315
|
|
|
57300
57316
|
if (entry) {
|
|
@@ -57308,7 +57324,7 @@ MixpanelPersistence.prototype.upgrade = function() {
|
|
|
57308
57324
|
|
|
57309
57325
|
// if transferring from cookie to localStorage or vice-versa, copy existing
|
|
57310
57326
|
// super properties over to new storage mode
|
|
57311
|
-
if (this.
|
|
57327
|
+
if (this.backend === mixpanel_module_.localStorage) {
|
|
57312
57328
|
old_cookie = mixpanel_module_.cookie.parse(this.name);
|
|
57313
57329
|
|
|
57314
57330
|
mixpanel_module_.cookie.remove(this.name);
|
|
@@ -57317,7 +57333,7 @@ MixpanelPersistence.prototype.upgrade = function() {
|
|
|
57317
57333
|
if (old_cookie) {
|
|
57318
57334
|
this.register_once(old_cookie);
|
|
57319
57335
|
}
|
|
57320
|
-
} else if (this.
|
|
57336
|
+
} else if (this.backend === mixpanel_module_.cookie) {
|
|
57321
57337
|
old_localstorage = mixpanel_module_.localStorage.parse(this.name);
|
|
57322
57338
|
|
|
57323
57339
|
mixpanel_module_.localStorage.remove(this.name);
|
|
@@ -57329,8 +57345,6 @@ MixpanelPersistence.prototype.upgrade = function() {
|
|
|
57329
57345
|
};
|
|
57330
57346
|
|
|
57331
57347
|
MixpanelPersistence.prototype.save = function() {
|
|
57332
|
-
if (this.disabled) { return; }
|
|
57333
|
-
|
|
57334
57348
|
this.storage.set(
|
|
57335
57349
|
this.name,
|
|
57336
57350
|
JSONStringify(this['props']),
|
|
@@ -57348,9 +57362,11 @@ MixpanelPersistence.prototype.load_prop = function(key) {
|
|
|
57348
57362
|
};
|
|
57349
57363
|
|
|
57350
57364
|
MixpanelPersistence.prototype.remove = function() {
|
|
57365
|
+
// persistence that started closed has no backend until it opens
|
|
57366
|
+
if (!this.backend) { return; }
|
|
57351
57367
|
// remove both domain and subdomain cookies
|
|
57352
|
-
this.
|
|
57353
|
-
this.
|
|
57368
|
+
this.backend.remove(this.name, false, this.cookie_domain);
|
|
57369
|
+
this.backend.remove(this.name, true, this.cookie_domain);
|
|
57354
57370
|
};
|
|
57355
57371
|
|
|
57356
57372
|
// removes the storage entry and deletes all loaded data
|
|
@@ -57439,11 +57455,67 @@ MixpanelPersistence.prototype.update_config = function(config) {
|
|
|
57439
57455
|
this.set_secure(config['secure_cookie']);
|
|
57440
57456
|
};
|
|
57441
57457
|
|
|
57458
|
+
/**
|
|
57459
|
+
* Turn persistence off or on for the disable_persistence config. Consent closes it separately, so a
|
|
57460
|
+
* config change doesn't reopen what consent closed.
|
|
57461
|
+
* @param {boolean} disabled
|
|
57462
|
+
*/
|
|
57442
57463
|
MixpanelPersistence.prototype.set_disabled = function(disabled) {
|
|
57443
57464
|
this.disabled = disabled;
|
|
57444
|
-
|
|
57465
|
+
this._update_storage();
|
|
57466
|
+
};
|
|
57467
|
+
|
|
57468
|
+
/**
|
|
57469
|
+
* Stop reading and writing storage, and remove the stored entry. The props stay in memory.
|
|
57470
|
+
*/
|
|
57471
|
+
MixpanelPersistence.prototype.close = function() {
|
|
57472
|
+
if (this.closed) { return; }
|
|
57473
|
+
this.closed = true;
|
|
57474
|
+
this._update_storage();
|
|
57475
|
+
};
|
|
57476
|
+
|
|
57477
|
+
/**
|
|
57478
|
+
* Read and write storage again, saving the props in memory to it.
|
|
57479
|
+
*/
|
|
57480
|
+
MixpanelPersistence.prototype.open = function() {
|
|
57481
|
+
if (!this.closed) { return; }
|
|
57482
|
+
this.closed = false;
|
|
57483
|
+
if (!this.backend) {
|
|
57484
|
+
// what the page set while closed goes on top of what's stored
|
|
57485
|
+
var memory_props = this['props'];
|
|
57486
|
+
this['props'] = {};
|
|
57487
|
+
this._choose_backend();
|
|
57488
|
+
this.load();
|
|
57489
|
+
mixpanel_module_.extend(this['props'], memory_props);
|
|
57490
|
+
// nothing is written until _update_storage, which writes nothing while persistence is
|
|
57491
|
+
// disabled
|
|
57492
|
+
this.storage = NULL_STORAGE;
|
|
57493
|
+
this.upgrade();
|
|
57494
|
+
// remove any copy an earlier config left at another cookie scope or in the other store
|
|
57495
|
+
this.remove_stored_entry();
|
|
57496
|
+
}
|
|
57497
|
+
this._update_storage();
|
|
57498
|
+
};
|
|
57499
|
+
|
|
57500
|
+
/**
|
|
57501
|
+
* Delete the stored entry from both backends at every cookie scope, whether or not storage is
|
|
57502
|
+
* open: an earlier page load or config may have left one anywhere.
|
|
57503
|
+
*/
|
|
57504
|
+
MixpanelPersistence.prototype.remove_stored_entry = function() {
|
|
57505
|
+
mixpanel_module_.cookie.remove(this.name);
|
|
57506
|
+
mixpanel_module_.cookie.remove(this.name, true);
|
|
57507
|
+
if (this.cookie_domain) {
|
|
57508
|
+
mixpanel_module_.cookie.remove(this.name, false, this.cookie_domain);
|
|
57509
|
+
}
|
|
57510
|
+
mixpanel_module_.localStorage.remove(this.name);
|
|
57511
|
+
};
|
|
57512
|
+
|
|
57513
|
+
MixpanelPersistence.prototype._update_storage = function() {
|
|
57514
|
+
if (this.disabled || this.closed) {
|
|
57515
|
+
this.storage = NULL_STORAGE;
|
|
57445
57516
|
this.remove();
|
|
57446
57517
|
} else {
|
|
57518
|
+
this.storage = this.backend;
|
|
57447
57519
|
this.save();
|
|
57448
57520
|
}
|
|
57449
57521
|
};
|
|
@@ -57643,6 +57715,848 @@ MixpanelPersistence.prototype.remove_event_timer = function(event_name) {
|
|
|
57643
57715
|
return timestamp;
|
|
57644
57716
|
};
|
|
57645
57717
|
|
|
57718
|
+
/**
|
|
57719
|
+
* The consent rules as two tables: CONSENT_MODES maps each mode's decisions to a state, and
|
|
57720
|
+
* CONSENT_STATES says what each state allows:
|
|
57721
|
+
* 'api_calls' the public tracking, people, group and replay methods run
|
|
57722
|
+
* 'send' tracking requests go out
|
|
57723
|
+
* 'fetch' feature flags and remote settings are fetched
|
|
57724
|
+
* 'store' the services store data about the visitor
|
|
57725
|
+
*/
|
|
57726
|
+
|
|
57727
|
+
|
|
57728
|
+
/** @const */ var CONSENT_MODE_NO_CONSENT_REQUIRED = 'no_consent_required';
|
|
57729
|
+
/** @const */ var CONSENT_MODE_REQUIRE_CONSENT = 'require_consent';
|
|
57730
|
+
|
|
57731
|
+
/** @const */ var CAPABILITIES = ['api_calls', 'send', 'fetch', 'store'];
|
|
57732
|
+
|
|
57733
|
+
/** @const */ var DECISION_NONE = 'none';
|
|
57734
|
+
/** @const */ var DECISION_OPTED_IN = 'opted_in';
|
|
57735
|
+
/** @const */ var DECISION_OPTED_OUT = 'opted_out';
|
|
57736
|
+
// Do Not Track counts as an objection
|
|
57737
|
+
/** @const */ var DECISION_OBJECTED = 'objected';
|
|
57738
|
+
|
|
57739
|
+
/** @const */ var STATE_FULL = 'full';
|
|
57740
|
+
/** @const */ var STATE_API_CALLS_STOPPED = 'api_calls_stopped';
|
|
57741
|
+
/** @const */ var STATE_BLOCKED = 'blocked';
|
|
57742
|
+
|
|
57743
|
+
/** @const */ var CONSENT_STATES = {
|
|
57744
|
+
// the SDK works normally, as for a site with no consent rules
|
|
57745
|
+
'full': {'api_calls': true, 'send': true, 'fetch': true, 'store': true},
|
|
57746
|
+
// an opt-out under 'no_consent_required': the public calls do nothing, flags keep loading,
|
|
57747
|
+
// and persistence follows the opt-out's clear_persistence and enable_persistence options
|
|
57748
|
+
'api_calls_stopped': {'api_calls': false, 'send': true, 'fetch': true, 'store': true},
|
|
57749
|
+
// nothing runs, is sent or is stored
|
|
57750
|
+
'blocked': {'api_calls': false, 'send': false, 'fetch': false, 'store': false}
|
|
57751
|
+
};
|
|
57752
|
+
|
|
57753
|
+
/**
|
|
57754
|
+
* Each mode's state for each decision. 'no_consent_required' keeps its decisions with
|
|
57755
|
+
* OptOutFlagDecisions, the other modes with ConsentDecisions.
|
|
57756
|
+
*/
|
|
57757
|
+
/** @const */ var CONSENT_MODES = {
|
|
57758
|
+
'no_consent_required': {'none': STATE_FULL, 'opted_in': STATE_FULL, 'opted_out': STATE_API_CALLS_STOPPED, 'objected': STATE_API_CALLS_STOPPED},
|
|
57759
|
+
'require_consent': {'none': STATE_BLOCKED, 'opted_in': STATE_FULL, 'opted_out': STATE_BLOCKED, 'objected': STATE_BLOCKED}
|
|
57760
|
+
};
|
|
57761
|
+
|
|
57762
|
+
/**
|
|
57763
|
+
* The mode for a consent_mode config value, by default 'no_consent_required'. An unknown value
|
|
57764
|
+
* falls back to 'require_consent', so a typo stores and sends nothing before consent.
|
|
57765
|
+
* @param {string|null|undefined} configuredMode
|
|
57766
|
+
* @returns {string}
|
|
57767
|
+
*/
|
|
57768
|
+
function resolveConsentMode(configuredMode) {
|
|
57769
|
+
if (!configuredMode) {
|
|
57770
|
+
return CONSENT_MODE_NO_CONSENT_REQUIRED;
|
|
57771
|
+
}
|
|
57772
|
+
if (!CONSENT_MODES.hasOwnProperty(configuredMode)) {
|
|
57773
|
+
console$1.critical('Unknown consent_mode ' + configuredMode + '; using \'' + CONSENT_MODE_REQUIRE_CONSENT + '\'');
|
|
57774
|
+
return CONSENT_MODE_REQUIRE_CONSENT;
|
|
57775
|
+
}
|
|
57776
|
+
return configuredMode;
|
|
57777
|
+
}
|
|
57778
|
+
|
|
57779
|
+
/**
|
|
57780
|
+
* The visitor's decision: Do Not Track, then the stored opt-out flag.
|
|
57781
|
+
* @param {boolean} doNotTrack whether Do Not Track is on and not ignored
|
|
57782
|
+
* @param {string|null} storedFlag '1', '0', or null when there's none
|
|
57783
|
+
* @returns {string}
|
|
57784
|
+
*/
|
|
57785
|
+
function readDecision(doNotTrack, storedFlag) {
|
|
57786
|
+
if (doNotTrack) {
|
|
57787
|
+
console$1.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"');
|
|
57788
|
+
return DECISION_OBJECTED;
|
|
57789
|
+
}
|
|
57790
|
+
|
|
57791
|
+
if (storedFlag === '1') {
|
|
57792
|
+
return DECISION_OPTED_IN;
|
|
57793
|
+
} else if (storedFlag === '0') {
|
|
57794
|
+
console$1.warn('You are opted out of Mixpanel tracking. This will prevent the Mixpanel SDK from sending any data.');
|
|
57795
|
+
return DECISION_OPTED_OUT;
|
|
57796
|
+
}
|
|
57797
|
+
return DECISION_NONE;
|
|
57798
|
+
}
|
|
57799
|
+
|
|
57800
|
+
/**
|
|
57801
|
+
* GDPR utils
|
|
57802
|
+
*
|
|
57803
|
+
* The General Data Protection Regulation (GDPR) is a regulation in EU law on data protection
|
|
57804
|
+
* and privacy for all individuals within the European Union. It addresses the export of personal
|
|
57805
|
+
* data outside the EU. The GDPR aims primarily to give control back to citizens and residents
|
|
57806
|
+
* over their personal data and to simplify the regulatory environment for international business
|
|
57807
|
+
* by unifying the regulation within the EU.
|
|
57808
|
+
*
|
|
57809
|
+
* This set of utilities is intended to enable opt in/out functionality in the Mixpanel JS SDK.
|
|
57810
|
+
* These functions are used internally by the SDK and are not intended to be publicly exposed.
|
|
57811
|
+
*/
|
|
57812
|
+
|
|
57813
|
+
|
|
57814
|
+
/**
|
|
57815
|
+
* A function used to track a Mixpanel event (e.g. MixpanelLib.track)
|
|
57816
|
+
* @callback trackFunction
|
|
57817
|
+
* @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
|
|
57818
|
+
* @param {Object} [properties] A set of properties to include with the event you're sending. These describe the user who did the event or details about the event itself.
|
|
57819
|
+
* @param {Function} [callback] If provided, the callback function will be called after tracking the event.
|
|
57820
|
+
*/
|
|
57821
|
+
|
|
57822
|
+
/** Public **/
|
|
57823
|
+
|
|
57824
|
+
var OPT_IN_OUT_FLAG_PREFIX = '__mp_opt_in_out_';
|
|
57825
|
+
|
|
57826
|
+
/**
|
|
57827
|
+
* Opt the user in to data tracking and cookies/localstorage for the given token
|
|
57828
|
+
* @param {string} token - Mixpanel project tracking token
|
|
57829
|
+
* @param {Object} [options]
|
|
57830
|
+
* @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
|
|
57831
|
+
* @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
|
|
57832
|
+
* @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
|
|
57833
|
+
* @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
|
|
57834
|
+
* @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
|
|
57835
|
+
* @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
|
|
57836
|
+
* @param {string} [options.cookieDomain] - custom cookie domain
|
|
57837
|
+
* @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
|
|
57838
|
+
* @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
|
|
57839
|
+
* @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
|
|
57840
|
+
*/
|
|
57841
|
+
function optIn(token, options) {
|
|
57842
|
+
_optInOut(true, token, options);
|
|
57843
|
+
}
|
|
57844
|
+
|
|
57845
|
+
/**
|
|
57846
|
+
* Opt the user out of data tracking and cookies/localstorage for the given token
|
|
57847
|
+
* @param {string} token - Mixpanel project tracking token
|
|
57848
|
+
* @param {Object} [options]
|
|
57849
|
+
* @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
|
|
57850
|
+
* @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
|
|
57851
|
+
* @param {Number} [options.cookieExpiration] - number of days until the opt-out cookie expires
|
|
57852
|
+
* @param {string} [options.cookieDomain] - custom cookie domain
|
|
57853
|
+
* @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
|
|
57854
|
+
* @param {boolean} [options.crossSubdomainCookie] - whether the opt-out cookie is set as cross-subdomain or not
|
|
57855
|
+
* @param {boolean} [options.secureCookie] - whether the opt-out cookie is set as secure or not
|
|
57856
|
+
*/
|
|
57857
|
+
function optOut(token, options) {
|
|
57858
|
+
_optInOut(false, token, options);
|
|
57859
|
+
}
|
|
57860
|
+
|
|
57861
|
+
/**
|
|
57862
|
+
* Get the persistence type to read the opt-in/out flag from. OptOutFlagDecisions writes
|
|
57863
|
+
* the flag to localStorage if it passes the localStorageSupported probe, otherwise to a cookie.
|
|
57864
|
+
* Read that store first, and the other one if no flag is there.
|
|
57865
|
+
* @param {string} token - Mixpanel project tracking token
|
|
57866
|
+
* @param {string} persistenceType - configured persistence type
|
|
57867
|
+
* @param {string} [persistencePrefix] - custom prefix used in the cookie/localstorage name
|
|
57868
|
+
* @returns {string} the persistence type to read
|
|
57869
|
+
*/
|
|
57870
|
+
function getOptOutCheckPersistenceType(token, persistenceType, persistencePrefix) {
|
|
57871
|
+
if (persistenceType !== 'localStorage') {
|
|
57872
|
+
return persistenceType;
|
|
57873
|
+
}
|
|
57874
|
+
var writtenTo = localStorageSupported(getLocalStorage()) ? 'localStorage' : 'cookie';
|
|
57875
|
+
var hasFlag = readOptInOutFlag(token, {persistenceType: writtenTo, persistencePrefix: persistencePrefix}) !== null;
|
|
57876
|
+
if (hasFlag) {
|
|
57877
|
+
return writtenTo;
|
|
57878
|
+
}
|
|
57879
|
+
return writtenTo === 'localStorage' ? 'cookie' : 'localStorage';
|
|
57880
|
+
}
|
|
57881
|
+
|
|
57882
|
+
/**
|
|
57883
|
+
* Clear the user's opt in/out status of data tracking and cookies/localstorage for the given token
|
|
57884
|
+
* @param {string} token - Mixpanel project tracking token
|
|
57885
|
+
* @param {Object} [options]
|
|
57886
|
+
* @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
|
|
57887
|
+
* @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
|
|
57888
|
+
* @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
|
|
57889
|
+
* @param {string} [options.cookieDomain] - custom cookie domain
|
|
57890
|
+
* @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
|
|
57891
|
+
* @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
|
|
57892
|
+
* @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
|
|
57893
|
+
*/
|
|
57894
|
+
function clearOptInOut(token, options) {
|
|
57895
|
+
options = options || {};
|
|
57896
|
+
_getStorage(options).remove(
|
|
57897
|
+
_getStorageKey(token, options), !!options.crossSubdomainCookie, options.cookieDomain
|
|
57898
|
+
);
|
|
57899
|
+
}
|
|
57900
|
+
|
|
57901
|
+
/** Private **/
|
|
57902
|
+
|
|
57903
|
+
/**
|
|
57904
|
+
* Get storage util
|
|
57905
|
+
* @param {Object} [options]
|
|
57906
|
+
* @param {string} [options.persistenceType]
|
|
57907
|
+
* @returns {object} either _.cookie or _.localstorage
|
|
57908
|
+
*/
|
|
57909
|
+
function _getStorage(options) {
|
|
57910
|
+
options = options || {};
|
|
57911
|
+
return options.persistenceType === 'localStorage' ? mixpanel_module_.localStorage : mixpanel_module_.cookie;
|
|
57912
|
+
}
|
|
57913
|
+
|
|
57914
|
+
/**
|
|
57915
|
+
* Get the name of the cookie that is used for the given opt type (tracking, cookie, etc.)
|
|
57916
|
+
* @param {string} token - Mixpanel project tracking token
|
|
57917
|
+
* @param {Object} [options]
|
|
57918
|
+
* @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
|
|
57919
|
+
* @returns {string} the name of the cookie for the given opt type
|
|
57920
|
+
*/
|
|
57921
|
+
function _getStorageKey(token, options) {
|
|
57922
|
+
options = options || {};
|
|
57923
|
+
return (options.persistencePrefix || OPT_IN_OUT_FLAG_PREFIX) + token;
|
|
57924
|
+
}
|
|
57925
|
+
|
|
57926
|
+
/**
|
|
57927
|
+
* Get the value of the cookie that is used for the given opt type (tracking, cookie, etc.)
|
|
57928
|
+
* @param {string} token - Mixpanel project tracking token
|
|
57929
|
+
* @param {Object} [options]
|
|
57930
|
+
* @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
|
|
57931
|
+
* @returns {string} the value of the cookie for the given opt type
|
|
57932
|
+
*/
|
|
57933
|
+
function readOptInOutFlag(token, options) {
|
|
57934
|
+
return _getStorage(options).get(_getStorageKey(token, options));
|
|
57935
|
+
}
|
|
57936
|
+
|
|
57937
|
+
/**
|
|
57938
|
+
* Whether Do Not Track is on for an instance, unless its config or a call's options ignore it.
|
|
57939
|
+
* @param {function(string): *} getConfigFunc the instance's get_config
|
|
57940
|
+
* @param {Object} [options] a call's ignore_dnt option, which overrides the config's
|
|
57941
|
+
* @returns {boolean}
|
|
57942
|
+
*/
|
|
57943
|
+
function doNotTrackApplies(getConfigFunc, options) {
|
|
57944
|
+
options = mixpanel_module_.extend({'ignore_dnt': getConfigFunc('ignore_dnt')}, options);
|
|
57945
|
+
return hasDoNotTrackFlagOn({
|
|
57946
|
+
ignoreDnt: options['ignore_dnt'],
|
|
57947
|
+
window: getConfigFunc('window') // used to override window during browser tests
|
|
57948
|
+
});
|
|
57949
|
+
}
|
|
57950
|
+
|
|
57951
|
+
/**
|
|
57952
|
+
* Check whether the user has set the DNT/doNotTrack setting to true in their browser
|
|
57953
|
+
* @param {Object} [options]
|
|
57954
|
+
* @param {string} [options.window] - alternate window object to check; used to force various DNT settings in browser tests
|
|
57955
|
+
* @param {boolean} [options.ignoreDnt] - flag to ignore browser DNT settings and always return false
|
|
57956
|
+
* @returns {boolean} whether the DNT setting is true
|
|
57957
|
+
*/
|
|
57958
|
+
function hasDoNotTrackFlagOn(options) {
|
|
57959
|
+
if (options && options.ignoreDnt) {
|
|
57960
|
+
return false;
|
|
57961
|
+
}
|
|
57962
|
+
var win$1 = (options && options.window) || mixpanel_module_win;
|
|
57963
|
+
var nav = win$1['navigator'] || {};
|
|
57964
|
+
var hasDntOn = false;
|
|
57965
|
+
|
|
57966
|
+
mixpanel_module_.each([
|
|
57967
|
+
nav['doNotTrack'], // standard
|
|
57968
|
+
nav['msDoNotTrack'],
|
|
57969
|
+
win$1['doNotTrack']
|
|
57970
|
+
], function(dntValue) {
|
|
57971
|
+
if (mixpanel_module_.includes([true, 1, '1', 'yes'], dntValue)) {
|
|
57972
|
+
hasDntOn = true;
|
|
57973
|
+
}
|
|
57974
|
+
});
|
|
57975
|
+
|
|
57976
|
+
return hasDntOn;
|
|
57977
|
+
}
|
|
57978
|
+
|
|
57979
|
+
/**
|
|
57980
|
+
* Set cookie/localstorage for the user indicating that they are opted in or out for the given opt type
|
|
57981
|
+
* @param {boolean} optValue - whether to opt the user in or out for the given opt type
|
|
57982
|
+
* @param {string} token - Mixpanel project tracking token
|
|
57983
|
+
* @param {Object} [options]
|
|
57984
|
+
* @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
|
|
57985
|
+
* @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
|
|
57986
|
+
* @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
|
|
57987
|
+
* @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
|
|
57988
|
+
* @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
|
|
57989
|
+
* @param {string} [options.cookieDomain] - custom cookie domain
|
|
57990
|
+
* @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
|
|
57991
|
+
* @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
|
|
57992
|
+
* @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
|
|
57993
|
+
*/
|
|
57994
|
+
function _optInOut(optValue, token, options) {
|
|
57995
|
+
if (!mixpanel_module_.isString(token) || !token.length) {
|
|
57996
|
+
console$1.error('gdpr.' + (optValue ? 'optIn' : 'optOut') + ' called with an invalid token');
|
|
57997
|
+
return;
|
|
57998
|
+
}
|
|
57999
|
+
|
|
58000
|
+
options = options || {};
|
|
58001
|
+
|
|
58002
|
+
_getStorage(options).set(
|
|
58003
|
+
_getStorageKey(token, options),
|
|
58004
|
+
optValue ? 1 : 0,
|
|
58005
|
+
mixpanel_module_.isNumber(options.cookieExpiration) ? options.cookieExpiration : null,
|
|
58006
|
+
!!options.crossSubdomainCookie,
|
|
58007
|
+
!!options.secureCookie,
|
|
58008
|
+
!!options.crossSiteCookie,
|
|
58009
|
+
options.cookieDomain
|
|
58010
|
+
);
|
|
58011
|
+
|
|
58012
|
+
if (options.track && optValue) { // only track event if opting in (optValue=true)
|
|
58013
|
+
options.track(options.trackEventName || '$opt_in', options.trackProperties, {
|
|
58014
|
+
'send_immediately': true
|
|
58015
|
+
});
|
|
58016
|
+
}
|
|
58017
|
+
}
|
|
58018
|
+
|
|
58019
|
+
/**
|
|
58020
|
+
* Decisions under 'no_consent_required', which is what the opt_out_* configs have always done. The
|
|
58021
|
+
* decision is the opt-out flag in opt_out_tracking_persistence_type, read at every check so another
|
|
58022
|
+
* tab's decision applies at once. A decision's clear_persistence and enable_persistence options
|
|
58023
|
+
* turn the instance's persistence off or on, and opt_out_tracking_by_default stores an opt-out at
|
|
58024
|
+
* init when nothing is stored.
|
|
58025
|
+
*/
|
|
58026
|
+
|
|
58027
|
+
|
|
58028
|
+
/**
|
|
58029
|
+
* @constructor
|
|
58030
|
+
* @param {string} mode
|
|
58031
|
+
* @param {Object} options
|
|
58032
|
+
* @param {function} options.getConfigFunc the instance's get_config
|
|
58033
|
+
* @param {function} options.trackFunc the instance's track, for the $opt_in event
|
|
58034
|
+
* @param {function(boolean)} options.setPersistenceDisabledFunc turn the instance's persistence,
|
|
58035
|
+
* batching and recording off (true) or back on (false)
|
|
58036
|
+
* @param {function} options.deleteUserFunc delete the identified user's profile and charges
|
|
58037
|
+
*/
|
|
58038
|
+
var OptOutFlagDecisions = function(mode, options) {
|
|
58039
|
+
this.mode = mode;
|
|
58040
|
+
this.getConfig = options.getConfigFunc;
|
|
58041
|
+
this.track = options.trackFunc;
|
|
58042
|
+
this.setPersistenceDisabled = options.setPersistenceDisabledFunc;
|
|
58043
|
+
this.deleteUser = options.deleteUserFunc;
|
|
58044
|
+
};
|
|
58045
|
+
|
|
58046
|
+
/**
|
|
58047
|
+
* Move a cookie flag to localStorage if that's the configured store, then apply a stored opt-out,
|
|
58048
|
+
* or opt out when nothing is stored and the configs say to.
|
|
58049
|
+
*/
|
|
58050
|
+
OptOutFlagDecisions.prototype.init = function() {
|
|
58051
|
+
var localStorageRequested = this.getConfig('opt_out_tracking_persistence_type') === 'localStorage';
|
|
58052
|
+
if (localStorageRequested && mixpanel_module_.localStorage.is_supported()) {
|
|
58053
|
+
if (!this.hasOptedIn({'persistence_type': 'localStorage'}) && this.hasOptedIn({'persistence_type': 'cookie'})) {
|
|
58054
|
+
this.optIn({'enable_persistence': false});
|
|
58055
|
+
}
|
|
58056
|
+
if (!this.hasOptedOut({'persistence_type': 'localStorage'}) && this.hasOptedOut({'persistence_type': 'cookie'})) {
|
|
58057
|
+
this.optOut({'clear_persistence': false});
|
|
58058
|
+
}
|
|
58059
|
+
this.clear({
|
|
58060
|
+
'persistence_type': 'cookie',
|
|
58061
|
+
'enable_persistence': false
|
|
58062
|
+
});
|
|
58063
|
+
}
|
|
58064
|
+
|
|
58065
|
+
if (this.hasOptedOut()) {
|
|
58066
|
+
this._updatePersistence({'clear_persistence': true});
|
|
58067
|
+
// persistence isn't cleared here by default, since the opt-out default is often an initial
|
|
58068
|
+
// state while consent is being collected
|
|
58069
|
+
} else if (!this.hasOptedIn() && (this._optsOutByDefault() || mixpanel_module_.cookie.get('mp_optout'))) {
|
|
58070
|
+
mixpanel_module_.cookie.remove('mp_optout');
|
|
58071
|
+
this.optOut({
|
|
58072
|
+
'clear_persistence': this.getConfig('opt_out_persistence_by_default')
|
|
58073
|
+
});
|
|
58074
|
+
}
|
|
58075
|
+
};
|
|
58076
|
+
|
|
58077
|
+
// opt_out_tracking_by_default applies only without consent_mode, which replaces it
|
|
58078
|
+
OptOutFlagDecisions.prototype._optsOutByDefault = function() {
|
|
58079
|
+
return !this.getConfig('consent_mode') && !!this.getConfig('opt_out_tracking_by_default');
|
|
58080
|
+
};
|
|
58081
|
+
|
|
58082
|
+
/**
|
|
58083
|
+
* @returns {string}
|
|
58084
|
+
*/
|
|
58085
|
+
OptOutFlagDecisions.prototype.state = function() {
|
|
58086
|
+
return CONSENT_MODES[this.mode][this._readDecision()];
|
|
58087
|
+
};
|
|
58088
|
+
|
|
58089
|
+
/**
|
|
58090
|
+
* @param {Object} [options] persistence_type and cookie_prefix to read
|
|
58091
|
+
* @returns {boolean}
|
|
58092
|
+
*/
|
|
58093
|
+
OptOutFlagDecisions.prototype.hasOptedIn = function(options) {
|
|
58094
|
+
return this._readFlag(options) === '1';
|
|
58095
|
+
};
|
|
58096
|
+
|
|
58097
|
+
/**
|
|
58098
|
+
* @param {Object} [options] persistence_type, cookie_prefix and ignore_dnt to read with
|
|
58099
|
+
* @returns {boolean}
|
|
58100
|
+
*/
|
|
58101
|
+
OptOutFlagDecisions.prototype.hasOptedOut = function(options) {
|
|
58102
|
+
var decision = this._readDecision(options);
|
|
58103
|
+
return decision === DECISION_OPTED_OUT || decision === DECISION_OBJECTED;
|
|
58104
|
+
};
|
|
58105
|
+
|
|
58106
|
+
/**
|
|
58107
|
+
* @param {Object} [options] opt_in_tracking() options
|
|
58108
|
+
*/
|
|
58109
|
+
OptOutFlagDecisions.prototype.optIn = function(options) {
|
|
58110
|
+
options = mixpanel_module_.extend({'enable_persistence': true}, options);
|
|
58111
|
+
this._writeFlag(optIn, options);
|
|
58112
|
+
this._updatePersistence(options);
|
|
58113
|
+
};
|
|
58114
|
+
|
|
58115
|
+
/**
|
|
58116
|
+
* @param {Object} [options] opt_out_tracking() options
|
|
58117
|
+
*/
|
|
58118
|
+
OptOutFlagDecisions.prototype.optOut = function(options) {
|
|
58119
|
+
options = mixpanel_module_.extend({
|
|
58120
|
+
'clear_persistence': true,
|
|
58121
|
+
'delete_user': true
|
|
58122
|
+
}, options);
|
|
58123
|
+
|
|
58124
|
+
// before the opt-out, which blocks the people calls this makes
|
|
58125
|
+
if (options['delete_user']) {
|
|
58126
|
+
this.deleteUser();
|
|
58127
|
+
}
|
|
58128
|
+
|
|
58129
|
+
this._writeFlag(optOut, options);
|
|
58130
|
+
this._updatePersistence(options);
|
|
58131
|
+
};
|
|
58132
|
+
|
|
58133
|
+
/**
|
|
58134
|
+
* @param {Object} [options] clear_opt_in_out_tracking() options
|
|
58135
|
+
*/
|
|
58136
|
+
OptOutFlagDecisions.prototype.clear = function(options) {
|
|
58137
|
+
options = mixpanel_module_.extend({'enable_persistence': true}, options);
|
|
58138
|
+
this._writeFlag(clearOptInOut, options);
|
|
58139
|
+
this._updatePersistence(options);
|
|
58140
|
+
};
|
|
58141
|
+
|
|
58142
|
+
/**
|
|
58143
|
+
* @param {Object} options a decision's clear_persistence or enable_persistence option
|
|
58144
|
+
*/
|
|
58145
|
+
OptOutFlagDecisions.prototype._updatePersistence = function(options) {
|
|
58146
|
+
if (options['clear_persistence']) {
|
|
58147
|
+
this.setPersistenceDisabled(true);
|
|
58148
|
+
} else if (options['enable_persistence']) {
|
|
58149
|
+
this.setPersistenceDisabled(false);
|
|
58150
|
+
}
|
|
58151
|
+
};
|
|
58152
|
+
|
|
58153
|
+
/**
|
|
58154
|
+
* Call an opt-out-flag write with the instance's opt-out flag and cookie config, overridden by the
|
|
58155
|
+
* call's options.
|
|
58156
|
+
* @param {function} func optIn, optOut or clearOptInOut
|
|
58157
|
+
* @param {Object} options
|
|
58158
|
+
*/
|
|
58159
|
+
OptOutFlagDecisions.prototype._writeFlag = function(func, options) {
|
|
58160
|
+
var getConfig = this.getConfig;
|
|
58161
|
+
options = mixpanel_module_.extend({
|
|
58162
|
+
'track': this.track,
|
|
58163
|
+
'persistence_type': getConfig('opt_out_tracking_persistence_type'),
|
|
58164
|
+
'cookie_prefix': getConfig('opt_out_tracking_cookie_prefix'),
|
|
58165
|
+
'cookie_expiration': getConfig('cookie_expiration'),
|
|
58166
|
+
'cross_site_cookie': getConfig('cross_site_cookie'),
|
|
58167
|
+
'cross_subdomain_cookie': getConfig('cross_subdomain_cookie'),
|
|
58168
|
+
'cookie_domain': getConfig('cookie_domain'),
|
|
58169
|
+
'secure_cookie': getConfig('secure_cookie')
|
|
58170
|
+
}, options);
|
|
58171
|
+
|
|
58172
|
+
// check if localStorage can be used for recording opt out status, fall back to cookie if not
|
|
58173
|
+
if (!mixpanel_module_.localStorage.is_supported()) {
|
|
58174
|
+
options['persistence_type'] = 'cookie';
|
|
58175
|
+
}
|
|
58176
|
+
|
|
58177
|
+
func(getConfig('token'), {
|
|
58178
|
+
track: options['track'],
|
|
58179
|
+
trackEventName: options['track_event_name'],
|
|
58180
|
+
trackProperties: options['track_properties'],
|
|
58181
|
+
persistenceType: options['persistence_type'],
|
|
58182
|
+
persistencePrefix: options['cookie_prefix'],
|
|
58183
|
+
cookieDomain: options['cookie_domain'],
|
|
58184
|
+
cookieExpiration: options['cookie_expiration'],
|
|
58185
|
+
crossSiteCookie: options['cross_site_cookie'],
|
|
58186
|
+
crossSubdomainCookie: options['cross_subdomain_cookie'],
|
|
58187
|
+
secureCookie: options['secure_cookie']
|
|
58188
|
+
});
|
|
58189
|
+
};
|
|
58190
|
+
|
|
58191
|
+
/**
|
|
58192
|
+
* @param {Object} [options] persistence_type, cookie_prefix and ignore_dnt to read with
|
|
58193
|
+
* @returns {string}
|
|
58194
|
+
*/
|
|
58195
|
+
OptOutFlagDecisions.prototype._readDecision = function(options) {
|
|
58196
|
+
return readDecision(doNotTrackApplies(this.getConfig, options), this._readFlag(options));
|
|
58197
|
+
};
|
|
58198
|
+
|
|
58199
|
+
/**
|
|
58200
|
+
* The opt-out flag, from the store that holds it unless options name one.
|
|
58201
|
+
* @param {Object} [options] persistence_type and cookie_prefix to read
|
|
58202
|
+
* @returns {string|null} '1', '0', or null when there's none
|
|
58203
|
+
*/
|
|
58204
|
+
OptOutFlagDecisions.prototype._readFlag = function(options) {
|
|
58205
|
+
options = mixpanel_module_.extend({
|
|
58206
|
+
'cookie_prefix': this.getConfig('opt_out_tracking_cookie_prefix')
|
|
58207
|
+
}, options);
|
|
58208
|
+
|
|
58209
|
+
var token = this.getConfig('token');
|
|
58210
|
+
var persistenceType = options['persistence_type'];
|
|
58211
|
+
if (!persistenceType) {
|
|
58212
|
+
persistenceType = getOptOutCheckPersistenceType(
|
|
58213
|
+
token, this.getConfig('opt_out_tracking_persistence_type'), options['cookie_prefix']
|
|
58214
|
+
);
|
|
58215
|
+
} else if (!mixpanel_module_.localStorage.is_supported()) {
|
|
58216
|
+
persistenceType = 'cookie';
|
|
58217
|
+
}
|
|
58218
|
+
|
|
58219
|
+
return readOptInOutFlag(token, {
|
|
58220
|
+
persistenceType: persistenceType,
|
|
58221
|
+
persistencePrefix: options['cookie_prefix']
|
|
58222
|
+
});
|
|
58223
|
+
};
|
|
58224
|
+
|
|
58225
|
+
/**
|
|
58226
|
+
* Decisions under 'require_consent'. The decision is stored with the persistence, so a subdomain
|
|
58227
|
+
* sharing the identity cookie shares it. The state is read once, when the instance is built, and
|
|
58228
|
+
* then changed only by this page's decisions; storage opens and closes when it changes, and without
|
|
58229
|
+
* consent to store, everything stored about the visitor but the decision is deleted.
|
|
58230
|
+
*
|
|
58231
|
+
* The constructor reads the stored decision and writes nothing, so the instance can ask allows()
|
|
58232
|
+
* while it builds persistence and the services. init() runs once they exist and makes the writes.
|
|
58233
|
+
*/
|
|
58234
|
+
|
|
58235
|
+
|
|
58236
|
+
/**
|
|
58237
|
+
* @constructor
|
|
58238
|
+
* @param {string} mode
|
|
58239
|
+
* @param {Object} options
|
|
58240
|
+
* @param {function} options.getConfigFunc the instance's get_config
|
|
58241
|
+
* @param {function} options.trackFunc the instance's track, for the $opt_in event
|
|
58242
|
+
* @param {function} options.startTrackingFunc open storage and start the services when the state
|
|
58243
|
+
* starts allowing storage
|
|
58244
|
+
* @param {function} options.stopTrackingFunc stop the services and close storage when it stops
|
|
58245
|
+
* @param {function} options.purgeIdentifiersFunc delete everything stored about the visitor except
|
|
58246
|
+
* the decision
|
|
58247
|
+
*/
|
|
58248
|
+
var ConsentDecisions = function(mode, options) {
|
|
58249
|
+
this.mode = mode;
|
|
58250
|
+
this.getConfig = options.getConfigFunc;
|
|
58251
|
+
this.track = options.trackFunc;
|
|
58252
|
+
this.startTracking = options.startTrackingFunc;
|
|
58253
|
+
this.stopTracking = options.stopTrackingFunc;
|
|
58254
|
+
this.purgeIdentifiers = options.purgeIdentifiersFunc;
|
|
58255
|
+
// read from storage the first time it's asked for
|
|
58256
|
+
this.appliedState = null;
|
|
58257
|
+
};
|
|
58258
|
+
|
|
58259
|
+
// delete what an earlier page stored without consent
|
|
58260
|
+
ConsentDecisions.prototype.init = function() {
|
|
58261
|
+
this._reconcile();
|
|
58262
|
+
};
|
|
58263
|
+
|
|
58264
|
+
/**
|
|
58265
|
+
* @returns {string}
|
|
58266
|
+
*/
|
|
58267
|
+
ConsentDecisions.prototype.state = function() {
|
|
58268
|
+
if (this.appliedState === null) {
|
|
58269
|
+
this.appliedState = CONSENT_MODES[this.mode][this._readDecision()];
|
|
58270
|
+
}
|
|
58271
|
+
return this.appliedState;
|
|
58272
|
+
};
|
|
58273
|
+
|
|
58274
|
+
/**
|
|
58275
|
+
* @returns {boolean}
|
|
58276
|
+
*/
|
|
58277
|
+
ConsentDecisions.prototype.hasOptedIn = function() {
|
|
58278
|
+
return this._readFlag() === '1';
|
|
58279
|
+
};
|
|
58280
|
+
|
|
58281
|
+
/**
|
|
58282
|
+
* @param {Object} [options] a call's ignore_dnt option
|
|
58283
|
+
* @returns {boolean}
|
|
58284
|
+
*/
|
|
58285
|
+
ConsentDecisions.prototype.hasOptedOut = function(options) {
|
|
58286
|
+
var decision = this._readDecision(options);
|
|
58287
|
+
return decision === DECISION_OPTED_OUT || decision === DECISION_OBJECTED;
|
|
58288
|
+
};
|
|
58289
|
+
|
|
58290
|
+
/**
|
|
58291
|
+
* @param {Object} [options] opt_in_tracking() options; only the track options apply
|
|
58292
|
+
*/
|
|
58293
|
+
ConsentDecisions.prototype.optIn = function(options) {
|
|
58294
|
+
this._decide(DECISION_OPTED_IN, options);
|
|
58295
|
+
};
|
|
58296
|
+
|
|
58297
|
+
ConsentDecisions.prototype.optOut = function() {
|
|
58298
|
+
this._decide(DECISION_OPTED_OUT);
|
|
58299
|
+
};
|
|
58300
|
+
|
|
58301
|
+
ConsentDecisions.prototype.clear = function() {
|
|
58302
|
+
this._decide(DECISION_NONE);
|
|
58303
|
+
};
|
|
58304
|
+
|
|
58305
|
+
/**
|
|
58306
|
+
* Store a decision, move this page's state to match it, and open or close storage when that
|
|
58307
|
+
* changes whether storage is allowed.
|
|
58308
|
+
* @param {string} decision
|
|
58309
|
+
* @param {Object} [options] opt_in_tracking() options
|
|
58310
|
+
*/
|
|
58311
|
+
ConsentDecisions.prototype._decide = function(decision, options) {
|
|
58312
|
+
options = options || {};
|
|
58313
|
+
var wasStoring = this._allowsStore();
|
|
58314
|
+
this._writeDecision(decision);
|
|
58315
|
+
|
|
58316
|
+
// the state changes before the services start or stop, because they ask it. It follows the
|
|
58317
|
+
// decision even if storing it failed; Do Not Track still wins.
|
|
58318
|
+
this.appliedState = CONSENT_MODES[this.mode][doNotTrackApplies(this.getConfig) ? DECISION_OBJECTED : decision];
|
|
58319
|
+
var storing = this._allowsStore();
|
|
58320
|
+
|
|
58321
|
+
if (wasStoring && !storing) {
|
|
58322
|
+
this.stopTracking();
|
|
58323
|
+
}
|
|
58324
|
+
this._reconcile();
|
|
58325
|
+
if (!wasStoring && storing) {
|
|
58326
|
+
this.startTracking();
|
|
58327
|
+
}
|
|
58328
|
+
|
|
58329
|
+
// after the services start, so it carries the visitor's ID and a recording it triggers finds
|
|
58330
|
+
// replay set up
|
|
58331
|
+
var track = mixpanel_module_.isUndefined(options['track']) ? this.track : options['track'];
|
|
58332
|
+
if (decision === DECISION_OPTED_IN && storing && track) {
|
|
58333
|
+
track(options['track_event_name'] || '$opt_in', options['track_properties'], {'send_immediately': true});
|
|
58334
|
+
}
|
|
58335
|
+
};
|
|
58336
|
+
|
|
58337
|
+
ConsentDecisions.prototype._allowsStore = function() {
|
|
58338
|
+
return CONSENT_STATES[this.state()]['store'] === true;
|
|
58339
|
+
};
|
|
58340
|
+
|
|
58341
|
+
/**
|
|
58342
|
+
* Make what's stored match the state, whatever an earlier page, SDK version or decision left:
|
|
58343
|
+
* without consent to store, delete everything about the visitor but the decision.
|
|
58344
|
+
*/
|
|
58345
|
+
ConsentDecisions.prototype._reconcile = function() {
|
|
58346
|
+
if (!this._allowsStore()) {
|
|
58347
|
+
this.purgeIdentifiers();
|
|
58348
|
+
}
|
|
58349
|
+
};
|
|
58350
|
+
|
|
58351
|
+
/**
|
|
58352
|
+
* Store a decision as the opt-out flag ('1' for an opt-in, '0' for an opt-out), removed at every
|
|
58353
|
+
* cookie scope first so a copy an earlier config left can't shadow it.
|
|
58354
|
+
* @param {string} decision
|
|
58355
|
+
*/
|
|
58356
|
+
ConsentDecisions.prototype._writeDecision = function(decision) {
|
|
58357
|
+
var flag = null;
|
|
58358
|
+
if (decision === DECISION_OPTED_IN) {
|
|
58359
|
+
flag = '1';
|
|
58360
|
+
} else if (decision === DECISION_OPTED_OUT) {
|
|
58361
|
+
flag = '0';
|
|
58362
|
+
}
|
|
58363
|
+
// a decision that's already stored isn't written again
|
|
58364
|
+
if (this._readFlag() === flag) {
|
|
58365
|
+
return;
|
|
58366
|
+
}
|
|
58367
|
+
this._writeDecisionKey(this._decisionKey(), flag);
|
|
58368
|
+
};
|
|
58369
|
+
|
|
58370
|
+
/**
|
|
58371
|
+
* @param {string} key
|
|
58372
|
+
* @param {string|null} value null to remove it
|
|
58373
|
+
*/
|
|
58374
|
+
ConsentDecisions.prototype._writeDecisionKey = function(key, value) {
|
|
58375
|
+
var getConfig = this.getConfig;
|
|
58376
|
+
var cookieDomain = getConfig('cookie_domain');
|
|
58377
|
+
mixpanel_module_.cookie.remove(key);
|
|
58378
|
+
mixpanel_module_.cookie.remove(key, true);
|
|
58379
|
+
if (cookieDomain) {
|
|
58380
|
+
mixpanel_module_.cookie.remove(key, false, cookieDomain);
|
|
58381
|
+
}
|
|
58382
|
+
if (this._decisionInLocalStorage()) {
|
|
58383
|
+
if (value === null) {
|
|
58384
|
+
mixpanel_module_.localStorage.remove(key);
|
|
58385
|
+
} else {
|
|
58386
|
+
mixpanel_module_.localStorage.set(key, value);
|
|
58387
|
+
}
|
|
58388
|
+
} else if (value !== null) {
|
|
58389
|
+
mixpanel_module_.cookie.set(
|
|
58390
|
+
key,
|
|
58391
|
+
value,
|
|
58392
|
+
getConfig('cookie_expiration'),
|
|
58393
|
+
getConfig('cross_subdomain_cookie'),
|
|
58394
|
+
getConfig('secure_cookie'),
|
|
58395
|
+
getConfig('cross_site_cookie'),
|
|
58396
|
+
cookieDomain
|
|
58397
|
+
);
|
|
58398
|
+
}
|
|
58399
|
+
};
|
|
58400
|
+
|
|
58401
|
+
// the store the persistence uses, chosen without the localStorage support probe, which writes a key
|
|
58402
|
+
ConsentDecisions.prototype._decisionInLocalStorage = function() {
|
|
58403
|
+
return this.getConfig('persistence') === 'localStorage' && !!getLocalStorage();
|
|
58404
|
+
};
|
|
58405
|
+
|
|
58406
|
+
ConsentDecisions.prototype._decisionStore = function() {
|
|
58407
|
+
return this._decisionInLocalStorage() ? mixpanel_module_.localStorage : mixpanel_module_.cookie;
|
|
58408
|
+
};
|
|
58409
|
+
|
|
58410
|
+
ConsentDecisions.prototype._decisionKey = function() {
|
|
58411
|
+
return (this.getConfig('opt_out_tracking_cookie_prefix') || OPT_IN_OUT_FLAG_PREFIX) + this.getConfig('token');
|
|
58412
|
+
};
|
|
58413
|
+
|
|
58414
|
+
/**
|
|
58415
|
+
* @param {Object} [options] a call's ignore_dnt option
|
|
58416
|
+
* @returns {string}
|
|
58417
|
+
*/
|
|
58418
|
+
ConsentDecisions.prototype._readDecision = function(options) {
|
|
58419
|
+
return readDecision(doNotTrackApplies(this.getConfig, options), this._readFlag());
|
|
58420
|
+
};
|
|
58421
|
+
|
|
58422
|
+
/**
|
|
58423
|
+
* @returns {string|null} the stored opt-out flag: '1', '0', or null when there's none
|
|
58424
|
+
*/
|
|
58425
|
+
ConsentDecisions.prototype._readFlag = function() {
|
|
58426
|
+
return this._decisionStore().get(this._decisionKey());
|
|
58427
|
+
};
|
|
58428
|
+
|
|
58429
|
+
/**
|
|
58430
|
+
* Consent for one instance, and the instance's ConsentGate: the rest of the SDK asks its
|
|
58431
|
+
* allowsApiCalls(), allowsSending() and so on, and never reads the mode. The mode picks a row of
|
|
58432
|
+
* CONSENT_MODES (consent-modes.js), which maps the visitor's decision to a state, and
|
|
58433
|
+
* CONSENT_STATES says what that state allows. Where the decision is stored, and what changes when
|
|
58434
|
+
* the visitor decides, is up to OptOutFlagDecisions under 'no_consent_required' and
|
|
58435
|
+
* ConsentDecisions under the other modes.
|
|
58436
|
+
*/
|
|
58437
|
+
|
|
58438
|
+
|
|
58439
|
+
/**
|
|
58440
|
+
* The answers that are the same in every state a mode can reach, which allows() gives without
|
|
58441
|
+
* reading the decision.
|
|
58442
|
+
* @param {string} mode
|
|
58443
|
+
* @returns {Object<string, boolean>}
|
|
58444
|
+
*/
|
|
58445
|
+
function fixedAnswers(mode) {
|
|
58446
|
+
var states = mixpanel_module_.values(CONSENT_MODES[mode]);
|
|
58447
|
+
var answers = {};
|
|
58448
|
+
mixpanel_module_.each(CAPABILITIES, function(capability) {
|
|
58449
|
+
var answer = CONSENT_STATES[states[0]][capability];
|
|
58450
|
+
var same = true;
|
|
58451
|
+
mixpanel_module_.each(states, function(state) {
|
|
58452
|
+
same = same && CONSENT_STATES[state][capability] === answer;
|
|
58453
|
+
});
|
|
58454
|
+
if (same) {
|
|
58455
|
+
answers[capability] = answer;
|
|
58456
|
+
}
|
|
58457
|
+
});
|
|
58458
|
+
return answers;
|
|
58459
|
+
}
|
|
58460
|
+
|
|
58461
|
+
/**
|
|
58462
|
+
* @constructor
|
|
58463
|
+
* @param {Object} options the options of OptOutFlagDecisions and ConsentDecisions; each uses its
|
|
58464
|
+
* own
|
|
58465
|
+
*/
|
|
58466
|
+
var ConsentManager = function(options) {
|
|
58467
|
+
this.getConfig = options.getConfigFunc;
|
|
58468
|
+
this.mode = resolveConsentMode(options.getConfigFunc('consent_mode'));
|
|
58469
|
+
this.fixedAnswers = fixedAnswers(this.mode);
|
|
58470
|
+
this.decisions = this.mode === CONSENT_MODE_NO_CONSENT_REQUIRED ?
|
|
58471
|
+
new OptOutFlagDecisions(this.mode, options) :
|
|
58472
|
+
new ConsentDecisions(this.mode, options);
|
|
58473
|
+
mixpanel_module_.extend(this, buildConsentGate(mixpanel_module_.bind(this.allows, this), this.getConfig));
|
|
58474
|
+
// the arguments of the latest identify() made while storage isn't allowed
|
|
58475
|
+
this.heldIdentify = null;
|
|
58476
|
+
};
|
|
58477
|
+
|
|
58478
|
+
/**
|
|
58479
|
+
* Whether the visitor's current state allows something. The rest of the SDK asks the ConsentGate
|
|
58480
|
+
* methods built on this.
|
|
58481
|
+
* @param {string} capability 'api_calls', 'send', 'fetch' or 'store'
|
|
58482
|
+
* @returns {boolean}
|
|
58483
|
+
*/
|
|
58484
|
+
ConsentManager.prototype.allows = function(capability) {
|
|
58485
|
+
if (this.fixedAnswers.hasOwnProperty(capability)) {
|
|
58486
|
+
return this.fixedAnswers[capability];
|
|
58487
|
+
}
|
|
58488
|
+
return CONSENT_STATES[this.state()][capability];
|
|
58489
|
+
};
|
|
58490
|
+
|
|
58491
|
+
/**
|
|
58492
|
+
* @returns {string}
|
|
58493
|
+
*/
|
|
58494
|
+
ConsentManager.prototype.state = function() {
|
|
58495
|
+
return this.decisions.state();
|
|
58496
|
+
};
|
|
58497
|
+
|
|
58498
|
+
/**
|
|
58499
|
+
* Keep an identify() made while storage isn't allowed, to apply if the visitor opts in on this page.
|
|
58500
|
+
* @param {Array} identifyArgs
|
|
58501
|
+
*/
|
|
58502
|
+
ConsentManager.prototype.holdIdentify = function(identifyArgs) {
|
|
58503
|
+
this.heldIdentify = identifyArgs;
|
|
58504
|
+
};
|
|
58505
|
+
|
|
58506
|
+
/**
|
|
58507
|
+
* @returns {Array|null} the held identify() arguments, which are then no longer held
|
|
58508
|
+
*/
|
|
58509
|
+
ConsentManager.prototype.takeHeldIdentify = function() {
|
|
58510
|
+
var identifyArgs = this.heldIdentify;
|
|
58511
|
+
this.heldIdentify = null;
|
|
58512
|
+
return identifyArgs;
|
|
58513
|
+
};
|
|
58514
|
+
|
|
58515
|
+
/**
|
|
58516
|
+
* Make the writes the stored decision calls for, once the instance has built the persistence and
|
|
58517
|
+
* services they touch. allows() already answers before this.
|
|
58518
|
+
*/
|
|
58519
|
+
ConsentManager.prototype.init = function() {
|
|
58520
|
+
this.decisions.init();
|
|
58521
|
+
};
|
|
58522
|
+
|
|
58523
|
+
/**
|
|
58524
|
+
* @param {Object} [options] has_opted_in_tracking() options
|
|
58525
|
+
* @returns {boolean}
|
|
58526
|
+
*/
|
|
58527
|
+
ConsentManager.prototype.hasOptedIn = function(options) {
|
|
58528
|
+
return this.decisions.hasOptedIn(options);
|
|
58529
|
+
};
|
|
58530
|
+
|
|
58531
|
+
/**
|
|
58532
|
+
* @param {Object} [options] has_opted_out_tracking() options
|
|
58533
|
+
* @returns {boolean}
|
|
58534
|
+
*/
|
|
58535
|
+
ConsentManager.prototype.hasOptedOut = function(options) {
|
|
58536
|
+
return this.decisions.hasOptedOut(options);
|
|
58537
|
+
};
|
|
58538
|
+
|
|
58539
|
+
/**
|
|
58540
|
+
* @param {Object} [options] opt_in_tracking() options
|
|
58541
|
+
*/
|
|
58542
|
+
ConsentManager.prototype.optIn = function(options) {
|
|
58543
|
+
this.decisions.optIn(options);
|
|
58544
|
+
};
|
|
58545
|
+
|
|
58546
|
+
/**
|
|
58547
|
+
* @param {Object} [options] opt_out_tracking() options
|
|
58548
|
+
*/
|
|
58549
|
+
ConsentManager.prototype.optOut = function(options) {
|
|
58550
|
+
this.decisions.optOut(options);
|
|
58551
|
+
};
|
|
58552
|
+
|
|
58553
|
+
/**
|
|
58554
|
+
* @param {Object} [options] clear_opt_in_out_tracking() options
|
|
58555
|
+
*/
|
|
58556
|
+
ConsentManager.prototype.clear = function(options) {
|
|
58557
|
+
this.decisions.clear(options);
|
|
58558
|
+
};
|
|
58559
|
+
|
|
57646
58560
|
/* eslint camelcase: "off" */
|
|
57647
58561
|
|
|
57648
58562
|
/*
|
|
@@ -57761,6 +58675,7 @@ var DEFAULT_CONFIG = {
|
|
|
57761
58675
|
'opt_out_persistence_by_default': false,
|
|
57762
58676
|
'opt_out_tracking_persistence_type': 'localStorage',
|
|
57763
58677
|
'opt_out_tracking_cookie_prefix': null,
|
|
58678
|
+
'consent_mode': null,
|
|
57764
58679
|
'property_blacklist': [],
|
|
57765
58680
|
'xhr_headers': {}, // { header: value, header2: value }
|
|
57766
58681
|
'ignore_dnt': false,
|
|
@@ -57795,9 +58710,9 @@ var DOM_LOADED = false;
|
|
|
57795
58710
|
|
|
57796
58711
|
/**
|
|
57797
58712
|
* Mixpanel Library Object
|
|
57798
|
-
* @
|
|
58713
|
+
* @class
|
|
57799
58714
|
*/
|
|
57800
|
-
|
|
58715
|
+
function MixpanelLib() {}
|
|
57801
58716
|
|
|
57802
58717
|
|
|
57803
58718
|
/**
|
|
@@ -57827,26 +58742,9 @@ var create_mplib = function(token, config, name) {
|
|
|
57827
58742
|
instance._init(token, config, name);
|
|
57828
58743
|
|
|
57829
58744
|
instance['people'] = new MixpanelPeople();
|
|
57830
|
-
instance['people']._init(instance);
|
|
58745
|
+
instance['people']._init(instance, instance._consent);
|
|
57831
58746
|
|
|
57832
|
-
|
|
57833
|
-
// We need null UTM params in the object because
|
|
57834
|
-
// UTM parameters act as a tuple. If any UTM param
|
|
57835
|
-
// is present, then we set all UTM params including
|
|
57836
|
-
// empty ones together
|
|
57837
|
-
var utm_params = mixpanel_module_.info.campaignParams(null);
|
|
57838
|
-
var initial_utm_params = {};
|
|
57839
|
-
var has_utm = false;
|
|
57840
|
-
mixpanel_module_.each(utm_params, function(utm_value, utm_key) {
|
|
57841
|
-
initial_utm_params['initial_' + utm_key] = utm_value;
|
|
57842
|
-
if (utm_value) {
|
|
57843
|
-
has_utm = true;
|
|
57844
|
-
}
|
|
57845
|
-
});
|
|
57846
|
-
if (has_utm) {
|
|
57847
|
-
instance['people'].set_once(initial_utm_params);
|
|
57848
|
-
}
|
|
57849
|
-
}
|
|
58747
|
+
instance._set_first_touch_people_properties();
|
|
57850
58748
|
|
|
57851
58749
|
// if any instance on the page has debug = true, we set the
|
|
57852
58750
|
// global debug to be true
|
|
@@ -57890,7 +58788,7 @@ var create_mplib = function(token, config, name) {
|
|
|
57890
58788
|
* mixpanel.library_name.track(...);
|
|
57891
58789
|
*
|
|
57892
58790
|
* @param {String} token Your Mixpanel API token
|
|
57893
|
-
* @param {
|
|
58791
|
+
* @param {Partial<import('./index.d.ts').Config>} [config] A dictionary of config options to override; see the Config type for the available options and their defaults.
|
|
57894
58792
|
* @param {String} [name] The name for the new mixpanel instance that you want created
|
|
57895
58793
|
*/
|
|
57896
58794
|
MixpanelLib.prototype.init = function (token, config, name) {
|
|
@@ -57941,6 +58839,19 @@ MixpanelLib.prototype._init = function(token, config, name) {
|
|
|
57941
58839
|
'callback_fn': ((name === PRIMARY_INSTANCE_NAME) ? name : PRIMARY_INSTANCE_NAME + '.' + name) + '._jsc'
|
|
57942
58840
|
}));
|
|
57943
58841
|
|
|
58842
|
+
this._consent = new ConsentManager({
|
|
58843
|
+
getConfigFunc: mixpanel_module_.bind(this.get_config, this),
|
|
58844
|
+
// looks track up at each call, so a wrapper added after init sees it
|
|
58845
|
+
trackFunc: mixpanel_module_.bind(function() {
|
|
58846
|
+
return this.track.apply(this, arguments);
|
|
58847
|
+
}, this),
|
|
58848
|
+
setPersistenceDisabledFunc: mixpanel_module_.bind(this._set_persistence_disabled, this),
|
|
58849
|
+
deleteUserFunc: mixpanel_module_.bind(this._delete_user_for_opt_out, this),
|
|
58850
|
+
startTrackingFunc: mixpanel_module_.bind(this._start_tracking, this),
|
|
58851
|
+
stopTrackingFunc: mixpanel_module_.bind(this._stop_tracking, this),
|
|
58852
|
+
purgeIdentifiersFunc: mixpanel_module_.bind(this._purge_stored_identifiers, this)
|
|
58853
|
+
});
|
|
58854
|
+
|
|
57944
58855
|
this.recorderManager = new RecorderManager({
|
|
57945
58856
|
mixpanelInstance: this,
|
|
57946
58857
|
getConfigFunc: mixpanel_module_.bind(this.get_config, this),
|
|
@@ -57948,6 +58859,7 @@ MixpanelLib.prototype._init = function(token, config, name) {
|
|
|
57948
58859
|
getTabIdFunc: mixpanel_module_.bind(this.get_tab_id, this),
|
|
57949
58860
|
reportErrorFunc: mixpanel_module_.bind(this.report_error, this),
|
|
57950
58861
|
getDistinctIdFunc: mixpanel_module_.bind(this.get_distinct_id, this),
|
|
58862
|
+
consentGate: this._consent,
|
|
57951
58863
|
recorderSrc: this.get_config('recorder_src'),
|
|
57952
58864
|
targetingSrc: this.get_config('targeting_src'),
|
|
57953
58865
|
libBasePath: this.get_config('lib_base_path'),
|
|
@@ -57965,64 +58877,16 @@ MixpanelLib.prototype._init = function(token, config, name) {
|
|
|
57965
58877
|
};
|
|
57966
58878
|
this._remote_settings_strict_disabled = false;
|
|
57967
58879
|
|
|
57968
|
-
// set up request queueing/batching
|
|
57969
58880
|
this.request_batchers = {};
|
|
57970
|
-
|
|
57971
|
-
|
|
57972
|
-
|
|
57973
|
-
|
|
57974
|
-
|
|
57975
|
-
mixpanel_module_.each(this.get_batcher_configs(), function(batcher_config) {
|
|
57976
|
-
console$1.log('Clearing batch queue ' + batcher_config.queue_key);
|
|
57977
|
-
mixpanel_module_.localStorage.remove(batcher_config.queue_key);
|
|
57978
|
-
});
|
|
57979
|
-
} else {
|
|
57980
|
-
this.init_batchers();
|
|
57981
|
-
if (sendBeacon && mixpanel_module_win.addEventListener) {
|
|
57982
|
-
// Before page closes or hides (user tabs away etc), attempt to flush any events
|
|
57983
|
-
// queued up via navigator.sendBeacon. Since sendBeacon doesn't report success/failure,
|
|
57984
|
-
// events will not be removed from the persistent store; if the site is loaded again,
|
|
57985
|
-
// the events will be flushed again on startup and deduplicated on the Mixpanel server
|
|
57986
|
-
// side.
|
|
57987
|
-
// There is no reliable way to capture only page close events, so we lean on the
|
|
57988
|
-
// visibilitychange and pagehide events as recommended at
|
|
57989
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event#usage_notes.
|
|
57990
|
-
// These events fire when the user clicks away from the current page/tab, so will occur
|
|
57991
|
-
// more frequently than page unload, but are the only mechanism currently for capturing
|
|
57992
|
-
// this scenario somewhat reliably.
|
|
57993
|
-
var flush_on_unload = mixpanel_module_.bind(function() {
|
|
57994
|
-
if (!this.request_batchers.events.stopped) {
|
|
57995
|
-
this.request_batchers.events.flush({unloading: true});
|
|
57996
|
-
}
|
|
57997
|
-
}, this);
|
|
57998
|
-
mixpanel_module_win.addEventListener('pagehide', function(ev) {
|
|
57999
|
-
if (ev['persisted']) {
|
|
58000
|
-
flush_on_unload();
|
|
58001
|
-
}
|
|
58002
|
-
});
|
|
58003
|
-
mixpanel_module_win.addEventListener('visibilitychange', function() {
|
|
58004
|
-
if (document$1['visibilityState'] === 'hidden') {
|
|
58005
|
-
flush_on_unload();
|
|
58006
|
-
}
|
|
58007
|
-
});
|
|
58008
|
-
}
|
|
58009
|
-
}
|
|
58881
|
+
// without consent to store, the props stay in memory, and batching and the services wait for
|
|
58882
|
+
// _start_tracking()
|
|
58883
|
+
var allows_storage = this._consent.allowsStoring();
|
|
58884
|
+
if (allows_storage) {
|
|
58885
|
+
this._init_batching();
|
|
58010
58886
|
}
|
|
58011
58887
|
|
|
58012
|
-
this['persistence'] = this['cookie'] = new MixpanelPersistence(this['config']);
|
|
58888
|
+
this['persistence'] = this['cookie'] = new MixpanelPersistence(this['config'], {closed: !allows_storage});
|
|
58013
58889
|
this.unpersisted_superprops = {};
|
|
58014
|
-
this._gdpr_init();
|
|
58015
|
-
|
|
58016
|
-
var uuid = mixpanel_module_.UUID();
|
|
58017
|
-
if (!this.get_distinct_id()) {
|
|
58018
|
-
// There is no need to set the distinct id
|
|
58019
|
-
// or the device id if something was already stored
|
|
58020
|
-
// in the persitence
|
|
58021
|
-
this.register_once({
|
|
58022
|
-
'distinct_id': DEVICE_ID_PREFIX + uuid,
|
|
58023
|
-
'$device_id': uuid
|
|
58024
|
-
}, '');
|
|
58025
|
-
}
|
|
58026
58890
|
|
|
58027
58891
|
this.flags = new FeatureFlagManager({
|
|
58028
58892
|
getFullApiRoute: mixpanel_module_.bind(function() {
|
|
@@ -58032,12 +58896,52 @@ MixpanelLib.prototype._init = function(token, config, name) {
|
|
|
58032
58896
|
setConfigFunc: mixpanel_module_.bind(this.set_config, this),
|
|
58033
58897
|
getPropertyFunc: mixpanel_module_.bind(this.get_property, this),
|
|
58034
58898
|
trackingFunc: mixpanel_module_.bind(this.track, this),
|
|
58899
|
+
consentGate: this._consent,
|
|
58035
58900
|
loadExtraBundle: load_extra_bundle,
|
|
58036
58901
|
targetingSrc: this.get_config('targeting_src') || (this.get_config('lib_base_path') + TARGETING_FILENAME)
|
|
58037
58902
|
});
|
|
58038
|
-
this.flags.init();
|
|
58039
58903
|
this['flags'] = this.flags;
|
|
58040
58904
|
|
|
58905
|
+
this._consent.init();
|
|
58906
|
+
if (allows_storage) {
|
|
58907
|
+
this._start_services();
|
|
58908
|
+
}
|
|
58909
|
+
|
|
58910
|
+
this.autocapture = new Autocapture(this);
|
|
58911
|
+
this.autocapture.init();
|
|
58912
|
+
};
|
|
58913
|
+
|
|
58914
|
+
MixpanelLib.prototype._set_first_touch_people_properties = function() {
|
|
58915
|
+
if (this.get_config('skip_first_touch_marketing')) {
|
|
58916
|
+
return;
|
|
58917
|
+
}
|
|
58918
|
+
// We need null UTM params in the object because
|
|
58919
|
+
// UTM parameters act as a tuple. If any UTM param
|
|
58920
|
+
// is present, then we set all UTM params including
|
|
58921
|
+
// empty ones together
|
|
58922
|
+
var utm_params = mixpanel_module_.info.campaignParams(null);
|
|
58923
|
+
var initial_utm_params = {};
|
|
58924
|
+
var has_utm = false;
|
|
58925
|
+
mixpanel_module_.each(utm_params, function(utm_value, utm_key) {
|
|
58926
|
+
initial_utm_params['initial_' + utm_key] = utm_value;
|
|
58927
|
+
if (utm_value) {
|
|
58928
|
+
has_utm = true;
|
|
58929
|
+
}
|
|
58930
|
+
});
|
|
58931
|
+
if (has_utm) {
|
|
58932
|
+
this['people'].set_once(initial_utm_params);
|
|
58933
|
+
}
|
|
58934
|
+
};
|
|
58935
|
+
|
|
58936
|
+
// the services that store or send on their own; at init, and again on an opt-in under 'require_consent'
|
|
58937
|
+
MixpanelLib.prototype._start_services = function() {
|
|
58938
|
+
// There is no need to set the distinct id
|
|
58939
|
+
// or the device id if something was already stored
|
|
58940
|
+
// in the persistence
|
|
58941
|
+
if (!this.get_distinct_id()) {
|
|
58942
|
+
this._init_device_id();
|
|
58943
|
+
}
|
|
58944
|
+
this.flags.init();
|
|
58041
58945
|
this._init_tab_id();
|
|
58042
58946
|
|
|
58043
58947
|
// Based on remote_settings_mode, fetch remote settings and then start session recording if applicable
|
|
@@ -58049,21 +58953,174 @@ MixpanelLib.prototype._init = function(token, config, name) {
|
|
|
58049
58953
|
} else {
|
|
58050
58954
|
this.__session_recording_init_promise = this._check_and_start_session_recording();
|
|
58051
58955
|
}
|
|
58956
|
+
};
|
|
58052
58957
|
|
|
58053
|
-
|
|
58054
|
-
|
|
58958
|
+
/**
|
|
58959
|
+
* Start tracking when consent starts allowing storage: batching, storage and the services, then
|
|
58960
|
+
* what the page did before consent.
|
|
58961
|
+
*/
|
|
58962
|
+
MixpanelLib.prototype._start_tracking = function() {
|
|
58963
|
+
if (!this._batch_requests) {
|
|
58964
|
+
this._init_batching();
|
|
58965
|
+
}
|
|
58966
|
+
this['persistence'].open();
|
|
58967
|
+
this._start_services();
|
|
58968
|
+
|
|
58969
|
+
// an identify() held from before consent goes first, so the people updates below go to that user
|
|
58970
|
+
var held_identify = this._consent.takeHeldIdentify();
|
|
58971
|
+
if (held_identify) {
|
|
58972
|
+
this.identify.apply(this, held_identify);
|
|
58973
|
+
}
|
|
58974
|
+
// first-touch and referrer properties were dropped before consent; an init with consent sends
|
|
58975
|
+
// them from create_mplib and _loaded instead
|
|
58976
|
+
this._set_first_touch_people_properties();
|
|
58977
|
+
this['people'].set_once(this['persistence'].get_referrer_info());
|
|
58978
|
+
};
|
|
58979
|
+
|
|
58980
|
+
/**
|
|
58981
|
+
* Stop tracking when consent stops allowing storage: stop sending, recording and storing. The
|
|
58982
|
+
* props stay in memory, so an opt-in later on the page keeps the visitor's ID.
|
|
58983
|
+
*/
|
|
58984
|
+
MixpanelLib.prototype._stop_tracking = function() {
|
|
58985
|
+
this.stop_batch_senders();
|
|
58986
|
+
this.flags.reset();
|
|
58987
|
+
this['persistence'].close();
|
|
58988
|
+
this.recorderManager.stopSessionRecording();
|
|
58989
|
+
};
|
|
58990
|
+
|
|
58991
|
+
/**
|
|
58992
|
+
* Delete everything stored about the visitor except the decision itself and unsent replay: the
|
|
58993
|
+
* persistence entry, queued requests, the tab ID and flag variants. Unsent replay stays on the
|
|
58994
|
+
* device; the recorder only loads, and so only uploads it, once consent allows storage again. Run
|
|
58995
|
+
* whenever consent doesn't allow storage, at init and after each decision.
|
|
58996
|
+
*/
|
|
58997
|
+
MixpanelLib.prototype._purge_stored_identifiers = function() {
|
|
58998
|
+
this['persistence'].remove_stored_entry();
|
|
58999
|
+
mixpanel_module_.each(this.get_batcher_configs(), function(batcher_config) {
|
|
59000
|
+
mixpanel_module_.localStorage.remove(batcher_config.queue_key);
|
|
59001
|
+
});
|
|
59002
|
+
this._remove_tab_id();
|
|
59003
|
+
this.flags.clearPersistedVariants();
|
|
59004
|
+
};
|
|
59005
|
+
|
|
59006
|
+
MixpanelLib.prototype._remove_tab_id = function() {
|
|
59007
|
+
this.tab_id = null;
|
|
59008
|
+
// the support check probes storage by writing a key, which isn't allowed here; removing a key
|
|
59009
|
+
// the browser doesn't have costs nothing and is handled where storage isn't there at all
|
|
59010
|
+
var key_suffix = this._tab_id_key_suffix();
|
|
59011
|
+
mixpanel_module_.sessionStorage.remove('mp_tab_id_' + key_suffix);
|
|
59012
|
+
mixpanel_module_.sessionStorage.remove('mp_gen_new_tab_id_' + key_suffix);
|
|
59013
|
+
};
|
|
59014
|
+
|
|
59015
|
+
MixpanelLib.prototype._init_batching = function() {
|
|
59016
|
+
this._batch_requests = this.get_config('batch_requests');
|
|
59017
|
+
if (!this._batch_requests) {
|
|
59018
|
+
return;
|
|
59019
|
+
}
|
|
59020
|
+
if (!mixpanel_module_.localStorage.is_supported(true) || !USE_XHR) {
|
|
59021
|
+
this._batch_requests = false;
|
|
59022
|
+
console$1.log('Turning off Mixpanel request-queueing; needs XHR and localStorage support');
|
|
59023
|
+
mixpanel_module_.each(this.get_batcher_configs(), function(batcher_config) {
|
|
59024
|
+
console$1.log('Clearing batch queue ' + batcher_config.queue_key);
|
|
59025
|
+
mixpanel_module_.localStorage.remove(batcher_config.queue_key);
|
|
59026
|
+
});
|
|
59027
|
+
return;
|
|
59028
|
+
}
|
|
59029
|
+
|
|
59030
|
+
if (!this.are_batchers_initialized()) {
|
|
59031
|
+
var batcher_for = mixpanel_module_.bind(function(attrs) {
|
|
59032
|
+
return new RequestBatcher(
|
|
59033
|
+
attrs.queue_key,
|
|
59034
|
+
{
|
|
59035
|
+
libConfig: this['config'],
|
|
59036
|
+
errorReporter: this.get_config('error_reporter'),
|
|
59037
|
+
sendRequestFunc: mixpanel_module_.bind(function(data, options, cb) {
|
|
59038
|
+
var api_routes = this.get_config('api_routes');
|
|
59039
|
+
this._send_request(
|
|
59040
|
+
this.get_api_host(attrs.api_name) + '/' + api_routes[attrs.api_name],
|
|
59041
|
+
this._encode_data_for_request(data),
|
|
59042
|
+
options,
|
|
59043
|
+
this._prepare_callback(cb, data)
|
|
59044
|
+
);
|
|
59045
|
+
}, this),
|
|
59046
|
+
beforeSendHook: mixpanel_module_.bind(function(item) {
|
|
59047
|
+
var ret = this._run_hook('before_send_' + attrs.type, item);
|
|
59048
|
+
if (ret) {
|
|
59049
|
+
return ret[0];
|
|
59050
|
+
} else {
|
|
59051
|
+
return null;
|
|
59052
|
+
}
|
|
59053
|
+
}, this),
|
|
59054
|
+
stopAllBatchingFunc: mixpanel_module_.bind(this.stop_batch_senders, this),
|
|
59055
|
+
usePersistence: true,
|
|
59056
|
+
consentGate: this._consent,
|
|
59057
|
+
}
|
|
59058
|
+
);
|
|
59059
|
+
}, this);
|
|
59060
|
+
var batcher_configs = this.get_batcher_configs();
|
|
59061
|
+
this.request_batchers = {
|
|
59062
|
+
events: batcher_for(batcher_configs.events),
|
|
59063
|
+
people: batcher_for(batcher_configs.people),
|
|
59064
|
+
groups: batcher_for(batcher_configs.groups)
|
|
59065
|
+
};
|
|
59066
|
+
|
|
59067
|
+
if (sendBeacon && mixpanel_module_win.addEventListener) {
|
|
59068
|
+
// Before page closes or hides (user tabs away etc), attempt to flush any events
|
|
59069
|
+
// queued up via navigator.sendBeacon. Since sendBeacon doesn't report success/failure,
|
|
59070
|
+
// events will not be removed from the persistent store; if the site is loaded again,
|
|
59071
|
+
// the events will be flushed again on startup and deduplicated on the Mixpanel server
|
|
59072
|
+
// side.
|
|
59073
|
+
// There is no reliable way to capture only page close events, so we lean on the
|
|
59074
|
+
// visibilitychange and pagehide events as recommended at
|
|
59075
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event#usage_notes.
|
|
59076
|
+
// These events fire when the user clicks away from the current page/tab, so will occur
|
|
59077
|
+
// more frequently than page unload, but are the only mechanism currently for capturing
|
|
59078
|
+
// this scenario somewhat reliably.
|
|
59079
|
+
var flush_on_unload = mixpanel_module_.bind(function() {
|
|
59080
|
+
if (!this.request_batchers.events.stopped) {
|
|
59081
|
+
this.request_batchers.events.flush({unloading: true});
|
|
59082
|
+
}
|
|
59083
|
+
}, this);
|
|
59084
|
+
mixpanel_module_win.addEventListener('pagehide', function(ev) {
|
|
59085
|
+
if (ev['persisted']) {
|
|
59086
|
+
flush_on_unload();
|
|
59087
|
+
}
|
|
59088
|
+
});
|
|
59089
|
+
mixpanel_module_win.addEventListener('visibilitychange', function() {
|
|
59090
|
+
if (document$1['visibilityState'] === 'hidden') {
|
|
59091
|
+
flush_on_unload();
|
|
59092
|
+
}
|
|
59093
|
+
});
|
|
59094
|
+
}
|
|
59095
|
+
}
|
|
59096
|
+
// a page that started the senders before consent expects them running once it's given
|
|
59097
|
+
if (this.get_config('batch_autostart') || this._batchers_were_started) {
|
|
59098
|
+
this.start_batch_senders();
|
|
59099
|
+
}
|
|
59100
|
+
};
|
|
59101
|
+
|
|
59102
|
+
MixpanelLib.prototype._init_device_id = function() {
|
|
59103
|
+
var uuid = mixpanel_module_.UUID();
|
|
59104
|
+
this.register_once({
|
|
59105
|
+
'distinct_id': DEVICE_ID_PREFIX + uuid,
|
|
59106
|
+
'$device_id': uuid
|
|
59107
|
+
}, '');
|
|
58055
59108
|
};
|
|
58056
59109
|
|
|
58057
59110
|
/**
|
|
58058
59111
|
* Assigns a unique UUID to this tab / window by leveraging sessionStorage.
|
|
58059
59112
|
* This is primarily used for session recording, where data must be isolated to the current tab.
|
|
58060
59113
|
*/
|
|
59114
|
+
MixpanelLib.prototype._tab_id_key_suffix = function() {
|
|
59115
|
+
return this.get_config('name') + '_' + this.get_config('token');
|
|
59116
|
+
};
|
|
59117
|
+
|
|
58061
59118
|
MixpanelLib.prototype._init_tab_id = function() {
|
|
58062
|
-
if (this.
|
|
58063
|
-
console$1.log('Tab ID initialization skipped
|
|
59119
|
+
if (!this._consent.allowsPersistence()) {
|
|
59120
|
+
console$1.log('Tab ID initialization skipped without persistence');
|
|
58064
59121
|
} else if (mixpanel_module_.sessionStorage.is_supported()) {
|
|
58065
59122
|
try {
|
|
58066
|
-
var key_suffix = this.
|
|
59123
|
+
var key_suffix = this._tab_id_key_suffix();
|
|
58067
59124
|
var tab_id_key = 'mp_tab_id_' + key_suffix;
|
|
58068
59125
|
|
|
58069
59126
|
// A flag is used to determine if sessionStorage is copied over and we need to generate a new tab ID.
|
|
@@ -58094,9 +59151,12 @@ MixpanelLib.prototype.get_tab_id = function () {
|
|
|
58094
59151
|
return this.tab_id || null;
|
|
58095
59152
|
};
|
|
58096
59153
|
|
|
58097
|
-
MixpanelLib.prototype._check_and_start_session_recording =
|
|
59154
|
+
MixpanelLib.prototype._check_and_start_session_recording = function(force_start) {
|
|
59155
|
+
if (!this._consent.allowsApiCalls()) {
|
|
59156
|
+
return;
|
|
59157
|
+
}
|
|
58098
59158
|
return this.recorderManager.checkAndStartSessionRecording(force_start);
|
|
58099
|
-
}
|
|
59159
|
+
};
|
|
58100
59160
|
|
|
58101
59161
|
MixpanelLib.prototype._start_recording_on_event = safewrap(function(event_name, properties) {
|
|
58102
59162
|
// Wait for recording init to complete before evaluating event triggers.
|
|
@@ -58186,7 +59246,7 @@ MixpanelLib.prototype._dom_loaded = function() {
|
|
|
58186
59246
|
this._track_dom.apply(this, item);
|
|
58187
59247
|
}, this);
|
|
58188
59248
|
|
|
58189
|
-
if (
|
|
59249
|
+
if (this._consent.allowsApiCalls()) {
|
|
58190
59250
|
mixpanel_module_.each(this.__request_queue, function(item) {
|
|
58191
59251
|
this._send_request.apply(this, item);
|
|
58192
59252
|
}, this);
|
|
@@ -58248,6 +59308,15 @@ MixpanelLib.prototype._prepare_callback = function(callback, data) {
|
|
|
58248
59308
|
MixpanelLib.prototype._send_request = function(url, data, options, callback) {
|
|
58249
59309
|
var succeeded = true;
|
|
58250
59310
|
|
|
59311
|
+
// event, people and group requests all pass here; flags and replay ask the gate themselves
|
|
59312
|
+
if (!this._consent.allowsSending()) {
|
|
59313
|
+
console$1.log('Request dropped without consent');
|
|
59314
|
+
if (mixpanel_module_.isFunction(callback)) {
|
|
59315
|
+
callback(0);
|
|
59316
|
+
}
|
|
59317
|
+
return false;
|
|
59318
|
+
}
|
|
59319
|
+
|
|
58251
59320
|
if (ENQUEUE_REQUESTS) {
|
|
58252
59321
|
this.__request_queue.push(arguments);
|
|
58253
59322
|
return succeeded;
|
|
@@ -58405,6 +59474,10 @@ MixpanelLib.prototype._send_request = function(url, data, options, callback) {
|
|
|
58405
59474
|
};
|
|
58406
59475
|
|
|
58407
59476
|
MixpanelLib.prototype._fetch_remote_settings = function(mode) {
|
|
59477
|
+
if (!this._consent.allowsFetching()) {
|
|
59478
|
+
return Promise.resolve();
|
|
59479
|
+
}
|
|
59480
|
+
|
|
58408
59481
|
var self = this;
|
|
58409
59482
|
var disableRecordingIfStrict = function() {
|
|
58410
59483
|
if (mode === 'strict') {
|
|
@@ -58542,48 +59615,6 @@ MixpanelLib.prototype.get_batcher_configs = function() {
|
|
|
58542
59615
|
return this._batcher_configs;
|
|
58543
59616
|
};
|
|
58544
59617
|
|
|
58545
|
-
MixpanelLib.prototype.init_batchers = function() {
|
|
58546
|
-
if (!this.are_batchers_initialized()) {
|
|
58547
|
-
var batcher_for = mixpanel_module_.bind(function(attrs) {
|
|
58548
|
-
return new RequestBatcher(
|
|
58549
|
-
attrs.queue_key,
|
|
58550
|
-
{
|
|
58551
|
-
libConfig: this['config'],
|
|
58552
|
-
errorReporter: this.get_config('error_reporter'),
|
|
58553
|
-
sendRequestFunc: mixpanel_module_.bind(function(data, options, cb) {
|
|
58554
|
-
var api_routes = this.get_config('api_routes');
|
|
58555
|
-
this._send_request(
|
|
58556
|
-
this.get_api_host(attrs.api_name) + '/' + api_routes[attrs.api_name],
|
|
58557
|
-
this._encode_data_for_request(data),
|
|
58558
|
-
options,
|
|
58559
|
-
this._prepare_callback(cb, data)
|
|
58560
|
-
);
|
|
58561
|
-
}, this),
|
|
58562
|
-
beforeSendHook: mixpanel_module_.bind(function(item) {
|
|
58563
|
-
var ret = this._run_hook('before_send_' + attrs.type, item);
|
|
58564
|
-
if (ret) {
|
|
58565
|
-
return ret[0];
|
|
58566
|
-
} else {
|
|
58567
|
-
return null;
|
|
58568
|
-
}
|
|
58569
|
-
}, this),
|
|
58570
|
-
stopAllBatchingFunc: mixpanel_module_.bind(this.stop_batch_senders, this),
|
|
58571
|
-
usePersistence: true,
|
|
58572
|
-
}
|
|
58573
|
-
);
|
|
58574
|
-
}, this);
|
|
58575
|
-
var batcher_configs = this.get_batcher_configs();
|
|
58576
|
-
this.request_batchers = {
|
|
58577
|
-
events: batcher_for(batcher_configs.events),
|
|
58578
|
-
people: batcher_for(batcher_configs.people),
|
|
58579
|
-
groups: batcher_for(batcher_configs.groups)
|
|
58580
|
-
};
|
|
58581
|
-
}
|
|
58582
|
-
if (this.get_config('batch_autostart')) {
|
|
58583
|
-
this.start_batch_senders();
|
|
58584
|
-
}
|
|
58585
|
-
};
|
|
58586
|
-
|
|
58587
59618
|
MixpanelLib.prototype.start_batch_senders = function() {
|
|
58588
59619
|
this._batchers_were_started = true;
|
|
58589
59620
|
if (this.are_batchers_initialized()) {
|
|
@@ -58609,8 +59640,10 @@ MixpanelLib.prototype.stop_batch_senders = function() {
|
|
|
58609
59640
|
* do not wish to rely on our convenience methods
|
|
58610
59641
|
* (created in the snippet).
|
|
58611
59642
|
*
|
|
58612
|
-
*
|
|
58613
|
-
*
|
|
59643
|
+
* @example
|
|
59644
|
+
* ```js
|
|
59645
|
+
* mixpanel.push(['register', { a: 'b' }]);
|
|
59646
|
+
* ```
|
|
58614
59647
|
*
|
|
58615
59648
|
* @param {Array} item A [function_name, args...] array to be executed
|
|
58616
59649
|
*/
|
|
@@ -58723,15 +59756,16 @@ MixpanelLib.prototype._track_or_batch = function(options, callback) {
|
|
|
58723
59756
|
* Track an event. This is the most important and
|
|
58724
59757
|
* frequently used Mixpanel function.
|
|
58725
59758
|
*
|
|
58726
|
-
*
|
|
58727
|
-
*
|
|
58728
|
-
* // track an event named 'Registered'
|
|
58729
|
-
* mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
|
|
59759
|
+
* To track link clicks or form submissions, see track_links() or track_forms().
|
|
58730
59760
|
*
|
|
58731
|
-
*
|
|
58732
|
-
*
|
|
59761
|
+
* @example
|
|
59762
|
+
* ```js
|
|
59763
|
+
* // track an event named 'Registered'
|
|
59764
|
+
* mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
|
|
58733
59765
|
*
|
|
58734
|
-
*
|
|
59766
|
+
* // track an event using navigator.sendBeacon
|
|
59767
|
+
* mixpanel.track('Left page', {'duration_seconds': 35}, {transport: 'sendBeacon'});
|
|
59768
|
+
* ```
|
|
58735
59769
|
*
|
|
58736
59770
|
* @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
|
|
58737
59771
|
* @param {Object} [properties] A set of properties to include with the event you're sending. These describe the user who did the event or details about the event itself.
|
|
@@ -58742,7 +59776,17 @@ MixpanelLib.prototype._track_or_batch = function(options, callback) {
|
|
|
58742
59776
|
* @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
|
|
58743
59777
|
* with the tracking payload sent to the API server is returned; otherwise false.
|
|
58744
59778
|
*/
|
|
58745
|
-
MixpanelLib.prototype.track =
|
|
59779
|
+
MixpanelLib.prototype.track = function(event_name, properties, options, callback) {
|
|
59780
|
+
if (!callback && typeof options === 'function') {
|
|
59781
|
+
callback = options;
|
|
59782
|
+
options = null;
|
|
59783
|
+
}
|
|
59784
|
+
if (!this._consent.allowsApiCalls()) {
|
|
59785
|
+
if (mixpanel_module_.isFunction(callback)) {
|
|
59786
|
+
callback(0);
|
|
59787
|
+
}
|
|
59788
|
+
return;
|
|
59789
|
+
}
|
|
58746
59790
|
var ret;
|
|
58747
59791
|
if (!(options && options.skip_hooks)) {
|
|
58748
59792
|
ret = this._run_hook('before_track', event_name, properties);
|
|
@@ -58754,10 +59798,6 @@ MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, pro
|
|
|
58754
59798
|
}
|
|
58755
59799
|
}
|
|
58756
59800
|
|
|
58757
|
-
if (!callback && typeof options === 'function') {
|
|
58758
|
-
callback = options;
|
|
58759
|
-
options = null;
|
|
58760
|
-
}
|
|
58761
59801
|
options = options || {};
|
|
58762
59802
|
var transport = options['transport']; // external API, don't minify 'transport' prop
|
|
58763
59803
|
if (transport) {
|
|
@@ -58819,6 +59859,14 @@ MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, pro
|
|
|
58819
59859
|
this.report_error('Invalid value for property_blacklist config: ' + property_blacklist);
|
|
58820
59860
|
}
|
|
58821
59861
|
|
|
59862
|
+
// Intentionally not checking skip_hooks here. on_track is intended to fire for all events
|
|
59863
|
+
ret = this._run_hook('on_track', event_name, properties);
|
|
59864
|
+
if (ret === null) {
|
|
59865
|
+
return;
|
|
59866
|
+
}
|
|
59867
|
+
event_name = ret[0];
|
|
59868
|
+
properties = ret[1];
|
|
59869
|
+
|
|
58822
59870
|
this._start_recording_on_event(event_name, properties);
|
|
58823
59871
|
|
|
58824
59872
|
var data = {
|
|
@@ -58840,23 +59888,30 @@ MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, pro
|
|
|
58840
59888
|
}
|
|
58841
59889
|
|
|
58842
59890
|
return ret;
|
|
58843
|
-
}
|
|
59891
|
+
};
|
|
58844
59892
|
|
|
58845
59893
|
/**
|
|
58846
59894
|
* Register the current user into one/many groups.
|
|
58847
59895
|
*
|
|
58848
|
-
*
|
|
58849
|
-
*
|
|
58850
|
-
*
|
|
58851
|
-
*
|
|
58852
|
-
*
|
|
59896
|
+
* @example
|
|
59897
|
+
* ```js
|
|
59898
|
+
* mixpanel.set_group('company', ['mixpanel', 'google']) // an array of IDs
|
|
59899
|
+
* mixpanel.set_group('company', 'mixpanel')
|
|
59900
|
+
* mixpanel.set_group('company', 128746312)
|
|
59901
|
+
* ```
|
|
58853
59902
|
*
|
|
58854
59903
|
* @param {String} group_key Group key
|
|
58855
59904
|
* @param {Array|String|Number} group_ids An array of group IDs, or a singular group ID
|
|
58856
59905
|
* @param {Function} [callback] If provided, the callback will be called after tracking the event.
|
|
58857
59906
|
*
|
|
58858
59907
|
*/
|
|
58859
|
-
MixpanelLib.prototype.set_group =
|
|
59908
|
+
MixpanelLib.prototype.set_group = function(group_key, group_ids, callback) {
|
|
59909
|
+
if (!this._consent.allowsApiCalls()) {
|
|
59910
|
+
if (mixpanel_module_.isFunction(callback)) {
|
|
59911
|
+
callback(0);
|
|
59912
|
+
}
|
|
59913
|
+
return;
|
|
59914
|
+
}
|
|
58860
59915
|
if (!mixpanel_module_.isArray(group_ids)) {
|
|
58861
59916
|
group_ids = [group_ids];
|
|
58862
59917
|
}
|
|
@@ -58864,20 +59919,27 @@ MixpanelLib.prototype.set_group = addOptOutCheckMixpanelLib(function(group_key,
|
|
|
58864
59919
|
prop[group_key] = group_ids;
|
|
58865
59920
|
this.register(prop);
|
|
58866
59921
|
return this['people'].set(group_key, group_ids, callback);
|
|
58867
|
-
}
|
|
59922
|
+
};
|
|
58868
59923
|
|
|
58869
59924
|
/**
|
|
58870
59925
|
* Add a new group for this user.
|
|
58871
59926
|
*
|
|
58872
|
-
*
|
|
58873
|
-
*
|
|
58874
|
-
*
|
|
59927
|
+
* @example
|
|
59928
|
+
* ```js
|
|
59929
|
+
* mixpanel.add_group('company', 'mixpanel')
|
|
59930
|
+
* ```
|
|
58875
59931
|
*
|
|
58876
59932
|
* @param {String} group_key Group key
|
|
58877
59933
|
* @param {*} group_id A valid Mixpanel property type
|
|
58878
59934
|
* @param {Function} [callback] If provided, the callback will be called after tracking the event.
|
|
58879
59935
|
*/
|
|
58880
|
-
MixpanelLib.prototype.add_group =
|
|
59936
|
+
MixpanelLib.prototype.add_group = function(group_key, group_id, callback) {
|
|
59937
|
+
if (!this._consent.allowsApiCalls()) {
|
|
59938
|
+
if (mixpanel_module_.isFunction(callback)) {
|
|
59939
|
+
callback(0);
|
|
59940
|
+
}
|
|
59941
|
+
return;
|
|
59942
|
+
}
|
|
58881
59943
|
var old_values = this.get_property(group_key);
|
|
58882
59944
|
var prop = {};
|
|
58883
59945
|
if (old_values === undefined) {
|
|
@@ -58891,20 +59953,27 @@ MixpanelLib.prototype.add_group = addOptOutCheckMixpanelLib(function(group_key,
|
|
|
58891
59953
|
}
|
|
58892
59954
|
}
|
|
58893
59955
|
return this['people'].union(group_key, group_id, callback);
|
|
58894
|
-
}
|
|
59956
|
+
};
|
|
58895
59957
|
|
|
58896
59958
|
/**
|
|
58897
59959
|
* Remove a group from this user.
|
|
58898
59960
|
*
|
|
58899
|
-
*
|
|
58900
|
-
*
|
|
58901
|
-
*
|
|
59961
|
+
* @example
|
|
59962
|
+
* ```js
|
|
59963
|
+
* mixpanel.remove_group('company', 'mixpanel')
|
|
59964
|
+
* ```
|
|
58902
59965
|
*
|
|
58903
59966
|
* @param {String} group_key Group key
|
|
58904
59967
|
* @param {*} group_id A valid Mixpanel property type
|
|
58905
59968
|
* @param {Function} [callback] If provided, the callback will be called after tracking the event.
|
|
58906
59969
|
*/
|
|
58907
|
-
MixpanelLib.prototype.remove_group =
|
|
59970
|
+
MixpanelLib.prototype.remove_group = function(group_key, group_id, callback) {
|
|
59971
|
+
if (!this._consent.allowsApiCalls()) {
|
|
59972
|
+
if (mixpanel_module_.isFunction(callback)) {
|
|
59973
|
+
callback(0);
|
|
59974
|
+
}
|
|
59975
|
+
return;
|
|
59976
|
+
}
|
|
58908
59977
|
var old_value = this.get_property(group_key);
|
|
58909
59978
|
// if the value doesn't exist, the persistent store is unchanged
|
|
58910
59979
|
if (old_value !== undefined) {
|
|
@@ -58918,21 +59987,22 @@ MixpanelLib.prototype.remove_group = addOptOutCheckMixpanelLib(function(group_ke
|
|
|
58918
59987
|
}
|
|
58919
59988
|
}
|
|
58920
59989
|
return this['people'].remove(group_key, group_id, callback);
|
|
58921
|
-
}
|
|
59990
|
+
};
|
|
58922
59991
|
|
|
58923
59992
|
/**
|
|
58924
59993
|
* Track an event with specific groups.
|
|
58925
59994
|
*
|
|
58926
|
-
*
|
|
58927
|
-
*
|
|
58928
|
-
*
|
|
59995
|
+
* @example
|
|
59996
|
+
* ```js
|
|
59997
|
+
* mixpanel.track_with_groups('purchase', {'product': 'iphone'}, {'University': ['UCB', 'UCLA']})
|
|
59998
|
+
* ```
|
|
58929
59999
|
*
|
|
58930
60000
|
* @param {String} event_name The name of the event (see `mixpanel.track()`)
|
|
58931
60001
|
* @param {Object=} properties A set of properties to include with the event you're sending (see `mixpanel.track()`)
|
|
58932
60002
|
* @param {Object=} groups An object mapping group name keys to one or more values
|
|
58933
60003
|
* @param {Function} [callback] If provided, the callback will be called after tracking the event.
|
|
58934
60004
|
*/
|
|
58935
|
-
MixpanelLib.prototype.track_with_groups =
|
|
60005
|
+
MixpanelLib.prototype.track_with_groups = function(event_name, properties, groups, callback) {
|
|
58936
60006
|
var tracking_props = mixpanel_module_.extend({}, properties || {});
|
|
58937
60007
|
mixpanel_module_.each(groups, function(v, k) {
|
|
58938
60008
|
if (v !== null && v !== undefined) {
|
|
@@ -58940,7 +60010,7 @@ MixpanelLib.prototype.track_with_groups = addOptOutCheckMixpanelLib(function(eve
|
|
|
58940
60010
|
}
|
|
58941
60011
|
});
|
|
58942
60012
|
return this.track(event_name, tracking_props, callback);
|
|
58943
|
-
}
|
|
60013
|
+
};
|
|
58944
60014
|
|
|
58945
60015
|
MixpanelLib.prototype._create_map_key = function (group_key, group_id) {
|
|
58946
60016
|
return group_key + '_' + JSON.stringify(group_id);
|
|
@@ -58953,9 +60023,10 @@ MixpanelLib.prototype._remove_group_from_cache = function (group_key, group_id)
|
|
|
58953
60023
|
/**
|
|
58954
60024
|
* Look up reference to a Mixpanel group
|
|
58955
60025
|
*
|
|
58956
|
-
*
|
|
58957
|
-
*
|
|
58958
|
-
*
|
|
60026
|
+
* @example
|
|
60027
|
+
* ```js
|
|
60028
|
+
* mixpanel.get_group(group_key, group_id)
|
|
60029
|
+
* ```
|
|
58959
60030
|
*
|
|
58960
60031
|
* @param {String} group_key Group key
|
|
58961
60032
|
* @param {Object} group_id A valid Mixpanel property type
|
|
@@ -58966,7 +60037,7 @@ MixpanelLib.prototype.get_group = function (group_key, group_id) {
|
|
|
58966
60037
|
var group = this._cached_groups[map_key];
|
|
58967
60038
|
if (group === undefined || group._group_key !== group_key || group._group_id !== group_id) {
|
|
58968
60039
|
group = new MixpanelGroup();
|
|
58969
|
-
group._init(this, group_key, group_id);
|
|
60040
|
+
group._init(this, group_key, group_id, this._consent);
|
|
58970
60041
|
this._cached_groups[map_key] = group;
|
|
58971
60042
|
}
|
|
58972
60043
|
return group;
|
|
@@ -58976,24 +60047,25 @@ MixpanelLib.prototype.get_group = function (group_key, group_id) {
|
|
|
58976
60047
|
* Track a default Mixpanel page view event, which includes extra default event properties to
|
|
58977
60048
|
* improve page view data.
|
|
58978
60049
|
*
|
|
58979
|
-
*
|
|
58980
|
-
*
|
|
58981
|
-
*
|
|
58982
|
-
*
|
|
60050
|
+
* @example
|
|
60051
|
+
* ```js
|
|
60052
|
+
* // track a default $mp_web_page_view event
|
|
60053
|
+
* mixpanel.track_pageview();
|
|
58983
60054
|
*
|
|
58984
|
-
*
|
|
58985
|
-
*
|
|
60055
|
+
* // track a page view event with additional event properties
|
|
60056
|
+
* mixpanel.track_pageview({'ab_test_variant': 'card-layout-b'});
|
|
58986
60057
|
*
|
|
58987
|
-
*
|
|
58988
|
-
*
|
|
58989
|
-
*
|
|
60058
|
+
* // example approach to track page views on different page types as event properties
|
|
60059
|
+
* mixpanel.track_pageview({'page': 'pricing'});
|
|
60060
|
+
* mixpanel.track_pageview({'page': 'homepage'});
|
|
58990
60061
|
*
|
|
58991
|
-
*
|
|
58992
|
-
*
|
|
58993
|
-
*
|
|
58994
|
-
*
|
|
60062
|
+
* // UNCOMMON: Tracking a page view event with a custom event_name option. NOT expected to be used for
|
|
60063
|
+
* // individual pages on the same site or product. Use cases for custom event_name may be page
|
|
60064
|
+
* // views on different products or internal applications that are considered completely separate
|
|
60065
|
+
* mixpanel.track_pageview({'page': 'customer-search'}, {'event_name': '[internal] Admin Page View'});
|
|
60066
|
+
* ```
|
|
58995
60067
|
*
|
|
58996
|
-
*
|
|
60068
|
+
* @remarks
|
|
58997
60069
|
*
|
|
58998
60070
|
* The `config.track_pageview` option for <a href="#mixpanelinit">mixpanel.init()</a>
|
|
58999
60071
|
* may be turned on for tracking page loads automatically.
|
|
@@ -59016,7 +60088,7 @@ MixpanelLib.prototype.get_group = function (group_key, group_id) {
|
|
|
59016
60088
|
* @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
|
|
59017
60089
|
* with the tracking payload sent to the API server is returned; otherwise false.
|
|
59018
60090
|
*/
|
|
59019
|
-
MixpanelLib.prototype.track_pageview =
|
|
60091
|
+
MixpanelLib.prototype.track_pageview = function(properties, options) {
|
|
59020
60092
|
if (typeof properties !== 'object') {
|
|
59021
60093
|
properties = {};
|
|
59022
60094
|
}
|
|
@@ -59040,18 +60112,19 @@ MixpanelLib.prototype.track_pageview = addOptOutCheckMixpanelLib(function(proper
|
|
|
59040
60112
|
}
|
|
59041
60113
|
|
|
59042
60114
|
return this.track(event_name, event_properties);
|
|
59043
|
-
}
|
|
60115
|
+
};
|
|
59044
60116
|
|
|
59045
60117
|
/**
|
|
59046
60118
|
* Track clicks on a set of document elements. Selector must be a
|
|
59047
60119
|
* valid query. Elements must exist on the page at the time track_links is called.
|
|
59048
60120
|
*
|
|
59049
|
-
*
|
|
59050
|
-
*
|
|
59051
|
-
*
|
|
59052
|
-
*
|
|
60121
|
+
* @example
|
|
60122
|
+
* ```js
|
|
60123
|
+
* // track click for link id #nav
|
|
60124
|
+
* mixpanel.track_links('#nav', 'Clicked Nav Link');
|
|
60125
|
+
* ```
|
|
59053
60126
|
*
|
|
59054
|
-
*
|
|
60127
|
+
* @remarks
|
|
59055
60128
|
*
|
|
59056
60129
|
* This function will wait up to 300 ms for the Mixpanel
|
|
59057
60130
|
* servers to respond. If they have not responded by that time
|
|
@@ -59065,24 +60138,24 @@ MixpanelLib.prototype.track_pageview = addOptOutCheckMixpanelLib(function(proper
|
|
|
59065
60138
|
* from the function; any properties defined on this object
|
|
59066
60139
|
* will be sent to mixpanel as event properties.
|
|
59067
60140
|
*
|
|
59068
|
-
* @type {Function}
|
|
59069
60141
|
* @param {Object|String} query A valid DOM query, element or jQuery-esque list
|
|
59070
60142
|
* @param {String} event_name The name of the event to track
|
|
59071
60143
|
* @param {Object|Function} [properties] A properties object or function that returns a dictionary of properties when passed a DOMElement
|
|
59072
60144
|
*/
|
|
59073
|
-
MixpanelLib.prototype.track_links = function() {
|
|
60145
|
+
MixpanelLib.prototype.track_links = function(query, event_name, properties) { // eslint-disable-line no-unused-vars
|
|
59074
60146
|
return this._track_dom.call(this, LinkTracker, arguments);
|
|
59075
60147
|
};
|
|
59076
60148
|
|
|
59077
60149
|
/**
|
|
59078
60150
|
* Track form submissions. Selector must be a valid query.
|
|
59079
60151
|
*
|
|
59080
|
-
*
|
|
59081
|
-
*
|
|
59082
|
-
*
|
|
59083
|
-
*
|
|
60152
|
+
* @example
|
|
60153
|
+
* ```js
|
|
60154
|
+
* // track submission for form id 'register'
|
|
60155
|
+
* mixpanel.track_forms('#register', 'Created Account');
|
|
60156
|
+
* ```
|
|
59084
60157
|
*
|
|
59085
|
-
*
|
|
60158
|
+
* @remarks
|
|
59086
60159
|
*
|
|
59087
60160
|
* This function will wait up to 300 ms for the mixpanel
|
|
59088
60161
|
* servers to respond, if they have not responded by that time
|
|
@@ -59096,12 +60169,11 @@ MixpanelLib.prototype.track_links = function() {
|
|
|
59096
60169
|
* from the function; any properties defined on this object
|
|
59097
60170
|
* will be sent to mixpanel as event properties.
|
|
59098
60171
|
*
|
|
59099
|
-
* @type {Function}
|
|
59100
60172
|
* @param {Object|String} query A valid DOM query, element or jQuery-esque list
|
|
59101
60173
|
* @param {String} event_name The name of the event to track
|
|
59102
60174
|
* @param {Object|Function} [properties] This can be a set of properties, or a function that returns a set of properties after being passed a DOMElement
|
|
59103
60175
|
*/
|
|
59104
|
-
MixpanelLib.prototype.track_forms = function() {
|
|
60176
|
+
MixpanelLib.prototype.track_forms = function(query, event_name, properties) { // eslint-disable-line no-unused-vars
|
|
59105
60177
|
return this._track_dom.call(this, FormTracker, arguments);
|
|
59106
60178
|
};
|
|
59107
60179
|
|
|
@@ -59110,16 +60182,17 @@ MixpanelLib.prototype.track_forms = function() {
|
|
|
59110
60182
|
* later 'track' call for the same event in the properties sent
|
|
59111
60183
|
* with the event.
|
|
59112
60184
|
*
|
|
59113
|
-
* ### Usage:
|
|
59114
|
-
*
|
|
59115
|
-
* // time an event named 'Registered'
|
|
59116
|
-
* mixpanel.time_event('Registered');
|
|
59117
|
-
* mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
|
|
59118
|
-
*
|
|
59119
60185
|
* When called for a particular event name, the next track call for that event
|
|
59120
60186
|
* name will include the elapsed time between the 'time_event' and 'track'
|
|
59121
60187
|
* calls. This value is stored as seconds in the '$duration' property.
|
|
59122
60188
|
*
|
|
60189
|
+
* @example
|
|
60190
|
+
* ```js
|
|
60191
|
+
* // time an event named 'Registered'
|
|
60192
|
+
* mixpanel.time_event('Registered');
|
|
60193
|
+
* mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
|
|
60194
|
+
* ```
|
|
60195
|
+
*
|
|
59123
60196
|
* @param {String} event_name The name of the event.
|
|
59124
60197
|
*/
|
|
59125
60198
|
MixpanelLib.prototype.time_event = function(event_name) {
|
|
@@ -59160,21 +60233,22 @@ var options_for_register = function(days_or_options) {
|
|
|
59160
60233
|
* Register a set of super properties, which are included with all
|
|
59161
60234
|
* events. This will overwrite previous super property values.
|
|
59162
60235
|
*
|
|
59163
|
-
*
|
|
59164
|
-
*
|
|
59165
|
-
*
|
|
59166
|
-
*
|
|
60236
|
+
* @example
|
|
60237
|
+
* ```js
|
|
60238
|
+
* // register 'Gender' as a super property
|
|
60239
|
+
* mixpanel.register({'Gender': 'Female'});
|
|
59167
60240
|
*
|
|
59168
|
-
*
|
|
59169
|
-
*
|
|
59170
|
-
*
|
|
59171
|
-
*
|
|
59172
|
-
*
|
|
60241
|
+
* // register several super properties when a user signs up
|
|
60242
|
+
* mixpanel.register({
|
|
60243
|
+
* 'Email': 'jdoe@example.com',
|
|
60244
|
+
* 'Account Type': 'Free'
|
|
60245
|
+
* });
|
|
59173
60246
|
*
|
|
59174
|
-
*
|
|
59175
|
-
*
|
|
60247
|
+
* // register only for the current pageload
|
|
60248
|
+
* mixpanel.register({'Name': 'Pat'}, {persistent: false});
|
|
60249
|
+
* ```
|
|
59176
60250
|
*
|
|
59177
|
-
* @param {Object}
|
|
60251
|
+
* @param {Object} props An associative array of properties to store about the user
|
|
59178
60252
|
* @param {Number|Object} [days_or_options] Options object or number of days since the user's last visit to store the super properties (only valid for persisted props)
|
|
59179
60253
|
* @param {boolean} [days_or_options.days] - number of days since the user's last visit to store the super properties (only valid for persisted props)
|
|
59180
60254
|
* @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
|
|
@@ -59200,24 +60274,25 @@ MixpanelLib.prototype.register = function(props, days_or_options) {
|
|
|
59200
60274
|
* Register a set of super properties only once. This will not
|
|
59201
60275
|
* overwrite previous super property values, unlike register().
|
|
59202
60276
|
*
|
|
59203
|
-
*
|
|
59204
|
-
*
|
|
59205
|
-
*
|
|
59206
|
-
*
|
|
59207
|
-
*
|
|
59208
|
-
*
|
|
60277
|
+
* @example
|
|
60278
|
+
* ```js
|
|
60279
|
+
* // register a super property for the first time only
|
|
60280
|
+
* mixpanel.register_once({
|
|
60281
|
+
* 'First Login Date': new Date().toISOString()
|
|
60282
|
+
* });
|
|
59209
60283
|
*
|
|
59210
|
-
*
|
|
59211
|
-
*
|
|
59212
|
-
*
|
|
59213
|
-
*
|
|
60284
|
+
* // register once, only for the current pageload
|
|
60285
|
+
* mixpanel.register_once({
|
|
60286
|
+
* 'First interaction time': new Date().toISOString()
|
|
60287
|
+
* }, 'None', {persistent: false});
|
|
60288
|
+
* ```
|
|
59214
60289
|
*
|
|
59215
|
-
*
|
|
60290
|
+
* @remarks
|
|
59216
60291
|
*
|
|
59217
60292
|
* If default_value is specified, current super properties
|
|
59218
60293
|
* with that value will be overwritten.
|
|
59219
60294
|
*
|
|
59220
|
-
* @param {Object}
|
|
60295
|
+
* @param {Object} props An associative array of properties to store about the user
|
|
59221
60296
|
* @param {*} [default_value] Value to override if already set in super properties (ex: 'False') Default: 'None'
|
|
59222
60297
|
* @param {Number|Object} [days_or_options] Options object or number of days since the user's last visit to store the super properties (only valid for persisted props)
|
|
59223
60298
|
* @param {boolean} [days_or_options.days] - number of days since the user's last visit to store the super properties (only valid for persisted props)
|
|
@@ -59288,7 +60363,7 @@ MixpanelLib.prototype._register_single = function(prop, value) {
|
|
|
59288
60363
|
* typically after login or signup. We recommend against using
|
|
59289
60364
|
* identify for anonymous visitors to your site.
|
|
59290
60365
|
*
|
|
59291
|
-
*
|
|
60366
|
+
* @remarks
|
|
59292
60367
|
* If your project has
|
|
59293
60368
|
* <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a>
|
|
59294
60369
|
* enabled, the identify method will connect pre- and
|
|
@@ -59300,7 +60375,11 @@ MixpanelLib.prototype._register_single = function(prop, value) {
|
|
|
59300
60375
|
* to the same user identity. If ID Merge is disabled, alias can
|
|
59301
60376
|
* be used to connect pre- and post-registration events.
|
|
59302
60377
|
*
|
|
59303
|
-
*
|
|
60378
|
+
* With consent_mode 'require_consent', the latest call made before the visitor consents is held in
|
|
60379
|
+
* memory, without storing or sending anything, and applied if they opt in on the same page. reset()
|
|
60380
|
+
* discards it.
|
|
60381
|
+
*
|
|
60382
|
+
* @param {String} [new_distinct_id] A string that uniquely identifies a user. If not provided, the distinct_id currently in the persistent store (cookie or localStorage) will be used.
|
|
59304
60383
|
*/
|
|
59305
60384
|
MixpanelLib.prototype.identify = function(
|
|
59306
60385
|
new_distinct_id, _set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback
|
|
@@ -59312,6 +60391,12 @@ MixpanelLib.prototype.identify = function(
|
|
|
59312
60391
|
// _set_once_callback:function A callback to be run if and when the People set_once queue is flushed
|
|
59313
60392
|
// _union_callback:function A callback to be run if and when the People union queue is flushed
|
|
59314
60393
|
// _unset_callback:function A callback to be run if and when the People unset queue is flushed
|
|
60394
|
+
if (!this._consent.allowsStoring()) {
|
|
60395
|
+
this._consent.holdIdentify(Array.prototype.slice.call(arguments));
|
|
60396
|
+
console$1.log('identify() held until consent');
|
|
60397
|
+
return;
|
|
60398
|
+
}
|
|
60399
|
+
|
|
59315
60400
|
var ret = this._run_hook('before_identify', new_distinct_id);
|
|
59316
60401
|
|
|
59317
60402
|
if (ret === null) {
|
|
@@ -59376,11 +60461,11 @@ MixpanelLib.prototype.reset = function() {
|
|
|
59376
60461
|
this.stop_session_recording();
|
|
59377
60462
|
this['persistence'].clear();
|
|
59378
60463
|
this._flags.identify_called = false;
|
|
59379
|
-
|
|
59380
|
-
|
|
59381
|
-
|
|
59382
|
-
|
|
59383
|
-
}
|
|
60464
|
+
this._consent.takeHeldIdentify();
|
|
60465
|
+
// before consent the device ID is minted on opt-in instead
|
|
60466
|
+
if (this._consent.allowsStoring()) {
|
|
60467
|
+
this._init_device_id();
|
|
60468
|
+
}
|
|
59384
60469
|
this._check_and_start_session_recording();
|
|
59385
60470
|
this.flags.reset();
|
|
59386
60471
|
};
|
|
@@ -59389,7 +60474,7 @@ MixpanelLib.prototype.reset = function() {
|
|
|
59389
60474
|
* Returns the current distinct id of the user. This is either the id automatically
|
|
59390
60475
|
* generated by the library or the id that has been passed by a call to identify().
|
|
59391
60476
|
*
|
|
59392
|
-
*
|
|
60477
|
+
* @remarks
|
|
59393
60478
|
*
|
|
59394
60479
|
* get_distinct_id() can only be called after the Mixpanel library has finished loading.
|
|
59395
60480
|
* init() has a loaded function available to handle this automatically. For example:
|
|
@@ -59429,7 +60514,7 @@ MixpanelLib.prototype.get_distinct_id = function() {
|
|
|
59429
60514
|
* // this is invalid as 'new_id' already points to 'existing_id'
|
|
59430
60515
|
* mixpanel.alias('new_id', 'newer_id');
|
|
59431
60516
|
*
|
|
59432
|
-
*
|
|
60517
|
+
* @remarks
|
|
59433
60518
|
*
|
|
59434
60519
|
* If your project does not have
|
|
59435
60520
|
* <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a>
|
|
@@ -59442,6 +60527,11 @@ MixpanelLib.prototype.get_distinct_id = function() {
|
|
|
59442
60527
|
* @param {String} [original] The current identifier being used for this user.
|
|
59443
60528
|
*/
|
|
59444
60529
|
MixpanelLib.prototype.alias = function(alias, original) {
|
|
60530
|
+
if (!this._consent.allowsStoring()) {
|
|
60531
|
+
console$1.log('alias() dropped without consent');
|
|
60532
|
+
return;
|
|
60533
|
+
}
|
|
60534
|
+
|
|
59445
60535
|
// If the $people_distinct_id key exists in persistence, there has been a previous
|
|
59446
60536
|
// mixpanel.people.identify() call made for this user. It is VERY BAD to make an alias with
|
|
59447
60537
|
// this ID, as it will duplicate users.
|
|
@@ -59571,6 +60661,11 @@ MixpanelLib.prototype.name_tag = function(name_tag) {
|
|
|
59571
60661
|
* // customize the name of cookie/localStorage set by opt-in/opt-out methods
|
|
59572
60662
|
* opt_out_tracking_cookie_prefix: null
|
|
59573
60663
|
*
|
|
60664
|
+
* // what happens before the visitor decides: 'no_consent_required' (unset) or
|
|
60665
|
+
* // 'require_consent'. opt_out_tracking_by_default applies only when it's unset.
|
|
60666
|
+
* // Fixed at init.
|
|
60667
|
+
* consent_mode: null
|
|
60668
|
+
*
|
|
59574
60669
|
* // type of persistent store for super properties (cookie/
|
|
59575
60670
|
* // localStorage) if set to 'localStorage', any existing
|
|
59576
60671
|
* // mixpanel cookie value with the same persistence_name
|
|
@@ -59618,10 +60713,15 @@ MixpanelLib.prototype.name_tag = function(name_tag) {
|
|
|
59618
60713
|
* }
|
|
59619
60714
|
*
|
|
59620
60715
|
*
|
|
59621
|
-
* @param {
|
|
60716
|
+
* @param {Partial<import('./index.d.ts').Config>} config A dictionary of new configuration values to update; see the Config type for the available options.
|
|
59622
60717
|
*/
|
|
59623
60718
|
MixpanelLib.prototype.set_config = function(config) {
|
|
59624
60719
|
if (mixpanel_module_.isObject(config)) {
|
|
60720
|
+
if (this._consent && 'consent_mode' in config && config['consent_mode'] !== this.get_config('consent_mode')) {
|
|
60721
|
+
console$1.critical('consent_mode can only be set at init; ignoring the change');
|
|
60722
|
+
config = mixpanel_module_.extend({}, config);
|
|
60723
|
+
delete config['consent_mode'];
|
|
60724
|
+
}
|
|
59625
60725
|
mixpanel_module_.extend(this['config'], config);
|
|
59626
60726
|
|
|
59627
60727
|
var new_batch_size = config['batch_size'];
|
|
@@ -59708,7 +60808,7 @@ MixpanelLib.prototype._run_hook = function(hook_name) {
|
|
|
59708
60808
|
* Returns the value of the super property named property_name. If no such
|
|
59709
60809
|
* property is set, get_property() will return the undefined value.
|
|
59710
60810
|
*
|
|
59711
|
-
*
|
|
60811
|
+
* @remarks
|
|
59712
60812
|
*
|
|
59713
60813
|
* get_property() can only be called after the Mixpanel library has finished loading.
|
|
59714
60814
|
* init() has a loaded function available to handle this automatically. For example:
|
|
@@ -59750,124 +60850,66 @@ MixpanelLib.prototype._event_is_disabled = function(event_name) {
|
|
|
59750
60850
|
mixpanel_module_.include(this.__disabled_events, event_name);
|
|
59751
60851
|
};
|
|
59752
60852
|
|
|
59753
|
-
|
|
59754
|
-
|
|
59755
|
-
|
|
59756
|
-
|
|
59757
|
-
|
|
59758
|
-
|
|
59759
|
-
|
|
59760
|
-
|
|
59761
|
-
}
|
|
59762
|
-
if (!this.has_opted_out_tracking() && this.has_opted_out_tracking({'persistence_type': 'cookie'})) {
|
|
59763
|
-
this.opt_out_tracking({'clear_persistence': false});
|
|
59764
|
-
}
|
|
59765
|
-
this.clear_opt_in_out_tracking({
|
|
59766
|
-
'persistence_type': 'cookie',
|
|
59767
|
-
'enable_persistence': false
|
|
59768
|
-
});
|
|
59769
|
-
}
|
|
59770
|
-
|
|
59771
|
-
// check whether the user has already opted out - if so, clear & disable persistence
|
|
59772
|
-
if (this.has_opted_out_tracking()) {
|
|
59773
|
-
this._gdpr_update_persistence({'clear_persistence': true});
|
|
59774
|
-
|
|
59775
|
-
// check whether we should opt out by default
|
|
59776
|
-
// note: we don't clear persistence here by default since opt-out default state is often
|
|
59777
|
-
// used as an initial state while GDPR information is being collected
|
|
59778
|
-
} else if (!this.has_opted_in_tracking() && (
|
|
59779
|
-
this.get_config('opt_out_tracking_by_default') || mixpanel_module_.cookie.get('mp_optout')
|
|
59780
|
-
)) {
|
|
59781
|
-
mixpanel_module_.cookie.remove('mp_optout');
|
|
59782
|
-
this.opt_out_tracking({
|
|
59783
|
-
'clear_persistence': this.get_config('opt_out_persistence_by_default')
|
|
59784
|
-
});
|
|
59785
|
-
}
|
|
60853
|
+
/**
|
|
60854
|
+
* Whether consent allows something now; see ConsentManager.allows. The separately built recorder
|
|
60855
|
+
* bundle calls this by its quoted name.
|
|
60856
|
+
* @param {string} capability
|
|
60857
|
+
* @returns {boolean}
|
|
60858
|
+
*/
|
|
60859
|
+
MixpanelLib.prototype._consent_allows = function(capability) {
|
|
60860
|
+
return this._consent.allows(capability);
|
|
59786
60861
|
};
|
|
59787
60862
|
|
|
59788
60863
|
/**
|
|
59789
|
-
*
|
|
59790
|
-
*
|
|
59791
|
-
* @param {boolean}
|
|
59792
|
-
* @param {boolean} [options.enable_persistence] If true, will re-enable sdk persistence
|
|
60864
|
+
* Turn persistence, batching and recording off, or back on after an opt-in. Batching only restarts
|
|
60865
|
+
* if it was running before, so an opt-in doesn't start it for the first time.
|
|
60866
|
+
* @param {boolean} disabled
|
|
59793
60867
|
*/
|
|
59794
|
-
MixpanelLib.prototype.
|
|
59795
|
-
|
|
59796
|
-
|
|
59797
|
-
disabled = true;
|
|
59798
|
-
} else if (options && options['enable_persistence']) {
|
|
59799
|
-
disabled = false;
|
|
60868
|
+
MixpanelLib.prototype._set_persistence_disabled = function(disabled) {
|
|
60869
|
+
if (disabled) {
|
|
60870
|
+
this['persistence'].close();
|
|
59800
60871
|
} else {
|
|
59801
|
-
|
|
59802
|
-
}
|
|
59803
|
-
|
|
59804
|
-
if (!this.get_config('disable_persistence') && this['persistence'].disabled !== disabled) {
|
|
59805
|
-
this['persistence'].set_disabled(disabled);
|
|
60872
|
+
this['persistence'].open();
|
|
59806
60873
|
}
|
|
59807
60874
|
|
|
59808
60875
|
if (disabled) {
|
|
59809
60876
|
this.stop_batch_senders();
|
|
59810
60877
|
this.stop_session_recording();
|
|
59811
|
-
} else {
|
|
59812
|
-
|
|
59813
|
-
// in order to avoid unintentionally starting up batching for the first time
|
|
59814
|
-
if (this._batchers_were_started) {
|
|
59815
|
-
this.start_batch_senders();
|
|
59816
|
-
}
|
|
60878
|
+
} else if (this._batchers_were_started) {
|
|
60879
|
+
this.start_batch_senders();
|
|
59817
60880
|
}
|
|
59818
60881
|
};
|
|
59819
60882
|
|
|
59820
|
-
//
|
|
59821
|
-
MixpanelLib.prototype.
|
|
59822
|
-
|
|
59823
|
-
'
|
|
59824
|
-
'
|
|
59825
|
-
'cookie_prefix': this.get_config('opt_out_tracking_cookie_prefix'),
|
|
59826
|
-
'cookie_expiration': this.get_config('cookie_expiration'),
|
|
59827
|
-
'cross_site_cookie': this.get_config('cross_site_cookie'),
|
|
59828
|
-
'cross_subdomain_cookie': this.get_config('cross_subdomain_cookie'),
|
|
59829
|
-
'cookie_domain': this.get_config('cookie_domain'),
|
|
59830
|
-
'secure_cookie': this.get_config('secure_cookie'),
|
|
59831
|
-
'ignore_dnt': this.get_config('ignore_dnt')
|
|
59832
|
-
}, options);
|
|
59833
|
-
|
|
59834
|
-
// check if localStorage can be used for recording opt out status, fall back to cookie if not
|
|
59835
|
-
if (!mixpanel_module_.localStorage.is_supported()) {
|
|
59836
|
-
options['persistence_type'] = 'cookie';
|
|
60883
|
+
// delete the identified user's profile and charges, which the opt-out about to happen would block
|
|
60884
|
+
MixpanelLib.prototype._delete_user_for_opt_out = function() {
|
|
60885
|
+
if (this['people'] && this['people']._identify_called()) {
|
|
60886
|
+
this['people'].delete_user();
|
|
60887
|
+
this['people'].clear_charges();
|
|
59837
60888
|
}
|
|
59838
|
-
|
|
59839
|
-
return func(this.get_config('token'), {
|
|
59840
|
-
track: options['track'],
|
|
59841
|
-
trackEventName: options['track_event_name'],
|
|
59842
|
-
trackProperties: options['track_properties'],
|
|
59843
|
-
persistenceType: options['persistence_type'],
|
|
59844
|
-
persistencePrefix: options['cookie_prefix'],
|
|
59845
|
-
cookieDomain: options['cookie_domain'],
|
|
59846
|
-
cookieExpiration: options['cookie_expiration'],
|
|
59847
|
-
crossSiteCookie: options['cross_site_cookie'],
|
|
59848
|
-
crossSubdomainCookie: options['cross_subdomain_cookie'],
|
|
59849
|
-
secureCookie: options['secure_cookie'],
|
|
59850
|
-
ignoreDnt: options['ignore_dnt']
|
|
59851
|
-
});
|
|
59852
60889
|
};
|
|
59853
60890
|
|
|
59854
60891
|
/**
|
|
59855
60892
|
* Opt the user in to data tracking and cookies/localstorage for this Mixpanel instance
|
|
59856
60893
|
*
|
|
59857
|
-
*
|
|
59858
|
-
*
|
|
59859
|
-
*
|
|
59860
|
-
*
|
|
60894
|
+
* @example
|
|
60895
|
+
* ```js
|
|
60896
|
+
* // opt user in
|
|
60897
|
+
* mixpanel.opt_in_tracking();
|
|
60898
|
+
*
|
|
60899
|
+
* // opt user in with specific event name, properties, cookie configuration
|
|
60900
|
+
* mixpanel.opt_in_tracking({
|
|
60901
|
+
* track_event_name: 'User opted in',
|
|
60902
|
+
* track_event_properties: {
|
|
60903
|
+
* 'Email': 'jdoe@example.com'
|
|
60904
|
+
* },
|
|
60905
|
+
* cookie_expiration: 30,
|
|
60906
|
+
* secure_cookie: true
|
|
60907
|
+
* });
|
|
60908
|
+
* ```
|
|
59861
60909
|
*
|
|
59862
|
-
*
|
|
59863
|
-
*
|
|
59864
|
-
*
|
|
59865
|
-
* track_event_properties: {
|
|
59866
|
-
* 'Email': 'jdoe@example.com'
|
|
59867
|
-
* },
|
|
59868
|
-
* cookie_expiration: 30,
|
|
59869
|
-
* secure_cookie: true
|
|
59870
|
-
* });
|
|
60910
|
+
* With consent_mode 'require_consent', the decision is stored with the instance's persistence and
|
|
60911
|
+
* cookie config: the storage options and enable_persistence below don't apply, and the track
|
|
60912
|
+
* options do.
|
|
59871
60913
|
*
|
|
59872
60914
|
* @param {Object} [options] A dictionary of config options to override
|
|
59873
60915
|
* @param {function} [options.track] Function used for tracking a Mixpanel event to record the opt-in action (default is this Mixpanel instance's track method)
|
|
@@ -59883,27 +60925,27 @@ MixpanelLib.prototype._gdpr_call_func = function(func, options) {
|
|
|
59883
60925
|
* @param {boolean} [options.secure_cookie] Whether the opt-in cookie is set as secure or not (overrides value specified in this Mixpanel instance's config)
|
|
59884
60926
|
*/
|
|
59885
60927
|
MixpanelLib.prototype.opt_in_tracking = function(options) {
|
|
59886
|
-
|
|
59887
|
-
'enable_persistence': true
|
|
59888
|
-
}, options);
|
|
59889
|
-
|
|
59890
|
-
this._gdpr_call_func(optIn, options);
|
|
59891
|
-
this._gdpr_update_persistence(options);
|
|
60928
|
+
this._consent.optIn(options);
|
|
59892
60929
|
};
|
|
59893
60930
|
|
|
59894
60931
|
/**
|
|
59895
60932
|
* Opt the user out of data tracking and cookies/localstorage for this Mixpanel instance
|
|
59896
60933
|
*
|
|
59897
|
-
*
|
|
60934
|
+
* @example
|
|
60935
|
+
* ```js
|
|
60936
|
+
* // opt user out
|
|
60937
|
+
* mixpanel.opt_out_tracking();
|
|
59898
60938
|
*
|
|
59899
|
-
*
|
|
59900
|
-
*
|
|
60939
|
+
* // opt user out with different cookie configuration from Mixpanel instance
|
|
60940
|
+
* mixpanel.opt_out_tracking({
|
|
60941
|
+
* cookie_expiration: 30,
|
|
60942
|
+
* secure_cookie: true
|
|
60943
|
+
* });
|
|
60944
|
+
* ```
|
|
59901
60945
|
*
|
|
59902
|
-
*
|
|
59903
|
-
*
|
|
59904
|
-
*
|
|
59905
|
-
* secure_cookie: true
|
|
59906
|
-
* });
|
|
60946
|
+
* With consent_mode 'require_consent', the decision is stored with the instance's persistence and
|
|
60947
|
+
* cookie config: the storage options, clear_persistence and delete_user below don't apply. The
|
|
60948
|
+
* stored identifiers are deleted instead, and no $delete is sent.
|
|
59907
60949
|
*
|
|
59908
60950
|
* @param {Object} [options] A dictionary of config options to override
|
|
59909
60951
|
* @param {boolean} [options.delete_user=true] If true, will delete the currently identified user's profile and clear all charges after opting the user out
|
|
@@ -59917,69 +60959,70 @@ MixpanelLib.prototype.opt_in_tracking = function(options) {
|
|
|
59917
60959
|
* @param {boolean} [options.secure_cookie] Whether the opt-in cookie is set as secure or not (overrides value specified in this Mixpanel instance's config)
|
|
59918
60960
|
*/
|
|
59919
60961
|
MixpanelLib.prototype.opt_out_tracking = function(options) {
|
|
59920
|
-
|
|
59921
|
-
'clear_persistence': true,
|
|
59922
|
-
'delete_user': true
|
|
59923
|
-
}, options);
|
|
59924
|
-
|
|
59925
|
-
// delete user and clear charges since these methods may be disabled by opt-out
|
|
59926
|
-
if (options['delete_user'] && this['people'] && this['people']._identify_called()) {
|
|
59927
|
-
this['people'].delete_user();
|
|
59928
|
-
this['people'].clear_charges();
|
|
59929
|
-
}
|
|
59930
|
-
|
|
59931
|
-
this._gdpr_call_func(optOut, options);
|
|
59932
|
-
this._gdpr_update_persistence(options);
|
|
60962
|
+
this._consent.optOut(options);
|
|
59933
60963
|
};
|
|
59934
60964
|
|
|
59935
60965
|
/**
|
|
59936
60966
|
* Check whether the user has opted in to data tracking and cookies/localstorage for this Mixpanel instance
|
|
59937
60967
|
*
|
|
59938
|
-
*
|
|
60968
|
+
* @example
|
|
60969
|
+
* ```js
|
|
60970
|
+
* var has_opted_in = mixpanel.has_opted_in_tracking();
|
|
60971
|
+
* // use has_opted_in value
|
|
60972
|
+
* ```
|
|
59939
60973
|
*
|
|
59940
|
-
*
|
|
59941
|
-
* // use has_opted_in value
|
|
60974
|
+
* With consent_mode 'require_consent' the options don't apply.
|
|
59942
60975
|
*
|
|
59943
60976
|
* @param {Object} [options] A dictionary of config options to override
|
|
59944
|
-
* @param {string} [options.persistence_type
|
|
60977
|
+
* @param {string} [options.persistence_type] Persistence mechanism to read - cookie or localStorage - falls back to cookie if localStorage is unavailable. Defaults to opt_out_tracking_persistence_type; for localStorage, whichever store holds the flag
|
|
59945
60978
|
* @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
|
|
59946
60979
|
* @returns {boolean} current opt-in status
|
|
59947
60980
|
*/
|
|
59948
60981
|
MixpanelLib.prototype.has_opted_in_tracking = function(options) {
|
|
59949
|
-
return this.
|
|
60982
|
+
return this._consent.hasOptedIn(options);
|
|
59950
60983
|
};
|
|
59951
60984
|
|
|
59952
60985
|
/**
|
|
59953
60986
|
* Check whether the user has opted out of data tracking and cookies/localstorage for this Mixpanel instance
|
|
59954
60987
|
*
|
|
59955
|
-
*
|
|
60988
|
+
* @example
|
|
60989
|
+
* ```js
|
|
60990
|
+
* var has_opted_out = mixpanel.has_opted_out_tracking();
|
|
60991
|
+
* // use has_opted_out value
|
|
60992
|
+
* ```
|
|
59956
60993
|
*
|
|
59957
|
-
*
|
|
59958
|
-
*
|
|
60994
|
+
* With consent_mode 'require_consent' the options don't apply, and a stored refusal or Do Not Track
|
|
60995
|
+
* counts as opted out.
|
|
59959
60996
|
*
|
|
59960
60997
|
* @param {Object} [options] A dictionary of config options to override
|
|
59961
|
-
* @param {string} [options.persistence_type
|
|
60998
|
+
* @param {string} [options.persistence_type] Persistence mechanism to read - cookie or localStorage - falls back to cookie if localStorage is unavailable. Defaults to opt_out_tracking_persistence_type; for localStorage, whichever store holds the flag
|
|
59962
60999
|
* @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
|
|
59963
61000
|
* @returns {boolean} current opt-out status
|
|
59964
61001
|
*/
|
|
59965
61002
|
MixpanelLib.prototype.has_opted_out_tracking = function(options) {
|
|
59966
|
-
return this.
|
|
61003
|
+
return this._consent.hasOptedOut(options);
|
|
59967
61004
|
};
|
|
59968
61005
|
|
|
59969
61006
|
/**
|
|
59970
61007
|
* Clear the user's opt in/out status of data tracking and cookies/localstorage for this Mixpanel instance
|
|
59971
61008
|
*
|
|
59972
|
-
*
|
|
59973
|
-
*
|
|
59974
|
-
*
|
|
59975
|
-
*
|
|
61009
|
+
* @example
|
|
61010
|
+
* ```js
|
|
61011
|
+
* // clear user's opt-in/out status
|
|
61012
|
+
* mixpanel.clear_opt_in_out_tracking();
|
|
61013
|
+
*
|
|
61014
|
+
* // clear user's opt-in/out status with specific cookie configuration - should match
|
|
61015
|
+
* // configuration used when opt_in_tracking/opt_out_tracking methods were called.
|
|
61016
|
+
* mixpanel.clear_opt_in_out_tracking({
|
|
61017
|
+
* cookie_expiration: 30,
|
|
61018
|
+
* secure_cookie: true
|
|
61019
|
+
* });
|
|
61020
|
+
* ```
|
|
59976
61021
|
*
|
|
59977
|
-
*
|
|
59978
|
-
*
|
|
59979
|
-
*
|
|
59980
|
-
*
|
|
59981
|
-
* secure_cookie: true
|
|
59982
|
-
* });
|
|
61022
|
+
* With consent_mode 'require_consent', the decision is stored with the instance's persistence and
|
|
61023
|
+
* cookie config: the storage options and enable_persistence below don't apply. Clearing also
|
|
61024
|
+
* deletes the device's stored identifiers, and on a page tracking after an opt-in it stops
|
|
61025
|
+
* tracking.
|
|
59983
61026
|
*
|
|
59984
61027
|
* @param {Object} [options] A dictionary of config options to override
|
|
59985
61028
|
* @param {boolean} [options.enable_persistence=true] If true, will re-enable sdk persistence
|
|
@@ -59992,12 +61035,7 @@ MixpanelLib.prototype.has_opted_out_tracking = function(options) {
|
|
|
59992
61035
|
* @param {boolean} [options.secure_cookie] Whether the opt-in cookie is set as secure or not (overrides value specified in this Mixpanel instance's config)
|
|
59993
61036
|
*/
|
|
59994
61037
|
MixpanelLib.prototype.clear_opt_in_out_tracking = function(options) {
|
|
59995
|
-
|
|
59996
|
-
'enable_persistence': true
|
|
59997
|
-
}, options);
|
|
59998
|
-
|
|
59999
|
-
this._gdpr_call_func(clearOptInOut, options);
|
|
60000
|
-
this._gdpr_update_persistence(options);
|
|
61038
|
+
this._consent.clear(options);
|
|
60001
61039
|
};
|
|
60002
61040
|
|
|
60003
61041
|
MixpanelLib.prototype.report_error = function(msg, err) {
|
|
@@ -60034,53 +61072,57 @@ MixpanelLib.prototype.remove_hook = function(hook_name, hook_fn) {
|
|
|
60034
61072
|
// EXPORTS (for closure compiler)
|
|
60035
61073
|
|
|
60036
61074
|
// MixpanelLib Exports
|
|
60037
|
-
MixpanelLib.prototype[
|
|
60038
|
-
|
|
60039
|
-
|
|
60040
|
-
|
|
60041
|
-
|
|
60042
|
-
|
|
60043
|
-
|
|
60044
|
-
|
|
60045
|
-
|
|
60046
|
-
|
|
60047
|
-
|
|
60048
|
-
|
|
60049
|
-
|
|
60050
|
-
|
|
60051
|
-
|
|
60052
|
-
|
|
60053
|
-
|
|
60054
|
-
|
|
60055
|
-
|
|
60056
|
-
|
|
60057
|
-
|
|
60058
|
-
|
|
60059
|
-
|
|
60060
|
-
|
|
60061
|
-
|
|
60062
|
-
|
|
60063
|
-
|
|
60064
|
-
|
|
60065
|
-
|
|
60066
|
-
|
|
60067
|
-
|
|
60068
|
-
|
|
60069
|
-
|
|
60070
|
-
|
|
60071
|
-
|
|
60072
|
-
|
|
60073
|
-
|
|
60074
|
-
|
|
60075
|
-
|
|
60076
|
-
|
|
60077
|
-
|
|
60078
|
-
|
|
60079
|
-
|
|
61075
|
+
// (assigned through an alias: a second `MixpanelLib.prototype[...]` declaration of each method would
|
|
61076
|
+
// make TypeScript type them as `any`, which breaks the generated API docs)
|
|
61077
|
+
var MixpanelLibProto = MixpanelLib.prototype;
|
|
61078
|
+
MixpanelLibProto['init'] = MixpanelLibProto.init;
|
|
61079
|
+
MixpanelLibProto['reset'] = MixpanelLibProto.reset;
|
|
61080
|
+
MixpanelLibProto['enable'] = MixpanelLibProto.enable;
|
|
61081
|
+
MixpanelLibProto['disable'] = MixpanelLibProto.disable;
|
|
61082
|
+
MixpanelLibProto['time_event'] = MixpanelLibProto.time_event;
|
|
61083
|
+
MixpanelLibProto['track'] = MixpanelLibProto.track;
|
|
61084
|
+
MixpanelLibProto['track_links'] = MixpanelLibProto.track_links;
|
|
61085
|
+
MixpanelLibProto['track_forms'] = MixpanelLibProto.track_forms;
|
|
61086
|
+
MixpanelLibProto['track_pageview'] = MixpanelLibProto.track_pageview;
|
|
61087
|
+
MixpanelLibProto['register'] = MixpanelLibProto.register;
|
|
61088
|
+
MixpanelLibProto['register_once'] = MixpanelLibProto.register_once;
|
|
61089
|
+
MixpanelLibProto['unregister'] = MixpanelLibProto.unregister;
|
|
61090
|
+
MixpanelLibProto['identify'] = MixpanelLibProto.identify;
|
|
61091
|
+
MixpanelLibProto['alias'] = MixpanelLibProto.alias;
|
|
61092
|
+
MixpanelLibProto['name_tag'] = MixpanelLibProto.name_tag;
|
|
61093
|
+
MixpanelLibProto['set_config'] = MixpanelLibProto.set_config;
|
|
61094
|
+
MixpanelLibProto['get_config'] = MixpanelLibProto.get_config;
|
|
61095
|
+
MixpanelLibProto['get_api_host'] = MixpanelLibProto.get_api_host;
|
|
61096
|
+
MixpanelLibProto['get_property'] = MixpanelLibProto.get_property;
|
|
61097
|
+
MixpanelLibProto['get_distinct_id'] = MixpanelLibProto.get_distinct_id;
|
|
61098
|
+
MixpanelLibProto['toString'] = MixpanelLibProto.toString;
|
|
61099
|
+
MixpanelLibProto['opt_out_tracking'] = MixpanelLibProto.opt_out_tracking;
|
|
61100
|
+
MixpanelLibProto['opt_in_tracking'] = MixpanelLibProto.opt_in_tracking;
|
|
61101
|
+
MixpanelLibProto['has_opted_out_tracking'] = MixpanelLibProto.has_opted_out_tracking;
|
|
61102
|
+
MixpanelLibProto['_consent_allows'] = MixpanelLibProto._consent_allows;
|
|
61103
|
+
MixpanelLibProto['has_opted_in_tracking'] = MixpanelLibProto.has_opted_in_tracking;
|
|
61104
|
+
MixpanelLibProto['clear_opt_in_out_tracking'] = MixpanelLibProto.clear_opt_in_out_tracking;
|
|
61105
|
+
MixpanelLibProto['get_group'] = MixpanelLibProto.get_group;
|
|
61106
|
+
MixpanelLibProto['set_group'] = MixpanelLibProto.set_group;
|
|
61107
|
+
MixpanelLibProto['add_group'] = MixpanelLibProto.add_group;
|
|
61108
|
+
MixpanelLibProto['remove_group'] = MixpanelLibProto.remove_group;
|
|
61109
|
+
MixpanelLibProto['add_hook'] = MixpanelLibProto.add_hook;
|
|
61110
|
+
MixpanelLibProto['remove_hook'] = MixpanelLibProto.remove_hook;
|
|
61111
|
+
MixpanelLibProto['track_with_groups'] = MixpanelLibProto.track_with_groups;
|
|
61112
|
+
MixpanelLibProto['start_batch_senders'] = MixpanelLibProto.start_batch_senders;
|
|
61113
|
+
MixpanelLibProto['stop_batch_senders'] = MixpanelLibProto.stop_batch_senders;
|
|
61114
|
+
MixpanelLibProto['start_session_recording'] = MixpanelLibProto.start_session_recording;
|
|
61115
|
+
MixpanelLibProto['stop_session_recording'] = MixpanelLibProto.stop_session_recording;
|
|
61116
|
+
MixpanelLibProto['pause_session_recording'] = MixpanelLibProto.pause_session_recording;
|
|
61117
|
+
MixpanelLibProto['resume_session_recording'] = MixpanelLibProto.resume_session_recording;
|
|
61118
|
+
MixpanelLibProto['get_session_recording_properties'] = MixpanelLibProto.get_session_recording_properties;
|
|
61119
|
+
MixpanelLibProto['get_session_replay_url'] = MixpanelLibProto.get_session_replay_url;
|
|
61120
|
+
MixpanelLibProto['get_tab_id'] = MixpanelLibProto.get_tab_id;
|
|
61121
|
+
MixpanelLibProto['DEFAULT_API_ROUTES'] = DEFAULT_API_ROUTES;
|
|
60080
61122
|
|
|
60081
61123
|
// Exports intended only for testing
|
|
60082
|
-
|
|
60083
|
-
|
|
61124
|
+
MixpanelLibProto['__get_recorder'] = MixpanelLibProto.__get_recorder;
|
|
61125
|
+
MixpanelLibProto['__get_recording_init_promise'] = MixpanelLibProto.__get_recording_init_promise;
|
|
60084
61126
|
|
|
60085
61127
|
// MixpanelPersistence Exports
|
|
60086
61128
|
MixpanelPersistence.prototype['properties'] = MixpanelPersistence.prototype.properties;
|