posthog-node 3.6.2 → 3.6.3

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
@@ -154,7 +154,7 @@ function __spreadArray(to, from, pack) {
154
154
  return to.concat(ar || Array.prototype.slice.call(from));
155
155
  }
156
156
 
157
- var version = "3.6.2";
157
+ var version = "3.6.3";
158
158
 
159
159
  var PostHogPersistedProperty;
160
160
  (function (PostHogPersistedProperty) {
@@ -697,6 +697,8 @@ var SimpleEventEmitter = /** @class */ (function () {
697
697
  return SimpleEventEmitter;
698
698
  }());
699
699
 
700
+ // vendor from: https://github.com/LiosK/uuidv7/blob/f30b7a7faff73afbce0b27a46c638310f96912ba/src/index.ts
701
+ // https://github.com/LiosK/uuidv7#license
700
702
  /**
701
703
  * uuidv7: An experimental implementation of the proposed UUID Version 7
702
704
  *
@@ -1044,43 +1046,51 @@ var V7Generator = /** @class */ (function () {
1044
1046
  };
1045
1047
  return V7Generator;
1046
1048
  }());
1049
+ /** A global flag to force use of cryptographically strong RNG. */
1050
+ // declare const UUIDV7_DENY_WEAK_RNG: boolean;
1047
1051
  /** Returns the default random number generator available in the environment. */
1048
1052
  var getDefaultRandom = function () {
1049
- // detect Web Crypto API
1050
- if (typeof crypto !== "undefined" &&
1051
- typeof crypto.getRandomValues !== "undefined") {
1052
- return new BufferedCryptoRandom();
1053
- }
1054
- else {
1055
- // fall back on Math.random() unless the flag is set to true
1056
- if (typeof UUIDV7_DENY_WEAK_RNG !== "undefined" && UUIDV7_DENY_WEAK_RNG) {
1057
- throw new Error("no cryptographically strong RNG available");
1058
- }
1059
- return {
1060
- nextUint32: function () { return Math.trunc(Math.random() * 65536) * 65536 +
1061
- Math.trunc(Math.random() * 65536); },
1062
- };
1063
- }
1064
- };
1065
- /**
1066
- * Wraps `crypto.getRandomValues()` to enable buffering; this uses a small
1067
- * buffer by default to avoid both unbearable throughput decline in some
1068
- * environments and the waste of time and space for unused values.
1069
- */
1070
- var BufferedCryptoRandom = /** @class */ (function () {
1071
- function BufferedCryptoRandom() {
1072
- this.buffer = new Uint32Array(8);
1073
- this.cursor = 0xffff;
1074
- }
1075
- BufferedCryptoRandom.prototype.nextUint32 = function () {
1076
- if (this.cursor >= this.buffer.length) {
1077
- crypto.getRandomValues(this.buffer);
1078
- this.cursor = 0;
1079
- }
1080
- return this.buffer[this.cursor++];
1053
+ // fix: crypto isn't available in react-native, always use Math.random
1054
+ // // detect Web Crypto API
1055
+ // if (
1056
+ // typeof crypto !== "undefined" &&
1057
+ // typeof crypto.getRandomValues !== "undefined"
1058
+ // ) {
1059
+ // return new BufferedCryptoRandom();
1060
+ // } else {
1061
+ // // fall back on Math.random() unless the flag is set to true
1062
+ // if (typeof UUIDV7_DENY_WEAK_RNG !== "undefined" && UUIDV7_DENY_WEAK_RNG) {
1063
+ // throw new Error("no cryptographically strong RNG available");
1064
+ // }
1065
+ // return {
1066
+ // nextUint32: (): number =>
1067
+ // Math.trunc(Math.random() * 0x1_0000) * 0x1_0000 +
1068
+ // Math.trunc(Math.random() * 0x1_0000),
1069
+ // };
1070
+ // }
1071
+ return {
1072
+ nextUint32: function () {
1073
+ return Math.trunc(Math.random() * 65536) * 65536 +
1074
+ Math.trunc(Math.random() * 65536);
1075
+ },
1081
1076
  };
1082
- return BufferedCryptoRandom;
1083
- }());
1077
+ };
1078
+ // /**
1079
+ // * Wraps `crypto.getRandomValues()` to enable buffering; this uses a small
1080
+ // * buffer by default to avoid both unbearable throughput decline in some
1081
+ // * environments and the waste of time and space for unused values.
1082
+ // */
1083
+ // class BufferedCryptoRandom {
1084
+ // private readonly buffer = new Uint32Array(8);
1085
+ // private cursor = 0xffff;
1086
+ // nextUint32(): number {
1087
+ // if (this.cursor >= this.buffer.length) {
1088
+ // crypto.getRandomValues(this.buffer);
1089
+ // this.cursor = 0;
1090
+ // }
1091
+ // return this.buffer[this.cursor++];
1092
+ // }
1093
+ // }
1084
1094
  var defaultGenerator;
1085
1095
  /**
1086
1096
  * Generates a UUIDv7 string.
@@ -1090,7 +1100,9 @@ var defaultGenerator;
1090
1100
  */
1091
1101
  var uuidv7 = function () { return uuidv7obj().toString(); };
1092
1102
  /** Generates a UUIDv7 object. */
1093
- var uuidv7obj = function () { return (defaultGenerator || (defaultGenerator = new V7Generator())).generate(); };
1103
+ var uuidv7obj = function () {
1104
+ return (defaultGenerator || (defaultGenerator = new V7Generator())).generate();
1105
+ };
1094
1106
 
1095
1107
  var PostHogFetchHttpError = /** @class */ (function (_super) {
1096
1108
  __extends(PostHogFetchHttpError, _super);
@@ -1487,7 +1499,7 @@ var PostHogCoreStateless = /** @class */ (function () {
1487
1499
  return ctrl.signal;
1488
1500
  });
1489
1501
  return [4 /*yield*/, retriable(function () { return __awaiter(_this, void 0, void 0, function () {
1490
- var res, e_1;
1502
+ var res, e_1, isNoCors;
1491
1503
  return __generator(this, function (_a) {
1492
1504
  switch (_a.label) {
1493
1505
  case 0:
@@ -1504,7 +1516,8 @@ var PostHogCoreStateless = /** @class */ (function () {
1504
1516
  // fetch will only throw on network errors or on timeouts
1505
1517
  throw new PostHogFetchNetworkError(e_1);
1506
1518
  case 4:
1507
- if (res.status < 200 || res.status >= 400) {
1519
+ isNoCors = options.mode === 'no-cors';
1520
+ if (!isNoCors && (res.status < 200 || res.status >= 400)) {
1508
1521
  throw new PostHogFetchHttpError(res);
1509
1522
  }
1510
1523
  return [2 /*return*/, res];