@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 +1 -1
- package/dist/config.mjs +1 -1
- package/dist/utils/uuidv7.js +7 -1
- package/dist/utils/uuidv7.mjs +7 -1
- package/package.json +3 -3
package/dist/config.js
CHANGED
package/dist/config.mjs
CHANGED
package/dist/utils/uuidv7.js
CHANGED
|
@@ -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 =
|
|
121
|
+
const ts = currentUnixTsMs();
|
|
116
122
|
if (ts > this._timestamp) {
|
|
117
123
|
this._timestamp = ts;
|
|
118
124
|
this._resetCounter();
|
package/dist/utils/uuidv7.mjs
CHANGED
|
@@ -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 =
|
|
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.
|
|
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.
|
|
77
|
-
"@posthog/types": "^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",
|