@posthog/browser-common 0.7.2 → 0.7.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/dist/config.js CHANGED
@@ -27,7 +27,7 @@ var __webpack_require__ = {};
27
27
  })();
28
28
  var __webpack_exports__ = {};
29
29
  __webpack_require__.r(__webpack_exports__);
30
- const packageVersion = "0.7.2";
30
+ const packageVersion = "0.7.3";
31
31
  const Config = {
32
32
  DEBUG: false,
33
33
  LIB_VERSION: packageVersion,
package/dist/config.mjs CHANGED
@@ -1,4 +1,4 @@
1
- const packageVersion = "0.7.2";
1
+ const packageVersion = "0.7.3";
2
2
  const Config = {
3
3
  DEBUG: false,
4
4
  LIB_VERSION: packageVersion,
@@ -98,6 +98,12 @@ class UUID {
98
98
  return 0;
99
99
  }
100
100
  }
101
+ const MAX_UNIX_TS_MS = 0xffffffffffff;
102
+ const currentUnixTsMs = ()=>{
103
+ const now = Date.now();
104
+ if (!(0, core_namespaceObject.isNumber)(now) || !isFinite(now)) return 0;
105
+ return Math.min(Math.max(Math.floor(now), 0), MAX_UNIX_TS_MS);
106
+ };
101
107
  class V7Generator {
102
108
  generate() {
103
109
  const value = this.generateOrAbort();
@@ -112,7 +118,7 @@ class V7Generator {
112
118
  generateOrAbort() {
113
119
  const MAX_COUNTER = 0x3ffffffffff;
114
120
  const ROLLBACK_ALLOWANCE = 10000;
115
- const ts = Date.now();
121
+ const ts = currentUnixTsMs();
116
122
  if (ts > this._timestamp) {
117
123
  this._timestamp = ts;
118
124
  this._resetCounter();
@@ -64,6 +64,12 @@ class UUID {
64
64
  return 0;
65
65
  }
66
66
  }
67
+ const MAX_UNIX_TS_MS = 0xffffffffffff;
68
+ const currentUnixTsMs = ()=>{
69
+ const now = Date.now();
70
+ if (!isNumber(now) || !isFinite(now)) return 0;
71
+ return Math.min(Math.max(Math.floor(now), 0), MAX_UNIX_TS_MS);
72
+ };
67
73
  class V7Generator {
68
74
  generate() {
69
75
  const value = this.generateOrAbort();
@@ -78,7 +84,7 @@ class V7Generator {
78
84
  generateOrAbort() {
79
85
  const MAX_COUNTER = 0x3ffffffffff;
80
86
  const ROLLBACK_ALLOWANCE = 10000;
81
- const ts = Date.now();
87
+ const ts = currentUnixTsMs();
82
88
  if (ts > this._timestamp) {
83
89
  this._timestamp = ts;
84
90
  this._resetCounter();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/browser-common",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "Internal shared browser utilities and extension primitives for PostHog Browser SDKs",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -73,8 +73,8 @@
73
73
  }
74
74
  },
75
75
  "dependencies": {
76
- "@posthog/core": "^1.50.4",
77
- "@posthog/types": "^1.408.1"
76
+ "@posthog/core": "^1.50.6",
77
+ "@posthog/types": "^1.409.1"
78
78
  },
79
79
  "devDependencies": {
80
80
  "@rslib/core": "0.23.2",