@posthog/browser-common 0.9.2 → 0.9.4
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/client.d.ts +4 -2
- package/dist/config.js +1 -1
- package/dist/config.mjs +1 -1
- package/dist/console-logs.d.ts +15 -0
- package/dist/console-logs.js +317 -0
- package/dist/console-logs.mjs +276 -0
- package/dist/constants.d.ts +16 -0
- package/dist/constants.js +64 -0
- package/dist/constants.mjs +17 -1
- package/dist/extension-tokens.d.ts +4 -0
- package/dist/extension-tokens.js +40 -0
- package/dist/extension-tokens.mjs +2 -0
- package/dist/extension.d.ts +4 -0
- package/dist/feature-flags-config.d.ts +23 -0
- package/dist/feature-flags-config.js +18 -0
- package/dist/feature-flags-config.mjs +1 -0
- package/dist/feature-flags.d.ts +329 -0
- package/dist/feature-flags.js +1222 -0
- package/dist/feature-flags.mjs +1172 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +15 -7
- package/dist/index.mjs +1 -0
- package/dist/logs-config.d.ts +24 -0
- package/dist/logs-config.js +80 -0
- package/dist/logs-config.mjs +42 -0
- package/dist/logs-types.d.ts +31 -0
- package/dist/logs-types.js +46 -0
- package/dist/logs-types.mjs +8 -0
- package/dist/logs.d.ts +85 -0
- package/dist/logs.js +469 -0
- package/dist/logs.mjs +428 -0
- package/dist/token.d.ts +1 -1
- package/dist/types/feature-flags.d.ts +18 -0
- package/dist/types/feature-flags.js +18 -0
- package/dist/types/feature-flags.mjs +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +7 -0
- package/dist/types/index.mjs +1 -0
- package/dist/utils/console-original.d.ts +6 -0
- package/dist/utils/console-original.js +43 -0
- package/dist/utils/console-original.mjs +5 -0
- package/dist/utils/event-utils.d.ts +1 -1
- package/dist/utils/event-utils.js +3 -9
- package/dist/utils/event-utils.mjs +1 -7
- package/dist/utils/logger.js +8 -3
- package/dist/utils/logger.mjs +8 -3
- package/dist/utils/patch.d.ts +3 -0
- package/dist/utils/patch.js +90 -0
- package/dist/utils/patch.mjs +52 -0
- package/dist/utils/request-reachability.d.ts +2 -0
- package/dist/utils/request-reachability.js +61 -0
- package/dist/utils/request-reachability.mjs +20 -0
- package/dist/utils/request-utils.d.ts +1 -2
- package/dist/utils/request-utils.js +3 -14
- package/dist/utils/request-utils.mjs +3 -14
- package/dist/utils/sanitize-url.d.ts +11 -0
- package/dist/utils/sanitize-url.js +55 -0
- package/dist/utils/sanitize-url.mjs +17 -0
- package/dist/utils/timezone.d.ts +1 -0
- package/dist/utils/timezone.js +46 -0
- package/dist/utils/timezone.mjs +8 -0
- package/package.json +59 -3
package/dist/utils/logger.mjs
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import config from "../config.mjs";
|
|
2
2
|
import { isUndefined } from "@posthog/core";
|
|
3
|
-
import { window as external_globals_mjs_window } from "./globals.mjs";
|
|
4
3
|
const _createLogger = (prefix, { debugEnabled } = {})=>{
|
|
5
4
|
const logger = {
|
|
6
5
|
_log: (level, ...args)=>{
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
let browserWindow;
|
|
7
|
+
try {
|
|
8
|
+
browserWindow = "u" < typeof window ? void 0 : window;
|
|
9
|
+
} catch {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (browserWindow && (config.DEBUG || browserWindow.POSTHOG_DEBUG || debugEnabled) && !isUndefined(browserWindow.console) && browserWindow.console) {
|
|
13
|
+
const consoleLog = '__rrweb_original__' in browserWindow.console[level] ? browserWindow.console[level]['__rrweb_original__'] : browserWindow.console[level];
|
|
9
14
|
consoleLog(prefix, ...args);
|
|
10
15
|
}
|
|
11
16
|
},
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
patch: ()=>patch
|
|
32
|
+
});
|
|
33
|
+
const core_namespaceObject = require("@posthog/core");
|
|
34
|
+
const noop = ()=>{};
|
|
35
|
+
const spliceableLayer = (method)=>{
|
|
36
|
+
if (!(0, core_namespaceObject.isFunction)(method)) return;
|
|
37
|
+
return method.__posthog_layer__ ?? method.__rrweb_layer__;
|
|
38
|
+
};
|
|
39
|
+
function patch(source, name, replacement) {
|
|
40
|
+
try {
|
|
41
|
+
if (!(name in source)) return noop;
|
|
42
|
+
const original = source[name];
|
|
43
|
+
const layer = {
|
|
44
|
+
next: original
|
|
45
|
+
};
|
|
46
|
+
const callNext = function(...args) {
|
|
47
|
+
return layer.next.apply(this, args);
|
|
48
|
+
};
|
|
49
|
+
const wrapped = replacement(callNext);
|
|
50
|
+
if ((0, core_namespaceObject.isFunction)(wrapped)) {
|
|
51
|
+
wrapped.prototype = wrapped.prototype || {};
|
|
52
|
+
Object.defineProperties(wrapped, {
|
|
53
|
+
__posthog_wrapped__: {
|
|
54
|
+
enumerable: false,
|
|
55
|
+
value: true
|
|
56
|
+
},
|
|
57
|
+
__posthog_layer__: {
|
|
58
|
+
enumerable: false,
|
|
59
|
+
value: layer
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
source[name] = wrapped;
|
|
64
|
+
return ()=>{
|
|
65
|
+
if (source[name] === wrapped) {
|
|
66
|
+
source[name] = layer.next;
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
let current = source[name];
|
|
70
|
+
let currentLayer = spliceableLayer(current);
|
|
71
|
+
while(currentLayer){
|
|
72
|
+
if (currentLayer.next === wrapped) {
|
|
73
|
+
currentLayer.next = layer.next;
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
current = currentLayer.next;
|
|
77
|
+
currentLayer = spliceableLayer(current);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
} catch {
|
|
81
|
+
return noop;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.patch = __webpack_exports__.patch;
|
|
85
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
86
|
+
"patch"
|
|
87
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
88
|
+
Object.defineProperty(exports, '__esModule', {
|
|
89
|
+
value: true
|
|
90
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { isFunction } from "@posthog/core";
|
|
2
|
+
const noop = ()=>{};
|
|
3
|
+
const spliceableLayer = (method)=>{
|
|
4
|
+
if (!isFunction(method)) return;
|
|
5
|
+
return method.__posthog_layer__ ?? method.__rrweb_layer__;
|
|
6
|
+
};
|
|
7
|
+
function patch(source, name, replacement) {
|
|
8
|
+
try {
|
|
9
|
+
if (!(name in source)) return noop;
|
|
10
|
+
const original = source[name];
|
|
11
|
+
const layer = {
|
|
12
|
+
next: original
|
|
13
|
+
};
|
|
14
|
+
const callNext = function(...args) {
|
|
15
|
+
return layer.next.apply(this, args);
|
|
16
|
+
};
|
|
17
|
+
const wrapped = replacement(callNext);
|
|
18
|
+
if (isFunction(wrapped)) {
|
|
19
|
+
wrapped.prototype = wrapped.prototype || {};
|
|
20
|
+
Object.defineProperties(wrapped, {
|
|
21
|
+
__posthog_wrapped__: {
|
|
22
|
+
enumerable: false,
|
|
23
|
+
value: true
|
|
24
|
+
},
|
|
25
|
+
__posthog_layer__: {
|
|
26
|
+
enumerable: false,
|
|
27
|
+
value: layer
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
source[name] = wrapped;
|
|
32
|
+
return ()=>{
|
|
33
|
+
if (source[name] === wrapped) {
|
|
34
|
+
source[name] = layer.next;
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
let current = source[name];
|
|
38
|
+
let currentLayer = spliceableLayer(current);
|
|
39
|
+
while(currentLayer){
|
|
40
|
+
if (currentLayer.next === wrapped) {
|
|
41
|
+
currentLayer.next = layer.next;
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
current = currentLayer.next;
|
|
45
|
+
currentLayer = spliceableLayer(current);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
} catch {
|
|
49
|
+
return noop;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export { patch };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const isStatusZeroFailureCircuitBreakerTripped: (consecutiveStatusZeroFailures: number, maxConsecutiveStatusZeroFailures: number) => boolean;
|
|
2
|
+
export declare const updateStatusZeroFailureCount: (statusCode: number, consecutiveStatusZeroFailures: number, maxConsecutiveStatusZeroFailures: number, onCircuitBreakerTripped: () => void) => number;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
const isBrowserOnline = ()=>{
|
|
31
|
+
try {
|
|
32
|
+
return "u" > typeof window && false !== window.navigator.onLine;
|
|
33
|
+
} catch {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const isStatusZeroFailureCircuitBreakerTripped = (consecutiveStatusZeroFailures, maxConsecutiveStatusZeroFailures)=>consecutiveStatusZeroFailures >= maxConsecutiveStatusZeroFailures && isBrowserOnline();
|
|
38
|
+
const updateStatusZeroFailureCount = (statusCode, consecutiveStatusZeroFailures, maxConsecutiveStatusZeroFailures, onCircuitBreakerTripped)=>{
|
|
39
|
+
if (0 === statusCode) {
|
|
40
|
+
if (isBrowserOnline()) {
|
|
41
|
+
const updatedConsecutiveStatusZeroFailures = consecutiveStatusZeroFailures + 1;
|
|
42
|
+
if (updatedConsecutiveStatusZeroFailures === maxConsecutiveStatusZeroFailures) onCircuitBreakerTripped();
|
|
43
|
+
return updatedConsecutiveStatusZeroFailures;
|
|
44
|
+
}
|
|
45
|
+
return consecutiveStatusZeroFailures;
|
|
46
|
+
}
|
|
47
|
+
return 0;
|
|
48
|
+
};
|
|
49
|
+
__webpack_require__.d(__webpack_exports__, {}, {
|
|
50
|
+
isStatusZeroFailureCircuitBreakerTripped: isStatusZeroFailureCircuitBreakerTripped,
|
|
51
|
+
updateStatusZeroFailureCount: updateStatusZeroFailureCount
|
|
52
|
+
});
|
|
53
|
+
exports.isStatusZeroFailureCircuitBreakerTripped = __webpack_exports__.isStatusZeroFailureCircuitBreakerTripped;
|
|
54
|
+
exports.updateStatusZeroFailureCount = __webpack_exports__.updateStatusZeroFailureCount;
|
|
55
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
56
|
+
"isStatusZeroFailureCircuitBreakerTripped",
|
|
57
|
+
"updateStatusZeroFailureCount"
|
|
58
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
59
|
+
Object.defineProperty(exports, '__esModule', {
|
|
60
|
+
value: true
|
|
61
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const isBrowserOnline = ()=>{
|
|
2
|
+
try {
|
|
3
|
+
return "u" > typeof window && false !== window.navigator.onLine;
|
|
4
|
+
} catch {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
const isStatusZeroFailureCircuitBreakerTripped = (consecutiveStatusZeroFailures, maxConsecutiveStatusZeroFailures)=>consecutiveStatusZeroFailures >= maxConsecutiveStatusZeroFailures && isBrowserOnline();
|
|
9
|
+
const updateStatusZeroFailureCount = (statusCode, consecutiveStatusZeroFailures, maxConsecutiveStatusZeroFailures, onCircuitBreakerTripped)=>{
|
|
10
|
+
if (0 === statusCode) {
|
|
11
|
+
if (isBrowserOnline()) {
|
|
12
|
+
const updatedConsecutiveStatusZeroFailures = consecutiveStatusZeroFailures + 1;
|
|
13
|
+
if (updatedConsecutiveStatusZeroFailures === maxConsecutiveStatusZeroFailures) onCircuitBreakerTripped();
|
|
14
|
+
return updatedConsecutiveStatusZeroFailures;
|
|
15
|
+
}
|
|
16
|
+
return consecutiveStatusZeroFailures;
|
|
17
|
+
}
|
|
18
|
+
return 0;
|
|
19
|
+
};
|
|
20
|
+
export { isStatusZeroFailureCircuitBreakerTripped, updateStatusZeroFailureCount };
|
|
@@ -11,5 +11,4 @@ export declare const getQueryParam: (url: string, param: string) => string;
|
|
|
11
11
|
export declare const maskQueryParams: <T extends string | undefined>(url: T, maskedParams: string[] | undefined, mask: string) => T extends string ? string : undefined;
|
|
12
12
|
export declare const _getHashParam: (hash: string, param: string) => string | null;
|
|
13
13
|
export declare const isLocalhost: () => boolean;
|
|
14
|
-
export
|
|
15
|
-
export declare const updateStatusZeroFailureCount: (statusCode: number, consecutiveStatusZeroFailures: number, maxConsecutiveStatusZeroFailures: number, onCircuitBreakerTripped: () => void) => number;
|
|
14
|
+
export { isStatusZeroFailureCircuitBreakerTripped, updateStatusZeroFailureCount } from './request-reachability';
|
|
@@ -33,15 +33,16 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
33
33
|
formDataToQuery: ()=>formDataToQuery,
|
|
34
34
|
getQueryParam: ()=>getQueryParam,
|
|
35
35
|
isLocalhost: ()=>isLocalhost,
|
|
36
|
-
isStatusZeroFailureCircuitBreakerTripped: ()=>isStatusZeroFailureCircuitBreakerTripped,
|
|
36
|
+
isStatusZeroFailureCircuitBreakerTripped: ()=>external_request_reachability_js_namespaceObject.isStatusZeroFailureCircuitBreakerTripped,
|
|
37
37
|
jsonStringify: ()=>jsonStringify,
|
|
38
38
|
maskQueryParams: ()=>maskQueryParams,
|
|
39
|
-
updateStatusZeroFailureCount: ()=>updateStatusZeroFailureCount
|
|
39
|
+
updateStatusZeroFailureCount: ()=>external_request_reachability_js_namespaceObject.updateStatusZeroFailureCount
|
|
40
40
|
});
|
|
41
41
|
const core_namespaceObject = require("@posthog/core");
|
|
42
42
|
const external_general_utils_js_namespaceObject = require("./general-utils.js");
|
|
43
43
|
const external_globals_js_namespaceObject = require("./globals.js");
|
|
44
44
|
const external_logger_js_namespaceObject = require("./logger.js");
|
|
45
|
+
const external_request_reachability_js_namespaceObject = require("./request-reachability.js");
|
|
45
46
|
const localDomains = [
|
|
46
47
|
'localhost',
|
|
47
48
|
'127.0.0.1'
|
|
@@ -128,18 +129,6 @@ const _getHashParam = function(hash, param) {
|
|
|
128
129
|
return matches ? matches[1] : null;
|
|
129
130
|
};
|
|
130
131
|
const isLocalhost = ()=>localDomains.includes(external_globals_js_namespaceObject.location.hostname);
|
|
131
|
-
const isStatusZeroFailureCircuitBreakerTripped = (consecutiveStatusZeroFailures, maxConsecutiveStatusZeroFailures)=>consecutiveStatusZeroFailures >= maxConsecutiveStatusZeroFailures && (0, external_globals_js_namespaceObject.isBrowserOnline)();
|
|
132
|
-
const updateStatusZeroFailureCount = (statusCode, consecutiveStatusZeroFailures, maxConsecutiveStatusZeroFailures, onCircuitBreakerTripped)=>{
|
|
133
|
-
if (0 === statusCode) {
|
|
134
|
-
if ((0, external_globals_js_namespaceObject.isBrowserOnline)()) {
|
|
135
|
-
const updatedConsecutiveStatusZeroFailures = consecutiveStatusZeroFailures + 1;
|
|
136
|
-
if (updatedConsecutiveStatusZeroFailures === maxConsecutiveStatusZeroFailures) onCircuitBreakerTripped();
|
|
137
|
-
return updatedConsecutiveStatusZeroFailures;
|
|
138
|
-
}
|
|
139
|
-
return consecutiveStatusZeroFailures;
|
|
140
|
-
}
|
|
141
|
-
return 0;
|
|
142
|
-
};
|
|
143
132
|
exports._getHashParam = __webpack_exports__._getHashParam;
|
|
144
133
|
exports.convertToURL = __webpack_exports__.convertToURL;
|
|
145
134
|
exports.formDataToQuery = __webpack_exports__.formDataToQuery;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isArray, isError, isFile, isUndefined, safeJsonStringify } from "@posthog/core";
|
|
2
2
|
import { each, errorToProperties } from "./general-utils.mjs";
|
|
3
|
-
import { document as external_globals_mjs_document,
|
|
3
|
+
import { document as external_globals_mjs_document, location as external_globals_mjs_location } from "./globals.mjs";
|
|
4
4
|
import { logger } from "./logger.mjs";
|
|
5
5
|
const localDomains = [
|
|
6
6
|
'localhost',
|
|
@@ -88,16 +88,5 @@ const _getHashParam = function(hash, param) {
|
|
|
88
88
|
return matches ? matches[1] : null;
|
|
89
89
|
};
|
|
90
90
|
const isLocalhost = ()=>localDomains.includes(external_globals_mjs_location.hostname);
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (0 === statusCode) {
|
|
94
|
-
if (isBrowserOnline()) {
|
|
95
|
-
const updatedConsecutiveStatusZeroFailures = consecutiveStatusZeroFailures + 1;
|
|
96
|
-
if (updatedConsecutiveStatusZeroFailures === maxConsecutiveStatusZeroFailures) onCircuitBreakerTripped();
|
|
97
|
-
return updatedConsecutiveStatusZeroFailures;
|
|
98
|
-
}
|
|
99
|
-
return consecutiveStatusZeroFailures;
|
|
100
|
-
}
|
|
101
|
-
return 0;
|
|
102
|
-
};
|
|
103
|
-
export { _getHashParam, convertToURL, formDataToQuery, getQueryParam, isLocalhost, isStatusZeroFailureCircuitBreakerTripped, jsonStringify, maskQueryParams, updateStatusZeroFailureCount };
|
|
91
|
+
export { isStatusZeroFailureCircuitBreakerTripped, updateStatusZeroFailureCount } from "./request-reachability.mjs";
|
|
92
|
+
export { _getHashParam, convertToURL, formDataToQuery, getQueryParam, isLocalhost, jsonStringify, maskQueryParams };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Selects the URL components retained for capture. */
|
|
2
|
+
export interface UrlCaptureOptions {
|
|
3
|
+
/** Retain the pathname. Defaults to true. */
|
|
4
|
+
path?: boolean;
|
|
5
|
+
/** Retain query parameters. Defaults to false. */
|
|
6
|
+
search?: boolean;
|
|
7
|
+
/** Retain the fragment. Defaults to false. */
|
|
8
|
+
hash?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** Shape an absolute URL for capture without modifying the input. Invalid URLs are omitted. */
|
|
11
|
+
export declare function sanitizeUrl(url: URL | string, options: UrlCaptureOptions): string | undefined;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
function sanitizeUrl(url, options) {
|
|
31
|
+
try {
|
|
32
|
+
const result = new URL(String(url));
|
|
33
|
+
result.username = '';
|
|
34
|
+
result.password = '';
|
|
35
|
+
if (false === options.path) {
|
|
36
|
+
result.pathname = '/';
|
|
37
|
+
if ('/' !== result.pathname) return;
|
|
38
|
+
}
|
|
39
|
+
if (!options.search) result.search = '';
|
|
40
|
+
if (!options.hash) result.hash = '';
|
|
41
|
+
return result.toString();
|
|
42
|
+
} catch {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
47
|
+
sanitizeUrl: ()=>sanitizeUrl
|
|
48
|
+
});
|
|
49
|
+
exports.sanitizeUrl = __webpack_exports__.sanitizeUrl;
|
|
50
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
51
|
+
"sanitizeUrl"
|
|
52
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
53
|
+
Object.defineProperty(exports, '__esModule', {
|
|
54
|
+
value: true
|
|
55
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
function sanitizeUrl(url, options) {
|
|
2
|
+
try {
|
|
3
|
+
const result = new URL(String(url));
|
|
4
|
+
result.username = '';
|
|
5
|
+
result.password = '';
|
|
6
|
+
if (false === options.path) {
|
|
7
|
+
result.pathname = '/';
|
|
8
|
+
if ('/' !== result.pathname) return;
|
|
9
|
+
}
|
|
10
|
+
if (!options.search) result.search = '';
|
|
11
|
+
if (!options.hash) result.hash = '';
|
|
12
|
+
return result.toString();
|
|
13
|
+
} catch {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export { sanitizeUrl };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getTimezone(): string | undefined;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
function getTimezone() {
|
|
31
|
+
try {
|
|
32
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
33
|
+
} catch {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
38
|
+
getTimezone: ()=>getTimezone
|
|
39
|
+
});
|
|
40
|
+
exports.getTimezone = __webpack_exports__.getTimezone;
|
|
41
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
42
|
+
"getTimezone"
|
|
43
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
44
|
+
Object.defineProperty(exports, '__esModule', {
|
|
45
|
+
value: true
|
|
46
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posthog/browser-common",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.4",
|
|
4
4
|
"description": "Internal shared browser utilities and extension primitives for PostHog Browser SDKs",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -29,6 +29,9 @@
|
|
|
29
29
|
"constants": [
|
|
30
30
|
"dist/constants.d.ts"
|
|
31
31
|
],
|
|
32
|
+
"extension-tokens": [
|
|
33
|
+
"dist/extension-tokens.d.ts"
|
|
34
|
+
],
|
|
32
35
|
"extension-runtime": [
|
|
33
36
|
"dist/extension-runtime.d.ts"
|
|
34
37
|
],
|
|
@@ -37,6 +40,24 @@
|
|
|
37
40
|
],
|
|
38
41
|
"utils/*": [
|
|
39
42
|
"dist/utils/*.d.ts"
|
|
43
|
+
],
|
|
44
|
+
"feature-flags": [
|
|
45
|
+
"dist/feature-flags.d.ts"
|
|
46
|
+
],
|
|
47
|
+
"feature-flags-config": [
|
|
48
|
+
"dist/feature-flags-config.d.ts"
|
|
49
|
+
],
|
|
50
|
+
"logs": [
|
|
51
|
+
"dist/logs.d.ts"
|
|
52
|
+
],
|
|
53
|
+
"logs-types": [
|
|
54
|
+
"dist/logs-types.d.ts"
|
|
55
|
+
],
|
|
56
|
+
"logs-config": [
|
|
57
|
+
"dist/logs-config.d.ts"
|
|
58
|
+
],
|
|
59
|
+
"console-logs": [
|
|
60
|
+
"dist/console-logs.d.ts"
|
|
40
61
|
]
|
|
41
62
|
}
|
|
42
63
|
},
|
|
@@ -56,6 +77,11 @@
|
|
|
56
77
|
"require": "./dist/constants.js",
|
|
57
78
|
"import": "./dist/constants.mjs"
|
|
58
79
|
},
|
|
80
|
+
"./extension-tokens": {
|
|
81
|
+
"types": "./dist/extension-tokens.d.ts",
|
|
82
|
+
"require": "./dist/extension-tokens.js",
|
|
83
|
+
"import": "./dist/extension-tokens.mjs"
|
|
84
|
+
},
|
|
59
85
|
"./extension-runtime": {
|
|
60
86
|
"types": "./dist/extension-runtime.d.ts",
|
|
61
87
|
"require": "./dist/extension-runtime.js",
|
|
@@ -70,11 +96,41 @@
|
|
|
70
96
|
"types": "./dist/utils/*.d.ts",
|
|
71
97
|
"require": "./dist/utils/*.js",
|
|
72
98
|
"import": "./dist/utils/*.mjs"
|
|
99
|
+
},
|
|
100
|
+
"./feature-flags": {
|
|
101
|
+
"types": "./dist/feature-flags.d.ts",
|
|
102
|
+
"require": "./dist/feature-flags.js",
|
|
103
|
+
"import": "./dist/feature-flags.mjs"
|
|
104
|
+
},
|
|
105
|
+
"./feature-flags-config": {
|
|
106
|
+
"types": "./dist/feature-flags-config.d.ts",
|
|
107
|
+
"require": "./dist/feature-flags-config.js",
|
|
108
|
+
"import": "./dist/feature-flags-config.mjs"
|
|
109
|
+
},
|
|
110
|
+
"./logs": {
|
|
111
|
+
"types": "./dist/logs.d.ts",
|
|
112
|
+
"require": "./dist/logs.js",
|
|
113
|
+
"import": "./dist/logs.mjs"
|
|
114
|
+
},
|
|
115
|
+
"./logs-types": {
|
|
116
|
+
"types": "./dist/logs-types.d.ts",
|
|
117
|
+
"require": "./dist/logs-types.js",
|
|
118
|
+
"import": "./dist/logs-types.mjs"
|
|
119
|
+
},
|
|
120
|
+
"./logs-config": {
|
|
121
|
+
"types": "./dist/logs-config.d.ts",
|
|
122
|
+
"require": "./dist/logs-config.js",
|
|
123
|
+
"import": "./dist/logs-config.mjs"
|
|
124
|
+
},
|
|
125
|
+
"./console-logs": {
|
|
126
|
+
"types": "./dist/console-logs.d.ts",
|
|
127
|
+
"import": "./dist/console-logs.mjs",
|
|
128
|
+
"require": "./dist/console-logs.js"
|
|
73
129
|
}
|
|
74
130
|
},
|
|
75
131
|
"dependencies": {
|
|
76
|
-
"@posthog/core": "^1.57.
|
|
77
|
-
"@posthog/types": "^1.415.
|
|
132
|
+
"@posthog/core": "^1.57.4",
|
|
133
|
+
"@posthog/types": "^1.415.2"
|
|
78
134
|
},
|
|
79
135
|
"devDependencies": {
|
|
80
136
|
"@rslib/core": "0.23.2",
|