posthog-node 3.1.0 → 3.1.1

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
@@ -1,4 +1,4 @@
1
- import { createHash } from 'crypto';
1
+ import { createHash } from 'rusha';
2
2
  import axios from 'axios';
3
3
 
4
4
  /******************************************************************************
@@ -155,7 +155,7 @@ function __spreadArray(to, from, pack) {
155
155
  return to.concat(ar || Array.prototype.slice.call(from));
156
156
  }
157
157
 
158
- var version = "3.1.0";
158
+ var version = "3.1.1";
159
159
 
160
160
  var PostHogPersistedProperty;
161
161
  (function (PostHogPersistedProperty) {
@@ -1145,7 +1145,11 @@ var PostHogCoreStateless = /** @class */ (function () {
1145
1145
  return [4 /*yield*/, this.flushAsync()];
1146
1146
  case 2:
1147
1147
  _a.sent();
1148
- return [4 /*yield*/, Promise.allSettled(Object.values(this.pendingPromises))];
1148
+ return [4 /*yield*/, Promise.all(Object.values(this.pendingPromises).map(function (x) {
1149
+ return x.catch(function () {
1150
+ // ignore errors as we are shutting down and can't deal with them anyways.
1151
+ });
1152
+ }))];
1149
1153
  case 3:
1150
1154
  _a.sent();
1151
1155
  return [3 /*break*/, 5];
@@ -1177,12 +1181,6 @@ var PostHogCoreStateless = /** @class */ (function () {
1177
1181
  _this.flagCallReported = {};
1178
1182
  _this.sendFeatureFlagEvent = (_b = options === null || options === void 0 ? void 0 : options.sendFeatureFlagEvent) !== null && _b !== void 0 ? _b : true;
1179
1183
  _this._sessionExpirationTimeSeconds = (_c = options === null || options === void 0 ? void 0 : options.sessionExpirationTimeSeconds) !== null && _c !== void 0 ? _c : 1800; // 30 minutes
1180
- // NOTE: It is important we don't initiate anything in the constructor as some async IO may still be underway on the parent
1181
- if ((options === null || options === void 0 ? void 0 : options.preloadFeatureFlags) !== false) {
1182
- safeSetTimeout(function () {
1183
- _this.reloadFeatureFlags();
1184
- }, 1);
1185
- }
1186
1184
  return _this;
1187
1185
  }
1188
1186
  PostHogCore.prototype.setupBootstrap = function (options) {
@@ -1297,9 +1295,7 @@ var PostHogCoreStateless = /** @class */ (function () {
1297
1295
  // We keep the AnonymousId to be used by decide calls and identify to link the previousId
1298
1296
  this.setPersistedProperty(PostHogPersistedProperty.AnonymousId, previousDistinctId);
1299
1297
  this.setPersistedProperty(PostHogPersistedProperty.DistinctId, distinctId);
1300
- if (this.getFeatureFlags()) {
1301
- this.reloadFeatureFlags();
1302
- }
1298
+ this.reloadFeatureFlags();
1303
1299
  }
1304
1300
  _super.prototype.identifyStateless.call(this, distinctId, allProperties, options);
1305
1301
  return this;
@@ -1339,7 +1335,7 @@ var PostHogCoreStateless = /** @class */ (function () {
1339
1335
  this.register({
1340
1336
  $groups: __assign(__assign({}, existingGroups), groups),
1341
1337
  });
1342
- if (Object.keys(groups).find(function (type) { return existingGroups[type] !== groups[type]; }) && this.getFeatureFlags()) {
1338
+ if (Object.keys(groups).find(function (type) { return existingGroups[type] !== groups[type]; })) {
1343
1339
  this.reloadFeatureFlags();
1344
1340
  }
1345
1341
  return this;
@@ -2280,9 +2276,10 @@ function () {
2280
2276
  function _hash(key, distinctId, salt) {
2281
2277
  if (salt === void 0) {
2282
2278
  salt = '';
2283
- }
2279
+ } // rusha is a fast sha1 implementation in pure javascript
2280
+
2284
2281
 
2285
- var sha1Hash = createHash('sha1');
2282
+ var sha1Hash = createHash();
2286
2283
  sha1Hash.update("".concat(key, ".").concat(distinctId).concat(salt));
2287
2284
  return parseInt(sha1Hash.digest('hex').slice(0, 15), 16) / LONG_SCALE;
2288
2285
  }