mixpanel-browser 2.78.0 → 2.79.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +6 -11
- package/.eslintrc.json +12 -0
- package/.github/workflows/openfeature-provider-tests.yml +31 -0
- package/CHANGELOG.md +8 -1
- package/build.sh +2 -2
- package/dist/async-modules/{mixpanel-recorder-BjSlYaNJ.min.js → mixpanel-recorder-D5HJyV2E.min.js} +2 -2
- package/dist/async-modules/mixpanel-recorder-D5HJyV2E.min.js.map +1 -0
- package/dist/async-modules/{mixpanel-recorder-zMBXIyeG.js → mixpanel-recorder-P6SEnnPV.js} +57 -33
- package/dist/async-modules/mixpanel-targeting-1L9FyetZ.min.js +2 -0
- package/dist/async-modules/mixpanel-targeting-1L9FyetZ.min.js.map +1 -0
- package/dist/async-modules/{mixpanel-targeting-UHf4eBfC.js → mixpanel-targeting-BBMVbgJF.js} +24 -13
- package/dist/mixpanel-core.cjs.d.ts +45 -1
- package/dist/mixpanel-core.cjs.js +565 -197
- package/dist/mixpanel-recorder.js +57 -33
- package/dist/mixpanel-recorder.min.js +1 -1
- package/dist/mixpanel-recorder.min.js.map +1 -1
- package/dist/mixpanel-targeting.js +24 -13
- package/dist/mixpanel-targeting.min.js +1 -1
- package/dist/mixpanel-targeting.min.js.map +1 -1
- package/dist/mixpanel-with-async-modules.cjs.d.ts +45 -1
- package/dist/mixpanel-with-async-modules.cjs.js +567 -199
- package/dist/mixpanel-with-async-recorder.cjs.d.ts +45 -1
- package/dist/mixpanel-with-async-recorder.cjs.js +567 -199
- package/dist/mixpanel-with-recorder.d.ts +45 -1
- package/dist/mixpanel-with-recorder.js +490 -122
- package/dist/mixpanel-with-recorder.min.d.ts +45 -1
- package/dist/mixpanel-with-recorder.min.js +1 -1
- package/dist/mixpanel.amd.d.ts +45 -1
- package/dist/mixpanel.amd.js +490 -122
- package/dist/mixpanel.cjs.d.ts +45 -1
- package/dist/mixpanel.cjs.js +490 -122
- package/dist/mixpanel.globals.js +567 -199
- package/dist/mixpanel.min.js +199 -189
- package/dist/mixpanel.module.d.ts +45 -1
- package/dist/mixpanel.module.js +490 -122
- package/dist/mixpanel.umd.d.ts +45 -1
- package/dist/mixpanel.umd.js +490 -122
- package/package.json +1 -1
- package/packages/openfeature-web-provider/README.md +357 -0
- package/packages/openfeature-web-provider/package-lock.json +1636 -0
- package/packages/openfeature-web-provider/package.json +51 -0
- package/packages/openfeature-web-provider/rollup.config.browser.mjs +26 -0
- package/packages/openfeature-web-provider/src/MixpanelProvider.ts +302 -0
- package/packages/openfeature-web-provider/src/index.ts +1 -0
- package/packages/openfeature-web-provider/src/types.ts +72 -0
- package/packages/openfeature-web-provider/test/MixpanelProvider.spec.ts +484 -0
- package/packages/openfeature-web-provider/tsconfig.json +15 -0
- package/src/autocapture/index.js +7 -2
- package/src/config.js +1 -1
- package/src/flags/flags-persistence.js +176 -0
- package/src/flags/index.js +174 -23
- package/src/index.d.ts +45 -1
- package/src/mixpanel-core.js +24 -7
- package/src/recorder/idb-config.js +16 -0
- package/src/recorder/recording-registry.js +7 -2
- package/src/recorder/session-recording.js +9 -4
- package/src/recorder-manager.js +7 -2
- package/src/request-queue.js +1 -2
- package/src/shared-lock.js +2 -3
- package/src/storage/indexed-db.js +16 -15
- package/src/storage/local-storage.js +5 -3
- package/src/utils.js +25 -12
- package/tsconfig.base.json +9 -0
- package/dist/async-modules/mixpanel-recorder-BjSlYaNJ.min.js.map +0 -1
- package/dist/async-modules/mixpanel-targeting-BSHal4N9.min.js +0 -2
- package/dist/async-modules/mixpanel-targeting-BSHal4N9.min.js.map +0 -1
|
@@ -4,8 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
import { window } from '../window';
|
|
6
6
|
import { EventType, getRecordConsolePlugin, IncrementalSource } from './rrweb-entrypoint';
|
|
7
|
-
import { MAX_RECORDING_MS, MAX_VALUE_FOR_MIN_RECORDING_MS, console_with_prefix, NOOP_FUNC, _, localStorageSupported, canUseCompressionStream, navigator, userAgent, windowOpera} from '../utils'; // eslint-disable-line camelcase
|
|
8
|
-
import { IDBStorageWrapper
|
|
7
|
+
import { MAX_RECORDING_MS, MAX_VALUE_FOR_MIN_RECORDING_MS, console_with_prefix, NOOP_FUNC, _, localStorageSupported, getLocalStorage, canUseCompressionStream, navigator, userAgent, windowOpera} from '../utils'; // eslint-disable-line camelcase
|
|
8
|
+
import { IDBStorageWrapper } from '../storage/indexed-db';
|
|
9
|
+
import {
|
|
10
|
+
MIXPANEL_BROWSER_DB_NAME,
|
|
11
|
+
RECORDING_EVENTS_STORE_NAME,
|
|
12
|
+
RECORDER_VERSION_DATA
|
|
13
|
+
} from './idb-config';
|
|
9
14
|
import { addOptOutCheckMixpanelLib } from '../gdpr-utils';
|
|
10
15
|
import { RequestBatcher } from '../request-batcher';
|
|
11
16
|
|
|
@@ -111,11 +116,11 @@ var SessionRecording = function(options) {
|
|
|
111
116
|
|
|
112
117
|
// disable persistence if localStorage is not supported
|
|
113
118
|
// request-queue will automatically disable persistence if indexedDB fails to initialize
|
|
114
|
-
var usePersistence = localStorageSupported(options.sharedLockStorage, true) && !this.getConfig('disable_persistence');
|
|
119
|
+
var usePersistence = localStorageSupported(options.sharedLockStorage || getLocalStorage(), true) && !this.getConfig('disable_persistence');
|
|
115
120
|
|
|
116
121
|
// each replay has its own batcher key to avoid conflicts between rrweb events of different recordings
|
|
117
122
|
this.batcherKey = '__mprec_' + this.getConfig('name') + '_' + this.getConfig('token') + '_' + this.replayId;
|
|
118
|
-
this.queueStorage = new IDBStorageWrapper(RECORDING_EVENTS_STORE_NAME);
|
|
123
|
+
this.queueStorage = new IDBStorageWrapper(MIXPANEL_BROWSER_DB_NAME, RECORDING_EVENTS_STORE_NAME, RECORDER_VERSION_DATA);
|
|
119
124
|
this.batcher = new RequestBatcher(this.batcherKey, {
|
|
120
125
|
errorReporter: this.reportError.bind(this),
|
|
121
126
|
flushOnlyOnInterval: true,
|
package/src/recorder-manager.js
CHANGED
|
@@ -4,7 +4,12 @@ import {RECORDER_FILENAME, TARGETING_FILENAME, RECORDER_GLOBAL_NAME} from './con
|
|
|
4
4
|
import { _, console, console_with_prefix, safewrap, safewrapClass } from './utils';
|
|
5
5
|
import { window } from './window';
|
|
6
6
|
import { Promise } from './promise-polyfill';
|
|
7
|
-
import { IDBStorageWrapper
|
|
7
|
+
import { IDBStorageWrapper } from './storage/indexed-db';
|
|
8
|
+
import {
|
|
9
|
+
MIXPANEL_BROWSER_DB_NAME,
|
|
10
|
+
RECORDING_REGISTRY_STORE_NAME,
|
|
11
|
+
RECORDER_VERSION_DATA
|
|
12
|
+
} from './recorder/idb-config';
|
|
8
13
|
import { isRecordingExpired, validateAllowedOrigins } from './recorder/utils';
|
|
9
14
|
import { getTargetingPromise } from './targeting/loader';
|
|
10
15
|
|
|
@@ -43,7 +48,7 @@ RecorderManager.prototype.shouldLoadRecorder = function() {
|
|
|
43
48
|
return Promise.resolve(false);
|
|
44
49
|
}
|
|
45
50
|
|
|
46
|
-
var recording_registry_idb = new IDBStorageWrapper(RECORDING_REGISTRY_STORE_NAME);
|
|
51
|
+
var recording_registry_idb = new IDBStorageWrapper(MIXPANEL_BROWSER_DB_NAME, RECORDING_REGISTRY_STORE_NAME, RECORDER_VERSION_DATA);
|
|
47
52
|
var tab_id = this.getTabId();
|
|
48
53
|
return recording_registry_idb.init()
|
|
49
54
|
.then(function () {
|
package/src/request-queue.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { SharedLock } from './shared-lock';
|
|
2
2
|
import { batchedThrottle, cheap_guid, console_with_prefix, localStorageSupported, _ } from './utils'; // eslint-disable-line camelcase
|
|
3
|
-
import { window } from './window';
|
|
4
3
|
import { LocalStorageWrapper } from './storage/local-storage';
|
|
5
4
|
import { Promise } from './promise-polyfill';
|
|
6
5
|
|
|
@@ -29,7 +28,7 @@ var RequestQueue = function (storageKey, options) {
|
|
|
29
28
|
if (this.usePersistence) {
|
|
30
29
|
this.queueStorage = options.queueStorage || new LocalStorageWrapper();
|
|
31
30
|
this.lock = new SharedLock(storageKey, {
|
|
32
|
-
storage: options.sharedLockStorage
|
|
31
|
+
storage: options.sharedLockStorage,
|
|
33
32
|
timeoutMS: options.sharedLockTimeoutMS,
|
|
34
33
|
});
|
|
35
34
|
}
|
package/src/shared-lock.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Promise } from './promise-polyfill';
|
|
2
|
-
import { console_with_prefix, localStorageSupported, _ } from './utils'; // eslint-disable-line camelcase
|
|
3
|
-
import { window } from './window';
|
|
2
|
+
import { console_with_prefix, localStorageSupported, getLocalStorage, _ } from './utils'; // eslint-disable-line camelcase
|
|
4
3
|
|
|
5
4
|
var logger = console_with_prefix('lock');
|
|
6
5
|
|
|
@@ -28,7 +27,7 @@ var SharedLock = function(key, options) {
|
|
|
28
27
|
options = options || {};
|
|
29
28
|
|
|
30
29
|
this.storageKey = key;
|
|
31
|
-
this.storage = options.storage ||
|
|
30
|
+
this.storage = options.storage || getLocalStorage();
|
|
32
31
|
this.pollIntervalMS = options.pollIntervalMS || 100;
|
|
33
32
|
this.timeoutMS = options.timeoutMS || 2000;
|
|
34
33
|
|
|
@@ -1,29 +1,26 @@
|
|
|
1
1
|
import { Promise } from '../promise-polyfill';
|
|
2
2
|
import { window } from '../window';
|
|
3
3
|
|
|
4
|
-
var MIXPANEL_DB_NAME = 'mixpanelBrowserDb';
|
|
5
|
-
|
|
6
|
-
var RECORDING_EVENTS_STORE_NAME = 'mixpanelRecordingEvents';
|
|
7
|
-
var RECORDING_REGISTRY_STORE_NAME = 'mixpanelRecordingRegistry';
|
|
8
|
-
|
|
9
|
-
// note: increment the version number when adding new object stores
|
|
10
|
-
var DB_VERSION = 1;
|
|
11
|
-
var OBJECT_STORES = [RECORDING_EVENTS_STORE_NAME, RECORDING_REGISTRY_STORE_NAME];
|
|
12
|
-
|
|
13
4
|
/**
|
|
14
5
|
* @type {import('./wrapper').StorageWrapper}
|
|
15
6
|
*/
|
|
16
|
-
var IDBStorageWrapper = function (storeName) {
|
|
7
|
+
var IDBStorageWrapper = function (dbName, storeName, versionData) {
|
|
8
|
+
this.dbName = dbName;
|
|
9
|
+
this.storeName = storeName;
|
|
10
|
+
this.version = versionData.version;
|
|
11
|
+
this.storeNamesInDb = versionData.storeNames;
|
|
17
12
|
/**
|
|
18
13
|
* @type {Promise<IDBDatabase>|null}
|
|
19
14
|
*/
|
|
20
15
|
this.dbPromise = null;
|
|
21
|
-
this.storeName = storeName;
|
|
22
16
|
};
|
|
23
17
|
|
|
24
18
|
IDBStorageWrapper.prototype._openDb = function () {
|
|
19
|
+
var dbName = this.dbName;
|
|
20
|
+
var version = this.version;
|
|
21
|
+
var storeNamesInDb = this.storeNamesInDb;
|
|
25
22
|
return new Promise(function (resolve, reject) {
|
|
26
|
-
var openRequest = window.indexedDB.open(
|
|
23
|
+
var openRequest = window.indexedDB.open(dbName, version);
|
|
27
24
|
openRequest['onerror'] = function () {
|
|
28
25
|
reject(openRequest.error);
|
|
29
26
|
};
|
|
@@ -35,8 +32,10 @@ IDBStorageWrapper.prototype._openDb = function () {
|
|
|
35
32
|
openRequest['onupgradeneeded'] = function (ev) {
|
|
36
33
|
var db = ev.target.result;
|
|
37
34
|
|
|
38
|
-
|
|
39
|
-
db.
|
|
35
|
+
storeNamesInDb.forEach(function (storeName) {
|
|
36
|
+
if (!db.objectStoreNames.contains(storeName)) {
|
|
37
|
+
db.createObjectStore(storeName);
|
|
38
|
+
}
|
|
40
39
|
});
|
|
41
40
|
};
|
|
42
41
|
});
|
|
@@ -128,4 +127,6 @@ IDBStorageWrapper.prototype.getAll = function () {
|
|
|
128
127
|
});
|
|
129
128
|
};
|
|
130
129
|
|
|
131
|
-
export {
|
|
130
|
+
export {
|
|
131
|
+
IDBStorageWrapper
|
|
132
|
+
};
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { Promise } from '../promise-polyfill';
|
|
2
|
-
import { _, JSONParse, JSONStringify } from '../utils'; // eslint-disable-line camelcase
|
|
3
|
-
import { window } from '../window';
|
|
2
|
+
import { _, JSONParse, JSONStringify, getLocalStorage } from '../utils'; // eslint-disable-line camelcase
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* @type {import('./wrapper').StorageWrapper}
|
|
7
6
|
*/
|
|
8
7
|
var LocalStorageWrapper = function (storageOverride) {
|
|
9
|
-
this.storage = storageOverride ||
|
|
8
|
+
this.storage = storageOverride || getLocalStorage();
|
|
10
9
|
};
|
|
11
10
|
|
|
12
11
|
LocalStorageWrapper.prototype.init = function () {
|
|
12
|
+
if (!this.storage) {
|
|
13
|
+
return Promise.reject(new Error('localStorage is not available'));
|
|
14
|
+
}
|
|
13
15
|
return Promise.resolve();
|
|
14
16
|
};
|
|
15
17
|
|
package/src/utils.js
CHANGED
|
@@ -104,6 +104,7 @@ var log_func_with_prefix = function(func, prefix) {
|
|
|
104
104
|
var console_with_prefix = function(prefix) {
|
|
105
105
|
return {
|
|
106
106
|
log: log_func_with_prefix(console.log, prefix),
|
|
107
|
+
warn: log_func_with_prefix(console.warn, prefix),
|
|
107
108
|
error: log_func_with_prefix(console.error, prefix),
|
|
108
109
|
critical: log_func_with_prefix(console.critical, prefix)
|
|
109
110
|
};
|
|
@@ -1050,7 +1051,8 @@ var localStorageSupported = function(storage, forceCheck) {
|
|
|
1050
1051
|
if (_localStorageSupported !== null && !forceCheck) {
|
|
1051
1052
|
return _localStorageSupported;
|
|
1052
1053
|
}
|
|
1053
|
-
|
|
1054
|
+
|
|
1055
|
+
return _localStorageSupported = _testStorageSupported(storage);
|
|
1054
1056
|
};
|
|
1055
1057
|
|
|
1056
1058
|
var _sessionStorageSupported = null;
|
|
@@ -1058,7 +1060,8 @@ var sessionStorageSupported = function(storage, forceCheck) {
|
|
|
1058
1060
|
if (_sessionStorageSupported !== null && !forceCheck) {
|
|
1059
1061
|
return _sessionStorageSupported;
|
|
1060
1062
|
}
|
|
1061
|
-
|
|
1063
|
+
|
|
1064
|
+
return _sessionStorageSupported = _testStorageSupported(storage);
|
|
1062
1065
|
};
|
|
1063
1066
|
|
|
1064
1067
|
function _storageWrapper(storage, name, is_supported_fn) {
|
|
@@ -1108,17 +1111,26 @@ function _storageWrapper(storage, name, is_supported_fn) {
|
|
|
1108
1111
|
};
|
|
1109
1112
|
}
|
|
1110
1113
|
|
|
1111
|
-
// Safari
|
|
1112
|
-
//
|
|
1113
|
-
var
|
|
1114
|
-
try {
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
}
|
|
1114
|
+
// Safari and other browsers may error out accessing localStorage/sessionStorage
|
|
1115
|
+
// when cookies are disabled, so wrap access in a try-catch.
|
|
1116
|
+
var getLocalStorage = function() {
|
|
1117
|
+
try {
|
|
1118
|
+
return window.localStorage; // eslint-disable-line no-restricted-properties
|
|
1119
|
+
} catch (_err) {
|
|
1120
|
+
return null;
|
|
1121
|
+
}
|
|
1122
|
+
};
|
|
1123
|
+
|
|
1124
|
+
var getSessionStorage = function() {
|
|
1125
|
+
try {
|
|
1126
|
+
return window.sessionStorage; // eslint-disable-line no-restricted-properties
|
|
1127
|
+
} catch (_err) {
|
|
1128
|
+
return null;
|
|
1129
|
+
}
|
|
1130
|
+
};
|
|
1119
1131
|
|
|
1120
|
-
_.localStorage = _storageWrapper(
|
|
1121
|
-
_.sessionStorage = _storageWrapper(
|
|
1132
|
+
_.localStorage = _storageWrapper(getLocalStorage(), 'localStorage', localStorageSupported);
|
|
1133
|
+
_.sessionStorage = _storageWrapper(getSessionStorage(), 'sessionStorage', sessionStorageSupported);
|
|
1122
1134
|
|
|
1123
1135
|
_.register_event = (function() {
|
|
1124
1136
|
// written by Dean Edwards, 2005
|
|
@@ -1810,5 +1822,6 @@ export {
|
|
|
1810
1822
|
slice,
|
|
1811
1823
|
urlMatchesRegexList,
|
|
1812
1824
|
userAgent,
|
|
1825
|
+
getLocalStorage,
|
|
1813
1826
|
windowOpera,
|
|
1814
1827
|
};
|