posthog-node 3.6.1 → 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.1";
157
+ var version = "3.6.3";
158
158
 
159
159
  var PostHogPersistedProperty;
160
160
  (function (PostHogPersistedProperty) {
@@ -223,26 +223,6 @@ function retriable(fn, props) {
223
223
  });
224
224
  });
225
225
  }
226
- // https://stackoverflow.com/a/8809472
227
- function generateUUID(globalThis) {
228
- // Public Domain/MIT
229
- var d = new Date().getTime(); //Timestamp
230
- var d2 = (globalThis && globalThis.performance && globalThis.performance.now && globalThis.performance.now() * 1000) || 0; //Time in microseconds since page-load or 0 if unsupported
231
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
232
- var r = Math.random() * 16; //random number between 0 and 16
233
- if (d > 0) {
234
- //Use timestamp until depleted
235
- r = (d + r) % 16 | 0;
236
- d = Math.floor(d / 16);
237
- }
238
- else {
239
- //Use microseconds since page-load if supported
240
- r = (d2 + r) % 16 | 0;
241
- d2 = Math.floor(d2 / 16);
242
- }
243
- return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16);
244
- });
245
- }
246
226
  function currentTimestamp() {
247
227
  return new Date().getTime();
248
228
  }
@@ -717,6 +697,413 @@ var SimpleEventEmitter = /** @class */ (function () {
717
697
  return SimpleEventEmitter;
718
698
  }());
719
699
 
700
+ // vendor from: https://github.com/LiosK/uuidv7/blob/f30b7a7faff73afbce0b27a46c638310f96912ba/src/index.ts
701
+ // https://github.com/LiosK/uuidv7#license
702
+ /**
703
+ * uuidv7: An experimental implementation of the proposed UUID Version 7
704
+ *
705
+ * @license Apache-2.0
706
+ * @copyright 2021-2023 LiosK
707
+ * @packageDocumentation
708
+ */
709
+ var DIGITS = "0123456789abcdef";
710
+ /** Represents a UUID as a 16-byte byte array. */
711
+ var UUID = /** @class */ (function () {
712
+ /** @param bytes - The 16-byte byte array representation. */
713
+ function UUID(bytes) {
714
+ this.bytes = bytes;
715
+ }
716
+ /**
717
+ * Creates an object from the internal representation, a 16-byte byte array
718
+ * containing the binary UUID representation in the big-endian byte order.
719
+ *
720
+ * This method does NOT shallow-copy the argument, and thus the created object
721
+ * holds the reference to the underlying buffer.
722
+ *
723
+ * @throws TypeError if the length of the argument is not 16.
724
+ */
725
+ UUID.ofInner = function (bytes) {
726
+ if (bytes.length !== 16) {
727
+ throw new TypeError("not 128-bit length");
728
+ }
729
+ else {
730
+ return new UUID(bytes);
731
+ }
732
+ };
733
+ /**
734
+ * Builds a byte array from UUIDv7 field values.
735
+ *
736
+ * @param unixTsMs - A 48-bit `unix_ts_ms` field value.
737
+ * @param randA - A 12-bit `rand_a` field value.
738
+ * @param randBHi - The higher 30 bits of 62-bit `rand_b` field value.
739
+ * @param randBLo - The lower 32 bits of 62-bit `rand_b` field value.
740
+ * @throws RangeError if any field value is out of the specified range.
741
+ */
742
+ UUID.fromFieldsV7 = function (unixTsMs, randA, randBHi, randBLo) {
743
+ if (!Number.isInteger(unixTsMs) ||
744
+ !Number.isInteger(randA) ||
745
+ !Number.isInteger(randBHi) ||
746
+ !Number.isInteger(randBLo) ||
747
+ unixTsMs < 0 ||
748
+ randA < 0 ||
749
+ randBHi < 0 ||
750
+ randBLo < 0 ||
751
+ unixTsMs > 281474976710655 ||
752
+ randA > 0xfff ||
753
+ randBHi > 1073741823 ||
754
+ randBLo > 4294967295) {
755
+ throw new RangeError("invalid field value");
756
+ }
757
+ var bytes = new Uint8Array(16);
758
+ bytes[0] = unixTsMs / Math.pow(2, 40);
759
+ bytes[1] = unixTsMs / Math.pow(2, 32);
760
+ bytes[2] = unixTsMs / Math.pow(2, 24);
761
+ bytes[3] = unixTsMs / Math.pow(2, 16);
762
+ bytes[4] = unixTsMs / Math.pow(2, 8);
763
+ bytes[5] = unixTsMs;
764
+ bytes[6] = 0x70 | (randA >>> 8);
765
+ bytes[7] = randA;
766
+ bytes[8] = 0x80 | (randBHi >>> 24);
767
+ bytes[9] = randBHi >>> 16;
768
+ bytes[10] = randBHi >>> 8;
769
+ bytes[11] = randBHi;
770
+ bytes[12] = randBLo >>> 24;
771
+ bytes[13] = randBLo >>> 16;
772
+ bytes[14] = randBLo >>> 8;
773
+ bytes[15] = randBLo;
774
+ return new UUID(bytes);
775
+ };
776
+ /**
777
+ * Builds a byte array from a string representation.
778
+ *
779
+ * This method accepts the following formats:
780
+ *
781
+ * - 32-digit hexadecimal format without hyphens: `0189dcd553117d408db09496a2eef37b`
782
+ * - 8-4-4-4-12 hyphenated format: `0189dcd5-5311-7d40-8db0-9496a2eef37b`
783
+ * - Hyphenated format with surrounding braces: `{0189dcd5-5311-7d40-8db0-9496a2eef37b}`
784
+ * - RFC 4122 URN format: `urn:uuid:0189dcd5-5311-7d40-8db0-9496a2eef37b`
785
+ *
786
+ * Leading and trailing whitespaces represents an error.
787
+ *
788
+ * @throws SyntaxError if the argument could not parse as a valid UUID string.
789
+ */
790
+ UUID.parse = function (uuid) {
791
+ var _a, _b, _c, _d;
792
+ var hex = undefined;
793
+ switch (uuid.length) {
794
+ case 32:
795
+ hex = (_a = /^[0-9a-f]{32}$/i.exec(uuid)) === null || _a === void 0 ? void 0 : _a[0];
796
+ break;
797
+ case 36:
798
+ hex =
799
+ (_b = /^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i
800
+ .exec(uuid)) === null || _b === void 0 ? void 0 : _b.slice(1, 6).join("");
801
+ break;
802
+ case 38:
803
+ hex =
804
+ (_c = /^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i
805
+ .exec(uuid)) === null || _c === void 0 ? void 0 : _c.slice(1, 6).join("");
806
+ break;
807
+ case 45:
808
+ hex =
809
+ (_d = /^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i
810
+ .exec(uuid)) === null || _d === void 0 ? void 0 : _d.slice(1, 6).join("");
811
+ break;
812
+ }
813
+ if (hex) {
814
+ var inner = new Uint8Array(16);
815
+ for (var i = 0; i < 16; i += 4) {
816
+ var n = parseInt(hex.substring(2 * i, 2 * i + 8), 16);
817
+ inner[i + 0] = n >>> 24;
818
+ inner[i + 1] = n >>> 16;
819
+ inner[i + 2] = n >>> 8;
820
+ inner[i + 3] = n;
821
+ }
822
+ return new UUID(inner);
823
+ }
824
+ else {
825
+ throw new SyntaxError("could not parse UUID string");
826
+ }
827
+ };
828
+ /**
829
+ * @returns The 8-4-4-4-12 canonical hexadecimal string representation
830
+ * (`0189dcd5-5311-7d40-8db0-9496a2eef37b`).
831
+ */
832
+ UUID.prototype.toString = function () {
833
+ var text = "";
834
+ for (var i = 0; i < this.bytes.length; i++) {
835
+ text += DIGITS.charAt(this.bytes[i] >>> 4);
836
+ text += DIGITS.charAt(this.bytes[i] & 0xf);
837
+ if (i === 3 || i === 5 || i === 7 || i === 9) {
838
+ text += "-";
839
+ }
840
+ }
841
+ return text;
842
+ };
843
+ /**
844
+ * @returns The 32-digit hexadecimal representation without hyphens
845
+ * (`0189dcd553117d408db09496a2eef37b`).
846
+ */
847
+ UUID.prototype.toHex = function () {
848
+ var text = "";
849
+ for (var i = 0; i < this.bytes.length; i++) {
850
+ text += DIGITS.charAt(this.bytes[i] >>> 4);
851
+ text += DIGITS.charAt(this.bytes[i] & 0xf);
852
+ }
853
+ return text;
854
+ };
855
+ /** @returns The 8-4-4-4-12 canonical hexadecimal string representation. */
856
+ UUID.prototype.toJSON = function () {
857
+ return this.toString();
858
+ };
859
+ /**
860
+ * Reports the variant field value of the UUID or, if appropriate, "NIL" or
861
+ * "MAX".
862
+ *
863
+ * For convenience, this method reports "NIL" or "MAX" if `this` represents
864
+ * the Nil or Max UUID, although the Nil and Max UUIDs are technically
865
+ * subsumed under the variants `0b0` and `0b111`, respectively.
866
+ */
867
+ UUID.prototype.getVariant = function () {
868
+ var n = this.bytes[8] >>> 4;
869
+ if (n < 0) {
870
+ throw new Error("unreachable");
871
+ }
872
+ else if (n <= 7) {
873
+ return this.bytes.every(function (e) { return e === 0; }) ? "NIL" : "VAR_0";
874
+ }
875
+ else if (n <= 11) {
876
+ return "VAR_10";
877
+ }
878
+ else if (n <= 13) {
879
+ return "VAR_110";
880
+ }
881
+ else if (n <= 15) {
882
+ return this.bytes.every(function (e) { return e === 0xff; }) ? "MAX" : "VAR_RESERVED";
883
+ }
884
+ else {
885
+ throw new Error("unreachable");
886
+ }
887
+ };
888
+ /**
889
+ * Returns the version field value of the UUID or `undefined` if the UUID does
890
+ * not have the variant field value of `0b10`.
891
+ */
892
+ UUID.prototype.getVersion = function () {
893
+ return this.getVariant() === "VAR_10" ? this.bytes[6] >>> 4 : undefined;
894
+ };
895
+ /** Creates an object from `this`. */
896
+ UUID.prototype.clone = function () {
897
+ return new UUID(this.bytes.slice(0));
898
+ };
899
+ /** Returns true if `this` is equivalent to `other`. */
900
+ UUID.prototype.equals = function (other) {
901
+ return this.compareTo(other) === 0;
902
+ };
903
+ /**
904
+ * Returns a negative integer, zero, or positive integer if `this` is less
905
+ * than, equal to, or greater than `other`, respectively.
906
+ */
907
+ UUID.prototype.compareTo = function (other) {
908
+ for (var i = 0; i < 16; i++) {
909
+ var diff = this.bytes[i] - other.bytes[i];
910
+ if (diff !== 0) {
911
+ return Math.sign(diff);
912
+ }
913
+ }
914
+ return 0;
915
+ };
916
+ return UUID;
917
+ }());
918
+ /**
919
+ * Encapsulates the monotonic counter state.
920
+ *
921
+ * This class provides APIs to utilize a separate counter state from that of the
922
+ * global generator used by {@link uuidv7} and {@link uuidv7obj}. In addition to
923
+ * the default {@link generate} method, this class has {@link generateOrAbort}
924
+ * that is useful to absolutely guarantee the monotonically increasing order of
925
+ * generated UUIDs. See their respective documentation for details.
926
+ */
927
+ var V7Generator = /** @class */ (function () {
928
+ /**
929
+ * Creates a generator object with the default random number generator, or
930
+ * with the specified one if passed as an argument. The specified random
931
+ * number generator should be cryptographically strong and securely seeded.
932
+ */
933
+ function V7Generator(randomNumberGenerator) {
934
+ this.timestamp = 0;
935
+ this.counter = 0;
936
+ this.random = randomNumberGenerator !== null && randomNumberGenerator !== void 0 ? randomNumberGenerator : getDefaultRandom();
937
+ }
938
+ /**
939
+ * Generates a new UUIDv7 object from the current timestamp, or resets the
940
+ * generator upon significant timestamp rollback.
941
+ *
942
+ * This method returns a monotonically increasing UUID by reusing the previous
943
+ * timestamp even if the up-to-date timestamp is smaller than the immediately
944
+ * preceding UUID's. However, when such a clock rollback is considered
945
+ * significant (i.e., by more than ten seconds), this method resets the
946
+ * generator and returns a new UUID based on the given timestamp, breaking the
947
+ * increasing order of UUIDs.
948
+ *
949
+ * See {@link generateOrAbort} for the other mode of generation and
950
+ * {@link generateOrResetCore} for the low-level primitive.
951
+ */
952
+ V7Generator.prototype.generate = function () {
953
+ return this.generateOrResetCore(Date.now(), 10000);
954
+ };
955
+ /**
956
+ * Generates a new UUIDv7 object from the current timestamp, or returns
957
+ * `undefined` upon significant timestamp rollback.
958
+ *
959
+ * This method returns a monotonically increasing UUID by reusing the previous
960
+ * timestamp even if the up-to-date timestamp is smaller than the immediately
961
+ * preceding UUID's. However, when such a clock rollback is considered
962
+ * significant (i.e., by more than ten seconds), this method aborts and
963
+ * returns `undefined` immediately.
964
+ *
965
+ * See {@link generate} for the other mode of generation and
966
+ * {@link generateOrAbortCore} for the low-level primitive.
967
+ */
968
+ V7Generator.prototype.generateOrAbort = function () {
969
+ return this.generateOrAbortCore(Date.now(), 10000);
970
+ };
971
+ /**
972
+ * Generates a new UUIDv7 object from the `unixTsMs` passed, or resets the
973
+ * generator upon significant timestamp rollback.
974
+ *
975
+ * This method is equivalent to {@link generate} except that it takes a custom
976
+ * timestamp and clock rollback allowance.
977
+ *
978
+ * @param rollbackAllowance - The amount of `unixTsMs` rollback that is
979
+ * considered significant. A suggested value is `10_000` (milliseconds).
980
+ * @throws RangeError if `unixTsMs` is not a 48-bit positive integer.
981
+ */
982
+ V7Generator.prototype.generateOrResetCore = function (unixTsMs, rollbackAllowance) {
983
+ var value = this.generateOrAbortCore(unixTsMs, rollbackAllowance);
984
+ if (value === undefined) {
985
+ // reset state and resume
986
+ this.timestamp = 0;
987
+ value = this.generateOrAbortCore(unixTsMs, rollbackAllowance);
988
+ }
989
+ return value;
990
+ };
991
+ /**
992
+ * Generates a new UUIDv7 object from the `unixTsMs` passed, or returns
993
+ * `undefined` upon significant timestamp rollback.
994
+ *
995
+ * This method is equivalent to {@link generateOrAbort} except that it takes a
996
+ * custom timestamp and clock rollback allowance.
997
+ *
998
+ * @param rollbackAllowance - The amount of `unixTsMs` rollback that is
999
+ * considered significant. A suggested value is `10_000` (milliseconds).
1000
+ * @throws RangeError if `unixTsMs` is not a 48-bit positive integer.
1001
+ */
1002
+ V7Generator.prototype.generateOrAbortCore = function (unixTsMs, rollbackAllowance) {
1003
+ var MAX_COUNTER = 4398046511103;
1004
+ if (!Number.isInteger(unixTsMs) ||
1005
+ unixTsMs < 1 ||
1006
+ unixTsMs > 281474976710655) {
1007
+ throw new RangeError("`unixTsMs` must be a 48-bit positive integer");
1008
+ }
1009
+ else if (rollbackAllowance < 0 || rollbackAllowance > 281474976710655) {
1010
+ throw new RangeError("`rollbackAllowance` out of reasonable range");
1011
+ }
1012
+ if (unixTsMs > this.timestamp) {
1013
+ this.timestamp = unixTsMs;
1014
+ this.resetCounter();
1015
+ }
1016
+ else if (unixTsMs + rollbackAllowance >= this.timestamp) {
1017
+ // go on with previous timestamp if new one is not much smaller
1018
+ this.counter++;
1019
+ if (this.counter > MAX_COUNTER) {
1020
+ // increment timestamp at counter overflow
1021
+ this.timestamp++;
1022
+ this.resetCounter();
1023
+ }
1024
+ }
1025
+ else {
1026
+ // abort if clock went backwards to unbearable extent
1027
+ return undefined;
1028
+ }
1029
+ return UUID.fromFieldsV7(this.timestamp, Math.trunc(this.counter / Math.pow(2, 30)), this.counter & (Math.pow(2, 30) - 1), this.random.nextUint32());
1030
+ };
1031
+ /** Initializes the counter at a 42-bit random integer. */
1032
+ V7Generator.prototype.resetCounter = function () {
1033
+ this.counter =
1034
+ this.random.nextUint32() * 0x400 + (this.random.nextUint32() & 0x3ff);
1035
+ };
1036
+ /**
1037
+ * Generates a new UUIDv4 object utilizing the random number generator inside.
1038
+ *
1039
+ * @internal
1040
+ */
1041
+ V7Generator.prototype.generateV4 = function () {
1042
+ var bytes = new Uint8Array(Uint32Array.of(this.random.nextUint32(), this.random.nextUint32(), this.random.nextUint32(), this.random.nextUint32()).buffer);
1043
+ bytes[6] = 0x40 | (bytes[6] >>> 4);
1044
+ bytes[8] = 0x80 | (bytes[8] >>> 2);
1045
+ return UUID.ofInner(bytes);
1046
+ };
1047
+ return V7Generator;
1048
+ }());
1049
+ /** A global flag to force use of cryptographically strong RNG. */
1050
+ // declare const UUIDV7_DENY_WEAK_RNG: boolean;
1051
+ /** Returns the default random number generator available in the environment. */
1052
+ var getDefaultRandom = function () {
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
+ },
1076
+ };
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
+ // }
1094
+ var defaultGenerator;
1095
+ /**
1096
+ * Generates a UUIDv7 string.
1097
+ *
1098
+ * @returns The 8-4-4-4-12 canonical hexadecimal string representation
1099
+ * ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx").
1100
+ */
1101
+ var uuidv7 = function () { return uuidv7obj().toString(); };
1102
+ /** Generates a UUIDv7 object. */
1103
+ var uuidv7obj = function () {
1104
+ return (defaultGenerator || (defaultGenerator = new V7Generator())).generate();
1105
+ };
1106
+
720
1107
  var PostHogFetchHttpError = /** @class */ (function (_super) {
721
1108
  __extends(PostHogFetchHttpError, _super);
722
1109
  function PostHogFetchHttpError(response) {
@@ -808,7 +1195,7 @@ var PostHogCoreStateless = /** @class */ (function () {
808
1195
  };
809
1196
  PostHogCoreStateless.prototype.addPendingPromise = function (promise) {
810
1197
  var _this = this;
811
- var promiseUUID = generateUUID();
1198
+ var promiseUUID = uuidv7();
812
1199
  this.pendingPromises[promiseUUID] = promise;
813
1200
  promise.finally(function () {
814
1201
  delete _this.pendingPromises[promiseUUID];
@@ -1012,7 +1399,7 @@ var PostHogCoreStateless = /** @class */ (function () {
1012
1399
  this._events.emit(type, "Library is disabled. Not sending event. To re-enable, call posthog.optIn()");
1013
1400
  return;
1014
1401
  }
1015
- var message = __assign(__assign({}, _message), { type: type, library: this.getLibraryId(), library_version: this.getLibraryVersion(), timestamp: (options === null || options === void 0 ? void 0 : options.timestamp) ? options === null || options === void 0 ? void 0 : options.timestamp : currentISOTime(), uuid: (options === null || options === void 0 ? void 0 : options.uuid) ? options.uuid : generateUUID(globalThis) });
1402
+ var message = __assign(__assign({}, _message), { type: type, library: this.getLibraryId(), library_version: this.getLibraryVersion(), timestamp: (options === null || options === void 0 ? void 0 : options.timestamp) ? options === null || options === void 0 ? void 0 : options.timestamp : currentISOTime(), uuid: (options === null || options === void 0 ? void 0 : options.uuid) ? options.uuid : uuidv7() });
1016
1403
  var addGeoipDisableProperty = (_a = options === null || options === void 0 ? void 0 : options.disableGeoip) !== null && _a !== void 0 ? _a : this.disableGeoip;
1017
1404
  if (addGeoipDisableProperty) {
1018
1405
  if (!message.properties) {
@@ -1112,7 +1499,7 @@ var PostHogCoreStateless = /** @class */ (function () {
1112
1499
  return ctrl.signal;
1113
1500
  });
1114
1501
  return [4 /*yield*/, retriable(function () { return __awaiter(_this, void 0, void 0, function () {
1115
- var res, e_1;
1502
+ var res, e_1, isNoCors;
1116
1503
  return __generator(this, function (_a) {
1117
1504
  switch (_a.label) {
1118
1505
  case 0:
@@ -1129,7 +1516,8 @@ var PostHogCoreStateless = /** @class */ (function () {
1129
1516
  // fetch will only throw on network errors or on timeouts
1130
1517
  throw new PostHogFetchNetworkError(e_1);
1131
1518
  case 4:
1132
- if (res.status < 200 || res.status >= 400) {
1519
+ isNoCors = options.mode === 'no-cors';
1520
+ if (!isNoCors && (res.status < 200 || res.status >= 400)) {
1133
1521
  throw new PostHogFetchHttpError(res);
1134
1522
  }
1135
1523
  return [2 /*return*/, res];
@@ -1277,7 +1665,7 @@ var PostHogCoreStateless = /** @class */ (function () {
1277
1665
  var sessionId = this.getPersistedProperty(PostHogPersistedProperty.SessionId);
1278
1666
  var sessionTimestamp = this.getPersistedProperty(PostHogPersistedProperty.SessionLastTimestamp) || 0;
1279
1667
  if (!sessionId || Date.now() - sessionTimestamp > this._sessionExpirationTimeSeconds * 1000) {
1280
- sessionId = generateUUID(globalThis);
1668
+ sessionId = uuidv7();
1281
1669
  this.setPersistedProperty(PostHogPersistedProperty.SessionId, sessionId);
1282
1670
  }
1283
1671
  this.setPersistedProperty(PostHogPersistedProperty.SessionLastTimestamp, Date.now());
@@ -1289,7 +1677,7 @@ var PostHogCoreStateless = /** @class */ (function () {
1289
1677
  PostHogCore.prototype.getAnonymousId = function () {
1290
1678
  var anonId = this.getPersistedProperty(PostHogPersistedProperty.AnonymousId);
1291
1679
  if (!anonId) {
1292
- anonId = generateUUID(globalThis);
1680
+ anonId = uuidv7();
1293
1681
  this.setPersistedProperty(PostHogPersistedProperty.AnonymousId, anonId);
1294
1682
  }
1295
1683
  return anonId;