@posthog/browser-common 0.7.2 → 0.8.0
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/event-utils.js +3 -0
- package/dist/utils/event-utils.mjs +4 -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
|
@@ -261,6 +261,7 @@ function getEventProperties(maskPersonalDataProperties, customPersonalDataProper
|
|
|
261
261
|
...customPersonalDataProperties || []
|
|
262
262
|
] : [];
|
|
263
263
|
const [os_name, os_version] = (0, core_namespaceObject.detectOS)(external_globals_js_namespaceObject.userAgent);
|
|
264
|
+
const [webviewApp, webviewAppVersion] = (0, core_namespaceObject.detectWebviewApp)(external_globals_js_namespaceObject.userAgent);
|
|
264
265
|
const browserHints = getBrowserDetectionHints();
|
|
265
266
|
const browserOptions = {};
|
|
266
267
|
if (!(0, core_namespaceObject.isUndefined)(detectGoogleSearchApp)) browserOptions.detectGoogleSearchApp = detectGoogleSearchApp;
|
|
@@ -279,6 +280,8 @@ function getEventProperties(maskPersonalDataProperties, customPersonalDataProper
|
|
|
279
280
|
$os: os_name,
|
|
280
281
|
$os_version: os_version,
|
|
281
282
|
$browser: (0, core_namespaceObject.detectBrowser)(external_globals_js_namespaceObject.userAgent, navigator.vendor, browserHints, browserOptions),
|
|
283
|
+
$webview_app: webviewApp,
|
|
284
|
+
$webview_app_version: webviewAppVersion,
|
|
282
285
|
$device: (0, core_namespaceObject.detectDevice)(external_globals_js_namespaceObject.userAgent),
|
|
283
286
|
$device_type: (0, core_namespaceObject.detectDeviceType)(external_globals_js_namespaceObject.userAgent, deviceOptions),
|
|
284
287
|
$timezone: getTimezone(),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { convertToURL, getQueryParam, maskQueryParams } from "./request-utils.mjs";
|
|
2
|
-
import { detectBrowser, detectBrowserVersion, detectDevice, detectDeviceType, detectOS, isNull, isUndefined, stripLeadingDollar, stripUrlHash } from "@posthog/core";
|
|
2
|
+
import { detectBrowser, detectBrowserVersion, detectDevice, detectDeviceType, detectOS, detectWebviewApp, isNull, isUndefined, stripLeadingDollar, stripUrlHash } from "@posthog/core";
|
|
3
3
|
import config from "../config.mjs";
|
|
4
4
|
import { SDK_DIST_CHANNEL } from "../constants.mjs";
|
|
5
5
|
import { each, extend, stripEmptyProperties } from "./general-utils.mjs";
|
|
@@ -201,6 +201,7 @@ function getEventProperties(maskPersonalDataProperties, customPersonalDataProper
|
|
|
201
201
|
...customPersonalDataProperties || []
|
|
202
202
|
] : [];
|
|
203
203
|
const [os_name, os_version] = detectOS(userAgent);
|
|
204
|
+
const [webviewApp, webviewAppVersion] = detectWebviewApp(userAgent);
|
|
204
205
|
const browserHints = getBrowserDetectionHints();
|
|
205
206
|
const browserOptions = {};
|
|
206
207
|
if (!isUndefined(detectGoogleSearchApp)) browserOptions.detectGoogleSearchApp = detectGoogleSearchApp;
|
|
@@ -219,6 +220,8 @@ function getEventProperties(maskPersonalDataProperties, customPersonalDataProper
|
|
|
219
220
|
$os: os_name,
|
|
220
221
|
$os_version: os_version,
|
|
221
222
|
$browser: detectBrowser(userAgent, navigator.vendor, browserHints, browserOptions),
|
|
223
|
+
$webview_app: webviewApp,
|
|
224
|
+
$webview_app_version: webviewAppVersion,
|
|
222
225
|
$device: detectDevice(userAgent),
|
|
223
226
|
$device_type: detectDeviceType(userAgent, deviceOptions),
|
|
224
227
|
$timezone: getTimezone(),
|
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.
|
|
3
|
+
"version": "0.8.0",
|
|
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.
|
|
77
|
-
"@posthog/types": "^1.
|
|
76
|
+
"@posthog/core": "^1.51.0",
|
|
77
|
+
"@posthog/types": "^1.409.1"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@rslib/core": "0.23.2",
|