@posthog/browser-common 0.1.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 +17 -4
- 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/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 +37 -3
- package/LICENSE +0 -353
package/README.md
CHANGED
|
@@ -101,6 +101,18 @@ into your bundle — each extension stays independently tree-shakable and lazily
|
|
|
101
101
|
loadable. An extension that provides a capability declares its token(s) in
|
|
102
102
|
`provides`.
|
|
103
103
|
|
|
104
|
+
## Utilities
|
|
105
|
+
|
|
106
|
+
Reusable browser utilities are exposed through `utils/*` subpaths, but they are
|
|
107
|
+
intentionally not re-exported from the package root or a utility barrel. Import
|
|
108
|
+
the exact file you need so lazy extension bundles do not pull in unrelated
|
|
109
|
+
helpers:
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
import { createLogger } from '@posthog/browser-common/utils/logger'
|
|
113
|
+
import { formDataToQuery } from '@posthog/browser-common/utils/request-utils'
|
|
114
|
+
```
|
|
115
|
+
|
|
104
116
|
## Authoring
|
|
105
117
|
|
|
106
118
|
See the **`develop-extension`** skill
|
|
@@ -112,7 +124,8 @@ v1 → `Client` porting map.
|
|
|
112
124
|
|
|
113
125
|
## Status
|
|
114
126
|
|
|
115
|
-
Early and internal. The package currently defines the extension contract
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
the first
|
|
127
|
+
Early and internal. The package currently defines the extension contract, the
|
|
128
|
+
shared `Publisher` helper, and directly imported browser utilities under
|
|
129
|
+
`utils/*` subpaths. Additional shared runtime helpers — key-value stores, the
|
|
130
|
+
registry implementation, and a test `Client` — will land alongside the first
|
|
131
|
+
ported extension.
|
package/dist/config.d.ts
ADDED
package/dist/config.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
default: ()=>__WEBPACK_DEFAULT_EXPORT__
|
|
28
|
+
});
|
|
29
|
+
const packageVersion = "0.2.0";
|
|
30
|
+
const Config = {
|
|
31
|
+
DEBUG: false,
|
|
32
|
+
LIB_VERSION: packageVersion,
|
|
33
|
+
LIB_NAME: 'browser-common',
|
|
34
|
+
JS_SDK_VERSION: packageVersion
|
|
35
|
+
};
|
|
36
|
+
const __WEBPACK_DEFAULT_EXPORT__ = Config;
|
|
37
|
+
exports["default"] = __webpack_exports__["default"];
|
|
38
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
39
|
+
"default"
|
|
40
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
41
|
+
Object.defineProperty(exports, '__esModule', {
|
|
42
|
+
value: true
|
|
43
|
+
});
|
package/dist/config.mjs
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
SDK_DIST_CHANNEL: ()=>SDK_DIST_CHANNEL,
|
|
28
|
+
TOOLBAR_CONTAINER_CLASS: ()=>TOOLBAR_CONTAINER_CLASS,
|
|
29
|
+
TOOLBAR_ID: ()=>TOOLBAR_ID
|
|
30
|
+
});
|
|
31
|
+
const TOOLBAR_ID = '__POSTHOG_TOOLBAR__';
|
|
32
|
+
const TOOLBAR_CONTAINER_CLASS = 'toolbar-global-fade-container';
|
|
33
|
+
const SDK_DIST_CHANNEL = '$sdk_dist_channel';
|
|
34
|
+
exports.SDK_DIST_CHANNEL = __webpack_exports__.SDK_DIST_CHANNEL;
|
|
35
|
+
exports.TOOLBAR_CONTAINER_CLASS = __webpack_exports__.TOOLBAR_CONTAINER_CLASS;
|
|
36
|
+
exports.TOOLBAR_ID = __webpack_exports__.TOOLBAR_ID;
|
|
37
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
38
|
+
"SDK_DIST_CHANNEL",
|
|
39
|
+
"TOOLBAR_CONTAINER_CLASS",
|
|
40
|
+
"TOOLBAR_ID"
|
|
41
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
42
|
+
Object.defineProperty(exports, '__esModule', {
|
|
43
|
+
value: true
|
|
44
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
var __webpack_exports__ = {};
|
|
2
|
+
if ('function' != typeof Array.prototype.at) Object.defineProperty(Array.prototype, 'at', {
|
|
3
|
+
value: function(index) {
|
|
4
|
+
const len = this.length;
|
|
5
|
+
let relativeIndex = Math.trunc(index) || 0;
|
|
6
|
+
if (relativeIndex < 0) relativeIndex += len;
|
|
7
|
+
return relativeIndex < 0 || relativeIndex >= len ? void 0 : this[relativeIndex];
|
|
8
|
+
},
|
|
9
|
+
writable: true,
|
|
10
|
+
enumerable: false,
|
|
11
|
+
configurable: true
|
|
12
|
+
});
|
|
13
|
+
for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
14
|
+
Object.defineProperty(exports, '__esModule', {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
if ('function' != typeof Array.prototype.at) Object.defineProperty(Array.prototype, 'at', {
|
|
2
|
+
value: function(index) {
|
|
3
|
+
const len = this.length;
|
|
4
|
+
let relativeIndex = Math.trunc(index) || 0;
|
|
5
|
+
if (relativeIndex < 0) relativeIndex += len;
|
|
6
|
+
return relativeIndex < 0 || relativeIndex >= len ? void 0 : this[relativeIndex];
|
|
7
|
+
},
|
|
8
|
+
writable: true,
|
|
9
|
+
enumerable: false,
|
|
10
|
+
configurable: true
|
|
11
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AutocaptureConfig, PostHogConfig, Properties } from '@posthog/types';
|
|
2
|
+
import { type UrlTargetingInstance } from './url-targeting-utils';
|
|
3
|
+
export declare const MAX_DOM_ANCESTOR_DEPTH = 1000;
|
|
4
|
+
export declare function splitClassString(s: string): string[];
|
|
5
|
+
export declare function getClassNames(el: Element): string[];
|
|
6
|
+
export declare function makeSafeText(s: string | null | undefined): string | null;
|
|
7
|
+
export declare function getSafeText(el: Element): string;
|
|
8
|
+
export declare function getEventTarget(e: Event): Element | null;
|
|
9
|
+
export declare const autocaptureCompatibleElements: string[];
|
|
10
|
+
export declare function getParentElement(curEl: Element): Element | false;
|
|
11
|
+
export declare const DEFAULT_CONTENT_IGNORELIST_WITH_STEPPERS: string[];
|
|
12
|
+
export declare function shouldCaptureDeadClick(el: Element | null, _config: PostHogConfig['capture_dead_clicks']): boolean;
|
|
13
|
+
export declare function isTextSelectionTarget(el: Element | null): boolean;
|
|
14
|
+
export declare function shouldCaptureRageclick(el: Element | null, _config: PostHogConfig['rageclick']): boolean;
|
|
15
|
+
export declare function shouldSkipDeadClick(el: Element | null): boolean;
|
|
16
|
+
export declare function shouldCaptureDomEvent(el: Element, event: Event, autocaptureConfig?: AutocaptureConfig | undefined, captureOnAnyElement?: boolean, allowedEventTypes?: string[], instance?: UrlTargetingInstance): boolean;
|
|
17
|
+
export declare function shouldCaptureElement(el: Element): boolean;
|
|
18
|
+
export declare function isSensitiveElement(el: Element): boolean;
|
|
19
|
+
export declare function shouldCaptureValue(value: string, anchorRegexes?: boolean): boolean;
|
|
20
|
+
export declare function isAngularStyleAttr(attributeName: string): boolean;
|
|
21
|
+
export declare function getDirectAndNestedSpanText(target: Element): string;
|
|
22
|
+
export declare function getNestedSpanText(target: Element): string;
|
|
23
|
+
export declare function getElementsChainString(elements: Properties[]): string;
|