posthog-js-lite 2.3.0 → 2.4.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/lib/index.esm.js CHANGED
@@ -1128,7 +1128,11 @@ var PostHogCoreStateless = /** @class */ (function () {
1128
1128
  return [4 /*yield*/, this.flushAsync()];
1129
1129
  case 2:
1130
1130
  _a.sent();
1131
- return [4 /*yield*/, Promise.allSettled(Object.values(this.pendingPromises))];
1131
+ return [4 /*yield*/, Promise.all(Object.values(this.pendingPromises).map(function (x) {
1132
+ return x.catch(function () {
1133
+ // ignore errors as we are shutting down and can't deal with them anyways.
1134
+ });
1135
+ }))];
1132
1136
  case 3:
1133
1137
  _a.sent();
1134
1138
  return [3 /*break*/, 5];
@@ -1160,12 +1164,6 @@ var PostHogCore = /** @class */ (function (_super) {
1160
1164
  _this.flagCallReported = {};
1161
1165
  _this.sendFeatureFlagEvent = (_b = options === null || options === void 0 ? void 0 : options.sendFeatureFlagEvent) !== null && _b !== void 0 ? _b : true;
1162
1166
  _this._sessionExpirationTimeSeconds = (_c = options === null || options === void 0 ? void 0 : options.sessionExpirationTimeSeconds) !== null && _c !== void 0 ? _c : 1800; // 30 minutes
1163
- // NOTE: It is important we don't initiate anything in the constructor as some async IO may still be underway on the parent
1164
- if ((options === null || options === void 0 ? void 0 : options.preloadFeatureFlags) !== false) {
1165
- safeSetTimeout(function () {
1166
- _this.reloadFeatureFlags();
1167
- }, 1);
1168
- }
1169
1167
  return _this;
1170
1168
  }
1171
1169
  PostHogCore.prototype.setupBootstrap = function (options) {
@@ -1280,9 +1278,7 @@ var PostHogCore = /** @class */ (function (_super) {
1280
1278
  // We keep the AnonymousId to be used by decide calls and identify to link the previousId
1281
1279
  this.setPersistedProperty(PostHogPersistedProperty.AnonymousId, previousDistinctId);
1282
1280
  this.setPersistedProperty(PostHogPersistedProperty.DistinctId, distinctId);
1283
- if (this.getFeatureFlags()) {
1284
- this.reloadFeatureFlags();
1285
- }
1281
+ this.reloadFeatureFlags();
1286
1282
  }
1287
1283
  _super.prototype.identifyStateless.call(this, distinctId, allProperties, options);
1288
1284
  return this;
@@ -1322,7 +1318,7 @@ var PostHogCore = /** @class */ (function (_super) {
1322
1318
  this.register({
1323
1319
  $groups: __assign(__assign({}, existingGroups), groups),
1324
1320
  });
1325
- if (Object.keys(groups).find(function (type) { return existingGroups[type] !== groups[type]; }) && this.getFeatureFlags()) {
1321
+ if (Object.keys(groups).find(function (type) { return existingGroups[type] !== groups[type]; })) {
1326
1322
  this.reloadFeatureFlags();
1327
1323
  }
1328
1324
  return this;
@@ -1555,7 +1551,7 @@ var PostHogCore = /** @class */ (function (_super) {
1555
1551
  return PostHogCore;
1556
1552
  }(PostHogCoreStateless));
1557
1553
 
1558
- var version = "2.3.0";
1554
+ var version = "2.4.0";
1559
1555
 
1560
1556
  function getContext(window) {
1561
1557
  var context = {};
@@ -1920,6 +1916,10 @@ function (_super) {
1920
1916
 
1921
1917
  _this.setupBootstrap(options);
1922
1918
 
1919
+ if ((options === null || options === void 0 ? void 0 : options.preloadFeatureFlags) !== false) {
1920
+ _this.reloadFeatureFlags();
1921
+ }
1922
+
1923
1923
  return _this;
1924
1924
  }
1925
1925