mixpanel-browser 2.77.0 → 2.78.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 +3 -1
- package/CHANGELOG.md +4 -0
- package/dist/async-modules/{mixpanel-recorder-wIWnMDLA.min.js → mixpanel-recorder-BjSlYaNJ.min.js} +2 -2
- package/dist/async-modules/{mixpanel-recorder-wIWnMDLA.min.js.map → mixpanel-recorder-BjSlYaNJ.min.js.map} +1 -1
- package/dist/async-modules/{mixpanel-recorder-DLKbUIEE.js → mixpanel-recorder-zMBXIyeG.js} +1 -1
- package/dist/async-modules/{mixpanel-targeting-CTcftSJC.min.js → mixpanel-targeting-BSHal4N9.min.js} +2 -2
- package/dist/async-modules/{mixpanel-targeting-CTcftSJC.min.js.map → mixpanel-targeting-BSHal4N9.min.js.map} +1 -1
- package/dist/async-modules/{mixpanel-targeting-CmVvUyFM.js → mixpanel-targeting-UHf4eBfC.js} +1 -1
- package/dist/mixpanel-core.cjs.d.ts +1 -0
- package/dist/mixpanel-core.cjs.js +111 -80
- package/dist/mixpanel-recorder.js +1 -1
- package/dist/mixpanel-recorder.min.js +1 -1
- package/dist/mixpanel-recorder.min.js.map +1 -1
- package/dist/mixpanel-targeting.js +1 -1
- 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 +1 -0
- package/dist/mixpanel-with-async-modules.cjs.js +113 -82
- package/dist/mixpanel-with-async-recorder.cjs.d.ts +1 -0
- package/dist/mixpanel-with-async-recorder.cjs.js +113 -82
- package/dist/mixpanel-with-recorder.d.ts +1 -0
- package/dist/mixpanel-with-recorder.js +111 -80
- package/dist/mixpanel-with-recorder.min.d.ts +1 -0
- package/dist/mixpanel-with-recorder.min.js +1 -1
- package/dist/mixpanel.amd.d.ts +1 -0
- package/dist/mixpanel.amd.js +111 -80
- package/dist/mixpanel.cjs.d.ts +1 -0
- package/dist/mixpanel.cjs.js +111 -80
- package/dist/mixpanel.globals.js +113 -82
- package/dist/mixpanel.min.js +180 -179
- package/dist/mixpanel.module.d.ts +1 -0
- package/dist/mixpanel.module.js +111 -80
- package/dist/mixpanel.umd.d.ts +1 -0
- package/dist/mixpanel.umd.js +111 -80
- package/package.json +1 -1
- package/src/config.js +1 -1
- package/src/flags/CLAUDE.md +24 -0
- package/src/flags/index.js +109 -80
- package/src/index.d.ts +1 -0
- package/src/mixpanel-core.js +3 -1
- package/testServer.js +2 -0
package/dist/mixpanel.amd.d.ts
CHANGED
package/dist/mixpanel.amd.js
CHANGED
|
@@ -27,7 +27,7 @@ define((function () { 'use strict';
|
|
|
27
27
|
|
|
28
28
|
var Config = {
|
|
29
29
|
DEBUG: false,
|
|
30
|
-
LIB_VERSION: '2.
|
|
30
|
+
LIB_VERSION: '2.78.0'
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
// Window global names for async modules
|
|
@@ -26193,7 +26193,9 @@ define((function () { 'use strict';
|
|
|
26193
26193
|
}
|
|
26194
26194
|
|
|
26195
26195
|
this.flags = null;
|
|
26196
|
-
this.fetchFlags()
|
|
26196
|
+
this.fetchFlags().catch(function() {
|
|
26197
|
+
logger$1.error('Error fetching flags during init');
|
|
26198
|
+
});
|
|
26197
26199
|
|
|
26198
26200
|
this.trackedFeatures = new Set();
|
|
26199
26201
|
this.pendingFirstTimeEvents = {};
|
|
@@ -26234,8 +26236,12 @@ define((function () { 'use strict';
|
|
|
26234
26236
|
var oldContext = (options && options['replace']) ? {} : this.getConfig(CONFIG_CONTEXT);
|
|
26235
26237
|
ffConfig[CONFIG_CONTEXT] = _.extend({}, oldContext, newContext);
|
|
26236
26238
|
|
|
26237
|
-
|
|
26238
|
-
|
|
26239
|
+
var configUpdate = {};
|
|
26240
|
+
configUpdate[FLAGS_CONFIG_KEY] = ffConfig;
|
|
26241
|
+
this.setMpConfig(configUpdate);
|
|
26242
|
+
return this.fetchFlags().catch(function() {
|
|
26243
|
+
logger$1.error('Error fetching flags during updateContext');
|
|
26244
|
+
});
|
|
26239
26245
|
};
|
|
26240
26246
|
|
|
26241
26247
|
FeatureFlagManager.prototype.areFlagsReady = function() {
|
|
@@ -26272,96 +26278,110 @@ define((function () { 'use strict';
|
|
|
26272
26278
|
}
|
|
26273
26279
|
}).then(function(response) {
|
|
26274
26280
|
this.markFetchComplete();
|
|
26275
|
-
return response.json()
|
|
26276
|
-
|
|
26277
|
-
|
|
26278
|
-
|
|
26279
|
-
|
|
26280
|
-
|
|
26281
|
-
|
|
26282
|
-
|
|
26283
|
-
|
|
26284
|
-
|
|
26285
|
-
|
|
26286
|
-
|
|
26287
|
-
|
|
26288
|
-
|
|
26289
|
-
|
|
26290
|
-
|
|
26291
|
-
|
|
26292
|
-
}
|
|
26281
|
+
return response.json();
|
|
26282
|
+
}.bind(this)).then(function(responseBody) {
|
|
26283
|
+
var responseFlags = responseBody['flags'];
|
|
26284
|
+
if (!responseFlags) {
|
|
26285
|
+
throw new Error('No flags in API response');
|
|
26286
|
+
}
|
|
26287
|
+
var flags = new Map();
|
|
26288
|
+
var pendingFirstTimeEvents = {};
|
|
26289
|
+
|
|
26290
|
+
// Process flags from response
|
|
26291
|
+
_.each(responseFlags, function(data, key) {
|
|
26292
|
+
// Check if this flag has any activated first-time events this session
|
|
26293
|
+
var hasActivatedEvent = false;
|
|
26294
|
+
var prefix = key + ':';
|
|
26295
|
+
_.each(this.activatedFirstTimeEvents, function(activated, eventKey) {
|
|
26296
|
+
if (eventKey.startsWith(prefix)) {
|
|
26297
|
+
hasActivatedEvent = true;
|
|
26298
|
+
}
|
|
26299
|
+
});
|
|
26293
26300
|
|
|
26294
|
-
|
|
26295
|
-
|
|
26296
|
-
|
|
26297
|
-
|
|
26298
|
-
|
|
26299
|
-
}
|
|
26300
|
-
} else {
|
|
26301
|
-
// Use server's current variant
|
|
26302
|
-
flags.set(key, {
|
|
26303
|
-
'key': data['variant_key'],
|
|
26304
|
-
'value': data['variant_value'],
|
|
26305
|
-
'experiment_id': data['experiment_id'],
|
|
26306
|
-
'is_experiment_active': data['is_experiment_active'],
|
|
26307
|
-
'is_qa_tester': data['is_qa_tester']
|
|
26308
|
-
});
|
|
26301
|
+
if (hasActivatedEvent) {
|
|
26302
|
+
// Preserve the activated variant, don't overwrite with server's current variant
|
|
26303
|
+
var currentFlag = this.flags && this.flags.get(key);
|
|
26304
|
+
if (currentFlag) {
|
|
26305
|
+
flags.set(key, currentFlag);
|
|
26309
26306
|
}
|
|
26310
|
-
}
|
|
26307
|
+
} else {
|
|
26308
|
+
// Use server's current variant
|
|
26309
|
+
flags.set(key, {
|
|
26310
|
+
'key': data['variant_key'],
|
|
26311
|
+
'value': data['variant_value'],
|
|
26312
|
+
'experiment_id': data['experiment_id'],
|
|
26313
|
+
'is_experiment_active': data['is_experiment_active'],
|
|
26314
|
+
'is_qa_tester': data['is_qa_tester']
|
|
26315
|
+
});
|
|
26316
|
+
}
|
|
26317
|
+
}, this);
|
|
26311
26318
|
|
|
26312
|
-
|
|
26313
|
-
|
|
26314
|
-
|
|
26315
|
-
|
|
26316
|
-
|
|
26317
|
-
|
|
26319
|
+
// Process top-level pending_first_time_events array
|
|
26320
|
+
var topLevelDefinitions = responseBody['pending_first_time_events'];
|
|
26321
|
+
if (topLevelDefinitions && topLevelDefinitions.length > 0) {
|
|
26322
|
+
_.each(topLevelDefinitions, function(def) {
|
|
26323
|
+
var flagKey = def['flag_key'];
|
|
26324
|
+
var eventKey = getPendingEventKey(flagKey, def['first_time_event_hash']);
|
|
26318
26325
|
|
|
26319
|
-
|
|
26320
|
-
|
|
26321
|
-
|
|
26322
|
-
|
|
26326
|
+
// Skip if this specific event has already been activated this session
|
|
26327
|
+
if (this.activatedFirstTimeEvents[eventKey]) {
|
|
26328
|
+
return;
|
|
26329
|
+
}
|
|
26323
26330
|
|
|
26324
|
-
|
|
26325
|
-
|
|
26326
|
-
|
|
26327
|
-
|
|
26328
|
-
|
|
26329
|
-
|
|
26330
|
-
|
|
26331
|
-
|
|
26332
|
-
|
|
26333
|
-
|
|
26334
|
-
|
|
26335
|
-
|
|
26331
|
+
// Store pending event definition using composite key
|
|
26332
|
+
pendingFirstTimeEvents[eventKey] = {
|
|
26333
|
+
'flag_key': flagKey,
|
|
26334
|
+
'flag_id': def['flag_id'],
|
|
26335
|
+
'project_id': def['project_id'],
|
|
26336
|
+
'first_time_event_hash': def['first_time_event_hash'],
|
|
26337
|
+
'event_name': def['event_name'],
|
|
26338
|
+
'property_filters': def['property_filters'],
|
|
26339
|
+
'pending_variant': def['pending_variant']
|
|
26340
|
+
};
|
|
26341
|
+
}, this);
|
|
26342
|
+
}
|
|
26336
26343
|
|
|
26337
|
-
|
|
26338
|
-
|
|
26339
|
-
|
|
26340
|
-
|
|
26341
|
-
|
|
26342
|
-
|
|
26343
|
-
|
|
26344
|
-
|
|
26345
|
-
|
|
26346
|
-
|
|
26344
|
+
// Preserve any activated orphaned flags (flags that were activated but are no longer in response)
|
|
26345
|
+
if (this.activatedFirstTimeEvents) {
|
|
26346
|
+
_.each(this.activatedFirstTimeEvents, function(activated, eventKey) {
|
|
26347
|
+
var flagKey = getFlagKeyFromPendingEventKey(eventKey);
|
|
26348
|
+
if (activated && !flags.has(flagKey) && this.flags && this.flags.has(flagKey)) {
|
|
26349
|
+
// Keep the activated flag even though it's not in the new response
|
|
26350
|
+
flags.set(flagKey, this.flags.get(flagKey));
|
|
26351
|
+
}
|
|
26352
|
+
}, this);
|
|
26353
|
+
}
|
|
26347
26354
|
|
|
26348
|
-
|
|
26349
|
-
|
|
26350
|
-
|
|
26355
|
+
this.flags = flags;
|
|
26356
|
+
this.pendingFirstTimeEvents = pendingFirstTimeEvents;
|
|
26357
|
+
this._traceparent = traceparent;
|
|
26351
26358
|
|
|
26352
|
-
|
|
26353
|
-
}.bind(this)).catch(function(error) {
|
|
26354
|
-
this.markFetchComplete();
|
|
26355
|
-
logger$1.error(error);
|
|
26356
|
-
}.bind(this));
|
|
26359
|
+
this._loadTargetingIfNeeded();
|
|
26357
26360
|
}.bind(this)).catch(function(error) {
|
|
26358
|
-
this.
|
|
26361
|
+
if (this._fetchInProgressStartTime) {
|
|
26362
|
+
this.markFetchComplete();
|
|
26363
|
+
}
|
|
26359
26364
|
logger$1.error(error);
|
|
26365
|
+
throw error;
|
|
26360
26366
|
}.bind(this));
|
|
26361
26367
|
|
|
26362
26368
|
return this.fetchPromise;
|
|
26363
26369
|
};
|
|
26364
26370
|
|
|
26371
|
+
FeatureFlagManager.prototype.loadFlags = function() {
|
|
26372
|
+
if (!this.isSystemEnabled()) {
|
|
26373
|
+
return Promise.resolve();
|
|
26374
|
+
}
|
|
26375
|
+
if (!this.trackedFeatures) {
|
|
26376
|
+
logger$1.error('loadFlags called before init');
|
|
26377
|
+
return Promise.resolve();
|
|
26378
|
+
}
|
|
26379
|
+
if (this._fetchInProgressStartTime) {
|
|
26380
|
+
return this.fetchPromise;
|
|
26381
|
+
}
|
|
26382
|
+
return this.fetchFlags();
|
|
26383
|
+
};
|
|
26384
|
+
|
|
26365
26385
|
FeatureFlagManager.prototype.markFetchComplete = function() {
|
|
26366
26386
|
if (!this._fetchInProgressStartTime) {
|
|
26367
26387
|
logger$1.error('Fetch in progress started time not set, cannot mark fetch complete');
|
|
@@ -26641,6 +26661,13 @@ define((function () { 'use strict';
|
|
|
26641
26661
|
this.track('$experiment_started', trackingProperties);
|
|
26642
26662
|
};
|
|
26643
26663
|
|
|
26664
|
+
FeatureFlagManager.prototype.whenReady = function() {
|
|
26665
|
+
if (this.fetchPromise) {
|
|
26666
|
+
return this.fetchPromise;
|
|
26667
|
+
}
|
|
26668
|
+
return Promise.resolve();
|
|
26669
|
+
};
|
|
26670
|
+
|
|
26644
26671
|
FeatureFlagManager.prototype.minApisSupported = function() {
|
|
26645
26672
|
return !!this.fetch &&
|
|
26646
26673
|
typeof Promise !== 'undefined' &&
|
|
@@ -26657,7 +26684,9 @@ define((function () { 'use strict';
|
|
|
26657
26684
|
FeatureFlagManager.prototype['get_variant_value_sync'] = FeatureFlagManager.prototype.getVariantValueSync;
|
|
26658
26685
|
FeatureFlagManager.prototype['is_enabled'] = FeatureFlagManager.prototype.isEnabled;
|
|
26659
26686
|
FeatureFlagManager.prototype['is_enabled_sync'] = FeatureFlagManager.prototype.isEnabledSync;
|
|
26687
|
+
FeatureFlagManager.prototype['load_flags'] = FeatureFlagManager.prototype.loadFlags;
|
|
26660
26688
|
FeatureFlagManager.prototype['update_context'] = FeatureFlagManager.prototype.updateContext;
|
|
26689
|
+
FeatureFlagManager.prototype['when_ready'] = FeatureFlagManager.prototype.whenReady;
|
|
26661
26690
|
|
|
26662
26691
|
// Deprecated method
|
|
26663
26692
|
FeatureFlagManager.prototype['get_feature_data'] = FeatureFlagManager.prototype.getFeatureData;
|
|
@@ -30013,7 +30042,9 @@ define((function () { 'use strict';
|
|
|
30013
30042
|
|
|
30014
30043
|
// check feature flags again if distinct id has changed
|
|
30015
30044
|
if (new_distinct_id !== previous_distinct_id) {
|
|
30016
|
-
this.flags.fetchFlags()
|
|
30045
|
+
this.flags.fetchFlags().catch(function() {
|
|
30046
|
+
console$1.error('[flags] Error fetching flags during identify');
|
|
30047
|
+
});
|
|
30017
30048
|
}
|
|
30018
30049
|
};
|
|
30019
30050
|
|
package/dist/mixpanel.cjs.d.ts
CHANGED
package/dist/mixpanel.cjs.js
CHANGED
|
@@ -27,7 +27,7 @@ if (typeof(window) === 'undefined') {
|
|
|
27
27
|
|
|
28
28
|
var Config = {
|
|
29
29
|
DEBUG: false,
|
|
30
|
-
LIB_VERSION: '2.
|
|
30
|
+
LIB_VERSION: '2.78.0'
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
// Window global names for async modules
|
|
@@ -26193,7 +26193,9 @@ FeatureFlagManager.prototype.init = function() {
|
|
|
26193
26193
|
}
|
|
26194
26194
|
|
|
26195
26195
|
this.flags = null;
|
|
26196
|
-
this.fetchFlags()
|
|
26196
|
+
this.fetchFlags().catch(function() {
|
|
26197
|
+
logger$1.error('Error fetching flags during init');
|
|
26198
|
+
});
|
|
26197
26199
|
|
|
26198
26200
|
this.trackedFeatures = new Set();
|
|
26199
26201
|
this.pendingFirstTimeEvents = {};
|
|
@@ -26234,8 +26236,12 @@ FeatureFlagManager.prototype.updateContext = function(newContext, options) {
|
|
|
26234
26236
|
var oldContext = (options && options['replace']) ? {} : this.getConfig(CONFIG_CONTEXT);
|
|
26235
26237
|
ffConfig[CONFIG_CONTEXT] = _.extend({}, oldContext, newContext);
|
|
26236
26238
|
|
|
26237
|
-
|
|
26238
|
-
|
|
26239
|
+
var configUpdate = {};
|
|
26240
|
+
configUpdate[FLAGS_CONFIG_KEY] = ffConfig;
|
|
26241
|
+
this.setMpConfig(configUpdate);
|
|
26242
|
+
return this.fetchFlags().catch(function() {
|
|
26243
|
+
logger$1.error('Error fetching flags during updateContext');
|
|
26244
|
+
});
|
|
26239
26245
|
};
|
|
26240
26246
|
|
|
26241
26247
|
FeatureFlagManager.prototype.areFlagsReady = function() {
|
|
@@ -26272,96 +26278,110 @@ FeatureFlagManager.prototype.fetchFlags = function() {
|
|
|
26272
26278
|
}
|
|
26273
26279
|
}).then(function(response) {
|
|
26274
26280
|
this.markFetchComplete();
|
|
26275
|
-
return response.json()
|
|
26276
|
-
|
|
26277
|
-
|
|
26278
|
-
|
|
26279
|
-
|
|
26280
|
-
|
|
26281
|
-
|
|
26282
|
-
|
|
26283
|
-
|
|
26284
|
-
|
|
26285
|
-
|
|
26286
|
-
|
|
26287
|
-
|
|
26288
|
-
|
|
26289
|
-
|
|
26290
|
-
|
|
26291
|
-
|
|
26292
|
-
}
|
|
26281
|
+
return response.json();
|
|
26282
|
+
}.bind(this)).then(function(responseBody) {
|
|
26283
|
+
var responseFlags = responseBody['flags'];
|
|
26284
|
+
if (!responseFlags) {
|
|
26285
|
+
throw new Error('No flags in API response');
|
|
26286
|
+
}
|
|
26287
|
+
var flags = new Map();
|
|
26288
|
+
var pendingFirstTimeEvents = {};
|
|
26289
|
+
|
|
26290
|
+
// Process flags from response
|
|
26291
|
+
_.each(responseFlags, function(data, key) {
|
|
26292
|
+
// Check if this flag has any activated first-time events this session
|
|
26293
|
+
var hasActivatedEvent = false;
|
|
26294
|
+
var prefix = key + ':';
|
|
26295
|
+
_.each(this.activatedFirstTimeEvents, function(activated, eventKey) {
|
|
26296
|
+
if (eventKey.startsWith(prefix)) {
|
|
26297
|
+
hasActivatedEvent = true;
|
|
26298
|
+
}
|
|
26299
|
+
});
|
|
26293
26300
|
|
|
26294
|
-
|
|
26295
|
-
|
|
26296
|
-
|
|
26297
|
-
|
|
26298
|
-
|
|
26299
|
-
}
|
|
26300
|
-
} else {
|
|
26301
|
-
// Use server's current variant
|
|
26302
|
-
flags.set(key, {
|
|
26303
|
-
'key': data['variant_key'],
|
|
26304
|
-
'value': data['variant_value'],
|
|
26305
|
-
'experiment_id': data['experiment_id'],
|
|
26306
|
-
'is_experiment_active': data['is_experiment_active'],
|
|
26307
|
-
'is_qa_tester': data['is_qa_tester']
|
|
26308
|
-
});
|
|
26301
|
+
if (hasActivatedEvent) {
|
|
26302
|
+
// Preserve the activated variant, don't overwrite with server's current variant
|
|
26303
|
+
var currentFlag = this.flags && this.flags.get(key);
|
|
26304
|
+
if (currentFlag) {
|
|
26305
|
+
flags.set(key, currentFlag);
|
|
26309
26306
|
}
|
|
26310
|
-
}
|
|
26307
|
+
} else {
|
|
26308
|
+
// Use server's current variant
|
|
26309
|
+
flags.set(key, {
|
|
26310
|
+
'key': data['variant_key'],
|
|
26311
|
+
'value': data['variant_value'],
|
|
26312
|
+
'experiment_id': data['experiment_id'],
|
|
26313
|
+
'is_experiment_active': data['is_experiment_active'],
|
|
26314
|
+
'is_qa_tester': data['is_qa_tester']
|
|
26315
|
+
});
|
|
26316
|
+
}
|
|
26317
|
+
}, this);
|
|
26311
26318
|
|
|
26312
|
-
|
|
26313
|
-
|
|
26314
|
-
|
|
26315
|
-
|
|
26316
|
-
|
|
26317
|
-
|
|
26319
|
+
// Process top-level pending_first_time_events array
|
|
26320
|
+
var topLevelDefinitions = responseBody['pending_first_time_events'];
|
|
26321
|
+
if (topLevelDefinitions && topLevelDefinitions.length > 0) {
|
|
26322
|
+
_.each(topLevelDefinitions, function(def) {
|
|
26323
|
+
var flagKey = def['flag_key'];
|
|
26324
|
+
var eventKey = getPendingEventKey(flagKey, def['first_time_event_hash']);
|
|
26318
26325
|
|
|
26319
|
-
|
|
26320
|
-
|
|
26321
|
-
|
|
26322
|
-
|
|
26326
|
+
// Skip if this specific event has already been activated this session
|
|
26327
|
+
if (this.activatedFirstTimeEvents[eventKey]) {
|
|
26328
|
+
return;
|
|
26329
|
+
}
|
|
26323
26330
|
|
|
26324
|
-
|
|
26325
|
-
|
|
26326
|
-
|
|
26327
|
-
|
|
26328
|
-
|
|
26329
|
-
|
|
26330
|
-
|
|
26331
|
-
|
|
26332
|
-
|
|
26333
|
-
|
|
26334
|
-
|
|
26335
|
-
|
|
26331
|
+
// Store pending event definition using composite key
|
|
26332
|
+
pendingFirstTimeEvents[eventKey] = {
|
|
26333
|
+
'flag_key': flagKey,
|
|
26334
|
+
'flag_id': def['flag_id'],
|
|
26335
|
+
'project_id': def['project_id'],
|
|
26336
|
+
'first_time_event_hash': def['first_time_event_hash'],
|
|
26337
|
+
'event_name': def['event_name'],
|
|
26338
|
+
'property_filters': def['property_filters'],
|
|
26339
|
+
'pending_variant': def['pending_variant']
|
|
26340
|
+
};
|
|
26341
|
+
}, this);
|
|
26342
|
+
}
|
|
26336
26343
|
|
|
26337
|
-
|
|
26338
|
-
|
|
26339
|
-
|
|
26340
|
-
|
|
26341
|
-
|
|
26342
|
-
|
|
26343
|
-
|
|
26344
|
-
|
|
26345
|
-
|
|
26346
|
-
|
|
26344
|
+
// Preserve any activated orphaned flags (flags that were activated but are no longer in response)
|
|
26345
|
+
if (this.activatedFirstTimeEvents) {
|
|
26346
|
+
_.each(this.activatedFirstTimeEvents, function(activated, eventKey) {
|
|
26347
|
+
var flagKey = getFlagKeyFromPendingEventKey(eventKey);
|
|
26348
|
+
if (activated && !flags.has(flagKey) && this.flags && this.flags.has(flagKey)) {
|
|
26349
|
+
// Keep the activated flag even though it's not in the new response
|
|
26350
|
+
flags.set(flagKey, this.flags.get(flagKey));
|
|
26351
|
+
}
|
|
26352
|
+
}, this);
|
|
26353
|
+
}
|
|
26347
26354
|
|
|
26348
|
-
|
|
26349
|
-
|
|
26350
|
-
|
|
26355
|
+
this.flags = flags;
|
|
26356
|
+
this.pendingFirstTimeEvents = pendingFirstTimeEvents;
|
|
26357
|
+
this._traceparent = traceparent;
|
|
26351
26358
|
|
|
26352
|
-
|
|
26353
|
-
}.bind(this)).catch(function(error) {
|
|
26354
|
-
this.markFetchComplete();
|
|
26355
|
-
logger$1.error(error);
|
|
26356
|
-
}.bind(this));
|
|
26359
|
+
this._loadTargetingIfNeeded();
|
|
26357
26360
|
}.bind(this)).catch(function(error) {
|
|
26358
|
-
this.
|
|
26361
|
+
if (this._fetchInProgressStartTime) {
|
|
26362
|
+
this.markFetchComplete();
|
|
26363
|
+
}
|
|
26359
26364
|
logger$1.error(error);
|
|
26365
|
+
throw error;
|
|
26360
26366
|
}.bind(this));
|
|
26361
26367
|
|
|
26362
26368
|
return this.fetchPromise;
|
|
26363
26369
|
};
|
|
26364
26370
|
|
|
26371
|
+
FeatureFlagManager.prototype.loadFlags = function() {
|
|
26372
|
+
if (!this.isSystemEnabled()) {
|
|
26373
|
+
return Promise.resolve();
|
|
26374
|
+
}
|
|
26375
|
+
if (!this.trackedFeatures) {
|
|
26376
|
+
logger$1.error('loadFlags called before init');
|
|
26377
|
+
return Promise.resolve();
|
|
26378
|
+
}
|
|
26379
|
+
if (this._fetchInProgressStartTime) {
|
|
26380
|
+
return this.fetchPromise;
|
|
26381
|
+
}
|
|
26382
|
+
return this.fetchFlags();
|
|
26383
|
+
};
|
|
26384
|
+
|
|
26365
26385
|
FeatureFlagManager.prototype.markFetchComplete = function() {
|
|
26366
26386
|
if (!this._fetchInProgressStartTime) {
|
|
26367
26387
|
logger$1.error('Fetch in progress started time not set, cannot mark fetch complete');
|
|
@@ -26641,6 +26661,13 @@ FeatureFlagManager.prototype.trackFeatureCheck = function(featureName, feature)
|
|
|
26641
26661
|
this.track('$experiment_started', trackingProperties);
|
|
26642
26662
|
};
|
|
26643
26663
|
|
|
26664
|
+
FeatureFlagManager.prototype.whenReady = function() {
|
|
26665
|
+
if (this.fetchPromise) {
|
|
26666
|
+
return this.fetchPromise;
|
|
26667
|
+
}
|
|
26668
|
+
return Promise.resolve();
|
|
26669
|
+
};
|
|
26670
|
+
|
|
26644
26671
|
FeatureFlagManager.prototype.minApisSupported = function() {
|
|
26645
26672
|
return !!this.fetch &&
|
|
26646
26673
|
typeof Promise !== 'undefined' &&
|
|
@@ -26657,7 +26684,9 @@ FeatureFlagManager.prototype['get_variant_value'] = FeatureFlagManager.prototype
|
|
|
26657
26684
|
FeatureFlagManager.prototype['get_variant_value_sync'] = FeatureFlagManager.prototype.getVariantValueSync;
|
|
26658
26685
|
FeatureFlagManager.prototype['is_enabled'] = FeatureFlagManager.prototype.isEnabled;
|
|
26659
26686
|
FeatureFlagManager.prototype['is_enabled_sync'] = FeatureFlagManager.prototype.isEnabledSync;
|
|
26687
|
+
FeatureFlagManager.prototype['load_flags'] = FeatureFlagManager.prototype.loadFlags;
|
|
26660
26688
|
FeatureFlagManager.prototype['update_context'] = FeatureFlagManager.prototype.updateContext;
|
|
26689
|
+
FeatureFlagManager.prototype['when_ready'] = FeatureFlagManager.prototype.whenReady;
|
|
26661
26690
|
|
|
26662
26691
|
// Deprecated method
|
|
26663
26692
|
FeatureFlagManager.prototype['get_feature_data'] = FeatureFlagManager.prototype.getFeatureData;
|
|
@@ -30013,7 +30042,9 @@ MixpanelLib.prototype.identify = function(
|
|
|
30013
30042
|
|
|
30014
30043
|
// check feature flags again if distinct id has changed
|
|
30015
30044
|
if (new_distinct_id !== previous_distinct_id) {
|
|
30016
|
-
this.flags.fetchFlags()
|
|
30045
|
+
this.flags.fetchFlags().catch(function() {
|
|
30046
|
+
console$1.error('[flags] Error fetching flags during identify');
|
|
30047
|
+
});
|
|
30017
30048
|
}
|
|
30018
30049
|
};
|
|
30019
30050
|
|