@sessionvision/core 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 +361 -0
- package/dist/react/capture/autocapture.d.ts +45 -0
- package/dist/react/capture/event.d.ts +29 -0
- package/dist/react/capture/pageview.d.ts +27 -0
- package/dist/react/capture/properties.d.ts +25 -0
- package/dist/react/core/config.d.ts +21 -0
- package/dist/react/core/init.d.ts +53 -0
- package/dist/react/core/queue.d.ts +22 -0
- package/dist/react/identity/anonymous.d.ts +30 -0
- package/dist/react/identity/identify.d.ts +46 -0
- package/dist/react/identity/session.d.ts +49 -0
- package/dist/react/index.cjs.js +48 -0
- package/dist/react/index.cjs.js.map +1 -0
- package/dist/react/index.d.ts +13 -0
- package/dist/react/index.esm.js +42 -0
- package/dist/react/index.esm.js.map +1 -0
- package/dist/react/react/SessionVisionProvider.d.ts +8 -0
- package/dist/react/react/context.d.ts +3 -0
- package/dist/react/react/hooks.d.ts +3 -0
- package/dist/react/react/index.d.ts +4 -0
- package/dist/react/stub.d.ts +9 -0
- package/dist/react/transport/buffer.d.ts +50 -0
- package/dist/react/transport/compress.d.ts +22 -0
- package/dist/react/transport/send.d.ts +30 -0
- package/dist/react/types.d.ts +228 -0
- package/dist/react/utils/dom.d.ts +51 -0
- package/dist/react/utils/pii.d.ts +26 -0
- package/dist/react/utils/selector.d.ts +12 -0
- package/dist/react/utils/storage.d.ts +44 -0
- package/dist/react/utils/uuid.d.ts +13 -0
- package/dist/react/vue/composables.d.ts +4 -0
- package/dist/react/vue/index.d.ts +2 -0
- package/dist/react/vue/plugin.d.ts +4 -0
- package/dist/sessionvision.cjs.js +1903 -0
- package/dist/sessionvision.cjs.js.map +1 -0
- package/dist/sessionvision.esm.js +1901 -0
- package/dist/sessionvision.esm.js.map +1 -0
- package/dist/sessionvision.js +1909 -0
- package/dist/sessionvision.js.map +1 -0
- package/dist/sessionvision.min.js +7 -0
- package/dist/sessionvision.min.js.map +1 -0
- package/dist/stub-template.ts +41 -0
- package/dist/stub.min.js +1 -0
- package/dist/types/capture/autocapture.d.ts +45 -0
- package/dist/types/capture/event.d.ts +29 -0
- package/dist/types/capture/pageview.d.ts +27 -0
- package/dist/types/capture/properties.d.ts +25 -0
- package/dist/types/core/config.d.ts +21 -0
- package/dist/types/core/init.d.ts +53 -0
- package/dist/types/core/queue.d.ts +22 -0
- package/dist/types/identity/anonymous.d.ts +30 -0
- package/dist/types/identity/identify.d.ts +46 -0
- package/dist/types/identity/session.d.ts +49 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/react/SessionVisionProvider.d.ts +8 -0
- package/dist/types/react/context.d.ts +3 -0
- package/dist/types/react/hooks.d.ts +3 -0
- package/dist/types/react/index.d.ts +4 -0
- package/dist/types/stub.d.ts +9 -0
- package/dist/types/transport/buffer.d.ts +50 -0
- package/dist/types/transport/compress.d.ts +22 -0
- package/dist/types/transport/send.d.ts +30 -0
- package/dist/types/types.d.ts +228 -0
- package/dist/types/utils/dom.d.ts +51 -0
- package/dist/types/utils/pii.d.ts +26 -0
- package/dist/types/utils/selector.d.ts +12 -0
- package/dist/types/utils/storage.d.ts +44 -0
- package/dist/types/utils/uuid.d.ts +13 -0
- package/dist/types/vue/composables.d.ts +4 -0
- package/dist/types/vue/index.d.ts +2 -0
- package/dist/types/vue/plugin.d.ts +4 -0
- package/dist/vue/capture/autocapture.d.ts +45 -0
- package/dist/vue/capture/event.d.ts +29 -0
- package/dist/vue/capture/pageview.d.ts +27 -0
- package/dist/vue/capture/properties.d.ts +25 -0
- package/dist/vue/core/config.d.ts +21 -0
- package/dist/vue/core/init.d.ts +53 -0
- package/dist/vue/core/queue.d.ts +22 -0
- package/dist/vue/identity/anonymous.d.ts +30 -0
- package/dist/vue/identity/identify.d.ts +46 -0
- package/dist/vue/identity/session.d.ts +49 -0
- package/dist/vue/index.cjs.js +43 -0
- package/dist/vue/index.cjs.js.map +1 -0
- package/dist/vue/index.d.ts +13 -0
- package/dist/vue/index.esm.js +38 -0
- package/dist/vue/index.esm.js.map +1 -0
- package/dist/vue/react/SessionVisionProvider.d.ts +8 -0
- package/dist/vue/react/context.d.ts +3 -0
- package/dist/vue/react/hooks.d.ts +3 -0
- package/dist/vue/react/index.d.ts +4 -0
- package/dist/vue/stub.d.ts +9 -0
- package/dist/vue/transport/buffer.d.ts +50 -0
- package/dist/vue/transport/compress.d.ts +22 -0
- package/dist/vue/transport/send.d.ts +30 -0
- package/dist/vue/types.d.ts +228 -0
- package/dist/vue/utils/dom.d.ts +51 -0
- package/dist/vue/utils/pii.d.ts +26 -0
- package/dist/vue/utils/selector.d.ts +12 -0
- package/dist/vue/utils/storage.d.ts +44 -0
- package/dist/vue/utils/uuid.d.ts +13 -0
- package/dist/vue/vue/composables.d.ts +4 -0
- package/dist/vue/vue/index.d.ts +2 -0
- package/dist/vue/vue/plugin.d.ts +4 -0
- package/package.json +109 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOM utility functions for element inspection and event handling
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Get the visible text content of an element, truncated to maxLength
|
|
6
|
+
*/
|
|
7
|
+
export declare function getElementText(element: Element, maxLength?: number): string;
|
|
8
|
+
/**
|
|
9
|
+
* Get CSS classes of an element as a space-separated string
|
|
10
|
+
*/
|
|
11
|
+
export declare function getElementClasses(element: Element): string;
|
|
12
|
+
/**
|
|
13
|
+
* Get the tag name of an element in lowercase
|
|
14
|
+
*/
|
|
15
|
+
export declare function getElementTag(element: Element): string;
|
|
16
|
+
/**
|
|
17
|
+
* Get the ID of an element, or null if not present
|
|
18
|
+
*/
|
|
19
|
+
export declare function getElementId(element: Element): string | null;
|
|
20
|
+
/**
|
|
21
|
+
* Get the href attribute for anchor elements
|
|
22
|
+
*/
|
|
23
|
+
export declare function getElementHref(element: Element): string | null;
|
|
24
|
+
/**
|
|
25
|
+
* Check if an element should be ignored for tracking
|
|
26
|
+
*/
|
|
27
|
+
export declare function shouldIgnoreElement(element: Element): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Check if an element is interactive (clickable, input, etc.)
|
|
30
|
+
*/
|
|
31
|
+
export declare function isInteractiveElement(element: Element): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Get the closest interactive parent element
|
|
34
|
+
*/
|
|
35
|
+
export declare function getInteractiveParent(element: Element): Element | null;
|
|
36
|
+
/**
|
|
37
|
+
* Safe document ready check
|
|
38
|
+
*/
|
|
39
|
+
export declare function onDocumentReady(callback: () => void): void;
|
|
40
|
+
/**
|
|
41
|
+
* Get the current page URL
|
|
42
|
+
*/
|
|
43
|
+
export declare function getCurrentUrl(): string;
|
|
44
|
+
/**
|
|
45
|
+
* Get the document referrer
|
|
46
|
+
*/
|
|
47
|
+
export declare function getReferrer(): string;
|
|
48
|
+
/**
|
|
49
|
+
* Get the document title
|
|
50
|
+
*/
|
|
51
|
+
export declare function getDocumentTitle(): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PII (Personally Identifiable Information) detection utility
|
|
3
|
+
* Detects and masks sensitive data patterns in text
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Check if text contains PII
|
|
7
|
+
*/
|
|
8
|
+
export declare function containsPII(text: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Mask PII in text
|
|
11
|
+
*/
|
|
12
|
+
export declare function maskPII(text: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Detect which types of PII are present in text
|
|
15
|
+
*/
|
|
16
|
+
export declare function detectPIITypes(text: string): string[];
|
|
17
|
+
/**
|
|
18
|
+
* Check if a string looks like a password field value
|
|
19
|
+
* (all masked characters or very short alphanumeric)
|
|
20
|
+
*/
|
|
21
|
+
export declare function looksLikePassword(value: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Safely mask a value that might be sensitive
|
|
24
|
+
* Returns masked version if PII detected, original otherwise
|
|
25
|
+
*/
|
|
26
|
+
export declare function safeMaskValue(value: string, alwaysMask?: boolean): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSS Selector generation utility
|
|
3
|
+
* Generates stable, unique selectors for DOM elements
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Generate a CSS selector for an element
|
|
7
|
+
* Priority:
|
|
8
|
+
* 1. data-sessionvision-id attribute
|
|
9
|
+
* 2. ID attribute (if unique)
|
|
10
|
+
* 3. Path-based selector with classes
|
|
11
|
+
*/
|
|
12
|
+
export declare function generateSelector(element: Element): string;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage utility for localStorage and sessionStorage operations
|
|
3
|
+
* Provides safe access with error handling for environments where storage is unavailable
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Check if localStorage is available
|
|
7
|
+
*/
|
|
8
|
+
export declare function isLocalStorageAvailable(): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Check if sessionStorage is available
|
|
11
|
+
*/
|
|
12
|
+
export declare function isSessionStorageAvailable(): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Get a value from localStorage
|
|
15
|
+
*/
|
|
16
|
+
export declare function getLocalStorage<T>(key: string): T | null;
|
|
17
|
+
/**
|
|
18
|
+
* Set a value in localStorage
|
|
19
|
+
*/
|
|
20
|
+
export declare function setLocalStorage<T>(key: string, value: T): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Remove a value from localStorage
|
|
23
|
+
*/
|
|
24
|
+
export declare function removeLocalStorage(key: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Get a value from sessionStorage
|
|
27
|
+
*/
|
|
28
|
+
export declare function getSessionStorage<T>(key: string): T | null;
|
|
29
|
+
/**
|
|
30
|
+
* Set a value in sessionStorage
|
|
31
|
+
*/
|
|
32
|
+
export declare function setSessionStorage<T>(key: string, value: T): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Remove a value from sessionStorage
|
|
35
|
+
*/
|
|
36
|
+
export declare function removeSessionStorage(key: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Get a raw string value from localStorage (without JSON parsing)
|
|
39
|
+
*/
|
|
40
|
+
export declare function getLocalStorageRaw(key: string): string | null;
|
|
41
|
+
/**
|
|
42
|
+
* Set a raw string value in localStorage (without JSON stringifying)
|
|
43
|
+
*/
|
|
44
|
+
export declare function setLocalStorageRaw(key: string, value: string): boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UUID v4 generation utility
|
|
3
|
+
* Generates cryptographically random UUIDs when available, falls back to Math.random
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Generate a UUID v4 string
|
|
7
|
+
* Uses crypto.randomUUID() when available, falls back to manual generation
|
|
8
|
+
*/
|
|
9
|
+
export declare function generateUUID(): string;
|
|
10
|
+
/**
|
|
11
|
+
* Validate a UUID string format
|
|
12
|
+
*/
|
|
13
|
+
export declare function isValidUUID(uuid: string): boolean;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { EventProperties, SessionVisionAPI, UserTraits } from '../types';
|
|
2
|
+
export declare function useSessionVision(): SessionVisionAPI;
|
|
3
|
+
export declare function useCapture(): (eventName: string, properties?: EventProperties) => void;
|
|
4
|
+
export declare function useIdentify(): (userId: string, traits?: UserTraits) => void;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { InjectionKey, Plugin } from 'vue';
|
|
2
|
+
import type { SessionVisionAPI, SessionVisionConfig } from '../types';
|
|
3
|
+
export declare const sessionVisionKey: InjectionKey<SessionVisionAPI>;
|
|
4
|
+
export declare function createSessionVision(apiKey: string, options?: Omit<SessionVisionConfig, 'apiHost'>): Plugin;
|
package/package.json
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sessionvision/core",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Session Vision client-side tracking library",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/sessionvision.cjs.js",
|
|
7
|
+
"module": "dist/sessionvision.esm.js",
|
|
8
|
+
"types": "dist/types/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/sessionvision.esm.js",
|
|
12
|
+
"require": "./dist/sessionvision.cjs.js",
|
|
13
|
+
"types": "./dist/types/index.d.ts"
|
|
14
|
+
},
|
|
15
|
+
"./react": {
|
|
16
|
+
"import": "./dist/react/index.esm.js",
|
|
17
|
+
"require": "./dist/react/index.cjs.js",
|
|
18
|
+
"types": "./dist/react/index.d.ts"
|
|
19
|
+
},
|
|
20
|
+
"./vue": {
|
|
21
|
+
"import": "./dist/vue/index.esm.js",
|
|
22
|
+
"require": "./dist/vue/index.cjs.js",
|
|
23
|
+
"types": "./dist/vue/index.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"./stub": {
|
|
26
|
+
"import": "./dist/stub-template.ts",
|
|
27
|
+
"types": "./dist/stub-template.ts"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist"
|
|
32
|
+
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "rollup -c && node scripts/generate-stub-export.js",
|
|
35
|
+
"build:watch": "rollup -c -w",
|
|
36
|
+
"test": "jest",
|
|
37
|
+
"test:watch": "jest --watch",
|
|
38
|
+
"test:coverage": "jest --coverage",
|
|
39
|
+
"test:e2e": "playwright test",
|
|
40
|
+
"test:e2e:ui": "playwright test --ui",
|
|
41
|
+
"test:e2e:headed": "playwright test --headed",
|
|
42
|
+
"test:e2e:debug": "playwright test --debug",
|
|
43
|
+
"lint": "eslint src",
|
|
44
|
+
"lint:fix": "eslint src --fix",
|
|
45
|
+
"format": "prettier --write 'src/**/*.ts'",
|
|
46
|
+
"format:check": "prettier --check 'src/**/*.ts'",
|
|
47
|
+
"typecheck": "tsc --noEmit",
|
|
48
|
+
"clean": "rm -rf dist",
|
|
49
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
50
|
+
},
|
|
51
|
+
"keywords": [
|
|
52
|
+
"analytics",
|
|
53
|
+
"tracking",
|
|
54
|
+
"session-recording",
|
|
55
|
+
"product-analytics"
|
|
56
|
+
],
|
|
57
|
+
"author": "Session Vision",
|
|
58
|
+
"license": "MIT",
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@testing-library/jest-dom": "^6.5.0",
|
|
61
|
+
"@testing-library/react": "^16.0.1",
|
|
62
|
+
"@testing-library/user-event": "^14.5.2",
|
|
63
|
+
"@eslint/js": "^9.18.0",
|
|
64
|
+
"@playwright/test": "^1.41.0",
|
|
65
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
66
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
67
|
+
"@rollup/plugin-replace": "^5.0.5",
|
|
68
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
69
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
70
|
+
"@types/jest": "^29.5.12",
|
|
71
|
+
"@types/react": "^18.3.12",
|
|
72
|
+
"@types/react-dom": "^18.3.0",
|
|
73
|
+
"@vue/test-utils": "^2.4.6",
|
|
74
|
+
"eslint": "^9.18.0",
|
|
75
|
+
"eslint-config-prettier": "^10.0.1",
|
|
76
|
+
"jest": "^29.7.0",
|
|
77
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
78
|
+
"prettier": "^3.4.2",
|
|
79
|
+
"rollup": "^4.9.6",
|
|
80
|
+
"react": "^18.3.1",
|
|
81
|
+
"react-dom": "^18.3.1",
|
|
82
|
+
"ts-jest": "^29.1.2",
|
|
83
|
+
"tslib": "^2.6.2",
|
|
84
|
+
"typescript": "^5.3.3",
|
|
85
|
+
"typescript-eslint": "^8.21.0",
|
|
86
|
+
"vue": "^3.5.12"
|
|
87
|
+
},
|
|
88
|
+
"peerDependencies": {
|
|
89
|
+
"react": ">=17.0.0",
|
|
90
|
+
"vue": ">=3.0.0"
|
|
91
|
+
},
|
|
92
|
+
"peerDependenciesMeta": {
|
|
93
|
+
"react": {
|
|
94
|
+
"optional": true
|
|
95
|
+
},
|
|
96
|
+
"vue": {
|
|
97
|
+
"optional": true
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"engines": {
|
|
101
|
+
"node": ">=18.0.0"
|
|
102
|
+
},
|
|
103
|
+
"browserslist": [
|
|
104
|
+
"last 2 Chrome versions",
|
|
105
|
+
"last 2 Firefox versions",
|
|
106
|
+
"last 2 Safari versions",
|
|
107
|
+
"last 2 Edge versions"
|
|
108
|
+
]
|
|
109
|
+
}
|