posthog-js-lite 2.6.0 → 2.6.2

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
@@ -207,26 +207,6 @@ function retriable(fn, props) {
207
207
  });
208
208
  });
209
209
  }
210
- // https://stackoverflow.com/a/8809472
211
- function generateUUID(globalThis) {
212
- // Public Domain/MIT
213
- var d = new Date().getTime(); //Timestamp
214
- var d2 = (globalThis && globalThis.performance && globalThis.performance.now && globalThis.performance.now() * 1000) || 0; //Time in microseconds since page-load or 0 if unsupported
215
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
216
- var r = Math.random() * 16; //random number between 0 and 16
217
- if (d > 0) {
218
- //Use timestamp until depleted
219
- r = (d + r) % 16 | 0;
220
- d = Math.floor(d / 16);
221
- }
222
- else {
223
- //Use microseconds since page-load if supported
224
- r = (d2 + r) % 16 | 0;
225
- d2 = Math.floor(d2 / 16);
226
- }
227
- return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16);
228
- });
229
- }
230
210
  function currentTimestamp() {
231
211
  return new Date().getTime();
232
212
  }
@@ -701,6 +681,413 @@ var SimpleEventEmitter = /** @class */ (function () {
701
681
  return SimpleEventEmitter;
702
682
  }());
703
683
 
684
+ // vendor from: https://github.com/LiosK/uuidv7/blob/f30b7a7faff73afbce0b27a46c638310f96912ba/src/index.ts
685
+ // https://github.com/LiosK/uuidv7#license
686
+ /**
687
+ * uuidv7: An experimental implementation of the proposed UUID Version 7
688
+ *
689
+ * @license Apache-2.0
690
+ * @copyright 2021-2023 LiosK
691
+ * @packageDocumentation
692
+ */
693
+ var DIGITS = "0123456789abcdef";
694
+ /** Represents a UUID as a 16-byte byte array. */
695
+ var UUID = /** @class */ (function () {
696
+ /** @param bytes - The 16-byte byte array representation. */
697
+ function UUID(bytes) {
698
+ this.bytes = bytes;
699
+ }
700
+ /**
701
+ * Creates an object from the internal representation, a 16-byte byte array
702
+ * containing the binary UUID representation in the big-endian byte order.
703
+ *
704
+ * This method does NOT shallow-copy the argument, and thus the created object
705
+ * holds the reference to the underlying buffer.
706
+ *
707
+ * @throws TypeError if the length of the argument is not 16.
708
+ */
709
+ UUID.ofInner = function (bytes) {
710
+ if (bytes.length !== 16) {
711
+ throw new TypeError("not 128-bit length");
712
+ }
713
+ else {
714
+ return new UUID(bytes);
715
+ }
716
+ };
717
+ /**
718
+ * Builds a byte array from UUIDv7 field values.
719
+ *
720
+ * @param unixTsMs - A 48-bit `unix_ts_ms` field value.
721
+ * @param randA - A 12-bit `rand_a` field value.
722
+ * @param randBHi - The higher 30 bits of 62-bit `rand_b` field value.
723
+ * @param randBLo - The lower 32 bits of 62-bit `rand_b` field value.
724
+ * @throws RangeError if any field value is out of the specified range.
725
+ */
726
+ UUID.fromFieldsV7 = function (unixTsMs, randA, randBHi, randBLo) {
727
+ if (!Number.isInteger(unixTsMs) ||
728
+ !Number.isInteger(randA) ||
729
+ !Number.isInteger(randBHi) ||
730
+ !Number.isInteger(randBLo) ||
731
+ unixTsMs < 0 ||
732
+ randA < 0 ||
733
+ randBHi < 0 ||
734
+ randBLo < 0 ||
735
+ unixTsMs > 281474976710655 ||
736
+ randA > 0xfff ||
737
+ randBHi > 1073741823 ||
738
+ randBLo > 4294967295) {
739
+ throw new RangeError("invalid field value");
740
+ }
741
+ var bytes = new Uint8Array(16);
742
+ bytes[0] = unixTsMs / Math.pow(2, 40);
743
+ bytes[1] = unixTsMs / Math.pow(2, 32);
744
+ bytes[2] = unixTsMs / Math.pow(2, 24);
745
+ bytes[3] = unixTsMs / Math.pow(2, 16);
746
+ bytes[4] = unixTsMs / Math.pow(2, 8);
747
+ bytes[5] = unixTsMs;
748
+ bytes[6] = 0x70 | (randA >>> 8);
749
+ bytes[7] = randA;
750
+ bytes[8] = 0x80 | (randBHi >>> 24);
751
+ bytes[9] = randBHi >>> 16;
752
+ bytes[10] = randBHi >>> 8;
753
+ bytes[11] = randBHi;
754
+ bytes[12] = randBLo >>> 24;
755
+ bytes[13] = randBLo >>> 16;
756
+ bytes[14] = randBLo >>> 8;
757
+ bytes[15] = randBLo;
758
+ return new UUID(bytes);
759
+ };
760
+ /**
761
+ * Builds a byte array from a string representation.
762
+ *
763
+ * This method accepts the following formats:
764
+ *
765
+ * - 32-digit hexadecimal format without hyphens: `0189dcd553117d408db09496a2eef37b`
766
+ * - 8-4-4-4-12 hyphenated format: `0189dcd5-5311-7d40-8db0-9496a2eef37b`
767
+ * - Hyphenated format with surrounding braces: `{0189dcd5-5311-7d40-8db0-9496a2eef37b}`
768
+ * - RFC 4122 URN format: `urn:uuid:0189dcd5-5311-7d40-8db0-9496a2eef37b`
769
+ *
770
+ * Leading and trailing whitespaces represents an error.
771
+ *
772
+ * @throws SyntaxError if the argument could not parse as a valid UUID string.
773
+ */
774
+ UUID.parse = function (uuid) {
775
+ var _a, _b, _c, _d;
776
+ var hex = undefined;
777
+ switch (uuid.length) {
778
+ case 32:
779
+ hex = (_a = /^[0-9a-f]{32}$/i.exec(uuid)) === null || _a === void 0 ? void 0 : _a[0];
780
+ break;
781
+ case 36:
782
+ hex =
783
+ (_b = /^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i
784
+ .exec(uuid)) === null || _b === void 0 ? void 0 : _b.slice(1, 6).join("");
785
+ break;
786
+ case 38:
787
+ hex =
788
+ (_c = /^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i
789
+ .exec(uuid)) === null || _c === void 0 ? void 0 : _c.slice(1, 6).join("");
790
+ break;
791
+ case 45:
792
+ hex =
793
+ (_d = /^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i
794
+ .exec(uuid)) === null || _d === void 0 ? void 0 : _d.slice(1, 6).join("");
795
+ break;
796
+ }
797
+ if (hex) {
798
+ var inner = new Uint8Array(16);
799
+ for (var i = 0; i < 16; i += 4) {
800
+ var n = parseInt(hex.substring(2 * i, 2 * i + 8), 16);
801
+ inner[i + 0] = n >>> 24;
802
+ inner[i + 1] = n >>> 16;
803
+ inner[i + 2] = n >>> 8;
804
+ inner[i + 3] = n;
805
+ }
806
+ return new UUID(inner);
807
+ }
808
+ else {
809
+ throw new SyntaxError("could not parse UUID string");
810
+ }
811
+ };
812
+ /**
813
+ * @returns The 8-4-4-4-12 canonical hexadecimal string representation
814
+ * (`0189dcd5-5311-7d40-8db0-9496a2eef37b`).
815
+ */
816
+ UUID.prototype.toString = function () {
817
+ var text = "";
818
+ for (var i = 0; i < this.bytes.length; i++) {
819
+ text += DIGITS.charAt(this.bytes[i] >>> 4);
820
+ text += DIGITS.charAt(this.bytes[i] & 0xf);
821
+ if (i === 3 || i === 5 || i === 7 || i === 9) {
822
+ text += "-";
823
+ }
824
+ }
825
+ return text;
826
+ };
827
+ /**
828
+ * @returns The 32-digit hexadecimal representation without hyphens
829
+ * (`0189dcd553117d408db09496a2eef37b`).
830
+ */
831
+ UUID.prototype.toHex = function () {
832
+ var text = "";
833
+ for (var i = 0; i < this.bytes.length; i++) {
834
+ text += DIGITS.charAt(this.bytes[i] >>> 4);
835
+ text += DIGITS.charAt(this.bytes[i] & 0xf);
836
+ }
837
+ return text;
838
+ };
839
+ /** @returns The 8-4-4-4-12 canonical hexadecimal string representation. */
840
+ UUID.prototype.toJSON = function () {
841
+ return this.toString();
842
+ };
843
+ /**
844
+ * Reports the variant field value of the UUID or, if appropriate, "NIL" or
845
+ * "MAX".
846
+ *
847
+ * For convenience, this method reports "NIL" or "MAX" if `this` represents
848
+ * the Nil or Max UUID, although the Nil and Max UUIDs are technically
849
+ * subsumed under the variants `0b0` and `0b111`, respectively.
850
+ */
851
+ UUID.prototype.getVariant = function () {
852
+ var n = this.bytes[8] >>> 4;
853
+ if (n < 0) {
854
+ throw new Error("unreachable");
855
+ }
856
+ else if (n <= 7) {
857
+ return this.bytes.every(function (e) { return e === 0; }) ? "NIL" : "VAR_0";
858
+ }
859
+ else if (n <= 11) {
860
+ return "VAR_10";
861
+ }
862
+ else if (n <= 13) {
863
+ return "VAR_110";
864
+ }
865
+ else if (n <= 15) {
866
+ return this.bytes.every(function (e) { return e === 0xff; }) ? "MAX" : "VAR_RESERVED";
867
+ }
868
+ else {
869
+ throw new Error("unreachable");
870
+ }
871
+ };
872
+ /**
873
+ * Returns the version field value of the UUID or `undefined` if the UUID does
874
+ * not have the variant field value of `0b10`.
875
+ */
876
+ UUID.prototype.getVersion = function () {
877
+ return this.getVariant() === "VAR_10" ? this.bytes[6] >>> 4 : undefined;
878
+ };
879
+ /** Creates an object from `this`. */
880
+ UUID.prototype.clone = function () {
881
+ return new UUID(this.bytes.slice(0));
882
+ };
883
+ /** Returns true if `this` is equivalent to `other`. */
884
+ UUID.prototype.equals = function (other) {
885
+ return this.compareTo(other) === 0;
886
+ };
887
+ /**
888
+ * Returns a negative integer, zero, or positive integer if `this` is less
889
+ * than, equal to, or greater than `other`, respectively.
890
+ */
891
+ UUID.prototype.compareTo = function (other) {
892
+ for (var i = 0; i < 16; i++) {
893
+ var diff = this.bytes[i] - other.bytes[i];
894
+ if (diff !== 0) {
895
+ return Math.sign(diff);
896
+ }
897
+ }
898
+ return 0;
899
+ };
900
+ return UUID;
901
+ }());
902
+ /**
903
+ * Encapsulates the monotonic counter state.
904
+ *
905
+ * This class provides APIs to utilize a separate counter state from that of the
906
+ * global generator used by {@link uuidv7} and {@link uuidv7obj}. In addition to
907
+ * the default {@link generate} method, this class has {@link generateOrAbort}
908
+ * that is useful to absolutely guarantee the monotonically increasing order of
909
+ * generated UUIDs. See their respective documentation for details.
910
+ */
911
+ var V7Generator = /** @class */ (function () {
912
+ /**
913
+ * Creates a generator object with the default random number generator, or
914
+ * with the specified one if passed as an argument. The specified random
915
+ * number generator should be cryptographically strong and securely seeded.
916
+ */
917
+ function V7Generator(randomNumberGenerator) {
918
+ this.timestamp = 0;
919
+ this.counter = 0;
920
+ this.random = randomNumberGenerator !== null && randomNumberGenerator !== void 0 ? randomNumberGenerator : getDefaultRandom();
921
+ }
922
+ /**
923
+ * Generates a new UUIDv7 object from the current timestamp, or resets the
924
+ * generator upon significant timestamp rollback.
925
+ *
926
+ * This method returns a monotonically increasing UUID by reusing the previous
927
+ * timestamp even if the up-to-date timestamp is smaller than the immediately
928
+ * preceding UUID's. However, when such a clock rollback is considered
929
+ * significant (i.e., by more than ten seconds), this method resets the
930
+ * generator and returns a new UUID based on the given timestamp, breaking the
931
+ * increasing order of UUIDs.
932
+ *
933
+ * See {@link generateOrAbort} for the other mode of generation and
934
+ * {@link generateOrResetCore} for the low-level primitive.
935
+ */
936
+ V7Generator.prototype.generate = function () {
937
+ return this.generateOrResetCore(Date.now(), 10000);
938
+ };
939
+ /**
940
+ * Generates a new UUIDv7 object from the current timestamp, or returns
941
+ * `undefined` upon significant timestamp rollback.
942
+ *
943
+ * This method returns a monotonically increasing UUID by reusing the previous
944
+ * timestamp even if the up-to-date timestamp is smaller than the immediately
945
+ * preceding UUID's. However, when such a clock rollback is considered
946
+ * significant (i.e., by more than ten seconds), this method aborts and
947
+ * returns `undefined` immediately.
948
+ *
949
+ * See {@link generate} for the other mode of generation and
950
+ * {@link generateOrAbortCore} for the low-level primitive.
951
+ */
952
+ V7Generator.prototype.generateOrAbort = function () {
953
+ return this.generateOrAbortCore(Date.now(), 10000);
954
+ };
955
+ /**
956
+ * Generates a new UUIDv7 object from the `unixTsMs` passed, or resets the
957
+ * generator upon significant timestamp rollback.
958
+ *
959
+ * This method is equivalent to {@link generate} except that it takes a custom
960
+ * timestamp and clock rollback allowance.
961
+ *
962
+ * @param rollbackAllowance - The amount of `unixTsMs` rollback that is
963
+ * considered significant. A suggested value is `10_000` (milliseconds).
964
+ * @throws RangeError if `unixTsMs` is not a 48-bit positive integer.
965
+ */
966
+ V7Generator.prototype.generateOrResetCore = function (unixTsMs, rollbackAllowance) {
967
+ var value = this.generateOrAbortCore(unixTsMs, rollbackAllowance);
968
+ if (value === undefined) {
969
+ // reset state and resume
970
+ this.timestamp = 0;
971
+ value = this.generateOrAbortCore(unixTsMs, rollbackAllowance);
972
+ }
973
+ return value;
974
+ };
975
+ /**
976
+ * Generates a new UUIDv7 object from the `unixTsMs` passed, or returns
977
+ * `undefined` upon significant timestamp rollback.
978
+ *
979
+ * This method is equivalent to {@link generateOrAbort} except that it takes a
980
+ * custom timestamp and clock rollback allowance.
981
+ *
982
+ * @param rollbackAllowance - The amount of `unixTsMs` rollback that is
983
+ * considered significant. A suggested value is `10_000` (milliseconds).
984
+ * @throws RangeError if `unixTsMs` is not a 48-bit positive integer.
985
+ */
986
+ V7Generator.prototype.generateOrAbortCore = function (unixTsMs, rollbackAllowance) {
987
+ var MAX_COUNTER = 4398046511103;
988
+ if (!Number.isInteger(unixTsMs) ||
989
+ unixTsMs < 1 ||
990
+ unixTsMs > 281474976710655) {
991
+ throw new RangeError("`unixTsMs` must be a 48-bit positive integer");
992
+ }
993
+ else if (rollbackAllowance < 0 || rollbackAllowance > 281474976710655) {
994
+ throw new RangeError("`rollbackAllowance` out of reasonable range");
995
+ }
996
+ if (unixTsMs > this.timestamp) {
997
+ this.timestamp = unixTsMs;
998
+ this.resetCounter();
999
+ }
1000
+ else if (unixTsMs + rollbackAllowance >= this.timestamp) {
1001
+ // go on with previous timestamp if new one is not much smaller
1002
+ this.counter++;
1003
+ if (this.counter > MAX_COUNTER) {
1004
+ // increment timestamp at counter overflow
1005
+ this.timestamp++;
1006
+ this.resetCounter();
1007
+ }
1008
+ }
1009
+ else {
1010
+ // abort if clock went backwards to unbearable extent
1011
+ return undefined;
1012
+ }
1013
+ return UUID.fromFieldsV7(this.timestamp, Math.trunc(this.counter / Math.pow(2, 30)), this.counter & (Math.pow(2, 30) - 1), this.random.nextUint32());
1014
+ };
1015
+ /** Initializes the counter at a 42-bit random integer. */
1016
+ V7Generator.prototype.resetCounter = function () {
1017
+ this.counter =
1018
+ this.random.nextUint32() * 0x400 + (this.random.nextUint32() & 0x3ff);
1019
+ };
1020
+ /**
1021
+ * Generates a new UUIDv4 object utilizing the random number generator inside.
1022
+ *
1023
+ * @internal
1024
+ */
1025
+ V7Generator.prototype.generateV4 = function () {
1026
+ var bytes = new Uint8Array(Uint32Array.of(this.random.nextUint32(), this.random.nextUint32(), this.random.nextUint32(), this.random.nextUint32()).buffer);
1027
+ bytes[6] = 0x40 | (bytes[6] >>> 4);
1028
+ bytes[8] = 0x80 | (bytes[8] >>> 2);
1029
+ return UUID.ofInner(bytes);
1030
+ };
1031
+ return V7Generator;
1032
+ }());
1033
+ /** A global flag to force use of cryptographically strong RNG. */
1034
+ // declare const UUIDV7_DENY_WEAK_RNG: boolean;
1035
+ /** Returns the default random number generator available in the environment. */
1036
+ var getDefaultRandom = function () {
1037
+ // fix: crypto isn't available in react-native, always use Math.random
1038
+ // // detect Web Crypto API
1039
+ // if (
1040
+ // typeof crypto !== "undefined" &&
1041
+ // typeof crypto.getRandomValues !== "undefined"
1042
+ // ) {
1043
+ // return new BufferedCryptoRandom();
1044
+ // } else {
1045
+ // // fall back on Math.random() unless the flag is set to true
1046
+ // if (typeof UUIDV7_DENY_WEAK_RNG !== "undefined" && UUIDV7_DENY_WEAK_RNG) {
1047
+ // throw new Error("no cryptographically strong RNG available");
1048
+ // }
1049
+ // return {
1050
+ // nextUint32: (): number =>
1051
+ // Math.trunc(Math.random() * 0x1_0000) * 0x1_0000 +
1052
+ // Math.trunc(Math.random() * 0x1_0000),
1053
+ // };
1054
+ // }
1055
+ return {
1056
+ nextUint32: function () {
1057
+ return Math.trunc(Math.random() * 65536) * 65536 +
1058
+ Math.trunc(Math.random() * 65536);
1059
+ },
1060
+ };
1061
+ };
1062
+ // /**
1063
+ // * Wraps `crypto.getRandomValues()` to enable buffering; this uses a small
1064
+ // * buffer by default to avoid both unbearable throughput decline in some
1065
+ // * environments and the waste of time and space for unused values.
1066
+ // */
1067
+ // class BufferedCryptoRandom {
1068
+ // private readonly buffer = new Uint32Array(8);
1069
+ // private cursor = 0xffff;
1070
+ // nextUint32(): number {
1071
+ // if (this.cursor >= this.buffer.length) {
1072
+ // crypto.getRandomValues(this.buffer);
1073
+ // this.cursor = 0;
1074
+ // }
1075
+ // return this.buffer[this.cursor++];
1076
+ // }
1077
+ // }
1078
+ var defaultGenerator;
1079
+ /**
1080
+ * Generates a UUIDv7 string.
1081
+ *
1082
+ * @returns The 8-4-4-4-12 canonical hexadecimal string representation
1083
+ * ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx").
1084
+ */
1085
+ var uuidv7 = function () { return uuidv7obj().toString(); };
1086
+ /** Generates a UUIDv7 object. */
1087
+ var uuidv7obj = function () {
1088
+ return (defaultGenerator || (defaultGenerator = new V7Generator())).generate();
1089
+ };
1090
+
704
1091
  var PostHogFetchHttpError = /** @class */ (function (_super) {
705
1092
  __extends(PostHogFetchHttpError, _super);
706
1093
  function PostHogFetchHttpError(response) {
@@ -792,7 +1179,7 @@ var PostHogCoreStateless = /** @class */ (function () {
792
1179
  };
793
1180
  PostHogCoreStateless.prototype.addPendingPromise = function (promise) {
794
1181
  var _this = this;
795
- var promiseUUID = generateUUID();
1182
+ var promiseUUID = uuidv7();
796
1183
  this.pendingPromises[promiseUUID] = promise;
797
1184
  promise.finally(function () {
798
1185
  delete _this.pendingPromises[promiseUUID];
@@ -996,7 +1383,7 @@ var PostHogCoreStateless = /** @class */ (function () {
996
1383
  this._events.emit(type, "Library is disabled. Not sending event. To re-enable, call posthog.optIn()");
997
1384
  return;
998
1385
  }
999
- 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) });
1386
+ 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() });
1000
1387
  var addGeoipDisableProperty = (_a = options === null || options === void 0 ? void 0 : options.disableGeoip) !== null && _a !== void 0 ? _a : this.disableGeoip;
1001
1388
  if (addGeoipDisableProperty) {
1002
1389
  if (!message.properties) {
@@ -1096,7 +1483,7 @@ var PostHogCoreStateless = /** @class */ (function () {
1096
1483
  return ctrl.signal;
1097
1484
  });
1098
1485
  return [4 /*yield*/, retriable(function () { return __awaiter(_this, void 0, void 0, function () {
1099
- var res, e_1;
1486
+ var res, e_1, isNoCors;
1100
1487
  return __generator(this, function (_a) {
1101
1488
  switch (_a.label) {
1102
1489
  case 0:
@@ -1113,7 +1500,8 @@ var PostHogCoreStateless = /** @class */ (function () {
1113
1500
  // fetch will only throw on network errors or on timeouts
1114
1501
  throw new PostHogFetchNetworkError(e_1);
1115
1502
  case 4:
1116
- if (res.status < 200 || res.status >= 400) {
1503
+ isNoCors = options.mode === 'no-cors';
1504
+ if (!isNoCors && (res.status < 200 || res.status >= 400)) {
1117
1505
  throw new PostHogFetchHttpError(res);
1118
1506
  }
1119
1507
  return [2 /*return*/, res];
@@ -1261,7 +1649,7 @@ var PostHogCore = /** @class */ (function (_super) {
1261
1649
  var sessionId = this.getPersistedProperty(PostHogPersistedProperty.SessionId);
1262
1650
  var sessionTimestamp = this.getPersistedProperty(PostHogPersistedProperty.SessionLastTimestamp) || 0;
1263
1651
  if (!sessionId || Date.now() - sessionTimestamp > this._sessionExpirationTimeSeconds * 1000) {
1264
- sessionId = generateUUID(globalThis);
1652
+ sessionId = uuidv7();
1265
1653
  this.setPersistedProperty(PostHogPersistedProperty.SessionId, sessionId);
1266
1654
  }
1267
1655
  this.setPersistedProperty(PostHogPersistedProperty.SessionLastTimestamp, Date.now());
@@ -1273,7 +1661,7 @@ var PostHogCore = /** @class */ (function (_super) {
1273
1661
  PostHogCore.prototype.getAnonymousId = function () {
1274
1662
  var anonId = this.getPersistedProperty(PostHogPersistedProperty.AnonymousId);
1275
1663
  if (!anonId) {
1276
- anonId = generateUUID(globalThis);
1664
+ anonId = uuidv7();
1277
1665
  this.setPersistedProperty(PostHogPersistedProperty.AnonymousId, anonId);
1278
1666
  }
1279
1667
  return anonId;
@@ -1596,7 +1984,7 @@ var PostHogCore = /** @class */ (function (_super) {
1596
1984
  return PostHogCore;
1597
1985
  }(PostHogCoreStateless));
1598
1986
 
1599
- var version = "2.6.0";
1987
+ var version = "2.6.2";
1600
1988
 
1601
1989
  function getContext(window) {
1602
1990
  var context = {};