@posthog/browser-common 0.0.0 → 0.2.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/README.md +114 -28
- package/dist/client.d.ts +136 -0
- package/dist/client.js +18 -0
- package/dist/client.mjs +0 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.js +43 -0
- package/dist/config.mjs +9 -0
- package/dist/constants.d.ts +3 -0
- package/dist/constants.js +44 -0
- package/dist/constants.mjs +4 -0
- package/dist/disposable.d.ts +13 -0
- package/dist/disposable.js +18 -0
- package/dist/disposable.mjs +0 -0
- package/dist/extension.d.ts +45 -0
- package/dist/extension.js +18 -0
- package/dist/extension.mjs +0 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +36 -0
- package/dist/index.mjs +2 -0
- package/dist/persistence.d.ts +24 -0
- package/dist/persistence.js +18 -0
- package/dist/persistence.mjs +0 -0
- package/dist/pubsub.d.ts +28 -0
- package/dist/pubsub.js +67 -0
- package/dist/pubsub.mjs +33 -0
- package/dist/token.d.ts +21 -0
- package/dist/token.js +18 -0
- package/dist/token.mjs +0 -0
- package/dist/utils/array-at-polyfill.d.ts +1 -0
- package/dist/utils/array-at-polyfill.js +16 -0
- package/dist/utils/array-at-polyfill.mjs +11 -0
- package/dist/utils/autocapture-utils.d.ts +23 -0
- package/dist/utils/autocapture-utils.js +479 -0
- package/dist/utils/autocapture-utils.mjs +385 -0
- package/dist/utils/blocked-uas.d.ts +17 -0
- package/dist/utils/blocked-uas.js +54 -0
- package/dist/utils/blocked-uas.mjs +14 -0
- package/dist/utils/cookie-utils.d.ts +1 -0
- package/dist/utils/cookie-utils.js +49 -0
- package/dist/utils/cookie-utils.mjs +15 -0
- package/dist/utils/device-model-utils.d.ts +8 -0
- package/dist/utils/device-model-utils.js +52 -0
- package/dist/utils/device-model-utils.mjs +18 -0
- package/dist/utils/element-utils.d.ts +5 -0
- package/dist/utils/element-utils.js +67 -0
- package/dist/utils/element-utils.mjs +21 -0
- package/dist/utils/elements-chain-utils.d.ts +4 -0
- package/dist/utils/elements-chain-utils.js +79 -0
- package/dist/utils/elements-chain-utils.mjs +36 -0
- package/dist/utils/encode-utils.d.ts +8 -0
- package/dist/utils/encode-utils.js +39 -0
- package/dist/utils/encode-utils.mjs +5 -0
- package/dist/utils/event-utils.d.ts +24 -0
- package/dist/utils/event-utils.js +344 -0
- package/dist/utils/event-utils.mjs +246 -0
- package/dist/utils/general-utils.d.ts +30 -0
- package/dist/utils/general-utils.js +191 -0
- package/dist/utils/general-utils.mjs +118 -0
- package/dist/utils/globals.d.ts +25 -0
- package/dist/utils/globals.js +75 -0
- package/dist/utils/globals.mjs +14 -0
- package/dist/utils/logger.d.ts +16 -0
- package/dist/utils/logger.js +83 -0
- package/dist/utils/logger.mjs +36 -0
- package/dist/utils/matcher-utils.d.ts +3 -0
- package/dist/utils/matcher-utils.js +63 -0
- package/dist/utils/matcher-utils.mjs +26 -0
- package/dist/utils/property-utils.d.ts +23 -0
- package/dist/utils/property-utils.js +108 -0
- package/dist/utils/property-utils.mjs +65 -0
- package/dist/utils/prototype-utils.d.ts +7 -0
- package/dist/utils/prototype-utils.js +64 -0
- package/dist/utils/prototype-utils.mjs +27 -0
- package/dist/utils/regex-utils.d.ts +2 -0
- package/dist/utils/regex-utils.js +54 -0
- package/dist/utils/regex-utils.mjs +17 -0
- package/dist/utils/request-utils.d.ts +15 -0
- package/dist/utils/request-utils.js +153 -0
- package/dist/utils/request-utils.mjs +95 -0
- package/dist/utils/simple-event-emitter.d.ts +5 -0
- package/dist/utils/simple-event-emitter.js +51 -0
- package/dist/utils/simple-event-emitter.mjs +17 -0
- package/dist/utils/stylesheet-loader.d.ts +7 -0
- package/dist/utils/stylesheet-loader.js +53 -0
- package/dist/utils/stylesheet-loader.mjs +19 -0
- package/dist/utils/type-utils.d.ts +2 -0
- package/dist/utils/type-utils.js +41 -0
- package/dist/utils/type-utils.mjs +4 -0
- package/dist/utils/url-targeting-utils.d.ts +28 -0
- package/dist/utils/url-targeting-utils.js +56 -0
- package/dist/utils/url-targeting-utils.mjs +19 -0
- package/dist/utils/uuidv7.d.ts +43 -0
- package/dist/utils/uuidv7.js +172 -0
- package/dist/utils/uuidv7.js.LICENSE.txt +9 -0
- package/dist/utils/uuidv7.mjs +132 -0
- package/dist/utils/uuidv7.mjs.LICENSE.txt +9 -0
- package/package.json +79 -8
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
isTag: ()=>isTag,
|
|
28
|
+
isElementInToolbar: ()=>isElementInToolbar,
|
|
29
|
+
isShadowRoot: ()=>isShadowRoot,
|
|
30
|
+
isTextNode: ()=>isTextNode,
|
|
31
|
+
isElementNode: ()=>isElementNode
|
|
32
|
+
});
|
|
33
|
+
const external_constants_js_namespaceObject = require("../constants.js");
|
|
34
|
+
const NODE_TYPE_ELEMENT = 1;
|
|
35
|
+
const NODE_TYPE_TEXT = 3;
|
|
36
|
+
const NODE_TYPE_DOCUMENT_FRAGMENT = 11;
|
|
37
|
+
function isElementInToolbar(el) {
|
|
38
|
+
if (el instanceof Element) return el.id === external_constants_js_namespaceObject.TOOLBAR_ID || !!el.closest?.('.' + external_constants_js_namespaceObject.TOOLBAR_CONTAINER_CLASS);
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
function isElementNode(el) {
|
|
42
|
+
return !!el && el.nodeType === NODE_TYPE_ELEMENT;
|
|
43
|
+
}
|
|
44
|
+
function isTag(el, tag) {
|
|
45
|
+
return !!el && !!el.tagName && el.tagName.toLowerCase() === tag.toLowerCase();
|
|
46
|
+
}
|
|
47
|
+
function isTextNode(el) {
|
|
48
|
+
return !!el && el.nodeType === NODE_TYPE_TEXT;
|
|
49
|
+
}
|
|
50
|
+
function isShadowRoot(el) {
|
|
51
|
+
return !!el && el.nodeType === NODE_TYPE_DOCUMENT_FRAGMENT && isElementNode(el.host);
|
|
52
|
+
}
|
|
53
|
+
exports.isElementInToolbar = __webpack_exports__.isElementInToolbar;
|
|
54
|
+
exports.isElementNode = __webpack_exports__.isElementNode;
|
|
55
|
+
exports.isShadowRoot = __webpack_exports__.isShadowRoot;
|
|
56
|
+
exports.isTag = __webpack_exports__.isTag;
|
|
57
|
+
exports.isTextNode = __webpack_exports__.isTextNode;
|
|
58
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
59
|
+
"isElementInToolbar",
|
|
60
|
+
"isElementNode",
|
|
61
|
+
"isShadowRoot",
|
|
62
|
+
"isTag",
|
|
63
|
+
"isTextNode"
|
|
64
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
65
|
+
Object.defineProperty(exports, '__esModule', {
|
|
66
|
+
value: true
|
|
67
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { TOOLBAR_CONTAINER_CLASS, TOOLBAR_ID } from "../constants.mjs";
|
|
2
|
+
const NODE_TYPE_ELEMENT = 1;
|
|
3
|
+
const NODE_TYPE_TEXT = 3;
|
|
4
|
+
const NODE_TYPE_DOCUMENT_FRAGMENT = 11;
|
|
5
|
+
function isElementInToolbar(el) {
|
|
6
|
+
if (el instanceof Element) return el.id === TOOLBAR_ID || !!el.closest?.('.' + TOOLBAR_CONTAINER_CLASS);
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
function isElementNode(el) {
|
|
10
|
+
return !!el && el.nodeType === NODE_TYPE_ELEMENT;
|
|
11
|
+
}
|
|
12
|
+
function isTag(el, tag) {
|
|
13
|
+
return !!el && !!el.tagName && el.tagName.toLowerCase() === tag.toLowerCase();
|
|
14
|
+
}
|
|
15
|
+
function isTextNode(el) {
|
|
16
|
+
return !!el && el.nodeType === NODE_TYPE_TEXT;
|
|
17
|
+
}
|
|
18
|
+
function isShadowRoot(el) {
|
|
19
|
+
return !!el && el.nodeType === NODE_TYPE_DOCUMENT_FRAGMENT && isElementNode(el.host);
|
|
20
|
+
}
|
|
21
|
+
export { isElementInToolbar, isElementNode, isShadowRoot, isTag, isTextNode };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function extractHref(elementsChain: string): string;
|
|
2
|
+
export declare function extractTexts(elementsChain: string): string[];
|
|
3
|
+
export declare function matchString(value: string | undefined | null, pattern: string, matching: 'exact' | 'contains' | 'regex'): boolean;
|
|
4
|
+
export declare function matchTexts(texts: string[], pattern: string, matching: 'exact' | 'contains' | 'regex'): boolean;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
matchString: ()=>matchString,
|
|
28
|
+
extractHref: ()=>extractHref,
|
|
29
|
+
extractTexts: ()=>extractTexts,
|
|
30
|
+
matchTexts: ()=>matchTexts
|
|
31
|
+
});
|
|
32
|
+
const core_namespaceObject = require("@posthog/core");
|
|
33
|
+
function extractHref(elementsChain) {
|
|
34
|
+
const match = elementsChain.match(/(?::|")href="(.*?)"/);
|
|
35
|
+
return match ? match[1] : '';
|
|
36
|
+
}
|
|
37
|
+
function extractTexts(elementsChain) {
|
|
38
|
+
const texts = [];
|
|
39
|
+
const regex = /(?::|")text="(.*?)"/g;
|
|
40
|
+
let match;
|
|
41
|
+
while(!(0, core_namespaceObject.isNullish)(match = regex.exec(elementsChain)))if (!texts.includes(match[1])) texts.push(match[1]);
|
|
42
|
+
return texts;
|
|
43
|
+
}
|
|
44
|
+
function matchString(value, pattern, matching) {
|
|
45
|
+
if ((0, core_namespaceObject.isNullish)(value)) return false;
|
|
46
|
+
switch(matching){
|
|
47
|
+
case 'exact':
|
|
48
|
+
return value === pattern;
|
|
49
|
+
case 'contains':
|
|
50
|
+
{
|
|
51
|
+
const likePattern = pattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&').replace(/_/g, '.').replace(/%/g, '.*');
|
|
52
|
+
return new RegExp(likePattern, 'i').test(value);
|
|
53
|
+
}
|
|
54
|
+
case 'regex':
|
|
55
|
+
try {
|
|
56
|
+
return new RegExp(pattern).test(value);
|
|
57
|
+
} catch {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
default:
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function matchTexts(texts, pattern, matching) {
|
|
65
|
+
return texts.some((text)=>matchString(text, pattern, matching));
|
|
66
|
+
}
|
|
67
|
+
exports.extractHref = __webpack_exports__.extractHref;
|
|
68
|
+
exports.extractTexts = __webpack_exports__.extractTexts;
|
|
69
|
+
exports.matchString = __webpack_exports__.matchString;
|
|
70
|
+
exports.matchTexts = __webpack_exports__.matchTexts;
|
|
71
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
72
|
+
"extractHref",
|
|
73
|
+
"extractTexts",
|
|
74
|
+
"matchString",
|
|
75
|
+
"matchTexts"
|
|
76
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
77
|
+
Object.defineProperty(exports, '__esModule', {
|
|
78
|
+
value: true
|
|
79
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { isNullish } from "@posthog/core";
|
|
2
|
+
function extractHref(elementsChain) {
|
|
3
|
+
const match = elementsChain.match(/(?::|")href="(.*?)"/);
|
|
4
|
+
return match ? match[1] : '';
|
|
5
|
+
}
|
|
6
|
+
function extractTexts(elementsChain) {
|
|
7
|
+
const texts = [];
|
|
8
|
+
const regex = /(?::|")text="(.*?)"/g;
|
|
9
|
+
let match;
|
|
10
|
+
while(!isNullish(match = regex.exec(elementsChain)))if (!texts.includes(match[1])) texts.push(match[1]);
|
|
11
|
+
return texts;
|
|
12
|
+
}
|
|
13
|
+
function matchString(value, pattern, matching) {
|
|
14
|
+
if (isNullish(value)) return false;
|
|
15
|
+
switch(matching){
|
|
16
|
+
case 'exact':
|
|
17
|
+
return value === pattern;
|
|
18
|
+
case 'contains':
|
|
19
|
+
{
|
|
20
|
+
const likePattern = pattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&').replace(/_/g, '.').replace(/%/g, '.*');
|
|
21
|
+
return new RegExp(likePattern, 'i').test(value);
|
|
22
|
+
}
|
|
23
|
+
case 'regex':
|
|
24
|
+
try {
|
|
25
|
+
return new RegExp(pattern).test(value);
|
|
26
|
+
} catch {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
default:
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function matchTexts(texts, pattern, matching) {
|
|
34
|
+
return texts.some((text)=>matchString(text, pattern, matching));
|
|
35
|
+
}
|
|
36
|
+
export { extractHref, extractTexts, matchString, matchTexts };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UTF-8 safe base64 encoding.
|
|
3
|
+
* Uses encodeURIComponent to handle Unicode, then converts percent-encoded bytes
|
|
4
|
+
* back to characters that btoa can handle.
|
|
5
|
+
*/
|
|
6
|
+
export declare function _base64Encode(data: null): null;
|
|
7
|
+
export declare function _base64Encode(data: undefined): undefined;
|
|
8
|
+
export declare function _base64Encode(data: string): string;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
_base64Encode: ()=>_base64Encode
|
|
28
|
+
});
|
|
29
|
+
function _base64Encode(data) {
|
|
30
|
+
if (!data) return data;
|
|
31
|
+
return btoa(encodeURIComponent(data).replace(/%([0-9A-F]{2})/g, (_, p1)=>String.fromCharCode(parseInt(p1, 16))));
|
|
32
|
+
}
|
|
33
|
+
exports._base64Encode = __webpack_exports__._base64Encode;
|
|
34
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
35
|
+
"_base64Encode"
|
|
36
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
37
|
+
Object.defineProperty(exports, '__esModule', {
|
|
38
|
+
value: true
|
|
39
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Properties } from '@posthog/types';
|
|
2
|
+
import type { BrowserDetectionHints } from '@posthog/core';
|
|
3
|
+
export declare const PERSONAL_DATA_CAMPAIGN_PARAMS: string[];
|
|
4
|
+
export declare const CAMPAIGN_PARAMS: string[];
|
|
5
|
+
export declare const EVENT_TO_PERSON_PROPERTIES: string[];
|
|
6
|
+
export declare const MASKED = "<masked>";
|
|
7
|
+
export declare const COOKIE_CAMPAIGN_PARAMS: string[];
|
|
8
|
+
export declare function getCampaignParams(customTrackedParams?: string[], maskPersonalDataProperties?: boolean, customPersonalDataProperties?: string[] | undefined): Record<string, string>;
|
|
9
|
+
export declare function getSearchInfo(): Record<string, any>;
|
|
10
|
+
export declare function getBrowserLanguage(): string | undefined;
|
|
11
|
+
export declare function getBrowserLanguagePrefix(): string | undefined;
|
|
12
|
+
export declare function getReferrer(): string;
|
|
13
|
+
export declare function getReferringDomain(): string;
|
|
14
|
+
export declare function getReferrerInfo(): Record<string, any>;
|
|
15
|
+
export declare function getPersonInfo(maskPersonalDataProperties?: boolean, customPersonalDataProperties?: string[], disableCaptureUrlHashes?: boolean): {
|
|
16
|
+
r: string;
|
|
17
|
+
u: string | undefined;
|
|
18
|
+
};
|
|
19
|
+
export declare function getPersonPropsFromInfo(info: Record<string, any>, disableCaptureUrlHashes?: boolean): Record<string, any>;
|
|
20
|
+
export declare function getInitialPersonPropsFromInfo(info: Record<string, any>, disableCaptureUrlHashes?: boolean): Record<string, any>;
|
|
21
|
+
export declare function getTimezone(): string | undefined;
|
|
22
|
+
export declare function getTimezoneOffset(): number | undefined;
|
|
23
|
+
export declare function getBrowserDetectionHints(): BrowserDetectionHints;
|
|
24
|
+
export declare function getEventProperties(maskPersonalDataProperties?: boolean, customPersonalDataProperties?: string[], detectGoogleSearchApp?: boolean, disableCaptureUrlHashes?: boolean): Properties;
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
getCampaignParams: ()=>getCampaignParams,
|
|
37
|
+
getReferrerInfo: ()=>getReferrerInfo,
|
|
38
|
+
getEventProperties: ()=>getEventProperties,
|
|
39
|
+
getPersonPropsFromInfo: ()=>getPersonPropsFromInfo,
|
|
40
|
+
COOKIE_CAMPAIGN_PARAMS: ()=>COOKIE_CAMPAIGN_PARAMS,
|
|
41
|
+
getReferrer: ()=>getReferrer,
|
|
42
|
+
getReferringDomain: ()=>getReferringDomain,
|
|
43
|
+
getTimezone: ()=>getTimezone,
|
|
44
|
+
getBrowserDetectionHints: ()=>getBrowserDetectionHints,
|
|
45
|
+
getBrowserLanguagePrefix: ()=>getBrowserLanguagePrefix,
|
|
46
|
+
getInitialPersonPropsFromInfo: ()=>getInitialPersonPropsFromInfo,
|
|
47
|
+
MASKED: ()=>MASKED,
|
|
48
|
+
getPersonInfo: ()=>getPersonInfo,
|
|
49
|
+
CAMPAIGN_PARAMS: ()=>CAMPAIGN_PARAMS,
|
|
50
|
+
getBrowserLanguage: ()=>getBrowserLanguage,
|
|
51
|
+
PERSONAL_DATA_CAMPAIGN_PARAMS: ()=>PERSONAL_DATA_CAMPAIGN_PARAMS,
|
|
52
|
+
getSearchInfo: ()=>getSearchInfo,
|
|
53
|
+
getTimezoneOffset: ()=>getTimezoneOffset,
|
|
54
|
+
EVENT_TO_PERSON_PROPERTIES: ()=>EVENT_TO_PERSON_PROPERTIES
|
|
55
|
+
});
|
|
56
|
+
const external_request_utils_js_namespaceObject = require("./request-utils.js");
|
|
57
|
+
const core_namespaceObject = require("@posthog/core");
|
|
58
|
+
const external_config_js_namespaceObject = require("../config.js");
|
|
59
|
+
var external_config_js_default = /*#__PURE__*/ __webpack_require__.n(external_config_js_namespaceObject);
|
|
60
|
+
const external_constants_js_namespaceObject = require("../constants.js");
|
|
61
|
+
const external_general_utils_js_namespaceObject = require("./general-utils.js");
|
|
62
|
+
const external_globals_js_namespaceObject = require("./globals.js");
|
|
63
|
+
const external_cookie_utils_js_namespaceObject = require("./cookie-utils.js");
|
|
64
|
+
const URL_REGEX_PREFIX = 'https?://(.*)';
|
|
65
|
+
const PERSONAL_DATA_CAMPAIGN_PARAMS = [
|
|
66
|
+
'gclid',
|
|
67
|
+
'gclsrc',
|
|
68
|
+
'dclid',
|
|
69
|
+
'gbraid',
|
|
70
|
+
'wbraid',
|
|
71
|
+
'fbclid',
|
|
72
|
+
'msclkid',
|
|
73
|
+
'twclid',
|
|
74
|
+
'li_fat_id',
|
|
75
|
+
'igshid',
|
|
76
|
+
'ttclid',
|
|
77
|
+
'rdt_cid',
|
|
78
|
+
'epik',
|
|
79
|
+
'qclid',
|
|
80
|
+
'sccid',
|
|
81
|
+
'irclid',
|
|
82
|
+
'_kx'
|
|
83
|
+
];
|
|
84
|
+
const CAMPAIGN_PARAMS = [
|
|
85
|
+
'utm_source',
|
|
86
|
+
'utm_medium',
|
|
87
|
+
'utm_campaign',
|
|
88
|
+
'utm_content',
|
|
89
|
+
'utm_term',
|
|
90
|
+
'gad_source',
|
|
91
|
+
'mc_cid',
|
|
92
|
+
...PERSONAL_DATA_CAMPAIGN_PARAMS
|
|
93
|
+
];
|
|
94
|
+
const EVENT_TO_PERSON_PROPERTIES = [
|
|
95
|
+
'$app_build',
|
|
96
|
+
'$app_name',
|
|
97
|
+
'$app_namespace',
|
|
98
|
+
'$app_version',
|
|
99
|
+
'$browser',
|
|
100
|
+
'$browser_version',
|
|
101
|
+
'$device_type',
|
|
102
|
+
'$current_url',
|
|
103
|
+
'$pathname',
|
|
104
|
+
'$os',
|
|
105
|
+
'$os_name',
|
|
106
|
+
'$os_version',
|
|
107
|
+
'$referring_domain',
|
|
108
|
+
'$referrer',
|
|
109
|
+
'$screen_height',
|
|
110
|
+
'$screen_width',
|
|
111
|
+
'$viewport_height',
|
|
112
|
+
'$viewport_width',
|
|
113
|
+
'$raw_user_agent'
|
|
114
|
+
];
|
|
115
|
+
const MASKED = '<masked>';
|
|
116
|
+
const COOKIE_CAMPAIGN_PARAMS = [
|
|
117
|
+
'li_fat_id'
|
|
118
|
+
];
|
|
119
|
+
function getCampaignParams(customTrackedParams, maskPersonalDataProperties, customPersonalDataProperties) {
|
|
120
|
+
if (!external_globals_js_namespaceObject.document) return {};
|
|
121
|
+
const paramsToMask = maskPersonalDataProperties ? [
|
|
122
|
+
...PERSONAL_DATA_CAMPAIGN_PARAMS,
|
|
123
|
+
...customPersonalDataProperties || []
|
|
124
|
+
] : [];
|
|
125
|
+
const urlCampaignParams = _getCampaignParamsFromUrl((0, external_request_utils_js_namespaceObject.maskQueryParams)(external_globals_js_namespaceObject.document.URL, paramsToMask, MASKED), customTrackedParams);
|
|
126
|
+
const cookieCampaignParams = _getCampaignParamsFromCookie();
|
|
127
|
+
return (0, external_general_utils_js_namespaceObject.extend)(cookieCampaignParams, urlCampaignParams);
|
|
128
|
+
}
|
|
129
|
+
function _getCampaignParamsFromUrl(url, customParams) {
|
|
130
|
+
const campaign_keywords = CAMPAIGN_PARAMS.concat(customParams || []);
|
|
131
|
+
const params = {};
|
|
132
|
+
(0, external_general_utils_js_namespaceObject.each)(campaign_keywords, function(kwkey) {
|
|
133
|
+
const kw = (0, external_request_utils_js_namespaceObject.getQueryParam)(url, kwkey);
|
|
134
|
+
params[kwkey] = kw ? kw : null;
|
|
135
|
+
});
|
|
136
|
+
return params;
|
|
137
|
+
}
|
|
138
|
+
function _getCampaignParamsFromCookie() {
|
|
139
|
+
const params = {};
|
|
140
|
+
(0, external_general_utils_js_namespaceObject.each)(COOKIE_CAMPAIGN_PARAMS, function(kwkey) {
|
|
141
|
+
const kw = (0, external_cookie_utils_js_namespaceObject.getCookieValue)(kwkey);
|
|
142
|
+
params[kwkey] = kw ? kw : null;
|
|
143
|
+
});
|
|
144
|
+
return params;
|
|
145
|
+
}
|
|
146
|
+
function _getSearchEngine(referrer) {
|
|
147
|
+
if (!referrer) return null;
|
|
148
|
+
if (0 === referrer.search(URL_REGEX_PREFIX + 'google.([^/?]*)')) return 'google';
|
|
149
|
+
if (0 === referrer.search(URL_REGEX_PREFIX + 'bing.com')) return 'bing';
|
|
150
|
+
if (0 === referrer.search(URL_REGEX_PREFIX + 'yahoo.com')) return 'yahoo';
|
|
151
|
+
if (0 === referrer.search(URL_REGEX_PREFIX + 'duckduckgo.com')) return 'duckduckgo';
|
|
152
|
+
else return null;
|
|
153
|
+
}
|
|
154
|
+
function _getSearchInfoFromReferrer(referrer) {
|
|
155
|
+
const search = _getSearchEngine(referrer);
|
|
156
|
+
const param = 'yahoo' != search ? 'q' : 'p';
|
|
157
|
+
const ret = {};
|
|
158
|
+
if (!(0, core_namespaceObject.isNull)(search)) {
|
|
159
|
+
ret['$search_engine'] = search;
|
|
160
|
+
const keyword = external_globals_js_namespaceObject.document ? (0, external_request_utils_js_namespaceObject.getQueryParam)(external_globals_js_namespaceObject.document.referrer, param) : '';
|
|
161
|
+
if (keyword.length) ret['ph_keyword'] = keyword;
|
|
162
|
+
}
|
|
163
|
+
return ret;
|
|
164
|
+
}
|
|
165
|
+
function getSearchInfo() {
|
|
166
|
+
const referrer = external_globals_js_namespaceObject.document?.referrer;
|
|
167
|
+
if (!referrer) return {};
|
|
168
|
+
return _getSearchInfoFromReferrer(referrer);
|
|
169
|
+
}
|
|
170
|
+
function getBrowserLanguage() {
|
|
171
|
+
return navigator.language || navigator.userLanguage;
|
|
172
|
+
}
|
|
173
|
+
function getBrowserLanguagePrefix() {
|
|
174
|
+
const lang = getBrowserLanguage();
|
|
175
|
+
return 'string' == typeof lang ? lang.split('-')[0] : void 0;
|
|
176
|
+
}
|
|
177
|
+
const DIRECT = '$direct';
|
|
178
|
+
function getReferrer() {
|
|
179
|
+
return external_globals_js_namespaceObject.document?.referrer || DIRECT;
|
|
180
|
+
}
|
|
181
|
+
function getReferringDomain() {
|
|
182
|
+
if (!external_globals_js_namespaceObject.document?.referrer) return DIRECT;
|
|
183
|
+
return (0, external_request_utils_js_namespaceObject.convertToURL)(external_globals_js_namespaceObject.document.referrer)?.host || DIRECT;
|
|
184
|
+
}
|
|
185
|
+
function getReferrerInfo() {
|
|
186
|
+
return {
|
|
187
|
+
$referrer: getReferrer(),
|
|
188
|
+
$referring_domain: getReferringDomain()
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function getPersonInfo(maskPersonalDataProperties, customPersonalDataProperties, disableCaptureUrlHashes = false) {
|
|
192
|
+
const paramsToMask = maskPersonalDataProperties ? [
|
|
193
|
+
...PERSONAL_DATA_CAMPAIGN_PARAMS,
|
|
194
|
+
...customPersonalDataProperties || []
|
|
195
|
+
] : [];
|
|
196
|
+
const href = disableCaptureUrlHashes ? (0, core_namespaceObject.stripUrlHash)(external_globals_js_namespaceObject.location?.href) : external_globals_js_namespaceObject.location?.href;
|
|
197
|
+
const url = href?.substring(0, 1000);
|
|
198
|
+
return {
|
|
199
|
+
r: getReferrer().substring(0, 1000),
|
|
200
|
+
u: url ? (0, external_request_utils_js_namespaceObject.maskQueryParams)(url, paramsToMask, MASKED) : void 0
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
function getPersonPropsFromInfo(info, disableCaptureUrlHashes = false) {
|
|
204
|
+
const { r: referrer, u } = info;
|
|
205
|
+
const url = disableCaptureUrlHashes ? (0, core_namespaceObject.stripUrlHash)(u) : u;
|
|
206
|
+
const referring_domain = null == referrer ? void 0 : referrer == DIRECT ? DIRECT : (0, external_request_utils_js_namespaceObject.convertToURL)(referrer)?.host;
|
|
207
|
+
const props = {
|
|
208
|
+
$referrer: referrer,
|
|
209
|
+
$referring_domain: referring_domain
|
|
210
|
+
};
|
|
211
|
+
if (url) {
|
|
212
|
+
props['$current_url'] = url;
|
|
213
|
+
const location = (0, external_request_utils_js_namespaceObject.convertToURL)(url);
|
|
214
|
+
props['$host'] = location?.host;
|
|
215
|
+
props['$pathname'] = location?.pathname;
|
|
216
|
+
const campaignParams = _getCampaignParamsFromUrl(url);
|
|
217
|
+
(0, external_general_utils_js_namespaceObject.extend)(props, campaignParams);
|
|
218
|
+
}
|
|
219
|
+
if (referrer) {
|
|
220
|
+
const searchInfo = _getSearchInfoFromReferrer(referrer);
|
|
221
|
+
(0, external_general_utils_js_namespaceObject.extend)(props, searchInfo);
|
|
222
|
+
}
|
|
223
|
+
return props;
|
|
224
|
+
}
|
|
225
|
+
function getInitialPersonPropsFromInfo(info, disableCaptureUrlHashes = false) {
|
|
226
|
+
const personProps = getPersonPropsFromInfo(info, disableCaptureUrlHashes);
|
|
227
|
+
const props = {};
|
|
228
|
+
(0, external_general_utils_js_namespaceObject.each)(personProps, function(val, key) {
|
|
229
|
+
props[`$initial_${(0, core_namespaceObject.stripLeadingDollar)(key)}`] = val;
|
|
230
|
+
});
|
|
231
|
+
return props;
|
|
232
|
+
}
|
|
233
|
+
function getTimezone() {
|
|
234
|
+
try {
|
|
235
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
236
|
+
} catch {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function getTimezoneOffset() {
|
|
241
|
+
try {
|
|
242
|
+
return new Date().getTimezoneOffset();
|
|
243
|
+
} catch {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
function getBrowserDetectionHints() {
|
|
248
|
+
const nav = 'undefined' != typeof navigator ? navigator : void 0;
|
|
249
|
+
return nav?.brave ? {
|
|
250
|
+
brave: true
|
|
251
|
+
} : {};
|
|
252
|
+
}
|
|
253
|
+
function getEventProperties(maskPersonalDataProperties, customPersonalDataProperties, detectGoogleSearchApp, disableCaptureUrlHashes = false) {
|
|
254
|
+
if (!external_globals_js_namespaceObject.userAgent) return {};
|
|
255
|
+
const paramsToMask = maskPersonalDataProperties ? [
|
|
256
|
+
...PERSONAL_DATA_CAMPAIGN_PARAMS,
|
|
257
|
+
...customPersonalDataProperties || []
|
|
258
|
+
] : [];
|
|
259
|
+
const [os_name, os_version] = (0, core_namespaceObject.detectOS)(external_globals_js_namespaceObject.userAgent);
|
|
260
|
+
const browserHints = getBrowserDetectionHints();
|
|
261
|
+
const browserOptions = {};
|
|
262
|
+
if (!(0, core_namespaceObject.isUndefined)(detectGoogleSearchApp)) browserOptions.detectGoogleSearchApp = detectGoogleSearchApp;
|
|
263
|
+
const deviceOptions = {};
|
|
264
|
+
const userAgentDataPlatform = navigator?.userAgentData?.platform;
|
|
265
|
+
const maxTouchPoints = navigator?.maxTouchPoints;
|
|
266
|
+
const screenWidth = external_globals_js_namespaceObject.window?.screen?.width;
|
|
267
|
+
const screenHeight = external_globals_js_namespaceObject.window?.screen?.height;
|
|
268
|
+
const devicePixelRatio = external_globals_js_namespaceObject.window?.devicePixelRatio;
|
|
269
|
+
if (!(0, core_namespaceObject.isUndefined)(userAgentDataPlatform)) deviceOptions.userAgentDataPlatform = userAgentDataPlatform;
|
|
270
|
+
if (!(0, core_namespaceObject.isUndefined)(maxTouchPoints)) deviceOptions.maxTouchPoints = maxTouchPoints;
|
|
271
|
+
if (!(0, core_namespaceObject.isUndefined)(screenWidth)) deviceOptions.screenWidth = screenWidth;
|
|
272
|
+
if (!(0, core_namespaceObject.isUndefined)(screenHeight)) deviceOptions.screenHeight = screenHeight;
|
|
273
|
+
if (!(0, core_namespaceObject.isUndefined)(devicePixelRatio)) deviceOptions.devicePixelRatio = devicePixelRatio;
|
|
274
|
+
const properties = (0, external_general_utils_js_namespaceObject.extend)((0, external_general_utils_js_namespaceObject.stripEmptyProperties)({
|
|
275
|
+
$os: os_name,
|
|
276
|
+
$os_version: os_version,
|
|
277
|
+
$browser: (0, core_namespaceObject.detectBrowser)(external_globals_js_namespaceObject.userAgent, navigator.vendor, browserHints, browserOptions),
|
|
278
|
+
$device: (0, core_namespaceObject.detectDevice)(external_globals_js_namespaceObject.userAgent),
|
|
279
|
+
$device_type: (0, core_namespaceObject.detectDeviceType)(external_globals_js_namespaceObject.userAgent, deviceOptions),
|
|
280
|
+
$timezone: getTimezone(),
|
|
281
|
+
$timezone_offset: getTimezoneOffset()
|
|
282
|
+
}), {
|
|
283
|
+
$current_url: (0, external_request_utils_js_namespaceObject.maskQueryParams)(disableCaptureUrlHashes ? (0, core_namespaceObject.stripUrlHash)(external_globals_js_namespaceObject.location?.href) : external_globals_js_namespaceObject.location?.href, paramsToMask, MASKED),
|
|
284
|
+
$host: external_globals_js_namespaceObject.location?.host,
|
|
285
|
+
$pathname: external_globals_js_namespaceObject.location?.pathname,
|
|
286
|
+
$raw_user_agent: external_globals_js_namespaceObject.userAgent.length > 1000 ? external_globals_js_namespaceObject.userAgent.substring(0, 997) + '...' : external_globals_js_namespaceObject.userAgent,
|
|
287
|
+
$browser_version: (0, core_namespaceObject.detectBrowserVersion)(external_globals_js_namespaceObject.userAgent, navigator.vendor, browserHints, browserOptions),
|
|
288
|
+
$browser_language: getBrowserLanguage(),
|
|
289
|
+
$browser_language_prefix: getBrowserLanguagePrefix(),
|
|
290
|
+
$screen_height: external_globals_js_namespaceObject.window?.screen.height,
|
|
291
|
+
$screen_width: external_globals_js_namespaceObject.window?.screen.width,
|
|
292
|
+
$viewport_height: external_globals_js_namespaceObject.window?.innerHeight,
|
|
293
|
+
$viewport_width: external_globals_js_namespaceObject.window?.innerWidth,
|
|
294
|
+
$lib: external_config_js_default().LIB_NAME,
|
|
295
|
+
$lib_version: external_config_js_default().LIB_VERSION,
|
|
296
|
+
$insert_id: Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10),
|
|
297
|
+
$time: Date.now() / 1000
|
|
298
|
+
});
|
|
299
|
+
if (external_config_js_default().SDK_DIST_CHANNEL) properties[external_constants_js_namespaceObject.SDK_DIST_CHANNEL] = external_config_js_default().SDK_DIST_CHANNEL;
|
|
300
|
+
return properties;
|
|
301
|
+
}
|
|
302
|
+
exports.CAMPAIGN_PARAMS = __webpack_exports__.CAMPAIGN_PARAMS;
|
|
303
|
+
exports.COOKIE_CAMPAIGN_PARAMS = __webpack_exports__.COOKIE_CAMPAIGN_PARAMS;
|
|
304
|
+
exports.EVENT_TO_PERSON_PROPERTIES = __webpack_exports__.EVENT_TO_PERSON_PROPERTIES;
|
|
305
|
+
exports.MASKED = __webpack_exports__.MASKED;
|
|
306
|
+
exports.PERSONAL_DATA_CAMPAIGN_PARAMS = __webpack_exports__.PERSONAL_DATA_CAMPAIGN_PARAMS;
|
|
307
|
+
exports.getBrowserDetectionHints = __webpack_exports__.getBrowserDetectionHints;
|
|
308
|
+
exports.getBrowserLanguage = __webpack_exports__.getBrowserLanguage;
|
|
309
|
+
exports.getBrowserLanguagePrefix = __webpack_exports__.getBrowserLanguagePrefix;
|
|
310
|
+
exports.getCampaignParams = __webpack_exports__.getCampaignParams;
|
|
311
|
+
exports.getEventProperties = __webpack_exports__.getEventProperties;
|
|
312
|
+
exports.getInitialPersonPropsFromInfo = __webpack_exports__.getInitialPersonPropsFromInfo;
|
|
313
|
+
exports.getPersonInfo = __webpack_exports__.getPersonInfo;
|
|
314
|
+
exports.getPersonPropsFromInfo = __webpack_exports__.getPersonPropsFromInfo;
|
|
315
|
+
exports.getReferrer = __webpack_exports__.getReferrer;
|
|
316
|
+
exports.getReferrerInfo = __webpack_exports__.getReferrerInfo;
|
|
317
|
+
exports.getReferringDomain = __webpack_exports__.getReferringDomain;
|
|
318
|
+
exports.getSearchInfo = __webpack_exports__.getSearchInfo;
|
|
319
|
+
exports.getTimezone = __webpack_exports__.getTimezone;
|
|
320
|
+
exports.getTimezoneOffset = __webpack_exports__.getTimezoneOffset;
|
|
321
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
322
|
+
"CAMPAIGN_PARAMS",
|
|
323
|
+
"COOKIE_CAMPAIGN_PARAMS",
|
|
324
|
+
"EVENT_TO_PERSON_PROPERTIES",
|
|
325
|
+
"MASKED",
|
|
326
|
+
"PERSONAL_DATA_CAMPAIGN_PARAMS",
|
|
327
|
+
"getBrowserDetectionHints",
|
|
328
|
+
"getBrowserLanguage",
|
|
329
|
+
"getBrowserLanguagePrefix",
|
|
330
|
+
"getCampaignParams",
|
|
331
|
+
"getEventProperties",
|
|
332
|
+
"getInitialPersonPropsFromInfo",
|
|
333
|
+
"getPersonInfo",
|
|
334
|
+
"getPersonPropsFromInfo",
|
|
335
|
+
"getReferrer",
|
|
336
|
+
"getReferrerInfo",
|
|
337
|
+
"getReferringDomain",
|
|
338
|
+
"getSearchInfo",
|
|
339
|
+
"getTimezone",
|
|
340
|
+
"getTimezoneOffset"
|
|
341
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
342
|
+
Object.defineProperty(exports, '__esModule', {
|
|
343
|
+
value: true
|
|
344
|
+
});
|