@shrfe/assets 1.0.70-staging → 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 +2112 -1068
- 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
|
}
|
|
@@ -26031,7 +26031,7 @@ class HTTPBaseService {
|
|
|
26031
26031
|
return Promise.reject(error.response || error);
|
|
26032
26032
|
};
|
|
26033
26033
|
async refreshToken() {
|
|
26034
|
-
|
|
26034
|
+
const refreshTokenPath = this.authService.getRefreshTokenPath();
|
|
26035
26035
|
//if (!refreshTokenPath) throw new Error('refreshTokenPath is not configured')
|
|
26036
26036
|
// Add this temporarily for breeze to work
|
|
26037
26037
|
if (!refreshTokenPath) {
|
|
@@ -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 {
|
|
@@ -28653,7 +28681,9 @@ const BRAND_HOSTS = {
|
|
|
28653
28681
|
'coronation.seamlesshrms.com': 'coronation',
|
|
28654
28682
|
'hchub.sterling.ng': 'sterling',
|
|
28655
28683
|
'wemabank.seamlesshrms.com': 'wema-bank',
|
|
28656
|
-
'humancapital.chapelhilldenham.com': 'chapel-hill-denham'
|
|
28684
|
+
'humancapital.chapelhilldenham.com': 'chapel-hill-denham',
|
|
28685
|
+
// For internal testing
|
|
28686
|
+
'unstable-reco.seamlesshrms.com': 'wema-bank'
|
|
28657
28687
|
};
|
|
28658
28688
|
function isBrand(slug) {
|
|
28659
28689
|
return !!slug && BRANDS.includes(slug);
|
|
@@ -28742,7 +28772,7 @@ if (typeof(window) === 'undefined') {
|
|
|
28742
28772
|
|
|
28743
28773
|
var Config = {
|
|
28744
28774
|
DEBUG: false,
|
|
28745
|
-
LIB_VERSION: '2.
|
|
28775
|
+
LIB_VERSION: '2.85.0'
|
|
28746
28776
|
};
|
|
28747
28777
|
|
|
28748
28778
|
// Window global names for async modules
|
|
@@ -47982,14 +48012,18 @@ mixpanel_module_.isElement = function(obj) {
|
|
|
47982
48012
|
};
|
|
47983
48013
|
|
|
47984
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) ? [] : {};
|
|
47985
48017
|
mixpanel_module_.each(obj, function(v, k) {
|
|
47986
48018
|
if (mixpanel_module_.isDate(v)) {
|
|
47987
|
-
|
|
48019
|
+
encoded[k] = mixpanel_module_.formatDate(v);
|
|
47988
48020
|
} else if (mixpanel_module_.isObject(v)) {
|
|
47989
|
-
|
|
48021
|
+
encoded[k] = mixpanel_module_.encodeDates(v); // recurse
|
|
48022
|
+
} else {
|
|
48023
|
+
encoded[k] = v;
|
|
47990
48024
|
}
|
|
47991
48025
|
});
|
|
47992
|
-
return
|
|
48026
|
+
return encoded;
|
|
47993
48027
|
};
|
|
47994
48028
|
|
|
47995
48029
|
mixpanel_module_.timestamp = function() {
|
|
@@ -49206,7 +49240,7 @@ mixpanel_module_.info = {
|
|
|
49206
49240
|
'Firefox iOS': /FxiOS\/(\d+(\.\d+)?)/,
|
|
49207
49241
|
'Konqueror': /Konqueror:(\d+(\.\d+)?)/,
|
|
49208
49242
|
'BlackBerry': /BlackBerry (\d+(\.\d+)?)/,
|
|
49209
|
-
'Android Mobile': /
|
|
49243
|
+
'Android Mobile': /Android\s(\d+(\.\d+)?)/,
|
|
49210
49244
|
'Samsung Internet': /SamsungBrowser\/(\d+(\.\d+)?)/,
|
|
49211
49245
|
'Internet Explorer': /(rv:|MSIE )(\d+(\.\d+)?)/,
|
|
49212
49246
|
'Mozilla': /rv:(\d+(\.\d+)?)/,
|
|
@@ -49460,11 +49494,13 @@ mixpanel_module_['NPO'] = NpoPromise;
|
|
|
49460
49494
|
/**
|
|
49461
49495
|
* @type {import('./wrapper').StorageWrapper}
|
|
49462
49496
|
*/
|
|
49463
|
-
var IDBStorageWrapper = function (dbName, storeName, versionData) {
|
|
49497
|
+
var IDBStorageWrapper = function (dbName, storeName, versionData, options) {
|
|
49464
49498
|
this.dbName = dbName;
|
|
49465
49499
|
this.storeName = storeName;
|
|
49466
49500
|
this.version = versionData.version;
|
|
49467
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;
|
|
49468
49504
|
/**
|
|
49469
49505
|
* @type {Promise<IDBDatabase>|null}
|
|
49470
49506
|
*/
|
|
@@ -49475,25 +49511,47 @@ IDBStorageWrapper.prototype._openDb = function () {
|
|
|
49475
49511
|
var dbName = this.dbName;
|
|
49476
49512
|
var version = this.version;
|
|
49477
49513
|
var storeNamesInDb = this.storeNamesInDb;
|
|
49478
|
-
|
|
49479
|
-
|
|
49480
|
-
|
|
49481
|
-
|
|
49482
|
-
|
|
49483
|
-
|
|
49484
|
-
|
|
49485
|
-
resolve(openRequest.result);
|
|
49486
|
-
};
|
|
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
|
+
};
|
|
49487
49521
|
|
|
49488
|
-
|
|
49489
|
-
|
|
49522
|
+
openRequest['onsuccess'] = function () {
|
|
49523
|
+
resolve(openRequest.result);
|
|
49524
|
+
};
|
|
49490
49525
|
|
|
49491
|
-
|
|
49492
|
-
if (!
|
|
49493
|
-
|
|
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;
|
|
49494
49532
|
}
|
|
49495
|
-
|
|
49496
|
-
|
|
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');
|
|
49497
49555
|
});
|
|
49498
49556
|
};
|
|
49499
49557
|
|
|
@@ -49593,306 +49651,6 @@ var RECORDER_VERSION_DATA = {
|
|
|
49593
49651
|
storeNames: [RECORDING_EVENTS_STORE_NAME, RECORDING_REGISTRY_STORE_NAME]
|
|
49594
49652
|
};
|
|
49595
49653
|
|
|
49596
|
-
/**
|
|
49597
|
-
* GDPR utils
|
|
49598
|
-
*
|
|
49599
|
-
* The General Data Protection Regulation (GDPR) is a regulation in EU law on data protection
|
|
49600
|
-
* and privacy for all individuals within the European Union. It addresses the export of personal
|
|
49601
|
-
* data outside the EU. The GDPR aims primarily to give control back to citizens and residents
|
|
49602
|
-
* over their personal data and to simplify the regulatory environment for international business
|
|
49603
|
-
* by unifying the regulation within the EU.
|
|
49604
|
-
*
|
|
49605
|
-
* This set of utilities is intended to enable opt in/out functionality in the Mixpanel JS SDK.
|
|
49606
|
-
* These functions are used internally by the SDK and are not intended to be publicly exposed.
|
|
49607
|
-
*/
|
|
49608
|
-
|
|
49609
|
-
|
|
49610
|
-
/**
|
|
49611
|
-
* A function used to track a Mixpanel event (e.g. MixpanelLib.track)
|
|
49612
|
-
* @callback trackFunction
|
|
49613
|
-
* @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
|
|
49614
|
-
* @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.
|
|
49615
|
-
* @param {Function} [callback] If provided, the callback function will be called after tracking the event.
|
|
49616
|
-
*/
|
|
49617
|
-
|
|
49618
|
-
/** Public **/
|
|
49619
|
-
|
|
49620
|
-
var GDPR_DEFAULT_PERSISTENCE_PREFIX = '__mp_opt_in_out_';
|
|
49621
|
-
|
|
49622
|
-
/**
|
|
49623
|
-
* Opt the user in to data tracking and cookies/localstorage for the given token
|
|
49624
|
-
* @param {string} token - Mixpanel project tracking token
|
|
49625
|
-
* @param {Object} [options]
|
|
49626
|
-
* @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
|
|
49627
|
-
* @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
|
|
49628
|
-
* @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
|
|
49629
|
-
* @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
|
|
49630
|
-
* @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
|
|
49631
|
-
* @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
|
|
49632
|
-
* @param {string} [options.cookieDomain] - custom cookie domain
|
|
49633
|
-
* @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
|
|
49634
|
-
* @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
|
|
49635
|
-
* @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
|
|
49636
|
-
*/
|
|
49637
|
-
function optIn(token, options) {
|
|
49638
|
-
_optInOut(true, token, options);
|
|
49639
|
-
}
|
|
49640
|
-
|
|
49641
|
-
/**
|
|
49642
|
-
* Opt the user out of data tracking and cookies/localstorage for the given token
|
|
49643
|
-
* @param {string} token - Mixpanel project tracking token
|
|
49644
|
-
* @param {Object} [options]
|
|
49645
|
-
* @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
|
|
49646
|
-
* @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
|
|
49647
|
-
* @param {Number} [options.cookieExpiration] - number of days until the opt-out cookie expires
|
|
49648
|
-
* @param {string} [options.cookieDomain] - custom cookie domain
|
|
49649
|
-
* @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
|
|
49650
|
-
* @param {boolean} [options.crossSubdomainCookie] - whether the opt-out cookie is set as cross-subdomain or not
|
|
49651
|
-
* @param {boolean} [options.secureCookie] - whether the opt-out cookie is set as secure or not
|
|
49652
|
-
*/
|
|
49653
|
-
function optOut(token, options) {
|
|
49654
|
-
_optInOut(false, token, options);
|
|
49655
|
-
}
|
|
49656
|
-
|
|
49657
|
-
/**
|
|
49658
|
-
* Check whether the user has opted in to data tracking and cookies/localstorage for the given token
|
|
49659
|
-
* @param {string} token - Mixpanel project tracking token
|
|
49660
|
-
* @param {Object} [options]
|
|
49661
|
-
* @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
|
|
49662
|
-
* @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
|
|
49663
|
-
* @returns {boolean} whether the user has opted in to the given opt type
|
|
49664
|
-
*/
|
|
49665
|
-
function hasOptedIn(token, options) {
|
|
49666
|
-
return _getStorageValue(token, options) === '1';
|
|
49667
|
-
}
|
|
49668
|
-
|
|
49669
|
-
/**
|
|
49670
|
-
* Check whether the user has opted out of data tracking and cookies/localstorage for the given token
|
|
49671
|
-
* @param {string} token - Mixpanel project tracking token
|
|
49672
|
-
* @param {Object} [options]
|
|
49673
|
-
* @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
|
|
49674
|
-
* @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
|
|
49675
|
-
* @param {boolean} [options.ignoreDnt] - flag to ignore browser DNT settings and always return false
|
|
49676
|
-
* @returns {boolean} whether the user has opted out of the given opt type
|
|
49677
|
-
*/
|
|
49678
|
-
function hasOptedOut(token, options) {
|
|
49679
|
-
if (_hasDoNotTrackFlagOn(options)) {
|
|
49680
|
-
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"');
|
|
49681
|
-
return true;
|
|
49682
|
-
}
|
|
49683
|
-
var optedOut = _getStorageValue(token, options) === '0';
|
|
49684
|
-
if (optedOut) {
|
|
49685
|
-
console$1.warn('You are opted out of Mixpanel tracking. This will prevent the Mixpanel SDK from sending any data.');
|
|
49686
|
-
}
|
|
49687
|
-
return optedOut;
|
|
49688
|
-
}
|
|
49689
|
-
|
|
49690
|
-
/**
|
|
49691
|
-
* Wrap a MixpanelLib method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
|
|
49692
|
-
* If the user has opted out, return early instead of executing the method.
|
|
49693
|
-
* If a callback argument was provided, execute it passing the 0 error code.
|
|
49694
|
-
* @param {function} method - wrapped method to be executed if the user has not opted out
|
|
49695
|
-
* @returns {*} the result of executing method OR undefined if the user has opted out
|
|
49696
|
-
*/
|
|
49697
|
-
function addOptOutCheckMixpanelLib(method) {
|
|
49698
|
-
return _addOptOutCheck(method, function(name) {
|
|
49699
|
-
return this.get_config(name);
|
|
49700
|
-
});
|
|
49701
|
-
}
|
|
49702
|
-
|
|
49703
|
-
/**
|
|
49704
|
-
* Wrap a MixpanelPeople method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
|
|
49705
|
-
* If the user has opted out, return early instead of executing the method.
|
|
49706
|
-
* If a callback argument was provided, execute it passing the 0 error code.
|
|
49707
|
-
* @param {function} method - wrapped method to be executed if the user has not opted out
|
|
49708
|
-
* @returns {*} the result of executing method OR undefined if the user has opted out
|
|
49709
|
-
*/
|
|
49710
|
-
function addOptOutCheckMixpanelPeople(method) {
|
|
49711
|
-
return _addOptOutCheck(method, function(name) {
|
|
49712
|
-
return this._get_config(name);
|
|
49713
|
-
});
|
|
49714
|
-
}
|
|
49715
|
-
|
|
49716
|
-
/**
|
|
49717
|
-
* Wrap a MixpanelGroup method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
|
|
49718
|
-
* If the user has opted out, return early instead of executing the method.
|
|
49719
|
-
* If a callback argument was provided, execute it passing the 0 error code.
|
|
49720
|
-
* @param {function} method - wrapped method to be executed if the user has not opted out
|
|
49721
|
-
* @returns {*} the result of executing method OR undefined if the user has opted out
|
|
49722
|
-
*/
|
|
49723
|
-
function addOptOutCheckMixpanelGroup(method) {
|
|
49724
|
-
return _addOptOutCheck(method, function(name) {
|
|
49725
|
-
return this._get_config(name);
|
|
49726
|
-
});
|
|
49727
|
-
}
|
|
49728
|
-
|
|
49729
|
-
/**
|
|
49730
|
-
* Clear the user's opt in/out status of data tracking and cookies/localstorage for the given token
|
|
49731
|
-
* @param {string} token - Mixpanel project tracking token
|
|
49732
|
-
* @param {Object} [options]
|
|
49733
|
-
* @param {string} [options.persistenceType] Persistence mechanism used - cookie or localStorage
|
|
49734
|
-
* @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
|
|
49735
|
-
* @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
|
|
49736
|
-
* @param {string} [options.cookieDomain] - custom cookie domain
|
|
49737
|
-
* @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
|
|
49738
|
-
* @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
|
|
49739
|
-
* @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
|
|
49740
|
-
*/
|
|
49741
|
-
function clearOptInOut(token, options) {
|
|
49742
|
-
options = options || {};
|
|
49743
|
-
_getStorage(options).remove(
|
|
49744
|
-
_getStorageKey(token, options), !!options.crossSubdomainCookie, options.cookieDomain
|
|
49745
|
-
);
|
|
49746
|
-
}
|
|
49747
|
-
|
|
49748
|
-
/** Private **/
|
|
49749
|
-
|
|
49750
|
-
/**
|
|
49751
|
-
* Get storage util
|
|
49752
|
-
* @param {Object} [options]
|
|
49753
|
-
* @param {string} [options.persistenceType]
|
|
49754
|
-
* @returns {object} either _.cookie or _.localstorage
|
|
49755
|
-
*/
|
|
49756
|
-
function _getStorage(options) {
|
|
49757
|
-
options = options || {};
|
|
49758
|
-
return options.persistenceType === 'localStorage' ? mixpanel_module_.localStorage : mixpanel_module_.cookie;
|
|
49759
|
-
}
|
|
49760
|
-
|
|
49761
|
-
/**
|
|
49762
|
-
* Get the name of the cookie that is used for the given opt type (tracking, cookie, etc.)
|
|
49763
|
-
* @param {string} token - Mixpanel project tracking token
|
|
49764
|
-
* @param {Object} [options]
|
|
49765
|
-
* @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
|
|
49766
|
-
* @returns {string} the name of the cookie for the given opt type
|
|
49767
|
-
*/
|
|
49768
|
-
function _getStorageKey(token, options) {
|
|
49769
|
-
options = options || {};
|
|
49770
|
-
return (options.persistencePrefix || GDPR_DEFAULT_PERSISTENCE_PREFIX) + token;
|
|
49771
|
-
}
|
|
49772
|
-
|
|
49773
|
-
/**
|
|
49774
|
-
* Get the value of the cookie that is used for the given opt type (tracking, cookie, etc.)
|
|
49775
|
-
* @param {string} token - Mixpanel project tracking token
|
|
49776
|
-
* @param {Object} [options]
|
|
49777
|
-
* @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
|
|
49778
|
-
* @returns {string} the value of the cookie for the given opt type
|
|
49779
|
-
*/
|
|
49780
|
-
function _getStorageValue(token, options) {
|
|
49781
|
-
return _getStorage(options).get(_getStorageKey(token, options));
|
|
49782
|
-
}
|
|
49783
|
-
|
|
49784
|
-
/**
|
|
49785
|
-
* Check whether the user has set the DNT/doNotTrack setting to true in their browser
|
|
49786
|
-
* @param {Object} [options]
|
|
49787
|
-
* @param {string} [options.window] - alternate window object to check; used to force various DNT settings in browser tests
|
|
49788
|
-
* @param {boolean} [options.ignoreDnt] - flag to ignore browser DNT settings and always return false
|
|
49789
|
-
* @returns {boolean} whether the DNT setting is true
|
|
49790
|
-
*/
|
|
49791
|
-
function _hasDoNotTrackFlagOn(options) {
|
|
49792
|
-
if (options && options.ignoreDnt) {
|
|
49793
|
-
return false;
|
|
49794
|
-
}
|
|
49795
|
-
var win$1 = (options && options.window) || mixpanel_module_win;
|
|
49796
|
-
var nav = win$1['navigator'] || {};
|
|
49797
|
-
var hasDntOn = false;
|
|
49798
|
-
|
|
49799
|
-
mixpanel_module_.each([
|
|
49800
|
-
nav['doNotTrack'], // standard
|
|
49801
|
-
nav['msDoNotTrack'],
|
|
49802
|
-
win$1['doNotTrack']
|
|
49803
|
-
], function(dntValue) {
|
|
49804
|
-
if (mixpanel_module_.includes([true, 1, '1', 'yes'], dntValue)) {
|
|
49805
|
-
hasDntOn = true;
|
|
49806
|
-
}
|
|
49807
|
-
});
|
|
49808
|
-
|
|
49809
|
-
return hasDntOn;
|
|
49810
|
-
}
|
|
49811
|
-
|
|
49812
|
-
/**
|
|
49813
|
-
* Set cookie/localstorage for the user indicating that they are opted in or out for the given opt type
|
|
49814
|
-
* @param {boolean} optValue - whether to opt the user in or out for the given opt type
|
|
49815
|
-
* @param {string} token - Mixpanel project tracking token
|
|
49816
|
-
* @param {Object} [options]
|
|
49817
|
-
* @param {trackFunction} [options.track] - function used for tracking a Mixpanel event to record the opt-in action
|
|
49818
|
-
* @param {string} [options.trackEventName] - event name to be used for tracking the opt-in action
|
|
49819
|
-
* @param {Object} [options.trackProperties] - set of properties to be tracked along with the opt-in action
|
|
49820
|
-
* @param {string} [options.persistencePrefix=__mp_opt_in_out] - custom prefix to be used in the cookie/localstorage name
|
|
49821
|
-
* @param {Number} [options.cookieExpiration] - number of days until the opt-in cookie expires
|
|
49822
|
-
* @param {string} [options.cookieDomain] - custom cookie domain
|
|
49823
|
-
* @param {boolean} [options.crossSiteCookie] - whether the opt-in cookie is set as cross-site-enabled
|
|
49824
|
-
* @param {boolean} [options.crossSubdomainCookie] - whether the opt-in cookie is set as cross-subdomain or not
|
|
49825
|
-
* @param {boolean} [options.secureCookie] - whether the opt-in cookie is set as secure or not
|
|
49826
|
-
*/
|
|
49827
|
-
function _optInOut(optValue, token, options) {
|
|
49828
|
-
if (!mixpanel_module_.isString(token) || !token.length) {
|
|
49829
|
-
console$1.error('gdpr.' + (optValue ? 'optIn' : 'optOut') + ' called with an invalid token');
|
|
49830
|
-
return;
|
|
49831
|
-
}
|
|
49832
|
-
|
|
49833
|
-
options = options || {};
|
|
49834
|
-
|
|
49835
|
-
_getStorage(options).set(
|
|
49836
|
-
_getStorageKey(token, options),
|
|
49837
|
-
optValue ? 1 : 0,
|
|
49838
|
-
mixpanel_module_.isNumber(options.cookieExpiration) ? options.cookieExpiration : null,
|
|
49839
|
-
!!options.crossSubdomainCookie,
|
|
49840
|
-
!!options.secureCookie,
|
|
49841
|
-
!!options.crossSiteCookie,
|
|
49842
|
-
options.cookieDomain
|
|
49843
|
-
);
|
|
49844
|
-
|
|
49845
|
-
if (options.track && optValue) { // only track event if opting in (optValue=true)
|
|
49846
|
-
options.track(options.trackEventName || '$opt_in', options.trackProperties, {
|
|
49847
|
-
'send_immediately': true
|
|
49848
|
-
});
|
|
49849
|
-
}
|
|
49850
|
-
}
|
|
49851
|
-
|
|
49852
|
-
/**
|
|
49853
|
-
* Wrap a method with a check for whether the user is opted out of data tracking and cookies/localstorage for the given token
|
|
49854
|
-
* If the user has opted out, return early instead of executing the method.
|
|
49855
|
-
* If a callback argument was provided, execute it passing the 0 error code.
|
|
49856
|
-
* @param {function} method - wrapped method to be executed if the user has not opted out
|
|
49857
|
-
* @param {function} getConfigValue - getter function for the Mixpanel API token and other options to be used with opt-out check
|
|
49858
|
-
* @returns {*} the result of executing method OR undefined if the user has opted out
|
|
49859
|
-
*/
|
|
49860
|
-
function _addOptOutCheck(method, getConfigValue) {
|
|
49861
|
-
return function() {
|
|
49862
|
-
var optedOut = false;
|
|
49863
|
-
|
|
49864
|
-
try {
|
|
49865
|
-
var token = getConfigValue.call(this, 'token');
|
|
49866
|
-
var ignoreDnt = getConfigValue.call(this, 'ignore_dnt');
|
|
49867
|
-
var persistenceType = getConfigValue.call(this, 'opt_out_tracking_persistence_type');
|
|
49868
|
-
var persistencePrefix = getConfigValue.call(this, 'opt_out_tracking_cookie_prefix');
|
|
49869
|
-
var win = getConfigValue.call(this, 'window'); // used to override window during browser tests
|
|
49870
|
-
|
|
49871
|
-
if (token) { // if there was an issue getting the token, continue method execution as normal
|
|
49872
|
-
optedOut = hasOptedOut(token, {
|
|
49873
|
-
ignoreDnt: ignoreDnt,
|
|
49874
|
-
persistenceType: persistenceType,
|
|
49875
|
-
persistencePrefix: persistencePrefix,
|
|
49876
|
-
window: win
|
|
49877
|
-
});
|
|
49878
|
-
}
|
|
49879
|
-
} catch(err) {
|
|
49880
|
-
console$1.error('Unexpected error when checking tracking opt-out status: ' + err);
|
|
49881
|
-
}
|
|
49882
|
-
|
|
49883
|
-
if (!optedOut) {
|
|
49884
|
-
return method.apply(this, arguments);
|
|
49885
|
-
}
|
|
49886
|
-
|
|
49887
|
-
var callback = arguments[arguments.length - 1];
|
|
49888
|
-
if (typeof(callback) === 'function') {
|
|
49889
|
-
callback(0);
|
|
49890
|
-
}
|
|
49891
|
-
|
|
49892
|
-
return;
|
|
49893
|
-
};
|
|
49894
|
-
}
|
|
49895
|
-
|
|
49896
49654
|
var logger$9 = console_with_prefix('lock');
|
|
49897
49655
|
|
|
49898
49656
|
/**
|
|
@@ -50125,6 +49883,7 @@ var RequestQueue = function (storageKey, options) {
|
|
|
50125
49883
|
});
|
|
50126
49884
|
}
|
|
50127
49885
|
this.reportError = options.errorReporter || mixpanel_module_.bind(logger$8.error, logger$8);
|
|
49886
|
+
this.consentGate = options.consentGate;
|
|
50128
49887
|
|
|
50129
49888
|
this.pid = options.pid || null; // pass pid to test out storage lock contention scenarios
|
|
50130
49889
|
|
|
@@ -50176,7 +49935,7 @@ RequestQueue.prototype.enqueue = function (item, flushInterval) {
|
|
|
50176
49935
|
'payload': item
|
|
50177
49936
|
};
|
|
50178
49937
|
|
|
50179
|
-
if (!this.
|
|
49938
|
+
if (!this._persists()) {
|
|
50180
49939
|
this.memQueue.push(queueEntry);
|
|
50181
49940
|
return PromisePolyfill.resolve(true);
|
|
50182
49941
|
} else {
|
|
@@ -50184,7 +49943,20 @@ RequestQueue.prototype.enqueue = function (item, flushInterval) {
|
|
|
50184
49943
|
}
|
|
50185
49944
|
};
|
|
50186
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
|
+
|
|
50187
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
|
+
}
|
|
50188
49960
|
var enqueueItem = mixpanel_module_.bind(function () {
|
|
50189
49961
|
return this.ensureInit()
|
|
50190
49962
|
.then(mixpanel_module_.bind(function () {
|
|
@@ -50284,7 +50056,7 @@ RequestQueue.prototype.removeItemsByID = function (ids) {
|
|
|
50284
50056
|
});
|
|
50285
50057
|
|
|
50286
50058
|
this.memQueue = filterOutIDsAndInvalid(this.memQueue, idSet);
|
|
50287
|
-
if (!this.
|
|
50059
|
+
if (!this._persists()) {
|
|
50288
50060
|
return PromisePolyfill.resolve(true);
|
|
50289
50061
|
} else {
|
|
50290
50062
|
var removeFromStorage = mixpanel_module_.bind(function () {
|
|
@@ -50372,7 +50144,7 @@ var updatePayloads = function (existingItems, itemsToUpdate) {
|
|
|
50372
50144
|
*/
|
|
50373
50145
|
RequestQueue.prototype.updatePayloads = function (itemsToUpdate) {
|
|
50374
50146
|
this.memQueue = updatePayloads(this.memQueue, itemsToUpdate);
|
|
50375
|
-
if (!this.
|
|
50147
|
+
if (!this._persists()) {
|
|
50376
50148
|
return PromisePolyfill.resolve(true);
|
|
50377
50149
|
} else {
|
|
50378
50150
|
return this.lock
|
|
@@ -50427,11 +50199,14 @@ RequestQueue.prototype.readFromStorage = function () {
|
|
|
50427
50199
|
RequestQueue.prototype.saveToStorage = function (queue) {
|
|
50428
50200
|
return this.ensureInit()
|
|
50429
50201
|
.then(mixpanel_module_.bind(function () {
|
|
50430
|
-
|
|
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
|
+
});
|
|
50431
50209
|
}, this))
|
|
50432
|
-
.then(function () {
|
|
50433
|
-
return true;
|
|
50434
|
-
})
|
|
50435
50210
|
.catch(mixpanel_module_.bind(function (err) {
|
|
50436
50211
|
this.reportError('Error saving queue', err);
|
|
50437
50212
|
return false;
|
|
@@ -50448,6 +50223,9 @@ RequestQueue.prototype.clear = function () {
|
|
|
50448
50223
|
return this.ensureInit()
|
|
50449
50224
|
.then(mixpanel_module_.bind(function () {
|
|
50450
50225
|
return this.queueStorage.removeItem(this.storageKey);
|
|
50226
|
+
}, this))
|
|
50227
|
+
.catch(mixpanel_module_.bind(function (err) {
|
|
50228
|
+
this.reportError('Error clearing queue', err);
|
|
50451
50229
|
}, this));
|
|
50452
50230
|
} else {
|
|
50453
50231
|
return PromisePolyfill.resolve();
|
|
@@ -50473,7 +50251,8 @@ var RequestBatcher = function(storageKey, options) {
|
|
|
50473
50251
|
sharedLockStorage: options.sharedLockStorage,
|
|
50474
50252
|
sharedLockTimeoutMS: options.sharedLockTimeoutMS,
|
|
50475
50253
|
usePersistence: options.usePersistence,
|
|
50476
|
-
enqueueThrottleMs: options.enqueueThrottleMs
|
|
50254
|
+
enqueueThrottleMs: options.enqueueThrottleMs,
|
|
50255
|
+
consentGate: options.consentGate
|
|
50477
50256
|
});
|
|
50478
50257
|
|
|
50479
50258
|
this.libConfig = options.libConfig;
|
|
@@ -52505,6 +52284,8 @@ function isUserEvent(ev) {
|
|
|
52505
52284
|
/**
|
|
52506
52285
|
* @typedef {Object} SessionRecordingOptions
|
|
52507
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
|
|
52508
52289
|
* @property {String} [options.replayId] - unique uuid for a single replay
|
|
52509
52290
|
* @property {Function} [options.onIdleTimeout] - callback when a recording reaches idle timeout
|
|
52510
52291
|
* @property {Function} [options.onMaxLengthReached] - callback when a recording reaches its maximum length
|
|
@@ -52535,6 +52316,7 @@ function isUserEvent(ev) {
|
|
|
52535
52316
|
*/
|
|
52536
52317
|
var SessionRecording = function(options) {
|
|
52537
52318
|
this._mixpanel = options.mixpanelInstance;
|
|
52319
|
+
this.consentGate = options.consentGate;
|
|
52538
52320
|
this._onIdleTimeout = options.onIdleTimeout || NOOP_FUNC;
|
|
52539
52321
|
this._onMaxLengthReached = options.onMaxLengthReached || NOOP_FUNC;
|
|
52540
52322
|
this._onBatchSent = options.onBatchSent || NOOP_FUNC;
|
|
@@ -52561,7 +52343,7 @@ var SessionRecording = function(options) {
|
|
|
52561
52343
|
|
|
52562
52344
|
// disable persistence if localStorage is not supported
|
|
52563
52345
|
// request-queue will automatically disable persistence if indexedDB fails to initialize
|
|
52564
|
-
var usePersistence = localStorageSupported(options.sharedLockStorage || getLocalStorage(), true) &&
|
|
52346
|
+
var usePersistence = localStorageSupported(options.sharedLockStorage || getLocalStorage(), true) && this.consentGate.allowsPersistence();
|
|
52565
52347
|
|
|
52566
52348
|
// each replay has its own batcher key to avoid conflicts between rrweb events of different recordings
|
|
52567
52349
|
this.batcherKey = '__mprec_' + this.getConfig('name') + '_' + this.getConfig('token') + '_' + this.replayId;
|
|
@@ -52575,6 +52357,7 @@ var SessionRecording = function(options) {
|
|
|
52575
52357
|
sharedLockStorage: options.sharedLockStorage,
|
|
52576
52358
|
usePersistence: usePersistence,
|
|
52577
52359
|
stopAllBatchingFunc: this.stopRecording.bind(this),
|
|
52360
|
+
consentGate: this.consentGate,
|
|
52578
52361
|
|
|
52579
52362
|
// increased throttle and shared lock timeout because recording events are very high frequency.
|
|
52580
52363
|
// this will minimize the amount of lock contention between enqueued events.
|
|
@@ -52630,13 +52413,6 @@ SessionRecording.prototype.getConfig = function(configVar) {
|
|
|
52630
52413
|
return this._mixpanel.get_config(configVar);
|
|
52631
52414
|
};
|
|
52632
52415
|
|
|
52633
|
-
// Alias for getConfig, used by the common addOptOutCheckMixpanelLib function which
|
|
52634
|
-
// reaches into this class instance and expects the snake case version of the function.
|
|
52635
|
-
// eslint-disable-next-line camelcase
|
|
52636
|
-
SessionRecording.prototype.get_config = function(configVar) {
|
|
52637
|
-
return this.getConfig(configVar);
|
|
52638
|
-
};
|
|
52639
|
-
|
|
52640
52416
|
SessionRecording.prototype.startRecording = function (shouldStopBatcher) {
|
|
52641
52417
|
if (this._rrwebRecord === null) {
|
|
52642
52418
|
this.reportError('rrweb record function not provided. ');
|
|
@@ -52811,19 +52587,15 @@ SessionRecording.prototype.isRrwebStopped = function () {
|
|
|
52811
52587
|
|
|
52812
52588
|
|
|
52813
52589
|
/**
|
|
52814
|
-
* Flushes the current batch of events to the server,
|
|
52815
|
-
* 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.
|
|
52816
52591
|
*/
|
|
52817
52592
|
SessionRecording.prototype.flushEventsWithOptOut = function (data, options, cb) {
|
|
52818
|
-
|
|
52819
|
-
|
|
52820
|
-
|
|
52821
|
-
|
|
52822
|
-
|
|
52823
|
-
|
|
52824
|
-
}.bind(this);
|
|
52825
|
-
|
|
52826
|
-
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);
|
|
52827
52599
|
};
|
|
52828
52600
|
|
|
52829
52601
|
/**
|
|
@@ -52879,7 +52651,12 @@ SessionRecording.prototype._getApiRoute = function () {
|
|
|
52879
52651
|
return this.getConfig('api_routes')['record'];
|
|
52880
52652
|
};
|
|
52881
52653
|
|
|
52654
|
+
// consent can be withdrawn while the batch is compressed, so it is checked again before sending
|
|
52882
52655
|
SessionRecording.prototype._sendRequest = function(currentReplayId, reqParams, reqBody, callback) {
|
|
52656
|
+
if (!this.consentGate.allowsApiCalls()) {
|
|
52657
|
+
callback(0);
|
|
52658
|
+
return;
|
|
52659
|
+
}
|
|
52883
52660
|
var onSuccess = function (response, responseBody) {
|
|
52884
52661
|
// Update batch specific props only if the request was successful to guarantee ordering.
|
|
52885
52662
|
// RequestBatcher will always flush the next batch after the previous one succeeds.
|
|
@@ -52916,7 +52693,7 @@ SessionRecording.prototype._sendRequest = function(currentReplayId, reqParams, r
|
|
|
52916
52693
|
});
|
|
52917
52694
|
};
|
|
52918
52695
|
|
|
52919
|
-
SessionRecording.prototype._flushEvents =
|
|
52696
|
+
SessionRecording.prototype._flushEvents = function(data, options, callback) {
|
|
52920
52697
|
var numEvents = data.length;
|
|
52921
52698
|
|
|
52922
52699
|
if (numEvents > 0) {
|
|
@@ -52962,6 +52739,11 @@ SessionRecording.prototype._flushEvents = addOptOutCheckMixpanelLib(function (da
|
|
|
52962
52739
|
var eventsJson = JSON.stringify(data);
|
|
52963
52740
|
Object.assign(reqParams, this.getUserIdInfo());
|
|
52964
52741
|
|
|
52742
|
+
var sendUncompressed = function() {
|
|
52743
|
+
reqParams['format'] = 'body';
|
|
52744
|
+
this._sendRequest(replayId, reqParams, eventsJson, callback);
|
|
52745
|
+
}.bind(this);
|
|
52746
|
+
|
|
52965
52747
|
if (canUseCompressionStream(mixpanel_module_userAgent, mixpanel_module_navigator.vendor, windowOpera)) {
|
|
52966
52748
|
var jsonStream = new Blob([eventsJson], {type: 'application/json'}).stream();
|
|
52967
52749
|
var gzipStream = jsonStream.pipeThrough(new CompressionStream('gzip'));
|
|
@@ -52970,13 +52752,15 @@ SessionRecording.prototype._flushEvents = addOptOutCheckMixpanelLib(function (da
|
|
|
52970
52752
|
.then(function(compressedBlob) {
|
|
52971
52753
|
reqParams['format'] = 'gzip';
|
|
52972
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();
|
|
52973
52758
|
}.bind(this));
|
|
52974
52759
|
} else {
|
|
52975
|
-
|
|
52976
|
-
this._sendRequest(replayId, reqParams, eventsJson, callback);
|
|
52760
|
+
sendUncompressed();
|
|
52977
52761
|
}
|
|
52978
52762
|
}
|
|
52979
|
-
}
|
|
52763
|
+
};
|
|
52980
52764
|
|
|
52981
52765
|
|
|
52982
52766
|
SessionRecording.prototype.reportError = function(msg, err) {
|
|
@@ -53031,9 +52815,10 @@ SessionRecording.prototype._getRecordMinMs = function() {
|
|
|
53031
52815
|
*/
|
|
53032
52816
|
SessionRecording.prototype._getMaskFn = function(shouldMaskFn, privacyConfig) {
|
|
53033
52817
|
return function(text, element) {
|
|
53034
|
-
//
|
|
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)
|
|
53035
52820
|
if (!text.trim().length) {
|
|
53036
|
-
return
|
|
52821
|
+
return text;
|
|
53037
52822
|
}
|
|
53038
52823
|
|
|
53039
52824
|
var shouldMask = true;
|
|
@@ -53061,11 +52846,12 @@ var RecordingRegistry = function (options) {
|
|
|
53061
52846
|
this.idb = new IDBStorageWrapper(MIXPANEL_BROWSER_DB_NAME, RECORDING_REGISTRY_STORE_NAME, RECORDER_VERSION_DATA);
|
|
53062
52847
|
this.errorReporter = options.errorReporter;
|
|
53063
52848
|
this.mixpanelInstance = options.mixpanelInstance;
|
|
52849
|
+
this.consentGate = options.consentGate;
|
|
53064
52850
|
this.sharedLockStorage = options.sharedLockStorage;
|
|
53065
52851
|
};
|
|
53066
52852
|
|
|
53067
52853
|
RecordingRegistry.prototype.isPersistenceEnabled = function() {
|
|
53068
|
-
return
|
|
52854
|
+
return this.consentGate.allowsPersistence();
|
|
53069
52855
|
};
|
|
53070
52856
|
|
|
53071
52857
|
RecordingRegistry.prototype.handleError = function (err) {
|
|
@@ -53076,6 +52862,7 @@ RecordingRegistry.prototype.handleError = function (err) {
|
|
|
53076
52862
|
* @param {import('./session-recording').SerializedRecording} serializedRecording
|
|
53077
52863
|
*/
|
|
53078
52864
|
RecordingRegistry.prototype.setActiveRecording = function (serializedRecording) {
|
|
52865
|
+
// a recording that resumes after consent stops storage writes nothing
|
|
53079
52866
|
if (!this.isPersistenceEnabled()) {
|
|
53080
52867
|
return PromisePolyfill.resolve();
|
|
53081
52868
|
}
|
|
@@ -53112,13 +52899,10 @@ RecordingRegistry.prototype.getActiveRecording = function () {
|
|
|
53112
52899
|
};
|
|
53113
52900
|
|
|
53114
52901
|
RecordingRegistry.prototype.clearActiveRecording = function () {
|
|
53115
|
-
|
|
53116
|
-
|
|
53117
|
-
|
|
53118
|
-
|
|
53119
|
-
} else {
|
|
53120
|
-
return this.deleteActiveRecording();
|
|
53121
|
-
}
|
|
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();
|
|
53122
52906
|
};
|
|
53123
52907
|
|
|
53124
52908
|
RecordingRegistry.prototype.markActiveRecordingExpired = function () {
|
|
@@ -53132,16 +52916,6 @@ RecordingRegistry.prototype.markActiveRecordingExpired = function () {
|
|
|
53132
52916
|
.catch(this.handleError.bind(this));
|
|
53133
52917
|
};
|
|
53134
52918
|
|
|
53135
|
-
RecordingRegistry.prototype.deleteActiveRecording = function () {
|
|
53136
|
-
// avoid initializing IDB if this registry instance hasn't already written a recording
|
|
53137
|
-
if (this.idb.isInitialized()) {
|
|
53138
|
-
return this.idb.removeItem(this.mixpanelInstance.get_tab_id())
|
|
53139
|
-
.catch(this.handleError.bind(this));
|
|
53140
|
-
} else {
|
|
53141
|
-
return PromisePolyfill.resolve();
|
|
53142
|
-
}
|
|
53143
|
-
};
|
|
53144
|
-
|
|
53145
52919
|
/**
|
|
53146
52920
|
* Flush any inactive recordings from the registry to minimize data loss.
|
|
53147
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.
|
|
@@ -53164,6 +52938,7 @@ RecordingRegistry.prototype.flushInactiveRecordings = function () {
|
|
|
53164
52938
|
.map(function (serializedRecording) {
|
|
53165
52939
|
var sessionRecording = SessionRecording.deserialize(serializedRecording, {
|
|
53166
52940
|
mixpanelInstance: this.mixpanelInstance,
|
|
52941
|
+
consentGate: this.consentGate,
|
|
53167
52942
|
sharedLockStorage: this.sharedLockStorage
|
|
53168
52943
|
});
|
|
53169
52944
|
return sessionRecording.unloadPersistedData()
|
|
@@ -53179,6 +52954,79 @@ RecordingRegistry.prototype.flushInactiveRecordings = function () {
|
|
|
53179
52954
|
.catch(this.handleError.bind(this));
|
|
53180
52955
|
};
|
|
53181
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
|
+
|
|
53182
53030
|
var logger$3 = console_with_prefix('recorder');
|
|
53183
53031
|
|
|
53184
53032
|
/**
|
|
@@ -53189,12 +53037,14 @@ var MixpanelRecorder = function(mixpanelInstance, rrwebRecord, sharedLockStorage
|
|
|
53189
53037
|
this.mixpanelInstance = mixpanelInstance;
|
|
53190
53038
|
this.rrwebRecord = rrwebRecord || record;
|
|
53191
53039
|
this.sharedLockStorage = sharedLockStorage;
|
|
53040
|
+
this.consentGate = consentGateFor(mixpanelInstance);
|
|
53192
53041
|
|
|
53193
53042
|
/**
|
|
53194
53043
|
* @member {import('./registry').RecordingRegistry}
|
|
53195
53044
|
*/
|
|
53196
53045
|
this.recordingRegistry = new RecordingRegistry({
|
|
53197
53046
|
mixpanelInstance: this.mixpanelInstance,
|
|
53047
|
+
consentGate: this.consentGate,
|
|
53198
53048
|
errorReporter: logger$3.error,
|
|
53199
53049
|
sharedLockStorage: sharedLockStorage
|
|
53200
53050
|
});
|
|
@@ -53231,6 +53081,7 @@ MixpanelRecorder.prototype.startRecording = function(options) {
|
|
|
53231
53081
|
*/
|
|
53232
53082
|
var sessionRecordingOptions = {
|
|
53233
53083
|
mixpanelInstance: this.mixpanelInstance,
|
|
53084
|
+
consentGate: this.consentGate,
|
|
53234
53085
|
onBatchSent: onBatchSent,
|
|
53235
53086
|
onIdleTimeout: onIdleTimeout,
|
|
53236
53087
|
onMaxLengthReached: onMaxLengthReached,
|
|
@@ -55252,16 +55103,23 @@ FeatureFlagPersistence.prototype.save = function(context, flagsMap, pendingFirst
|
|
|
55252
55103
|
});
|
|
55253
55104
|
};
|
|
55254
55105
|
|
|
55106
|
+
/**
|
|
55107
|
+
* Remove the persisted variants, without creating the database.
|
|
55108
|
+
* @returns {Promise}
|
|
55109
|
+
*/
|
|
55255
55110
|
FeatureFlagPersistence.prototype.clear = function() {
|
|
55256
55111
|
if (this.isGloballyDisabled()) {
|
|
55257
55112
|
return Promise.resolve();
|
|
55258
55113
|
}
|
|
55259
|
-
|
|
55260
|
-
|
|
55261
|
-
|
|
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() {
|
|
55262
55119
|
logger$2.log('Cleared persisted variants from IndexedDB');
|
|
55263
55120
|
}).catch(function(error) {
|
|
55264
|
-
|
|
55121
|
+
// usually the device has no database, so there's nothing to clear
|
|
55122
|
+
logger$2.log('No persisted variants cleared from IndexedDB:', error);
|
|
55265
55123
|
});
|
|
55266
55124
|
};
|
|
55267
55125
|
|
|
@@ -55324,11 +55182,15 @@ var FeatureFlagManager = function(initOptions) {
|
|
|
55324
55182
|
this.setMpConfig = initOptions.setConfigFunc;
|
|
55325
55183
|
this.getMpProperty = initOptions.getPropertyFunc;
|
|
55326
55184
|
this.track = initOptions.trackingFunc;
|
|
55185
|
+
this.consentGate = initOptions.consentGate;
|
|
55327
55186
|
this.loadExtraBundle = initOptions.loadExtraBundle || function() {};
|
|
55328
55187
|
this.targetingSrc = initOptions.targetingSrc || '';
|
|
55329
55188
|
};
|
|
55330
55189
|
|
|
55331
55190
|
FeatureFlagManager.prototype.init = function() {
|
|
55191
|
+
if (!this.consentGate.allowsFetching()) {
|
|
55192
|
+
return;
|
|
55193
|
+
}
|
|
55332
55194
|
if (!this.minApisSupported()) {
|
|
55333
55195
|
logger$1.critical('Feature Flags unavailable: missing minimum required APIs');
|
|
55334
55196
|
return;
|
|
@@ -55344,7 +55206,7 @@ FeatureFlagManager.prototype.init = function() {
|
|
|
55344
55206
|
this.persistence = new FeatureFlagPersistence(
|
|
55345
55207
|
this.getConfig(CONFIG_PERSISTENCE),
|
|
55346
55208
|
this.getMpConfig('token'),
|
|
55347
|
-
mixpanel_module_.bind(function() { return this.
|
|
55209
|
+
mixpanel_module_.bind(function() { return !this.consentGate.allowsPersistence(); }, this)
|
|
55348
55210
|
);
|
|
55349
55211
|
|
|
55350
55212
|
this.persistenceLoadedPromise = this.persistence.loadFlagsFromStorage(this._buildContext())
|
|
@@ -55412,7 +55274,7 @@ FeatureFlagManager.prototype.getConfig = function(key) {
|
|
|
55412
55274
|
};
|
|
55413
55275
|
|
|
55414
55276
|
FeatureFlagManager.prototype.isSystemEnabled = function() {
|
|
55415
|
-
return !!this.getMpConfig(FLAGS_CONFIG_KEY);
|
|
55277
|
+
return !!this.getMpConfig(FLAGS_CONFIG_KEY) && this.consentGate.allowsFetching();
|
|
55416
55278
|
};
|
|
55417
55279
|
|
|
55418
55280
|
FeatureFlagManager.prototype.updateContext = function(newContext, options) {
|
|
@@ -55443,6 +55305,14 @@ FeatureFlagManager.prototype.areFlagsReady = function() {
|
|
|
55443
55305
|
return !!this.flags;
|
|
55444
55306
|
};
|
|
55445
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
|
+
|
|
55446
55316
|
FeatureFlagManager.prototype.fetchFlags = function() {
|
|
55447
55317
|
if (!this.isSystemEnabled()) {
|
|
55448
55318
|
return Promise.resolve();
|
|
@@ -55738,6 +55608,9 @@ FeatureFlagManager.prototype.getFirstTimeEventApiRoute = function(flagId) {
|
|
|
55738
55608
|
};
|
|
55739
55609
|
|
|
55740
55610
|
FeatureFlagManager.prototype.recordFirstTimeEvent = function(flagId, projectId, firstTimeEventHash) {
|
|
55611
|
+
if (!this.consentGate.allowsFetching()) {
|
|
55612
|
+
return Promise.resolve();
|
|
55613
|
+
}
|
|
55741
55614
|
var distinctId = this.getMpProperty('distinct_id');
|
|
55742
55615
|
var traceparent = generateTraceparent();
|
|
55743
55616
|
|
|
@@ -56018,6 +55891,8 @@ var RecorderManager = function(initOptions) {
|
|
|
56018
55891
|
this.getTabId = initOptions.getTabIdFunc;
|
|
56019
55892
|
this.reportError = initOptions.reportErrorFunc;
|
|
56020
55893
|
this.getDistinctId = initOptions.getDistinctIdFunc;
|
|
55894
|
+
// recording stores the session before it sends it
|
|
55895
|
+
this.consentGate = initOptions.consentGate;
|
|
56021
55896
|
this.loadExtraBundle = initOptions.loadExtraBundle;
|
|
56022
55897
|
this.recorderSrc = initOptions.recorderSrc;
|
|
56023
55898
|
this.targetingSrc = initOptions.targetingSrc;
|
|
@@ -56029,8 +55904,8 @@ var RecorderManager = function(initOptions) {
|
|
|
56029
55904
|
};
|
|
56030
55905
|
|
|
56031
55906
|
RecorderManager.prototype.shouldLoadRecorder = function() {
|
|
56032
|
-
if (this.
|
|
56033
|
-
console$1.log('Load recorder check skipped
|
|
55907
|
+
if (!this.consentGate.allowsPersistence()) {
|
|
55908
|
+
console$1.log('Load recorder check skipped without persistence');
|
|
56034
55909
|
return PromisePolyfill.resolve(false);
|
|
56035
55910
|
}
|
|
56036
55911
|
|
|
@@ -56057,6 +55932,10 @@ RecorderManager.prototype.shouldLoadRecorder = function() {
|
|
|
56057
55932
|
};
|
|
56058
55933
|
|
|
56059
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
|
+
}
|
|
56060
55939
|
if (!mixpanel_module_win['MutationObserver']) {
|
|
56061
55940
|
console$1.critical('Browser does not support MutationObserver; skipping session recording');
|
|
56062
55941
|
return PromisePolyfill.resolve();
|
|
@@ -56065,6 +55944,11 @@ RecorderManager.prototype.checkAndStartSessionRecording = function(force_start,
|
|
|
56065
55944
|
var loadRecorder = mixpanel_module_.bind(function(startNewIfInactive) {
|
|
56066
55945
|
return new PromisePolyfill(mixpanel_module_.bind(function(resolve) {
|
|
56067
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
|
+
}
|
|
56068
55952
|
this._recorder = this._recorder || new mixpanel_module_win[RECORDER_GLOBAL_NAME](this.mixpanelInstance);
|
|
56069
55953
|
this._recorder['resumeRecording'](startNewIfInactive);
|
|
56070
55954
|
resolve();
|
|
@@ -56588,137 +56472,186 @@ var apiActions = {
|
|
|
56588
56472
|
|
|
56589
56473
|
/**
|
|
56590
56474
|
* Mixpanel Group Object
|
|
56591
|
-
* @
|
|
56475
|
+
* @class
|
|
56592
56476
|
*/
|
|
56593
|
-
|
|
56477
|
+
function MixpanelGroup() {}
|
|
56594
56478
|
|
|
56595
56479
|
mixpanel_module_.extend(MixpanelGroup.prototype, apiActions);
|
|
56596
56480
|
|
|
56597
|
-
|
|
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) {
|
|
56598
56488
|
this._mixpanel = mixpanel_instance;
|
|
56599
56489
|
this._group_key = group_key;
|
|
56600
56490
|
this._group_id = group_id;
|
|
56491
|
+
this.consentGate = consentGate;
|
|
56601
56492
|
};
|
|
56602
56493
|
|
|
56603
56494
|
/**
|
|
56604
56495
|
* Set properties on a group.
|
|
56605
56496
|
*
|
|
56606
|
-
*
|
|
56607
|
-
*
|
|
56608
|
-
*
|
|
56497
|
+
* @example
|
|
56498
|
+
* ```js
|
|
56499
|
+
* mixpanel.get_group('company', 'mixpanel').set('Location', '405 Howard');
|
|
56609
56500
|
*
|
|
56610
|
-
*
|
|
56611
|
-
*
|
|
56612
|
-
*
|
|
56613
|
-
*
|
|
56614
|
-
*
|
|
56615
|
-
*
|
|
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
|
+
* ```
|
|
56616
56508
|
*
|
|
56617
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.
|
|
56618
56510
|
* @param {*} [to] A value to set on the given property name
|
|
56619
56511
|
* @param {Function} [callback] If provided, the callback will be called after the tracking event
|
|
56620
56512
|
*/
|
|
56621
|
-
MixpanelGroup.prototype.set =
|
|
56622
|
-
var data = this.set_action(prop, to);
|
|
56513
|
+
MixpanelGroup.prototype.set = function(prop, to, callback) {
|
|
56623
56514
|
if (mixpanel_module_.isObject(prop)) {
|
|
56624
56515
|
callback = to;
|
|
56625
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);
|
|
56626
56524
|
return this._send_request(data, callback);
|
|
56627
|
-
}
|
|
56525
|
+
};
|
|
56628
56526
|
|
|
56629
56527
|
/**
|
|
56630
56528
|
* Set properties on a group, only if they do not yet exist.
|
|
56631
56529
|
* This will not overwrite previous group property values, unlike
|
|
56632
56530
|
* group.set().
|
|
56633
56531
|
*
|
|
56634
|
-
*
|
|
56635
|
-
*
|
|
56636
|
-
*
|
|
56532
|
+
* @example
|
|
56533
|
+
* ```js
|
|
56534
|
+
* mixpanel.get_group('company', 'mixpanel').set_once('Location', '405 Howard');
|
|
56637
56535
|
*
|
|
56638
|
-
*
|
|
56639
|
-
*
|
|
56640
|
-
*
|
|
56641
|
-
*
|
|
56642
|
-
*
|
|
56643
|
-
*
|
|
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
|
+
* ```
|
|
56644
56543
|
*
|
|
56645
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.
|
|
56646
56545
|
* @param {*} [to] A value to set on the given property name
|
|
56647
56546
|
* @param {Function} [callback] If provided, the callback will be called after the tracking event
|
|
56648
56547
|
*/
|
|
56649
|
-
MixpanelGroup.prototype.set_once =
|
|
56650
|
-
var data = this.set_once_action(prop, to);
|
|
56548
|
+
MixpanelGroup.prototype.set_once = function(prop, to, callback) {
|
|
56651
56549
|
if (mixpanel_module_.isObject(prop)) {
|
|
56652
56550
|
callback = to;
|
|
56653
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);
|
|
56654
56559
|
return this._send_request(data, callback);
|
|
56655
|
-
}
|
|
56560
|
+
};
|
|
56656
56561
|
|
|
56657
56562
|
/**
|
|
56658
56563
|
* Unset properties on a group permanently.
|
|
56659
56564
|
*
|
|
56660
|
-
*
|
|
56661
|
-
*
|
|
56662
|
-
*
|
|
56565
|
+
* @example
|
|
56566
|
+
* ```js
|
|
56567
|
+
* mixpanel.get_group('company', 'mixpanel').unset('Founded');
|
|
56568
|
+
* ```
|
|
56663
56569
|
*
|
|
56664
56570
|
* @param {String} prop The name of the property.
|
|
56665
56571
|
* @param {Function} [callback] If provided, the callback will be called after the tracking event
|
|
56666
56572
|
*/
|
|
56667
|
-
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
|
+
}
|
|
56668
56580
|
var data = this.unset_action(prop);
|
|
56669
56581
|
return this._send_request(data, callback);
|
|
56670
|
-
}
|
|
56582
|
+
};
|
|
56671
56583
|
|
|
56672
56584
|
/**
|
|
56673
56585
|
* Merge a given list with a list-valued group property, excluding duplicate values.
|
|
56674
56586
|
*
|
|
56675
|
-
*
|
|
56676
|
-
*
|
|
56677
|
-
*
|
|
56678
|
-
*
|
|
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
|
+
* ```
|
|
56679
56592
|
*
|
|
56680
56593
|
* @param {String} list_name Name of the property.
|
|
56681
56594
|
* @param {Array} values Values to merge with the given property
|
|
56682
56595
|
* @param {Function} [callback] If provided, the callback will be called after the tracking event
|
|
56683
56596
|
*/
|
|
56684
|
-
MixpanelGroup.prototype.union =
|
|
56597
|
+
MixpanelGroup.prototype.union = function(list_name, values, callback) {
|
|
56685
56598
|
if (mixpanel_module_.isObject(list_name)) {
|
|
56686
56599
|
callback = values;
|
|
56687
56600
|
}
|
|
56601
|
+
if (!this.consentGate.allowsApiCalls()) {
|
|
56602
|
+
if (mixpanel_module_.isFunction(callback)) {
|
|
56603
|
+
callback(0);
|
|
56604
|
+
}
|
|
56605
|
+
return;
|
|
56606
|
+
}
|
|
56688
56607
|
var data = this.union_action(list_name, values);
|
|
56689
56608
|
return this._send_request(data, callback);
|
|
56690
|
-
}
|
|
56609
|
+
};
|
|
56691
56610
|
|
|
56692
56611
|
/**
|
|
56693
56612
|
* Permanently delete a group.
|
|
56694
56613
|
*
|
|
56695
|
-
*
|
|
56696
|
-
*
|
|
56697
|
-
*
|
|
56614
|
+
* @example
|
|
56615
|
+
* ```js
|
|
56616
|
+
* mixpanel.get_group('company', 'mixpanel').delete();
|
|
56617
|
+
* ```
|
|
56698
56618
|
*
|
|
56699
56619
|
* @param {Function} [callback] If provided, the callback will be called after the tracking event
|
|
56700
56620
|
*/
|
|
56701
|
-
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
|
+
}
|
|
56702
56628
|
// bracket notation above prevents a minification error related to reserved words
|
|
56703
56629
|
var data = this.delete_action();
|
|
56704
56630
|
return this._send_request(data, callback);
|
|
56705
|
-
}
|
|
56631
|
+
};
|
|
56706
56632
|
|
|
56707
56633
|
/**
|
|
56708
56634
|
* Remove a property from a group. The value will be ignored if doesn't exist.
|
|
56709
56635
|
*
|
|
56710
|
-
*
|
|
56711
|
-
*
|
|
56712
|
-
*
|
|
56636
|
+
* @example
|
|
56637
|
+
* ```js
|
|
56638
|
+
* mixpanel.get_group('company', 'mixpanel').remove('Location', 'London');
|
|
56639
|
+
* ```
|
|
56713
56640
|
*
|
|
56714
56641
|
* @param {String} list_name Name of the property.
|
|
56715
56642
|
* @param {Object} value Value to remove from the given group property
|
|
56716
56643
|
* @param {Function} [callback] If provided, the callback will be called after the tracking event
|
|
56717
56644
|
*/
|
|
56718
|
-
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
|
+
}
|
|
56719
56652
|
var data = this.remove_action(list_name, value);
|
|
56720
56653
|
return this._send_request(data, callback);
|
|
56721
|
-
}
|
|
56654
|
+
};
|
|
56722
56655
|
|
|
56723
56656
|
MixpanelGroup.prototype._send_request = function(data, callback) {
|
|
56724
56657
|
data['$group_key'] = this._group_key;
|
|
@@ -56747,51 +56680,66 @@ MixpanelGroup.prototype.toString = function() {
|
|
|
56747
56680
|
};
|
|
56748
56681
|
|
|
56749
56682
|
// MixpanelGroup Exports
|
|
56750
|
-
MixpanelGroup.prototype[
|
|
56751
|
-
|
|
56752
|
-
|
|
56753
|
-
|
|
56754
|
-
|
|
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;
|
|
56755
56691
|
MixpanelGroup.prototype['toString'] = MixpanelGroup.prototype.toString;
|
|
56756
56692
|
|
|
56757
56693
|
/* eslint camelcase: "off" */
|
|
56758
56694
|
|
|
56759
56695
|
/**
|
|
56760
56696
|
* Mixpanel People Object
|
|
56761
|
-
* @
|
|
56697
|
+
* @class
|
|
56762
56698
|
*/
|
|
56763
|
-
|
|
56699
|
+
function MixpanelPeople() {}
|
|
56764
56700
|
|
|
56765
56701
|
mixpanel_module_.extend(MixpanelPeople.prototype, apiActions);
|
|
56766
56702
|
|
|
56767
|
-
|
|
56703
|
+
/**
|
|
56704
|
+
* @param {Object} mixpanel_instance
|
|
56705
|
+
* @param {import('./consent-gate').ConsentGate} consentGate
|
|
56706
|
+
*/
|
|
56707
|
+
MixpanelPeople.prototype._init = function(mixpanel_instance, consentGate) {
|
|
56768
56708
|
this._mixpanel = mixpanel_instance;
|
|
56709
|
+
this.consentGate = consentGate;
|
|
56769
56710
|
};
|
|
56770
56711
|
|
|
56771
|
-
|
|
56712
|
+
/**
|
|
56772
56713
|
* Set properties on a user record.
|
|
56773
56714
|
*
|
|
56774
|
-
*
|
|
56715
|
+
* @example
|
|
56716
|
+
* ```js
|
|
56717
|
+
* mixpanel.people.set('gender', 'm');
|
|
56775
56718
|
*
|
|
56776
|
-
*
|
|
56777
|
-
*
|
|
56778
|
-
*
|
|
56779
|
-
*
|
|
56780
|
-
*
|
|
56781
|
-
*
|
|
56782
|
-
*
|
|
56783
|
-
*
|
|
56784
|
-
* // 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
|
+
* ```
|
|
56785
56727
|
*
|
|
56786
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.
|
|
56787
56729
|
* @param {*} [to] A value to set on the given property name
|
|
56788
56730
|
* @param {Function} [callback] If provided, the callback will be called after tracking the event.
|
|
56789
56731
|
*/
|
|
56790
|
-
MixpanelPeople.prototype.set =
|
|
56791
|
-
var data = this.set_action(prop, to);
|
|
56732
|
+
MixpanelPeople.prototype.set = function(prop, to, callback) {
|
|
56792
56733
|
if (mixpanel_module_.isObject(prop)) {
|
|
56793
56734
|
callback = to;
|
|
56794
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);
|
|
56795
56743
|
// make sure that the referrer info has been updated and saved
|
|
56796
56744
|
if (this._get_config('save_referrer')) {
|
|
56797
56745
|
this._mixpanel['persistence'].update_referrer_info(document.referrer);
|
|
@@ -56804,81 +56752,105 @@ MixpanelPeople.prototype.set = addOptOutCheckMixpanelPeople(function(prop, to, c
|
|
|
56804
56752
|
data[SET_ACTION]
|
|
56805
56753
|
);
|
|
56806
56754
|
return this._send_request(data, callback);
|
|
56807
|
-
}
|
|
56755
|
+
};
|
|
56808
56756
|
|
|
56809
|
-
|
|
56757
|
+
/**
|
|
56810
56758
|
* Set properties on a user record, only if they do not yet exist.
|
|
56811
56759
|
* This will not overwrite previous people property values, unlike
|
|
56812
56760
|
* people.set().
|
|
56813
56761
|
*
|
|
56814
|
-
*
|
|
56762
|
+
* @example
|
|
56763
|
+
* ```js
|
|
56764
|
+
* mixpanel.people.set_once('First Login Date', new Date());
|
|
56815
56765
|
*
|
|
56816
|
-
*
|
|
56766
|
+
* // or set multiple properties at once
|
|
56767
|
+
* mixpanel.people.set_once({
|
|
56768
|
+
* 'First Login Date': new Date(),
|
|
56769
|
+
* 'Starting Plan': 'Premium'
|
|
56770
|
+
* });
|
|
56817
56771
|
*
|
|
56818
|
-
*
|
|
56819
|
-
*
|
|
56820
|
-
* 'First Login Date': new Date(),
|
|
56821
|
-
* 'Starting Plan': 'Premium'
|
|
56822
|
-
* });
|
|
56823
|
-
*
|
|
56824
|
-
* // properties can be strings, integers or dates
|
|
56772
|
+
* // properties can be strings, integers or dates
|
|
56773
|
+
* ```
|
|
56825
56774
|
*
|
|
56826
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.
|
|
56827
56776
|
* @param {*} [to] A value to set on the given property name
|
|
56828
56777
|
* @param {Function} [callback] If provided, the callback will be called after tracking the event.
|
|
56829
56778
|
*/
|
|
56830
|
-
MixpanelPeople.prototype.set_once =
|
|
56831
|
-
var data = this.set_once_action(prop, to);
|
|
56779
|
+
MixpanelPeople.prototype.set_once = function(prop, to, callback) {
|
|
56832
56780
|
if (mixpanel_module_.isObject(prop)) {
|
|
56833
56781
|
callback = to;
|
|
56834
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);
|
|
56835
56790
|
return this._send_request(data, callback);
|
|
56836
|
-
}
|
|
56791
|
+
};
|
|
56837
56792
|
|
|
56838
|
-
|
|
56793
|
+
/**
|
|
56839
56794
|
* Unset properties on a user record (permanently removes the properties and their values from a profile).
|
|
56840
56795
|
*
|
|
56841
|
-
*
|
|
56842
|
-
*
|
|
56843
|
-
*
|
|
56796
|
+
* @example
|
|
56797
|
+
* ```js
|
|
56798
|
+
* mixpanel.people.unset('gender');
|
|
56844
56799
|
*
|
|
56845
|
-
*
|
|
56846
|
-
*
|
|
56800
|
+
* // or unset multiple properties at once
|
|
56801
|
+
* mixpanel.people.unset(['gender', 'Company']);
|
|
56802
|
+
* ```
|
|
56847
56803
|
*
|
|
56848
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.
|
|
56849
56805
|
* @param {Function} [callback] If provided, the callback will be called after tracking the event.
|
|
56850
56806
|
*/
|
|
56851
|
-
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
|
+
}
|
|
56852
56814
|
var data = this.unset_action(prop);
|
|
56853
56815
|
return this._send_request(data, callback);
|
|
56854
|
-
}
|
|
56816
|
+
};
|
|
56855
56817
|
|
|
56856
|
-
|
|
56818
|
+
/**
|
|
56857
56819
|
* Increment/decrement numeric people analytics properties.
|
|
56858
56820
|
*
|
|
56859
|
-
*
|
|
56821
|
+
* @example
|
|
56822
|
+
* ```js
|
|
56823
|
+
* mixpanel.people.increment('page_views', 1);
|
|
56860
56824
|
*
|
|
56861
|
-
*
|
|
56825
|
+
* // or, for convenience, if you're just incrementing a counter by
|
|
56826
|
+
* // 1, you can simply do
|
|
56827
|
+
* mixpanel.people.increment('page_views');
|
|
56862
56828
|
*
|
|
56863
|
-
*
|
|
56864
|
-
*
|
|
56865
|
-
* mixpanel.people.increment('page_views');
|
|
56829
|
+
* // to decrement a counter, pass a negative number
|
|
56830
|
+
* mixpanel.people.increment('credits_left', -1);
|
|
56866
56831
|
*
|
|
56867
|
-
*
|
|
56868
|
-
*
|
|
56869
|
-
*
|
|
56870
|
-
*
|
|
56871
|
-
*
|
|
56872
|
-
*
|
|
56873
|
-
*
|
|
56874
|
-
* counter2: 6
|
|
56875
|
-
* });
|
|
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
|
+
* ```
|
|
56876
56839
|
*
|
|
56877
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.
|
|
56878
56841
|
* @param {Number} [by] An amount to increment the given property
|
|
56879
56842
|
* @param {Function} [callback] If provided, the callback will be called after tracking the event.
|
|
56880
56843
|
*/
|
|
56881
|
-
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
|
+
}
|
|
56882
56854
|
var data = {};
|
|
56883
56855
|
var $add = {};
|
|
56884
56856
|
if (mixpanel_module_.isObject(prop)) {
|
|
@@ -56892,7 +56864,6 @@ MixpanelPeople.prototype.increment = addOptOutCheckMixpanelPeople(function(prop,
|
|
|
56892
56864
|
}
|
|
56893
56865
|
}
|
|
56894
56866
|
}, this);
|
|
56895
|
-
callback = by;
|
|
56896
56867
|
} else {
|
|
56897
56868
|
// convenience: mixpanel.people.increment('property'); will
|
|
56898
56869
|
// increment 'property' by 1
|
|
@@ -56904,119 +56875,148 @@ MixpanelPeople.prototype.increment = addOptOutCheckMixpanelPeople(function(prop,
|
|
|
56904
56875
|
data[ADD_ACTION] = $add;
|
|
56905
56876
|
|
|
56906
56877
|
return this._send_request(data, callback);
|
|
56907
|
-
}
|
|
56878
|
+
};
|
|
56908
56879
|
|
|
56909
|
-
|
|
56880
|
+
/**
|
|
56910
56881
|
* Append a value to a list-valued people analytics property.
|
|
56911
56882
|
*
|
|
56912
|
-
*
|
|
56883
|
+
* @example
|
|
56884
|
+
* ```js
|
|
56885
|
+
* // append a value to a list, creating it if needed
|
|
56886
|
+
* mixpanel.people.append('pages_visited', 'homepage');
|
|
56913
56887
|
*
|
|
56914
|
-
*
|
|
56915
|
-
*
|
|
56916
|
-
*
|
|
56917
|
-
*
|
|
56918
|
-
*
|
|
56919
|
-
*
|
|
56920
|
-
*
|
|
56921
|
-
* list2: 123
|
|
56922
|
-
* });
|
|
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
|
+
* ```
|
|
56923
56895
|
*
|
|
56924
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.
|
|
56925
56897
|
* @param {*} [value] value An item to append to the list
|
|
56926
56898
|
* @param {Function} [callback] If provided, the callback will be called after tracking the event.
|
|
56927
56899
|
*/
|
|
56928
|
-
MixpanelPeople.prototype.append =
|
|
56900
|
+
MixpanelPeople.prototype.append = function(list_name, value, callback) {
|
|
56929
56901
|
if (mixpanel_module_.isObject(list_name)) {
|
|
56930
56902
|
callback = value;
|
|
56931
56903
|
}
|
|
56904
|
+
if (!this.consentGate.allowsApiCalls()) {
|
|
56905
|
+
if (mixpanel_module_.isFunction(callback)) {
|
|
56906
|
+
callback(0);
|
|
56907
|
+
}
|
|
56908
|
+
return;
|
|
56909
|
+
}
|
|
56932
56910
|
var data = this.append_action(list_name, value);
|
|
56933
56911
|
return this._send_request(data, callback);
|
|
56934
|
-
}
|
|
56912
|
+
};
|
|
56935
56913
|
|
|
56936
|
-
|
|
56914
|
+
/**
|
|
56937
56915
|
* Remove a value from a list-valued people analytics property.
|
|
56938
56916
|
*
|
|
56939
|
-
*
|
|
56940
|
-
*
|
|
56941
|
-
*
|
|
56917
|
+
* @example
|
|
56918
|
+
* ```js
|
|
56919
|
+
* mixpanel.people.remove('School', 'UCB');
|
|
56920
|
+
* ```
|
|
56942
56921
|
*
|
|
56943
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.
|
|
56944
56923
|
* @param {*} [value] value Item to remove from the list
|
|
56945
56924
|
* @param {Function} [callback] If provided, the callback will be called after tracking the event.
|
|
56946
56925
|
*/
|
|
56947
|
-
MixpanelPeople.prototype.remove =
|
|
56926
|
+
MixpanelPeople.prototype.remove = function(list_name, value, callback) {
|
|
56948
56927
|
if (mixpanel_module_.isObject(list_name)) {
|
|
56949
56928
|
callback = value;
|
|
56950
56929
|
}
|
|
56930
|
+
if (!this.consentGate.allowsApiCalls()) {
|
|
56931
|
+
if (mixpanel_module_.isFunction(callback)) {
|
|
56932
|
+
callback(0);
|
|
56933
|
+
}
|
|
56934
|
+
return;
|
|
56935
|
+
}
|
|
56951
56936
|
var data = this.remove_action(list_name, value);
|
|
56952
56937
|
return this._send_request(data, callback);
|
|
56953
|
-
}
|
|
56938
|
+
};
|
|
56954
56939
|
|
|
56955
|
-
|
|
56940
|
+
/**
|
|
56956
56941
|
* Merge a given list with a list-valued people analytics property,
|
|
56957
56942
|
* excluding duplicate values.
|
|
56958
56943
|
*
|
|
56959
|
-
*
|
|
56960
|
-
*
|
|
56961
|
-
*
|
|
56962
|
-
*
|
|
56944
|
+
* @example
|
|
56945
|
+
* ```js
|
|
56946
|
+
* // merge a value to a list, creating it if needed
|
|
56947
|
+
* mixpanel.people.union('pages_visited', 'homepage');
|
|
56963
56948
|
*
|
|
56964
|
-
*
|
|
56965
|
-
*
|
|
56966
|
-
*
|
|
56967
|
-
*
|
|
56968
|
-
*
|
|
56969
|
-
*
|
|
56949
|
+
* // like mixpanel.people.set(), you can append multiple
|
|
56950
|
+
* // properties at once:
|
|
56951
|
+
* mixpanel.people.union({
|
|
56952
|
+
* list1: 'bob',
|
|
56953
|
+
* list2: 123
|
|
56954
|
+
* });
|
|
56970
56955
|
*
|
|
56971
|
-
*
|
|
56972
|
-
*
|
|
56973
|
-
*
|
|
56974
|
-
*
|
|
56975
|
-
*
|
|
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
|
+
* ```
|
|
56976
56962
|
*
|
|
56977
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.
|
|
56978
|
-
* @param {*} [
|
|
56964
|
+
* @param {*} [values] Value / values to merge with the given property
|
|
56979
56965
|
* @param {Function} [callback] If provided, the callback will be called after tracking the event.
|
|
56980
56966
|
*/
|
|
56981
|
-
MixpanelPeople.prototype.union =
|
|
56967
|
+
MixpanelPeople.prototype.union = function(list_name, values, callback) {
|
|
56982
56968
|
if (mixpanel_module_.isObject(list_name)) {
|
|
56983
56969
|
callback = values;
|
|
56984
56970
|
}
|
|
56971
|
+
if (!this.consentGate.allowsApiCalls()) {
|
|
56972
|
+
if (mixpanel_module_.isFunction(callback)) {
|
|
56973
|
+
callback(0);
|
|
56974
|
+
}
|
|
56975
|
+
return;
|
|
56976
|
+
}
|
|
56985
56977
|
var data = this.union_action(list_name, values);
|
|
56986
56978
|
return this._send_request(data, callback);
|
|
56987
|
-
}
|
|
56979
|
+
};
|
|
56988
56980
|
|
|
56989
|
-
|
|
56981
|
+
/**
|
|
56990
56982
|
* Record that you have charged the current user a certain amount
|
|
56991
56983
|
* of money. Charges recorded with track_charge() will appear in the
|
|
56992
56984
|
* Mixpanel revenue report.
|
|
56993
56985
|
*
|
|
56994
|
-
*
|
|
56995
|
-
*
|
|
56996
|
-
*
|
|
56997
|
-
*
|
|
56986
|
+
* @example
|
|
56987
|
+
* ```js
|
|
56988
|
+
* // charge a user $50
|
|
56989
|
+
* mixpanel.people.track_charge(50);
|
|
56998
56990
|
*
|
|
56999
|
-
*
|
|
57000
|
-
*
|
|
57001
|
-
*
|
|
57002
|
-
*
|
|
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
|
+
* ```
|
|
57003
56996
|
*
|
|
57004
56997
|
* @param {Number} amount The amount of money charged to the current user
|
|
57005
56998
|
* @param {Object} [properties] An associative array of properties associated with the charge
|
|
57006
56999
|
* @param {Function} [callback] If provided, the callback will be called when the server responds
|
|
57007
57000
|
* @deprecated
|
|
57008
57001
|
*/
|
|
57009
|
-
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
|
+
}
|
|
57010
57009
|
console$1.error('mixpanel.people.track_charge() is deprecated and no longer has any effect.');
|
|
57011
|
-
}
|
|
57010
|
+
};
|
|
57012
57011
|
|
|
57013
|
-
|
|
57012
|
+
/**
|
|
57014
57013
|
* Permanently clear all revenue report transactions from the
|
|
57015
57014
|
* current user's people analytics profile.
|
|
57016
57015
|
*
|
|
57017
|
-
*
|
|
57018
|
-
*
|
|
57019
|
-
*
|
|
57016
|
+
* @example
|
|
57017
|
+
* ```js
|
|
57018
|
+
* mixpanel.people.clear_charges();
|
|
57019
|
+
* ```
|
|
57020
57020
|
*
|
|
57021
57021
|
* @param {Function} [callback] If provided, the callback will be called after tracking the event.
|
|
57022
57022
|
* @deprecated
|
|
@@ -57025,14 +57025,15 @@ MixpanelPeople.prototype.clear_charges = function(callback) {
|
|
|
57025
57025
|
return this.set('$transactions', [], callback);
|
|
57026
57026
|
};
|
|
57027
57027
|
|
|
57028
|
-
|
|
57028
|
+
/**
|
|
57029
57029
|
* Permanently deletes the current people analytics profile from
|
|
57030
57030
|
* Mixpanel (using the current distinct_id).
|
|
57031
57031
|
*
|
|
57032
|
-
*
|
|
57033
|
-
*
|
|
57034
|
-
*
|
|
57035
|
-
*
|
|
57032
|
+
* @example
|
|
57033
|
+
* ```js
|
|
57034
|
+
* // remove the all data you have stored about the current user
|
|
57035
|
+
* mixpanel.people.delete_user();
|
|
57036
|
+
* ```
|
|
57036
57037
|
*
|
|
57037
57038
|
*/
|
|
57038
57039
|
MixpanelPeople.prototype.delete_user = function() {
|
|
@@ -57067,7 +57068,7 @@ MixpanelPeople.prototype._send_request = function(data, callback) {
|
|
|
57067
57068
|
var date_encoded_data = mixpanel_module_.encodeDates(data);
|
|
57068
57069
|
|
|
57069
57070
|
if (!this._identify_called()) {
|
|
57070
|
-
this._enqueue(
|
|
57071
|
+
this._enqueue(date_encoded_data);
|
|
57071
57072
|
if (!mixpanel_module_.isUndefined(callback)) {
|
|
57072
57073
|
if (this._get_config('verbose')) {
|
|
57073
57074
|
callback({status: -1, error: null});
|
|
@@ -57202,16 +57203,19 @@ MixpanelPeople.prototype._is_reserved_property = function(prop) {
|
|
|
57202
57203
|
};
|
|
57203
57204
|
|
|
57204
57205
|
// MixpanelPeople Exports
|
|
57205
|
-
MixpanelPeople.prototype[
|
|
57206
|
-
|
|
57207
|
-
|
|
57208
|
-
|
|
57209
|
-
|
|
57210
|
-
|
|
57211
|
-
|
|
57212
|
-
|
|
57213
|
-
|
|
57214
|
-
|
|
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;
|
|
57215
57219
|
MixpanelPeople.prototype['toString'] = MixpanelPeople.prototype.toString;
|
|
57216
57220
|
|
|
57217
57221
|
/* eslint camelcase: "off" */
|
|
@@ -57244,11 +57248,21 @@ MixpanelPeople.prototype['toString'] = MixpanelPeople.prototype.toString;
|
|
|
57244
57248
|
EVENT_TIMERS_KEY
|
|
57245
57249
|
];
|
|
57246
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
|
+
|
|
57247
57257
|
/**
|
|
57248
57258
|
* Mixpanel Persistence Object
|
|
57249
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()
|
|
57250
57264
|
*/
|
|
57251
|
-
var MixpanelPersistence = function(config) {
|
|
57265
|
+
var MixpanelPersistence = function(config, options) {
|
|
57252
57266
|
this['props'] = {};
|
|
57253
57267
|
this.campaign_params_saved = false;
|
|
57254
57268
|
|
|
@@ -57261,19 +57275,25 @@ var MixpanelPersistence = function(config) {
|
|
|
57261
57275
|
var storage_type = config['persistence'];
|
|
57262
57276
|
if (storage_type !== 'cookie' && storage_type !== 'localStorage') {
|
|
57263
57277
|
console$1.critical('Unknown persistence type ' + storage_type + '; falling back to cookie');
|
|
57264
|
-
|
|
57278
|
+
config['persistence'] = 'cookie';
|
|
57265
57279
|
}
|
|
57280
|
+
this.storage_type = config['persistence'];
|
|
57266
57281
|
|
|
57267
|
-
|
|
57268
|
-
|
|
57269
|
-
|
|
57270
|
-
|
|
57282
|
+
this.closed = true;
|
|
57283
|
+
this.storage = NULL_STORAGE;
|
|
57284
|
+
this.update_config(config);
|
|
57285
|
+
if (!(options && options.closed)) {
|
|
57286
|
+
this.open();
|
|
57271
57287
|
}
|
|
57288
|
+
};
|
|
57272
57289
|
|
|
57273
|
-
|
|
57274
|
-
this.
|
|
57275
|
-
|
|
57276
|
-
|
|
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;
|
|
57277
57297
|
};
|
|
57278
57298
|
|
|
57279
57299
|
MixpanelPersistence.prototype.properties = function() {
|
|
@@ -57291,8 +57311,6 @@ MixpanelPersistence.prototype.properties = function() {
|
|
|
57291
57311
|
};
|
|
57292
57312
|
|
|
57293
57313
|
MixpanelPersistence.prototype.load = function() {
|
|
57294
|
-
if (this.disabled) { return; }
|
|
57295
|
-
|
|
57296
57314
|
var entry = this.storage.parse(this.name);
|
|
57297
57315
|
|
|
57298
57316
|
if (entry) {
|
|
@@ -57306,7 +57324,7 @@ MixpanelPersistence.prototype.upgrade = function() {
|
|
|
57306
57324
|
|
|
57307
57325
|
// if transferring from cookie to localStorage or vice-versa, copy existing
|
|
57308
57326
|
// super properties over to new storage mode
|
|
57309
|
-
if (this.
|
|
57327
|
+
if (this.backend === mixpanel_module_.localStorage) {
|
|
57310
57328
|
old_cookie = mixpanel_module_.cookie.parse(this.name);
|
|
57311
57329
|
|
|
57312
57330
|
mixpanel_module_.cookie.remove(this.name);
|
|
@@ -57315,7 +57333,7 @@ MixpanelPersistence.prototype.upgrade = function() {
|
|
|
57315
57333
|
if (old_cookie) {
|
|
57316
57334
|
this.register_once(old_cookie);
|
|
57317
57335
|
}
|
|
57318
|
-
} else if (this.
|
|
57336
|
+
} else if (this.backend === mixpanel_module_.cookie) {
|
|
57319
57337
|
old_localstorage = mixpanel_module_.localStorage.parse(this.name);
|
|
57320
57338
|
|
|
57321
57339
|
mixpanel_module_.localStorage.remove(this.name);
|
|
@@ -57327,8 +57345,6 @@ MixpanelPersistence.prototype.upgrade = function() {
|
|
|
57327
57345
|
};
|
|
57328
57346
|
|
|
57329
57347
|
MixpanelPersistence.prototype.save = function() {
|
|
57330
|
-
if (this.disabled) { return; }
|
|
57331
|
-
|
|
57332
57348
|
this.storage.set(
|
|
57333
57349
|
this.name,
|
|
57334
57350
|
JSONStringify(this['props']),
|
|
@@ -57346,9 +57362,11 @@ MixpanelPersistence.prototype.load_prop = function(key) {
|
|
|
57346
57362
|
};
|
|
57347
57363
|
|
|
57348
57364
|
MixpanelPersistence.prototype.remove = function() {
|
|
57365
|
+
// persistence that started closed has no backend until it opens
|
|
57366
|
+
if (!this.backend) { return; }
|
|
57349
57367
|
// remove both domain and subdomain cookies
|
|
57350
|
-
this.
|
|
57351
|
-
this.
|
|
57368
|
+
this.backend.remove(this.name, false, this.cookie_domain);
|
|
57369
|
+
this.backend.remove(this.name, true, this.cookie_domain);
|
|
57352
57370
|
};
|
|
57353
57371
|
|
|
57354
57372
|
// removes the storage entry and deletes all loaded data
|
|
@@ -57437,11 +57455,67 @@ MixpanelPersistence.prototype.update_config = function(config) {
|
|
|
57437
57455
|
this.set_secure(config['secure_cookie']);
|
|
57438
57456
|
};
|
|
57439
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
|
+
*/
|
|
57440
57463
|
MixpanelPersistence.prototype.set_disabled = function(disabled) {
|
|
57441
57464
|
this.disabled = disabled;
|
|
57442
|
-
|
|
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;
|
|
57443
57516
|
this.remove();
|
|
57444
57517
|
} else {
|
|
57518
|
+
this.storage = this.backend;
|
|
57445
57519
|
this.save();
|
|
57446
57520
|
}
|
|
57447
57521
|
};
|
|
@@ -57641,6 +57715,848 @@ MixpanelPersistence.prototype.remove_event_timer = function(event_name) {
|
|
|
57641
57715
|
return timestamp;
|
|
57642
57716
|
};
|
|
57643
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
|
+
|
|
57644
58560
|
/* eslint camelcase: "off" */
|
|
57645
58561
|
|
|
57646
58562
|
/*
|
|
@@ -57759,6 +58675,7 @@ var DEFAULT_CONFIG = {
|
|
|
57759
58675
|
'opt_out_persistence_by_default': false,
|
|
57760
58676
|
'opt_out_tracking_persistence_type': 'localStorage',
|
|
57761
58677
|
'opt_out_tracking_cookie_prefix': null,
|
|
58678
|
+
'consent_mode': null,
|
|
57762
58679
|
'property_blacklist': [],
|
|
57763
58680
|
'xhr_headers': {}, // { header: value, header2: value }
|
|
57764
58681
|
'ignore_dnt': false,
|
|
@@ -57793,9 +58710,9 @@ var DOM_LOADED = false;
|
|
|
57793
58710
|
|
|
57794
58711
|
/**
|
|
57795
58712
|
* Mixpanel Library Object
|
|
57796
|
-
* @
|
|
58713
|
+
* @class
|
|
57797
58714
|
*/
|
|
57798
|
-
|
|
58715
|
+
function MixpanelLib() {}
|
|
57799
58716
|
|
|
57800
58717
|
|
|
57801
58718
|
/**
|
|
@@ -57825,26 +58742,9 @@ var create_mplib = function(token, config, name) {
|
|
|
57825
58742
|
instance._init(token, config, name);
|
|
57826
58743
|
|
|
57827
58744
|
instance['people'] = new MixpanelPeople();
|
|
57828
|
-
instance['people']._init(instance);
|
|
58745
|
+
instance['people']._init(instance, instance._consent);
|
|
57829
58746
|
|
|
57830
|
-
|
|
57831
|
-
// We need null UTM params in the object because
|
|
57832
|
-
// UTM parameters act as a tuple. If any UTM param
|
|
57833
|
-
// is present, then we set all UTM params including
|
|
57834
|
-
// empty ones together
|
|
57835
|
-
var utm_params = mixpanel_module_.info.campaignParams(null);
|
|
57836
|
-
var initial_utm_params = {};
|
|
57837
|
-
var has_utm = false;
|
|
57838
|
-
mixpanel_module_.each(utm_params, function(utm_value, utm_key) {
|
|
57839
|
-
initial_utm_params['initial_' + utm_key] = utm_value;
|
|
57840
|
-
if (utm_value) {
|
|
57841
|
-
has_utm = true;
|
|
57842
|
-
}
|
|
57843
|
-
});
|
|
57844
|
-
if (has_utm) {
|
|
57845
|
-
instance['people'].set_once(initial_utm_params);
|
|
57846
|
-
}
|
|
57847
|
-
}
|
|
58747
|
+
instance._set_first_touch_people_properties();
|
|
57848
58748
|
|
|
57849
58749
|
// if any instance on the page has debug = true, we set the
|
|
57850
58750
|
// global debug to be true
|
|
@@ -57888,7 +58788,7 @@ var create_mplib = function(token, config, name) {
|
|
|
57888
58788
|
* mixpanel.library_name.track(...);
|
|
57889
58789
|
*
|
|
57890
58790
|
* @param {String} token Your Mixpanel API token
|
|
57891
|
-
* @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.
|
|
57892
58792
|
* @param {String} [name] The name for the new mixpanel instance that you want created
|
|
57893
58793
|
*/
|
|
57894
58794
|
MixpanelLib.prototype.init = function (token, config, name) {
|
|
@@ -57939,6 +58839,19 @@ MixpanelLib.prototype._init = function(token, config, name) {
|
|
|
57939
58839
|
'callback_fn': ((name === PRIMARY_INSTANCE_NAME) ? name : PRIMARY_INSTANCE_NAME + '.' + name) + '._jsc'
|
|
57940
58840
|
}));
|
|
57941
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
|
+
|
|
57942
58855
|
this.recorderManager = new RecorderManager({
|
|
57943
58856
|
mixpanelInstance: this,
|
|
57944
58857
|
getConfigFunc: mixpanel_module_.bind(this.get_config, this),
|
|
@@ -57946,6 +58859,7 @@ MixpanelLib.prototype._init = function(token, config, name) {
|
|
|
57946
58859
|
getTabIdFunc: mixpanel_module_.bind(this.get_tab_id, this),
|
|
57947
58860
|
reportErrorFunc: mixpanel_module_.bind(this.report_error, this),
|
|
57948
58861
|
getDistinctIdFunc: mixpanel_module_.bind(this.get_distinct_id, this),
|
|
58862
|
+
consentGate: this._consent,
|
|
57949
58863
|
recorderSrc: this.get_config('recorder_src'),
|
|
57950
58864
|
targetingSrc: this.get_config('targeting_src'),
|
|
57951
58865
|
libBasePath: this.get_config('lib_base_path'),
|
|
@@ -57963,64 +58877,16 @@ MixpanelLib.prototype._init = function(token, config, name) {
|
|
|
57963
58877
|
};
|
|
57964
58878
|
this._remote_settings_strict_disabled = false;
|
|
57965
58879
|
|
|
57966
|
-
// set up request queueing/batching
|
|
57967
58880
|
this.request_batchers = {};
|
|
57968
|
-
|
|
57969
|
-
|
|
57970
|
-
|
|
57971
|
-
|
|
57972
|
-
|
|
57973
|
-
mixpanel_module_.each(this.get_batcher_configs(), function(batcher_config) {
|
|
57974
|
-
console$1.log('Clearing batch queue ' + batcher_config.queue_key);
|
|
57975
|
-
mixpanel_module_.localStorage.remove(batcher_config.queue_key);
|
|
57976
|
-
});
|
|
57977
|
-
} else {
|
|
57978
|
-
this.init_batchers();
|
|
57979
|
-
if (sendBeacon && mixpanel_module_win.addEventListener) {
|
|
57980
|
-
// Before page closes or hides (user tabs away etc), attempt to flush any events
|
|
57981
|
-
// queued up via navigator.sendBeacon. Since sendBeacon doesn't report success/failure,
|
|
57982
|
-
// events will not be removed from the persistent store; if the site is loaded again,
|
|
57983
|
-
// the events will be flushed again on startup and deduplicated on the Mixpanel server
|
|
57984
|
-
// side.
|
|
57985
|
-
// There is no reliable way to capture only page close events, so we lean on the
|
|
57986
|
-
// visibilitychange and pagehide events as recommended at
|
|
57987
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/Window/unload_event#usage_notes.
|
|
57988
|
-
// These events fire when the user clicks away from the current page/tab, so will occur
|
|
57989
|
-
// more frequently than page unload, but are the only mechanism currently for capturing
|
|
57990
|
-
// this scenario somewhat reliably.
|
|
57991
|
-
var flush_on_unload = mixpanel_module_.bind(function() {
|
|
57992
|
-
if (!this.request_batchers.events.stopped) {
|
|
57993
|
-
this.request_batchers.events.flush({unloading: true});
|
|
57994
|
-
}
|
|
57995
|
-
}, this);
|
|
57996
|
-
mixpanel_module_win.addEventListener('pagehide', function(ev) {
|
|
57997
|
-
if (ev['persisted']) {
|
|
57998
|
-
flush_on_unload();
|
|
57999
|
-
}
|
|
58000
|
-
});
|
|
58001
|
-
mixpanel_module_win.addEventListener('visibilitychange', function() {
|
|
58002
|
-
if (document$1['visibilityState'] === 'hidden') {
|
|
58003
|
-
flush_on_unload();
|
|
58004
|
-
}
|
|
58005
|
-
});
|
|
58006
|
-
}
|
|
58007
|
-
}
|
|
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();
|
|
58008
58886
|
}
|
|
58009
58887
|
|
|
58010
|
-
this['persistence'] = this['cookie'] = new MixpanelPersistence(this['config']);
|
|
58888
|
+
this['persistence'] = this['cookie'] = new MixpanelPersistence(this['config'], {closed: !allows_storage});
|
|
58011
58889
|
this.unpersisted_superprops = {};
|
|
58012
|
-
this._gdpr_init();
|
|
58013
|
-
|
|
58014
|
-
var uuid = mixpanel_module_.UUID();
|
|
58015
|
-
if (!this.get_distinct_id()) {
|
|
58016
|
-
// There is no need to set the distinct id
|
|
58017
|
-
// or the device id if something was already stored
|
|
58018
|
-
// in the persitence
|
|
58019
|
-
this.register_once({
|
|
58020
|
-
'distinct_id': DEVICE_ID_PREFIX + uuid,
|
|
58021
|
-
'$device_id': uuid
|
|
58022
|
-
}, '');
|
|
58023
|
-
}
|
|
58024
58890
|
|
|
58025
58891
|
this.flags = new FeatureFlagManager({
|
|
58026
58892
|
getFullApiRoute: mixpanel_module_.bind(function() {
|
|
@@ -58030,12 +58896,52 @@ MixpanelLib.prototype._init = function(token, config, name) {
|
|
|
58030
58896
|
setConfigFunc: mixpanel_module_.bind(this.set_config, this),
|
|
58031
58897
|
getPropertyFunc: mixpanel_module_.bind(this.get_property, this),
|
|
58032
58898
|
trackingFunc: mixpanel_module_.bind(this.track, this),
|
|
58899
|
+
consentGate: this._consent,
|
|
58033
58900
|
loadExtraBundle: load_extra_bundle,
|
|
58034
58901
|
targetingSrc: this.get_config('targeting_src') || (this.get_config('lib_base_path') + TARGETING_FILENAME)
|
|
58035
58902
|
});
|
|
58036
|
-
this.flags.init();
|
|
58037
58903
|
this['flags'] = this.flags;
|
|
58038
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();
|
|
58039
58945
|
this._init_tab_id();
|
|
58040
58946
|
|
|
58041
58947
|
// Based on remote_settings_mode, fetch remote settings and then start session recording if applicable
|
|
@@ -58047,21 +58953,174 @@ MixpanelLib.prototype._init = function(token, config, name) {
|
|
|
58047
58953
|
} else {
|
|
58048
58954
|
this.__session_recording_init_promise = this._check_and_start_session_recording();
|
|
58049
58955
|
}
|
|
58956
|
+
};
|
|
58050
58957
|
|
|
58051
|
-
|
|
58052
|
-
|
|
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
|
+
}, '');
|
|
58053
59108
|
};
|
|
58054
59109
|
|
|
58055
59110
|
/**
|
|
58056
59111
|
* Assigns a unique UUID to this tab / window by leveraging sessionStorage.
|
|
58057
59112
|
* This is primarily used for session recording, where data must be isolated to the current tab.
|
|
58058
59113
|
*/
|
|
59114
|
+
MixpanelLib.prototype._tab_id_key_suffix = function() {
|
|
59115
|
+
return this.get_config('name') + '_' + this.get_config('token');
|
|
59116
|
+
};
|
|
59117
|
+
|
|
58059
59118
|
MixpanelLib.prototype._init_tab_id = function() {
|
|
58060
|
-
if (this.
|
|
58061
|
-
console$1.log('Tab ID initialization skipped
|
|
59119
|
+
if (!this._consent.allowsPersistence()) {
|
|
59120
|
+
console$1.log('Tab ID initialization skipped without persistence');
|
|
58062
59121
|
} else if (mixpanel_module_.sessionStorage.is_supported()) {
|
|
58063
59122
|
try {
|
|
58064
|
-
var key_suffix = this.
|
|
59123
|
+
var key_suffix = this._tab_id_key_suffix();
|
|
58065
59124
|
var tab_id_key = 'mp_tab_id_' + key_suffix;
|
|
58066
59125
|
|
|
58067
59126
|
// A flag is used to determine if sessionStorage is copied over and we need to generate a new tab ID.
|
|
@@ -58092,9 +59151,12 @@ MixpanelLib.prototype.get_tab_id = function () {
|
|
|
58092
59151
|
return this.tab_id || null;
|
|
58093
59152
|
};
|
|
58094
59153
|
|
|
58095
|
-
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
|
+
}
|
|
58096
59158
|
return this.recorderManager.checkAndStartSessionRecording(force_start);
|
|
58097
|
-
}
|
|
59159
|
+
};
|
|
58098
59160
|
|
|
58099
59161
|
MixpanelLib.prototype._start_recording_on_event = safewrap(function(event_name, properties) {
|
|
58100
59162
|
// Wait for recording init to complete before evaluating event triggers.
|
|
@@ -58184,7 +59246,7 @@ MixpanelLib.prototype._dom_loaded = function() {
|
|
|
58184
59246
|
this._track_dom.apply(this, item);
|
|
58185
59247
|
}, this);
|
|
58186
59248
|
|
|
58187
|
-
if (
|
|
59249
|
+
if (this._consent.allowsApiCalls()) {
|
|
58188
59250
|
mixpanel_module_.each(this.__request_queue, function(item) {
|
|
58189
59251
|
this._send_request.apply(this, item);
|
|
58190
59252
|
}, this);
|
|
@@ -58246,6 +59308,15 @@ MixpanelLib.prototype._prepare_callback = function(callback, data) {
|
|
|
58246
59308
|
MixpanelLib.prototype._send_request = function(url, data, options, callback) {
|
|
58247
59309
|
var succeeded = true;
|
|
58248
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
|
+
|
|
58249
59320
|
if (ENQUEUE_REQUESTS) {
|
|
58250
59321
|
this.__request_queue.push(arguments);
|
|
58251
59322
|
return succeeded;
|
|
@@ -58403,6 +59474,10 @@ MixpanelLib.prototype._send_request = function(url, data, options, callback) {
|
|
|
58403
59474
|
};
|
|
58404
59475
|
|
|
58405
59476
|
MixpanelLib.prototype._fetch_remote_settings = function(mode) {
|
|
59477
|
+
if (!this._consent.allowsFetching()) {
|
|
59478
|
+
return Promise.resolve();
|
|
59479
|
+
}
|
|
59480
|
+
|
|
58406
59481
|
var self = this;
|
|
58407
59482
|
var disableRecordingIfStrict = function() {
|
|
58408
59483
|
if (mode === 'strict') {
|
|
@@ -58540,48 +59615,6 @@ MixpanelLib.prototype.get_batcher_configs = function() {
|
|
|
58540
59615
|
return this._batcher_configs;
|
|
58541
59616
|
};
|
|
58542
59617
|
|
|
58543
|
-
MixpanelLib.prototype.init_batchers = function() {
|
|
58544
|
-
if (!this.are_batchers_initialized()) {
|
|
58545
|
-
var batcher_for = mixpanel_module_.bind(function(attrs) {
|
|
58546
|
-
return new RequestBatcher(
|
|
58547
|
-
attrs.queue_key,
|
|
58548
|
-
{
|
|
58549
|
-
libConfig: this['config'],
|
|
58550
|
-
errorReporter: this.get_config('error_reporter'),
|
|
58551
|
-
sendRequestFunc: mixpanel_module_.bind(function(data, options, cb) {
|
|
58552
|
-
var api_routes = this.get_config('api_routes');
|
|
58553
|
-
this._send_request(
|
|
58554
|
-
this.get_api_host(attrs.api_name) + '/' + api_routes[attrs.api_name],
|
|
58555
|
-
this._encode_data_for_request(data),
|
|
58556
|
-
options,
|
|
58557
|
-
this._prepare_callback(cb, data)
|
|
58558
|
-
);
|
|
58559
|
-
}, this),
|
|
58560
|
-
beforeSendHook: mixpanel_module_.bind(function(item) {
|
|
58561
|
-
var ret = this._run_hook('before_send_' + attrs.type, item);
|
|
58562
|
-
if (ret) {
|
|
58563
|
-
return ret[0];
|
|
58564
|
-
} else {
|
|
58565
|
-
return null;
|
|
58566
|
-
}
|
|
58567
|
-
}, this),
|
|
58568
|
-
stopAllBatchingFunc: mixpanel_module_.bind(this.stop_batch_senders, this),
|
|
58569
|
-
usePersistence: true,
|
|
58570
|
-
}
|
|
58571
|
-
);
|
|
58572
|
-
}, this);
|
|
58573
|
-
var batcher_configs = this.get_batcher_configs();
|
|
58574
|
-
this.request_batchers = {
|
|
58575
|
-
events: batcher_for(batcher_configs.events),
|
|
58576
|
-
people: batcher_for(batcher_configs.people),
|
|
58577
|
-
groups: batcher_for(batcher_configs.groups)
|
|
58578
|
-
};
|
|
58579
|
-
}
|
|
58580
|
-
if (this.get_config('batch_autostart')) {
|
|
58581
|
-
this.start_batch_senders();
|
|
58582
|
-
}
|
|
58583
|
-
};
|
|
58584
|
-
|
|
58585
59618
|
MixpanelLib.prototype.start_batch_senders = function() {
|
|
58586
59619
|
this._batchers_were_started = true;
|
|
58587
59620
|
if (this.are_batchers_initialized()) {
|
|
@@ -58607,8 +59640,10 @@ MixpanelLib.prototype.stop_batch_senders = function() {
|
|
|
58607
59640
|
* do not wish to rely on our convenience methods
|
|
58608
59641
|
* (created in the snippet).
|
|
58609
59642
|
*
|
|
58610
|
-
*
|
|
58611
|
-
*
|
|
59643
|
+
* @example
|
|
59644
|
+
* ```js
|
|
59645
|
+
* mixpanel.push(['register', { a: 'b' }]);
|
|
59646
|
+
* ```
|
|
58612
59647
|
*
|
|
58613
59648
|
* @param {Array} item A [function_name, args...] array to be executed
|
|
58614
59649
|
*/
|
|
@@ -58721,15 +59756,16 @@ MixpanelLib.prototype._track_or_batch = function(options, callback) {
|
|
|
58721
59756
|
* Track an event. This is the most important and
|
|
58722
59757
|
* frequently used Mixpanel function.
|
|
58723
59758
|
*
|
|
58724
|
-
*
|
|
58725
|
-
*
|
|
58726
|
-
* // track an event named 'Registered'
|
|
58727
|
-
* mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
|
|
59759
|
+
* To track link clicks or form submissions, see track_links() or track_forms().
|
|
58728
59760
|
*
|
|
58729
|
-
*
|
|
58730
|
-
*
|
|
59761
|
+
* @example
|
|
59762
|
+
* ```js
|
|
59763
|
+
* // track an event named 'Registered'
|
|
59764
|
+
* mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
|
|
58731
59765
|
*
|
|
58732
|
-
*
|
|
59766
|
+
* // track an event using navigator.sendBeacon
|
|
59767
|
+
* mixpanel.track('Left page', {'duration_seconds': 35}, {transport: 'sendBeacon'});
|
|
59768
|
+
* ```
|
|
58733
59769
|
*
|
|
58734
59770
|
* @param {String} event_name The name of the event. This can be anything the user does - 'Button Click', 'Sign Up', 'Item Purchased', etc.
|
|
58735
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.
|
|
@@ -58740,7 +59776,17 @@ MixpanelLib.prototype._track_or_batch = function(options, callback) {
|
|
|
58740
59776
|
* @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
|
|
58741
59777
|
* with the tracking payload sent to the API server is returned; otherwise false.
|
|
58742
59778
|
*/
|
|
58743
|
-
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
|
+
}
|
|
58744
59790
|
var ret;
|
|
58745
59791
|
if (!(options && options.skip_hooks)) {
|
|
58746
59792
|
ret = this._run_hook('before_track', event_name, properties);
|
|
@@ -58752,10 +59798,6 @@ MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, pro
|
|
|
58752
59798
|
}
|
|
58753
59799
|
}
|
|
58754
59800
|
|
|
58755
|
-
if (!callback && typeof options === 'function') {
|
|
58756
|
-
callback = options;
|
|
58757
|
-
options = null;
|
|
58758
|
-
}
|
|
58759
59801
|
options = options || {};
|
|
58760
59802
|
var transport = options['transport']; // external API, don't minify 'transport' prop
|
|
58761
59803
|
if (transport) {
|
|
@@ -58817,6 +59859,14 @@ MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, pro
|
|
|
58817
59859
|
this.report_error('Invalid value for property_blacklist config: ' + property_blacklist);
|
|
58818
59860
|
}
|
|
58819
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
|
+
|
|
58820
59870
|
this._start_recording_on_event(event_name, properties);
|
|
58821
59871
|
|
|
58822
59872
|
var data = {
|
|
@@ -58838,23 +59888,30 @@ MixpanelLib.prototype.track = addOptOutCheckMixpanelLib(function(event_name, pro
|
|
|
58838
59888
|
}
|
|
58839
59889
|
|
|
58840
59890
|
return ret;
|
|
58841
|
-
}
|
|
59891
|
+
};
|
|
58842
59892
|
|
|
58843
59893
|
/**
|
|
58844
59894
|
* Register the current user into one/many groups.
|
|
58845
59895
|
*
|
|
58846
|
-
*
|
|
58847
|
-
*
|
|
58848
|
-
*
|
|
58849
|
-
*
|
|
58850
|
-
*
|
|
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
|
+
* ```
|
|
58851
59902
|
*
|
|
58852
59903
|
* @param {String} group_key Group key
|
|
58853
59904
|
* @param {Array|String|Number} group_ids An array of group IDs, or a singular group ID
|
|
58854
59905
|
* @param {Function} [callback] If provided, the callback will be called after tracking the event.
|
|
58855
59906
|
*
|
|
58856
59907
|
*/
|
|
58857
|
-
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
|
+
}
|
|
58858
59915
|
if (!mixpanel_module_.isArray(group_ids)) {
|
|
58859
59916
|
group_ids = [group_ids];
|
|
58860
59917
|
}
|
|
@@ -58862,20 +59919,27 @@ MixpanelLib.prototype.set_group = addOptOutCheckMixpanelLib(function(group_key,
|
|
|
58862
59919
|
prop[group_key] = group_ids;
|
|
58863
59920
|
this.register(prop);
|
|
58864
59921
|
return this['people'].set(group_key, group_ids, callback);
|
|
58865
|
-
}
|
|
59922
|
+
};
|
|
58866
59923
|
|
|
58867
59924
|
/**
|
|
58868
59925
|
* Add a new group for this user.
|
|
58869
59926
|
*
|
|
58870
|
-
*
|
|
58871
|
-
*
|
|
58872
|
-
*
|
|
59927
|
+
* @example
|
|
59928
|
+
* ```js
|
|
59929
|
+
* mixpanel.add_group('company', 'mixpanel')
|
|
59930
|
+
* ```
|
|
58873
59931
|
*
|
|
58874
59932
|
* @param {String} group_key Group key
|
|
58875
59933
|
* @param {*} group_id A valid Mixpanel property type
|
|
58876
59934
|
* @param {Function} [callback] If provided, the callback will be called after tracking the event.
|
|
58877
59935
|
*/
|
|
58878
|
-
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
|
+
}
|
|
58879
59943
|
var old_values = this.get_property(group_key);
|
|
58880
59944
|
var prop = {};
|
|
58881
59945
|
if (old_values === undefined) {
|
|
@@ -58889,20 +59953,27 @@ MixpanelLib.prototype.add_group = addOptOutCheckMixpanelLib(function(group_key,
|
|
|
58889
59953
|
}
|
|
58890
59954
|
}
|
|
58891
59955
|
return this['people'].union(group_key, group_id, callback);
|
|
58892
|
-
}
|
|
59956
|
+
};
|
|
58893
59957
|
|
|
58894
59958
|
/**
|
|
58895
59959
|
* Remove a group from this user.
|
|
58896
59960
|
*
|
|
58897
|
-
*
|
|
58898
|
-
*
|
|
58899
|
-
*
|
|
59961
|
+
* @example
|
|
59962
|
+
* ```js
|
|
59963
|
+
* mixpanel.remove_group('company', 'mixpanel')
|
|
59964
|
+
* ```
|
|
58900
59965
|
*
|
|
58901
59966
|
* @param {String} group_key Group key
|
|
58902
59967
|
* @param {*} group_id A valid Mixpanel property type
|
|
58903
59968
|
* @param {Function} [callback] If provided, the callback will be called after tracking the event.
|
|
58904
59969
|
*/
|
|
58905
|
-
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
|
+
}
|
|
58906
59977
|
var old_value = this.get_property(group_key);
|
|
58907
59978
|
// if the value doesn't exist, the persistent store is unchanged
|
|
58908
59979
|
if (old_value !== undefined) {
|
|
@@ -58916,21 +59987,22 @@ MixpanelLib.prototype.remove_group = addOptOutCheckMixpanelLib(function(group_ke
|
|
|
58916
59987
|
}
|
|
58917
59988
|
}
|
|
58918
59989
|
return this['people'].remove(group_key, group_id, callback);
|
|
58919
|
-
}
|
|
59990
|
+
};
|
|
58920
59991
|
|
|
58921
59992
|
/**
|
|
58922
59993
|
* Track an event with specific groups.
|
|
58923
59994
|
*
|
|
58924
|
-
*
|
|
58925
|
-
*
|
|
58926
|
-
*
|
|
59995
|
+
* @example
|
|
59996
|
+
* ```js
|
|
59997
|
+
* mixpanel.track_with_groups('purchase', {'product': 'iphone'}, {'University': ['UCB', 'UCLA']})
|
|
59998
|
+
* ```
|
|
58927
59999
|
*
|
|
58928
60000
|
* @param {String} event_name The name of the event (see `mixpanel.track()`)
|
|
58929
60001
|
* @param {Object=} properties A set of properties to include with the event you're sending (see `mixpanel.track()`)
|
|
58930
60002
|
* @param {Object=} groups An object mapping group name keys to one or more values
|
|
58931
60003
|
* @param {Function} [callback] If provided, the callback will be called after tracking the event.
|
|
58932
60004
|
*/
|
|
58933
|
-
MixpanelLib.prototype.track_with_groups =
|
|
60005
|
+
MixpanelLib.prototype.track_with_groups = function(event_name, properties, groups, callback) {
|
|
58934
60006
|
var tracking_props = mixpanel_module_.extend({}, properties || {});
|
|
58935
60007
|
mixpanel_module_.each(groups, function(v, k) {
|
|
58936
60008
|
if (v !== null && v !== undefined) {
|
|
@@ -58938,7 +60010,7 @@ MixpanelLib.prototype.track_with_groups = addOptOutCheckMixpanelLib(function(eve
|
|
|
58938
60010
|
}
|
|
58939
60011
|
});
|
|
58940
60012
|
return this.track(event_name, tracking_props, callback);
|
|
58941
|
-
}
|
|
60013
|
+
};
|
|
58942
60014
|
|
|
58943
60015
|
MixpanelLib.prototype._create_map_key = function (group_key, group_id) {
|
|
58944
60016
|
return group_key + '_' + JSON.stringify(group_id);
|
|
@@ -58951,9 +60023,10 @@ MixpanelLib.prototype._remove_group_from_cache = function (group_key, group_id)
|
|
|
58951
60023
|
/**
|
|
58952
60024
|
* Look up reference to a Mixpanel group
|
|
58953
60025
|
*
|
|
58954
|
-
*
|
|
58955
|
-
*
|
|
58956
|
-
*
|
|
60026
|
+
* @example
|
|
60027
|
+
* ```js
|
|
60028
|
+
* mixpanel.get_group(group_key, group_id)
|
|
60029
|
+
* ```
|
|
58957
60030
|
*
|
|
58958
60031
|
* @param {String} group_key Group key
|
|
58959
60032
|
* @param {Object} group_id A valid Mixpanel property type
|
|
@@ -58964,7 +60037,7 @@ MixpanelLib.prototype.get_group = function (group_key, group_id) {
|
|
|
58964
60037
|
var group = this._cached_groups[map_key];
|
|
58965
60038
|
if (group === undefined || group._group_key !== group_key || group._group_id !== group_id) {
|
|
58966
60039
|
group = new MixpanelGroup();
|
|
58967
|
-
group._init(this, group_key, group_id);
|
|
60040
|
+
group._init(this, group_key, group_id, this._consent);
|
|
58968
60041
|
this._cached_groups[map_key] = group;
|
|
58969
60042
|
}
|
|
58970
60043
|
return group;
|
|
@@ -58974,24 +60047,25 @@ MixpanelLib.prototype.get_group = function (group_key, group_id) {
|
|
|
58974
60047
|
* Track a default Mixpanel page view event, which includes extra default event properties to
|
|
58975
60048
|
* improve page view data.
|
|
58976
60049
|
*
|
|
58977
|
-
*
|
|
58978
|
-
*
|
|
58979
|
-
*
|
|
58980
|
-
*
|
|
60050
|
+
* @example
|
|
60051
|
+
* ```js
|
|
60052
|
+
* // track a default $mp_web_page_view event
|
|
60053
|
+
* mixpanel.track_pageview();
|
|
58981
60054
|
*
|
|
58982
|
-
*
|
|
58983
|
-
*
|
|
60055
|
+
* // track a page view event with additional event properties
|
|
60056
|
+
* mixpanel.track_pageview({'ab_test_variant': 'card-layout-b'});
|
|
58984
60057
|
*
|
|
58985
|
-
*
|
|
58986
|
-
*
|
|
58987
|
-
*
|
|
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'});
|
|
58988
60061
|
*
|
|
58989
|
-
*
|
|
58990
|
-
*
|
|
58991
|
-
*
|
|
58992
|
-
*
|
|
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
|
+
* ```
|
|
58993
60067
|
*
|
|
58994
|
-
*
|
|
60068
|
+
* @remarks
|
|
58995
60069
|
*
|
|
58996
60070
|
* The `config.track_pageview` option for <a href="#mixpanelinit">mixpanel.init()</a>
|
|
58997
60071
|
* may be turned on for tracking page loads automatically.
|
|
@@ -59014,7 +60088,7 @@ MixpanelLib.prototype.get_group = function (group_key, group_id) {
|
|
|
59014
60088
|
* @returns {Boolean|Object} If the tracking request was successfully initiated/queued, an object
|
|
59015
60089
|
* with the tracking payload sent to the API server is returned; otherwise false.
|
|
59016
60090
|
*/
|
|
59017
|
-
MixpanelLib.prototype.track_pageview =
|
|
60091
|
+
MixpanelLib.prototype.track_pageview = function(properties, options) {
|
|
59018
60092
|
if (typeof properties !== 'object') {
|
|
59019
60093
|
properties = {};
|
|
59020
60094
|
}
|
|
@@ -59038,18 +60112,19 @@ MixpanelLib.prototype.track_pageview = addOptOutCheckMixpanelLib(function(proper
|
|
|
59038
60112
|
}
|
|
59039
60113
|
|
|
59040
60114
|
return this.track(event_name, event_properties);
|
|
59041
|
-
}
|
|
60115
|
+
};
|
|
59042
60116
|
|
|
59043
60117
|
/**
|
|
59044
60118
|
* Track clicks on a set of document elements. Selector must be a
|
|
59045
60119
|
* valid query. Elements must exist on the page at the time track_links is called.
|
|
59046
60120
|
*
|
|
59047
|
-
*
|
|
59048
|
-
*
|
|
59049
|
-
*
|
|
59050
|
-
*
|
|
60121
|
+
* @example
|
|
60122
|
+
* ```js
|
|
60123
|
+
* // track click for link id #nav
|
|
60124
|
+
* mixpanel.track_links('#nav', 'Clicked Nav Link');
|
|
60125
|
+
* ```
|
|
59051
60126
|
*
|
|
59052
|
-
*
|
|
60127
|
+
* @remarks
|
|
59053
60128
|
*
|
|
59054
60129
|
* This function will wait up to 300 ms for the Mixpanel
|
|
59055
60130
|
* servers to respond. If they have not responded by that time
|
|
@@ -59063,24 +60138,24 @@ MixpanelLib.prototype.track_pageview = addOptOutCheckMixpanelLib(function(proper
|
|
|
59063
60138
|
* from the function; any properties defined on this object
|
|
59064
60139
|
* will be sent to mixpanel as event properties.
|
|
59065
60140
|
*
|
|
59066
|
-
* @type {Function}
|
|
59067
60141
|
* @param {Object|String} query A valid DOM query, element or jQuery-esque list
|
|
59068
60142
|
* @param {String} event_name The name of the event to track
|
|
59069
60143
|
* @param {Object|Function} [properties] A properties object or function that returns a dictionary of properties when passed a DOMElement
|
|
59070
60144
|
*/
|
|
59071
|
-
MixpanelLib.prototype.track_links = function() {
|
|
60145
|
+
MixpanelLib.prototype.track_links = function(query, event_name, properties) { // eslint-disable-line no-unused-vars
|
|
59072
60146
|
return this._track_dom.call(this, LinkTracker, arguments);
|
|
59073
60147
|
};
|
|
59074
60148
|
|
|
59075
60149
|
/**
|
|
59076
60150
|
* Track form submissions. Selector must be a valid query.
|
|
59077
60151
|
*
|
|
59078
|
-
*
|
|
59079
|
-
*
|
|
59080
|
-
*
|
|
59081
|
-
*
|
|
60152
|
+
* @example
|
|
60153
|
+
* ```js
|
|
60154
|
+
* // track submission for form id 'register'
|
|
60155
|
+
* mixpanel.track_forms('#register', 'Created Account');
|
|
60156
|
+
* ```
|
|
59082
60157
|
*
|
|
59083
|
-
*
|
|
60158
|
+
* @remarks
|
|
59084
60159
|
*
|
|
59085
60160
|
* This function will wait up to 300 ms for the mixpanel
|
|
59086
60161
|
* servers to respond, if they have not responded by that time
|
|
@@ -59094,12 +60169,11 @@ MixpanelLib.prototype.track_links = function() {
|
|
|
59094
60169
|
* from the function; any properties defined on this object
|
|
59095
60170
|
* will be sent to mixpanel as event properties.
|
|
59096
60171
|
*
|
|
59097
|
-
* @type {Function}
|
|
59098
60172
|
* @param {Object|String} query A valid DOM query, element or jQuery-esque list
|
|
59099
60173
|
* @param {String} event_name The name of the event to track
|
|
59100
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
|
|
59101
60175
|
*/
|
|
59102
|
-
MixpanelLib.prototype.track_forms = function() {
|
|
60176
|
+
MixpanelLib.prototype.track_forms = function(query, event_name, properties) { // eslint-disable-line no-unused-vars
|
|
59103
60177
|
return this._track_dom.call(this, FormTracker, arguments);
|
|
59104
60178
|
};
|
|
59105
60179
|
|
|
@@ -59108,16 +60182,17 @@ MixpanelLib.prototype.track_forms = function() {
|
|
|
59108
60182
|
* later 'track' call for the same event in the properties sent
|
|
59109
60183
|
* with the event.
|
|
59110
60184
|
*
|
|
59111
|
-
* ### Usage:
|
|
59112
|
-
*
|
|
59113
|
-
* // time an event named 'Registered'
|
|
59114
|
-
* mixpanel.time_event('Registered');
|
|
59115
|
-
* mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});
|
|
59116
|
-
*
|
|
59117
60185
|
* When called for a particular event name, the next track call for that event
|
|
59118
60186
|
* name will include the elapsed time between the 'time_event' and 'track'
|
|
59119
60187
|
* calls. This value is stored as seconds in the '$duration' property.
|
|
59120
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
|
+
*
|
|
59121
60196
|
* @param {String} event_name The name of the event.
|
|
59122
60197
|
*/
|
|
59123
60198
|
MixpanelLib.prototype.time_event = function(event_name) {
|
|
@@ -59158,21 +60233,22 @@ var options_for_register = function(days_or_options) {
|
|
|
59158
60233
|
* Register a set of super properties, which are included with all
|
|
59159
60234
|
* events. This will overwrite previous super property values.
|
|
59160
60235
|
*
|
|
59161
|
-
*
|
|
59162
|
-
*
|
|
59163
|
-
*
|
|
59164
|
-
*
|
|
60236
|
+
* @example
|
|
60237
|
+
* ```js
|
|
60238
|
+
* // register 'Gender' as a super property
|
|
60239
|
+
* mixpanel.register({'Gender': 'Female'});
|
|
59165
60240
|
*
|
|
59166
|
-
*
|
|
59167
|
-
*
|
|
59168
|
-
*
|
|
59169
|
-
*
|
|
59170
|
-
*
|
|
60241
|
+
* // register several super properties when a user signs up
|
|
60242
|
+
* mixpanel.register({
|
|
60243
|
+
* 'Email': 'jdoe@example.com',
|
|
60244
|
+
* 'Account Type': 'Free'
|
|
60245
|
+
* });
|
|
59171
60246
|
*
|
|
59172
|
-
*
|
|
59173
|
-
*
|
|
60247
|
+
* // register only for the current pageload
|
|
60248
|
+
* mixpanel.register({'Name': 'Pat'}, {persistent: false});
|
|
60249
|
+
* ```
|
|
59174
60250
|
*
|
|
59175
|
-
* @param {Object}
|
|
60251
|
+
* @param {Object} props An associative array of properties to store about the user
|
|
59176
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)
|
|
59177
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)
|
|
59178
60254
|
* @param {boolean} [days_or_options.persistent=true] - whether to put in persistent storage (cookie/localStorage)
|
|
@@ -59198,24 +60274,25 @@ MixpanelLib.prototype.register = function(props, days_or_options) {
|
|
|
59198
60274
|
* Register a set of super properties only once. This will not
|
|
59199
60275
|
* overwrite previous super property values, unlike register().
|
|
59200
60276
|
*
|
|
59201
|
-
*
|
|
59202
|
-
*
|
|
59203
|
-
*
|
|
59204
|
-
*
|
|
59205
|
-
*
|
|
59206
|
-
*
|
|
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
|
+
* });
|
|
59207
60283
|
*
|
|
59208
|
-
*
|
|
59209
|
-
*
|
|
59210
|
-
*
|
|
59211
|
-
*
|
|
60284
|
+
* // register once, only for the current pageload
|
|
60285
|
+
* mixpanel.register_once({
|
|
60286
|
+
* 'First interaction time': new Date().toISOString()
|
|
60287
|
+
* }, 'None', {persistent: false});
|
|
60288
|
+
* ```
|
|
59212
60289
|
*
|
|
59213
|
-
*
|
|
60290
|
+
* @remarks
|
|
59214
60291
|
*
|
|
59215
60292
|
* If default_value is specified, current super properties
|
|
59216
60293
|
* with that value will be overwritten.
|
|
59217
60294
|
*
|
|
59218
|
-
* @param {Object}
|
|
60295
|
+
* @param {Object} props An associative array of properties to store about the user
|
|
59219
60296
|
* @param {*} [default_value] Value to override if already set in super properties (ex: 'False') Default: 'None'
|
|
59220
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)
|
|
59221
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)
|
|
@@ -59286,7 +60363,7 @@ MixpanelLib.prototype._register_single = function(prop, value) {
|
|
|
59286
60363
|
* typically after login or signup. We recommend against using
|
|
59287
60364
|
* identify for anonymous visitors to your site.
|
|
59288
60365
|
*
|
|
59289
|
-
*
|
|
60366
|
+
* @remarks
|
|
59290
60367
|
* If your project has
|
|
59291
60368
|
* <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a>
|
|
59292
60369
|
* enabled, the identify method will connect pre- and
|
|
@@ -59298,7 +60375,11 @@ MixpanelLib.prototype._register_single = function(prop, value) {
|
|
|
59298
60375
|
* to the same user identity. If ID Merge is disabled, alias can
|
|
59299
60376
|
* be used to connect pre- and post-registration events.
|
|
59300
60377
|
*
|
|
59301
|
-
*
|
|
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.
|
|
59302
60383
|
*/
|
|
59303
60384
|
MixpanelLib.prototype.identify = function(
|
|
59304
60385
|
new_distinct_id, _set_callback, _add_callback, _append_callback, _set_once_callback, _union_callback, _unset_callback, _remove_callback
|
|
@@ -59310,6 +60391,12 @@ MixpanelLib.prototype.identify = function(
|
|
|
59310
60391
|
// _set_once_callback:function A callback to be run if and when the People set_once queue is flushed
|
|
59311
60392
|
// _union_callback:function A callback to be run if and when the People union queue is flushed
|
|
59312
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
|
+
|
|
59313
60400
|
var ret = this._run_hook('before_identify', new_distinct_id);
|
|
59314
60401
|
|
|
59315
60402
|
if (ret === null) {
|
|
@@ -59374,11 +60461,11 @@ MixpanelLib.prototype.reset = function() {
|
|
|
59374
60461
|
this.stop_session_recording();
|
|
59375
60462
|
this['persistence'].clear();
|
|
59376
60463
|
this._flags.identify_called = false;
|
|
59377
|
-
|
|
59378
|
-
|
|
59379
|
-
|
|
59380
|
-
|
|
59381
|
-
}
|
|
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
|
+
}
|
|
59382
60469
|
this._check_and_start_session_recording();
|
|
59383
60470
|
this.flags.reset();
|
|
59384
60471
|
};
|
|
@@ -59387,7 +60474,7 @@ MixpanelLib.prototype.reset = function() {
|
|
|
59387
60474
|
* Returns the current distinct id of the user. This is either the id automatically
|
|
59388
60475
|
* generated by the library or the id that has been passed by a call to identify().
|
|
59389
60476
|
*
|
|
59390
|
-
*
|
|
60477
|
+
* @remarks
|
|
59391
60478
|
*
|
|
59392
60479
|
* get_distinct_id() can only be called after the Mixpanel library has finished loading.
|
|
59393
60480
|
* init() has a loaded function available to handle this automatically. For example:
|
|
@@ -59427,7 +60514,7 @@ MixpanelLib.prototype.get_distinct_id = function() {
|
|
|
59427
60514
|
* // this is invalid as 'new_id' already points to 'existing_id'
|
|
59428
60515
|
* mixpanel.alias('new_id', 'newer_id');
|
|
59429
60516
|
*
|
|
59430
|
-
*
|
|
60517
|
+
* @remarks
|
|
59431
60518
|
*
|
|
59432
60519
|
* If your project does not have
|
|
59433
60520
|
* <a href="https://help.mixpanel.com/hc/en-us/articles/360039133851">ID Merge</a>
|
|
@@ -59440,6 +60527,11 @@ MixpanelLib.prototype.get_distinct_id = function() {
|
|
|
59440
60527
|
* @param {String} [original] The current identifier being used for this user.
|
|
59441
60528
|
*/
|
|
59442
60529
|
MixpanelLib.prototype.alias = function(alias, original) {
|
|
60530
|
+
if (!this._consent.allowsStoring()) {
|
|
60531
|
+
console$1.log('alias() dropped without consent');
|
|
60532
|
+
return;
|
|
60533
|
+
}
|
|
60534
|
+
|
|
59443
60535
|
// If the $people_distinct_id key exists in persistence, there has been a previous
|
|
59444
60536
|
// mixpanel.people.identify() call made for this user. It is VERY BAD to make an alias with
|
|
59445
60537
|
// this ID, as it will duplicate users.
|
|
@@ -59569,6 +60661,11 @@ MixpanelLib.prototype.name_tag = function(name_tag) {
|
|
|
59569
60661
|
* // customize the name of cookie/localStorage set by opt-in/opt-out methods
|
|
59570
60662
|
* opt_out_tracking_cookie_prefix: null
|
|
59571
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
|
+
*
|
|
59572
60669
|
* // type of persistent store for super properties (cookie/
|
|
59573
60670
|
* // localStorage) if set to 'localStorage', any existing
|
|
59574
60671
|
* // mixpanel cookie value with the same persistence_name
|
|
@@ -59616,10 +60713,15 @@ MixpanelLib.prototype.name_tag = function(name_tag) {
|
|
|
59616
60713
|
* }
|
|
59617
60714
|
*
|
|
59618
60715
|
*
|
|
59619
|
-
* @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.
|
|
59620
60717
|
*/
|
|
59621
60718
|
MixpanelLib.prototype.set_config = function(config) {
|
|
59622
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
|
+
}
|
|
59623
60725
|
mixpanel_module_.extend(this['config'], config);
|
|
59624
60726
|
|
|
59625
60727
|
var new_batch_size = config['batch_size'];
|
|
@@ -59706,7 +60808,7 @@ MixpanelLib.prototype._run_hook = function(hook_name) {
|
|
|
59706
60808
|
* Returns the value of the super property named property_name. If no such
|
|
59707
60809
|
* property is set, get_property() will return the undefined value.
|
|
59708
60810
|
*
|
|
59709
|
-
*
|
|
60811
|
+
* @remarks
|
|
59710
60812
|
*
|
|
59711
60813
|
* get_property() can only be called after the Mixpanel library has finished loading.
|
|
59712
60814
|
* init() has a loaded function available to handle this automatically. For example:
|
|
@@ -59748,124 +60850,66 @@ MixpanelLib.prototype._event_is_disabled = function(event_name) {
|
|
|
59748
60850
|
mixpanel_module_.include(this.__disabled_events, event_name);
|
|
59749
60851
|
};
|
|
59750
60852
|
|
|
59751
|
-
|
|
59752
|
-
|
|
59753
|
-
|
|
59754
|
-
|
|
59755
|
-
|
|
59756
|
-
|
|
59757
|
-
|
|
59758
|
-
|
|
59759
|
-
}
|
|
59760
|
-
if (!this.has_opted_out_tracking() && this.has_opted_out_tracking({'persistence_type': 'cookie'})) {
|
|
59761
|
-
this.opt_out_tracking({'clear_persistence': false});
|
|
59762
|
-
}
|
|
59763
|
-
this.clear_opt_in_out_tracking({
|
|
59764
|
-
'persistence_type': 'cookie',
|
|
59765
|
-
'enable_persistence': false
|
|
59766
|
-
});
|
|
59767
|
-
}
|
|
59768
|
-
|
|
59769
|
-
// check whether the user has already opted out - if so, clear & disable persistence
|
|
59770
|
-
if (this.has_opted_out_tracking()) {
|
|
59771
|
-
this._gdpr_update_persistence({'clear_persistence': true});
|
|
59772
|
-
|
|
59773
|
-
// check whether we should opt out by default
|
|
59774
|
-
// note: we don't clear persistence here by default since opt-out default state is often
|
|
59775
|
-
// used as an initial state while GDPR information is being collected
|
|
59776
|
-
} else if (!this.has_opted_in_tracking() && (
|
|
59777
|
-
this.get_config('opt_out_tracking_by_default') || mixpanel_module_.cookie.get('mp_optout')
|
|
59778
|
-
)) {
|
|
59779
|
-
mixpanel_module_.cookie.remove('mp_optout');
|
|
59780
|
-
this.opt_out_tracking({
|
|
59781
|
-
'clear_persistence': this.get_config('opt_out_persistence_by_default')
|
|
59782
|
-
});
|
|
59783
|
-
}
|
|
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);
|
|
59784
60861
|
};
|
|
59785
60862
|
|
|
59786
60863
|
/**
|
|
59787
|
-
*
|
|
59788
|
-
*
|
|
59789
|
-
* @param {boolean}
|
|
59790
|
-
* @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
|
|
59791
60867
|
*/
|
|
59792
|
-
MixpanelLib.prototype.
|
|
59793
|
-
|
|
59794
|
-
|
|
59795
|
-
disabled = true;
|
|
59796
|
-
} else if (options && options['enable_persistence']) {
|
|
59797
|
-
disabled = false;
|
|
60868
|
+
MixpanelLib.prototype._set_persistence_disabled = function(disabled) {
|
|
60869
|
+
if (disabled) {
|
|
60870
|
+
this['persistence'].close();
|
|
59798
60871
|
} else {
|
|
59799
|
-
|
|
59800
|
-
}
|
|
59801
|
-
|
|
59802
|
-
if (!this.get_config('disable_persistence') && this['persistence'].disabled !== disabled) {
|
|
59803
|
-
this['persistence'].set_disabled(disabled);
|
|
60872
|
+
this['persistence'].open();
|
|
59804
60873
|
}
|
|
59805
60874
|
|
|
59806
60875
|
if (disabled) {
|
|
59807
60876
|
this.stop_batch_senders();
|
|
59808
60877
|
this.stop_session_recording();
|
|
59809
|
-
} else {
|
|
59810
|
-
|
|
59811
|
-
// in order to avoid unintentionally starting up batching for the first time
|
|
59812
|
-
if (this._batchers_were_started) {
|
|
59813
|
-
this.start_batch_senders();
|
|
59814
|
-
}
|
|
60878
|
+
} else if (this._batchers_were_started) {
|
|
60879
|
+
this.start_batch_senders();
|
|
59815
60880
|
}
|
|
59816
60881
|
};
|
|
59817
60882
|
|
|
59818
|
-
//
|
|
59819
|
-
MixpanelLib.prototype.
|
|
59820
|
-
|
|
59821
|
-
'
|
|
59822
|
-
'
|
|
59823
|
-
'cookie_prefix': this.get_config('opt_out_tracking_cookie_prefix'),
|
|
59824
|
-
'cookie_expiration': this.get_config('cookie_expiration'),
|
|
59825
|
-
'cross_site_cookie': this.get_config('cross_site_cookie'),
|
|
59826
|
-
'cross_subdomain_cookie': this.get_config('cross_subdomain_cookie'),
|
|
59827
|
-
'cookie_domain': this.get_config('cookie_domain'),
|
|
59828
|
-
'secure_cookie': this.get_config('secure_cookie'),
|
|
59829
|
-
'ignore_dnt': this.get_config('ignore_dnt')
|
|
59830
|
-
}, options);
|
|
59831
|
-
|
|
59832
|
-
// check if localStorage can be used for recording opt out status, fall back to cookie if not
|
|
59833
|
-
if (!mixpanel_module_.localStorage.is_supported()) {
|
|
59834
|
-
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();
|
|
59835
60888
|
}
|
|
59836
|
-
|
|
59837
|
-
return func(this.get_config('token'), {
|
|
59838
|
-
track: options['track'],
|
|
59839
|
-
trackEventName: options['track_event_name'],
|
|
59840
|
-
trackProperties: options['track_properties'],
|
|
59841
|
-
persistenceType: options['persistence_type'],
|
|
59842
|
-
persistencePrefix: options['cookie_prefix'],
|
|
59843
|
-
cookieDomain: options['cookie_domain'],
|
|
59844
|
-
cookieExpiration: options['cookie_expiration'],
|
|
59845
|
-
crossSiteCookie: options['cross_site_cookie'],
|
|
59846
|
-
crossSubdomainCookie: options['cross_subdomain_cookie'],
|
|
59847
|
-
secureCookie: options['secure_cookie'],
|
|
59848
|
-
ignoreDnt: options['ignore_dnt']
|
|
59849
|
-
});
|
|
59850
60889
|
};
|
|
59851
60890
|
|
|
59852
60891
|
/**
|
|
59853
60892
|
* Opt the user in to data tracking and cookies/localstorage for this Mixpanel instance
|
|
59854
60893
|
*
|
|
59855
|
-
*
|
|
59856
|
-
*
|
|
59857
|
-
*
|
|
59858
|
-
*
|
|
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
|
+
* ```
|
|
59859
60909
|
*
|
|
59860
|
-
*
|
|
59861
|
-
*
|
|
59862
|
-
*
|
|
59863
|
-
* track_event_properties: {
|
|
59864
|
-
* 'Email': 'jdoe@example.com'
|
|
59865
|
-
* },
|
|
59866
|
-
* cookie_expiration: 30,
|
|
59867
|
-
* secure_cookie: true
|
|
59868
|
-
* });
|
|
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.
|
|
59869
60913
|
*
|
|
59870
60914
|
* @param {Object} [options] A dictionary of config options to override
|
|
59871
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)
|
|
@@ -59881,27 +60925,27 @@ MixpanelLib.prototype._gdpr_call_func = function(func, options) {
|
|
|
59881
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)
|
|
59882
60926
|
*/
|
|
59883
60927
|
MixpanelLib.prototype.opt_in_tracking = function(options) {
|
|
59884
|
-
|
|
59885
|
-
'enable_persistence': true
|
|
59886
|
-
}, options);
|
|
59887
|
-
|
|
59888
|
-
this._gdpr_call_func(optIn, options);
|
|
59889
|
-
this._gdpr_update_persistence(options);
|
|
60928
|
+
this._consent.optIn(options);
|
|
59890
60929
|
};
|
|
59891
60930
|
|
|
59892
60931
|
/**
|
|
59893
60932
|
* Opt the user out of data tracking and cookies/localstorage for this Mixpanel instance
|
|
59894
60933
|
*
|
|
59895
|
-
*
|
|
60934
|
+
* @example
|
|
60935
|
+
* ```js
|
|
60936
|
+
* // opt user out
|
|
60937
|
+
* mixpanel.opt_out_tracking();
|
|
59896
60938
|
*
|
|
59897
|
-
*
|
|
59898
|
-
*
|
|
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
|
+
* ```
|
|
59899
60945
|
*
|
|
59900
|
-
*
|
|
59901
|
-
*
|
|
59902
|
-
*
|
|
59903
|
-
* secure_cookie: true
|
|
59904
|
-
* });
|
|
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.
|
|
59905
60949
|
*
|
|
59906
60950
|
* @param {Object} [options] A dictionary of config options to override
|
|
59907
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
|
|
@@ -59915,69 +60959,70 @@ MixpanelLib.prototype.opt_in_tracking = function(options) {
|
|
|
59915
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)
|
|
59916
60960
|
*/
|
|
59917
60961
|
MixpanelLib.prototype.opt_out_tracking = function(options) {
|
|
59918
|
-
|
|
59919
|
-
'clear_persistence': true,
|
|
59920
|
-
'delete_user': true
|
|
59921
|
-
}, options);
|
|
59922
|
-
|
|
59923
|
-
// delete user and clear charges since these methods may be disabled by opt-out
|
|
59924
|
-
if (options['delete_user'] && this['people'] && this['people']._identify_called()) {
|
|
59925
|
-
this['people'].delete_user();
|
|
59926
|
-
this['people'].clear_charges();
|
|
59927
|
-
}
|
|
59928
|
-
|
|
59929
|
-
this._gdpr_call_func(optOut, options);
|
|
59930
|
-
this._gdpr_update_persistence(options);
|
|
60962
|
+
this._consent.optOut(options);
|
|
59931
60963
|
};
|
|
59932
60964
|
|
|
59933
60965
|
/**
|
|
59934
60966
|
* Check whether the user has opted in to data tracking and cookies/localstorage for this Mixpanel instance
|
|
59935
60967
|
*
|
|
59936
|
-
*
|
|
60968
|
+
* @example
|
|
60969
|
+
* ```js
|
|
60970
|
+
* var has_opted_in = mixpanel.has_opted_in_tracking();
|
|
60971
|
+
* // use has_opted_in value
|
|
60972
|
+
* ```
|
|
59937
60973
|
*
|
|
59938
|
-
*
|
|
59939
|
-
* // use has_opted_in value
|
|
60974
|
+
* With consent_mode 'require_consent' the options don't apply.
|
|
59940
60975
|
*
|
|
59941
60976
|
* @param {Object} [options] A dictionary of config options to override
|
|
59942
|
-
* @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
|
|
59943
60978
|
* @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
|
|
59944
60979
|
* @returns {boolean} current opt-in status
|
|
59945
60980
|
*/
|
|
59946
60981
|
MixpanelLib.prototype.has_opted_in_tracking = function(options) {
|
|
59947
|
-
return this.
|
|
60982
|
+
return this._consent.hasOptedIn(options);
|
|
59948
60983
|
};
|
|
59949
60984
|
|
|
59950
60985
|
/**
|
|
59951
60986
|
* Check whether the user has opted out of data tracking and cookies/localstorage for this Mixpanel instance
|
|
59952
60987
|
*
|
|
59953
|
-
*
|
|
60988
|
+
* @example
|
|
60989
|
+
* ```js
|
|
60990
|
+
* var has_opted_out = mixpanel.has_opted_out_tracking();
|
|
60991
|
+
* // use has_opted_out value
|
|
60992
|
+
* ```
|
|
59954
60993
|
*
|
|
59955
|
-
*
|
|
59956
|
-
*
|
|
60994
|
+
* With consent_mode 'require_consent' the options don't apply, and a stored refusal or Do Not Track
|
|
60995
|
+
* counts as opted out.
|
|
59957
60996
|
*
|
|
59958
60997
|
* @param {Object} [options] A dictionary of config options to override
|
|
59959
|
-
* @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
|
|
59960
60999
|
* @param {string} [options.cookie_prefix=__mp_opt_in_out] Custom prefix to be used in the cookie/localstorage name
|
|
59961
61000
|
* @returns {boolean} current opt-out status
|
|
59962
61001
|
*/
|
|
59963
61002
|
MixpanelLib.prototype.has_opted_out_tracking = function(options) {
|
|
59964
|
-
return this.
|
|
61003
|
+
return this._consent.hasOptedOut(options);
|
|
59965
61004
|
};
|
|
59966
61005
|
|
|
59967
61006
|
/**
|
|
59968
61007
|
* Clear the user's opt in/out status of data tracking and cookies/localstorage for this Mixpanel instance
|
|
59969
61008
|
*
|
|
59970
|
-
*
|
|
59971
|
-
*
|
|
59972
|
-
*
|
|
59973
|
-
*
|
|
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
|
+
* ```
|
|
59974
61021
|
*
|
|
59975
|
-
*
|
|
59976
|
-
*
|
|
59977
|
-
*
|
|
59978
|
-
*
|
|
59979
|
-
* secure_cookie: true
|
|
59980
|
-
* });
|
|
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.
|
|
59981
61026
|
*
|
|
59982
61027
|
* @param {Object} [options] A dictionary of config options to override
|
|
59983
61028
|
* @param {boolean} [options.enable_persistence=true] If true, will re-enable sdk persistence
|
|
@@ -59990,12 +61035,7 @@ MixpanelLib.prototype.has_opted_out_tracking = function(options) {
|
|
|
59990
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)
|
|
59991
61036
|
*/
|
|
59992
61037
|
MixpanelLib.prototype.clear_opt_in_out_tracking = function(options) {
|
|
59993
|
-
|
|
59994
|
-
'enable_persistence': true
|
|
59995
|
-
}, options);
|
|
59996
|
-
|
|
59997
|
-
this._gdpr_call_func(clearOptInOut, options);
|
|
59998
|
-
this._gdpr_update_persistence(options);
|
|
61038
|
+
this._consent.clear(options);
|
|
59999
61039
|
};
|
|
60000
61040
|
|
|
60001
61041
|
MixpanelLib.prototype.report_error = function(msg, err) {
|
|
@@ -60032,53 +61072,57 @@ MixpanelLib.prototype.remove_hook = function(hook_name, hook_fn) {
|
|
|
60032
61072
|
// EXPORTS (for closure compiler)
|
|
60033
61073
|
|
|
60034
61074
|
// MixpanelLib Exports
|
|
60035
|
-
MixpanelLib.prototype[
|
|
60036
|
-
|
|
60037
|
-
|
|
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
|
-
|
|
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;
|
|
60078
61122
|
|
|
60079
61123
|
// Exports intended only for testing
|
|
60080
|
-
|
|
60081
|
-
|
|
61124
|
+
MixpanelLibProto['__get_recorder'] = MixpanelLibProto.__get_recorder;
|
|
61125
|
+
MixpanelLibProto['__get_recording_init_promise'] = MixpanelLibProto.__get_recording_init_promise;
|
|
60082
61126
|
|
|
60083
61127
|
// MixpanelPersistence Exports
|
|
60084
61128
|
MixpanelPersistence.prototype['properties'] = MixpanelPersistence.prototype.properties;
|