@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,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event buffer module
|
|
3
|
+
* Buffers events and flushes them periodically or when buffer is full
|
|
4
|
+
*/
|
|
5
|
+
import { CapturedEvent, ResolvedConfig } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* Set the configuration
|
|
8
|
+
*/
|
|
9
|
+
export declare function setBufferConfig(cfg: ResolvedConfig): void;
|
|
10
|
+
/**
|
|
11
|
+
* Add an event to the buffer
|
|
12
|
+
*/
|
|
13
|
+
export declare function addToBuffer(event: CapturedEvent): void;
|
|
14
|
+
/**
|
|
15
|
+
* Flush the event buffer
|
|
16
|
+
* Sends all buffered events to the server
|
|
17
|
+
*/
|
|
18
|
+
export declare function flush(): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Start the flush timer
|
|
21
|
+
*/
|
|
22
|
+
export declare function startFlushTimer(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Stop the flush timer
|
|
25
|
+
*/
|
|
26
|
+
export declare function stopFlushTimer(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Initialize visibility change handler for flushing on tab hide
|
|
29
|
+
*/
|
|
30
|
+
export declare function initVisibilityHandler(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Get the current buffer size
|
|
33
|
+
*/
|
|
34
|
+
export declare function getBufferSize(): number;
|
|
35
|
+
/**
|
|
36
|
+
* Check if the buffer is full
|
|
37
|
+
*/
|
|
38
|
+
export declare function isBufferFull(): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Clear the buffer (for testing or shutdown)
|
|
41
|
+
*/
|
|
42
|
+
export declare function clearBuffer(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Get buffer contents (for testing)
|
|
45
|
+
*/
|
|
46
|
+
export declare function _getBuffer(): CapturedEvent[];
|
|
47
|
+
/**
|
|
48
|
+
* Reset buffer state (for testing)
|
|
49
|
+
*/
|
|
50
|
+
export declare function _reset(): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payload compression module
|
|
3
|
+
* Uses CompressionStream API when available
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Check if compression is supported
|
|
7
|
+
*/
|
|
8
|
+
export declare function isCompressionSupported(): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Compress a string using gzip
|
|
11
|
+
* Returns the compressed data as a Blob, or null if compression is not supported
|
|
12
|
+
*/
|
|
13
|
+
export declare function compressPayload(data: string): Promise<Blob | null>;
|
|
14
|
+
/**
|
|
15
|
+
* Get the size of data in bytes
|
|
16
|
+
*/
|
|
17
|
+
export declare function getByteSize(data: string): number;
|
|
18
|
+
/**
|
|
19
|
+
* Check if payload should be compressed (based on size threshold)
|
|
20
|
+
* Only compress if payload is larger than 1KB
|
|
21
|
+
*/
|
|
22
|
+
export declare function shouldCompress(data: string): boolean;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP transport module
|
|
3
|
+
* Handles sending events to the ingest API
|
|
4
|
+
*/
|
|
5
|
+
import { EventBatchPayload, ResolvedConfig } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* Set the configuration
|
|
8
|
+
*/
|
|
9
|
+
export declare function setTransportConfig(cfg: ResolvedConfig): void;
|
|
10
|
+
/**
|
|
11
|
+
* Send events to the ingest API
|
|
12
|
+
* Handles compression and retry logic
|
|
13
|
+
*/
|
|
14
|
+
export declare function sendEvents(payload: EventBatchPayload): Promise<boolean>;
|
|
15
|
+
/**
|
|
16
|
+
* Get the number of consecutive failures
|
|
17
|
+
*/
|
|
18
|
+
export declare function getConsecutiveFailures(): number;
|
|
19
|
+
/**
|
|
20
|
+
* Check if we should stop retrying (3+ consecutive failures)
|
|
21
|
+
*/
|
|
22
|
+
export declare function shouldStopRetrying(): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Reset failure counter (for testing)
|
|
25
|
+
*/
|
|
26
|
+
export declare function _resetFailures(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Reset config (for testing)
|
|
29
|
+
*/
|
|
30
|
+
export declare function _resetConfig(): void;
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Vision Snippet Type Definitions
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Autocapture configuration options
|
|
6
|
+
*/
|
|
7
|
+
export interface AutocaptureConfig {
|
|
8
|
+
/** Capture $pageview events (default: true) */
|
|
9
|
+
pageview?: boolean;
|
|
10
|
+
/** Capture $click events (default: true) */
|
|
11
|
+
clicks?: boolean;
|
|
12
|
+
/** Capture $form_submit events (default: true) */
|
|
13
|
+
formSubmit?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* SDK configuration options passed to init()
|
|
17
|
+
*/
|
|
18
|
+
export interface SessionVisionConfig {
|
|
19
|
+
/** CDN endpoint for SDK loading (default: 'https://cdn.sessionvision.com') */
|
|
20
|
+
apiHost?: string;
|
|
21
|
+
/** API endpoint for event ingestion and config (default: 'https://app.sessionvision.com') */
|
|
22
|
+
ingestHost?: string;
|
|
23
|
+
/** SDK version to load (default: 'latest') */
|
|
24
|
+
version?: string;
|
|
25
|
+
/** Enable console logging of all events (default: false) */
|
|
26
|
+
debug?: boolean;
|
|
27
|
+
/** Disable all tracking for consent management (default: false) */
|
|
28
|
+
optOut?: boolean;
|
|
29
|
+
/** Mask all input values in recordings (default: true) */
|
|
30
|
+
maskAllInputs?: boolean;
|
|
31
|
+
/** Enable/disable auto-capture (default: true) */
|
|
32
|
+
autocapture?: boolean | AutocaptureConfig;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Internal resolved configuration
|
|
36
|
+
*/
|
|
37
|
+
export interface ResolvedConfig {
|
|
38
|
+
projectToken: string;
|
|
39
|
+
apiHost: string;
|
|
40
|
+
ingestHost: string;
|
|
41
|
+
version: string;
|
|
42
|
+
debug: boolean;
|
|
43
|
+
optOut: boolean;
|
|
44
|
+
maskAllInputs: boolean;
|
|
45
|
+
autocapture: {
|
|
46
|
+
pageview: boolean;
|
|
47
|
+
clicks: boolean;
|
|
48
|
+
formSubmit: boolean;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Remote configuration fetched from server
|
|
53
|
+
*/
|
|
54
|
+
export interface RemoteConfig {
|
|
55
|
+
recording?: {
|
|
56
|
+
enabled: boolean;
|
|
57
|
+
sampleRate: number;
|
|
58
|
+
};
|
|
59
|
+
session?: {
|
|
60
|
+
timeoutMinutes: number;
|
|
61
|
+
};
|
|
62
|
+
version?: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* User traits for identify()
|
|
66
|
+
*/
|
|
67
|
+
export interface UserTraits {
|
|
68
|
+
email?: string;
|
|
69
|
+
name?: string;
|
|
70
|
+
[key: string]: unknown;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Event properties
|
|
74
|
+
*/
|
|
75
|
+
export interface EventProperties {
|
|
76
|
+
[key: string]: unknown;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Automatic properties attached to every event
|
|
80
|
+
*/
|
|
81
|
+
export interface AutomaticProperties {
|
|
82
|
+
$current_url: string;
|
|
83
|
+
$referrer: string;
|
|
84
|
+
$browser: string;
|
|
85
|
+
$browser_version: string;
|
|
86
|
+
$os: string;
|
|
87
|
+
$device_type: string;
|
|
88
|
+
$screen_width: number;
|
|
89
|
+
$screen_height: number;
|
|
90
|
+
$viewport_width: number;
|
|
91
|
+
$viewport_height: number;
|
|
92
|
+
$timezone: string;
|
|
93
|
+
$locale: string;
|
|
94
|
+
$connection_type: string | null;
|
|
95
|
+
$lib_version: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Internal event structure
|
|
99
|
+
*/
|
|
100
|
+
export interface CapturedEvent {
|
|
101
|
+
event: string;
|
|
102
|
+
timestamp: number;
|
|
103
|
+
properties: EventProperties & Partial<AutomaticProperties>;
|
|
104
|
+
anonymousId: string;
|
|
105
|
+
userId: string | null;
|
|
106
|
+
sessionId: string;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Event batch payload sent to server
|
|
110
|
+
*/
|
|
111
|
+
export interface EventBatchPayload {
|
|
112
|
+
projectToken: string;
|
|
113
|
+
events: CapturedEvent[];
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Click event properties
|
|
117
|
+
*/
|
|
118
|
+
export interface ClickEventProperties extends EventProperties {
|
|
119
|
+
$element_tag: string;
|
|
120
|
+
$element_text: string;
|
|
121
|
+
$element_classes: string;
|
|
122
|
+
$element_id: string | null;
|
|
123
|
+
$element_selector: string;
|
|
124
|
+
$element_href: string | null;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Form submit event properties
|
|
128
|
+
*/
|
|
129
|
+
export interface FormSubmitEventProperties extends EventProperties {
|
|
130
|
+
$form_id: string | null;
|
|
131
|
+
$form_action: string;
|
|
132
|
+
$form_method: string;
|
|
133
|
+
$form_name: string | null;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Pageview event properties
|
|
137
|
+
*/
|
|
138
|
+
export interface PageviewEventProperties extends EventProperties {
|
|
139
|
+
$current_url: string;
|
|
140
|
+
$referrer: string;
|
|
141
|
+
$title: string;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Session data stored in sessionStorage
|
|
145
|
+
*/
|
|
146
|
+
export interface SessionData {
|
|
147
|
+
id: string;
|
|
148
|
+
lastActivity: number;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Identity data stored in localStorage
|
|
152
|
+
*/
|
|
153
|
+
export interface IdentityData {
|
|
154
|
+
anonymousId: string;
|
|
155
|
+
userId: string | null;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Registered properties stored in localStorage
|
|
159
|
+
*/
|
|
160
|
+
export interface RegisteredProperties {
|
|
161
|
+
[key: string]: unknown;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Queued method call before SDK loads
|
|
165
|
+
*/
|
|
166
|
+
export interface QueuedCall {
|
|
167
|
+
method: string;
|
|
168
|
+
args: unknown[];
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Public API interface
|
|
172
|
+
*/
|
|
173
|
+
export interface SessionVisionAPI {
|
|
174
|
+
/** Initialize the SDK with project token and config */
|
|
175
|
+
init(projectToken: string, config?: SessionVisionConfig): void;
|
|
176
|
+
/** Capture a custom event */
|
|
177
|
+
capture(eventName: string, properties?: EventProperties): void;
|
|
178
|
+
/** Identify a user */
|
|
179
|
+
identify(userId: string, traits?: UserTraits): void;
|
|
180
|
+
/** Reset identity (for logout) */
|
|
181
|
+
reset(): void;
|
|
182
|
+
/** Get the current distinct ID (userId if identified, anonymousId otherwise) */
|
|
183
|
+
getDistinctId(): string;
|
|
184
|
+
/** Register properties to be sent with every event */
|
|
185
|
+
register(properties: EventProperties): void;
|
|
186
|
+
/** Register properties only if they don't already exist */
|
|
187
|
+
registerOnce(properties: EventProperties): void;
|
|
188
|
+
/** SDK version */
|
|
189
|
+
version: string;
|
|
190
|
+
/** Internal: queued method calls before SDK loads */
|
|
191
|
+
_q?: QueuedCall[];
|
|
192
|
+
/** Internal: init calls */
|
|
193
|
+
_i?: Array<[string, SessionVisionConfig?]>;
|
|
194
|
+
/** Internal: SDK version marker */
|
|
195
|
+
__SV?: number;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Storage key constants
|
|
199
|
+
*/
|
|
200
|
+
export declare const STORAGE_KEYS: {
|
|
201
|
+
readonly ANONYMOUS_ID: "sessionvision_anonymous_id";
|
|
202
|
+
readonly USER_ID: "sessionvision_user_id";
|
|
203
|
+
readonly SESSION: "sessionvision_session";
|
|
204
|
+
readonly REGISTERED_PROPS: "sessionvision_registered";
|
|
205
|
+
readonly REGISTERED_ONCE_PROPS: "sessionvision_registered_once";
|
|
206
|
+
readonly CONFIG_CACHE: "sessionvision_config";
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* Default configuration values
|
|
210
|
+
*/
|
|
211
|
+
export declare const DEFAULT_CONFIG: Omit<ResolvedConfig, 'projectToken'>;
|
|
212
|
+
/**
|
|
213
|
+
* Session timeout in milliseconds (30 minutes)
|
|
214
|
+
*/
|
|
215
|
+
export declare const SESSION_TIMEOUT_MS: number;
|
|
216
|
+
/**
|
|
217
|
+
* Event buffer configuration
|
|
218
|
+
*/
|
|
219
|
+
export declare const BUFFER_CONFIG: {
|
|
220
|
+
readonly MAX_EVENTS: 10;
|
|
221
|
+
readonly FLUSH_INTERVAL_MS: 5000;
|
|
222
|
+
readonly MAX_RETRIES: 3;
|
|
223
|
+
readonly RETRY_DELAYS_MS: readonly [1000, 2000, 4000];
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Config cache TTL in milliseconds (1 hour)
|
|
227
|
+
*/
|
|
228
|
+
export declare const CONFIG_CACHE_TTL_MS: number;
|
|
@@ -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;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Autocapture module
|
|
3
|
+
* Handles automatic capture of clicks and form submissions
|
|
4
|
+
*/
|
|
5
|
+
import { ResolvedConfig } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* Set the configuration
|
|
8
|
+
*/
|
|
9
|
+
export declare function setAutocaptureConfig(cfg: ResolvedConfig): void;
|
|
10
|
+
/**
|
|
11
|
+
* Initialize click tracking
|
|
12
|
+
*/
|
|
13
|
+
export declare function initClickTracking(): void;
|
|
14
|
+
/**
|
|
15
|
+
* Stop click tracking
|
|
16
|
+
*/
|
|
17
|
+
export declare function stopClickTracking(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Initialize form submission tracking
|
|
20
|
+
*/
|
|
21
|
+
export declare function initFormTracking(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Stop form submission tracking
|
|
24
|
+
*/
|
|
25
|
+
export declare function stopFormTracking(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Initialize all autocapture based on configuration
|
|
28
|
+
*/
|
|
29
|
+
export declare function initAutocapture(cfg: ResolvedConfig): void;
|
|
30
|
+
/**
|
|
31
|
+
* Stop all autocapture
|
|
32
|
+
*/
|
|
33
|
+
export declare function stopAutocapture(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Check if click tracking is active
|
|
36
|
+
*/
|
|
37
|
+
export declare function isClickTrackingEnabled(): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Check if form tracking is active
|
|
40
|
+
*/
|
|
41
|
+
export declare function isFormTrackingEnabled(): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Reset for testing
|
|
44
|
+
*/
|
|
45
|
+
export declare function _reset(): void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event capture module
|
|
3
|
+
* Core event capture functionality
|
|
4
|
+
*/
|
|
5
|
+
import { CapturedEvent, EventProperties, ResolvedConfig } from '../types';
|
|
6
|
+
type EventCallback = (event: CapturedEvent) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Set the configuration
|
|
9
|
+
*/
|
|
10
|
+
export declare function setConfig(cfg: ResolvedConfig): void;
|
|
11
|
+
/**
|
|
12
|
+
* Set the callback to be called when an event is captured
|
|
13
|
+
*/
|
|
14
|
+
export declare function setEventCallback(callback: EventCallback): void;
|
|
15
|
+
/**
|
|
16
|
+
* Capture an event
|
|
17
|
+
*/
|
|
18
|
+
export declare function captureEvent(eventName: string, properties?: EventProperties, options?: {
|
|
19
|
+
includeAutoProperties?: boolean;
|
|
20
|
+
}): void;
|
|
21
|
+
/**
|
|
22
|
+
* Capture an internal/system event (like $identify)
|
|
23
|
+
*/
|
|
24
|
+
export declare function captureSystemEvent(eventName: string, properties?: EventProperties): void;
|
|
25
|
+
/**
|
|
26
|
+
* Clear callbacks (for testing)
|
|
27
|
+
*/
|
|
28
|
+
export declare function _clearCallbacks(): void;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pageview tracking module
|
|
3
|
+
* Handles initial page load and SPA navigation
|
|
4
|
+
*/
|
|
5
|
+
import { PageviewEventProperties } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* Capture a pageview event
|
|
8
|
+
*/
|
|
9
|
+
export declare function capturePageview(customProperties?: Partial<PageviewEventProperties>): void;
|
|
10
|
+
/**
|
|
11
|
+
* Initialize pageview tracking
|
|
12
|
+
* - Captures initial pageview
|
|
13
|
+
* - Listens for SPA navigation (pushState, replaceState, popstate)
|
|
14
|
+
*/
|
|
15
|
+
export declare function initPageviewTracking(): void;
|
|
16
|
+
/**
|
|
17
|
+
* Stop pageview tracking
|
|
18
|
+
*/
|
|
19
|
+
export declare function stopPageviewTracking(): void;
|
|
20
|
+
/**
|
|
21
|
+
* Check if pageview tracking is initialized
|
|
22
|
+
*/
|
|
23
|
+
export declare function isPageviewTrackingActive(): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Reset for testing
|
|
26
|
+
*/
|
|
27
|
+
export declare function _reset(): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Automatic properties module
|
|
3
|
+
* Collects browser, device, and environment information
|
|
4
|
+
*/
|
|
5
|
+
import { AutomaticProperties, EventProperties } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* Get all automatic properties
|
|
8
|
+
*/
|
|
9
|
+
export declare function getAutomaticProperties(): AutomaticProperties;
|
|
10
|
+
/**
|
|
11
|
+
* Get registered properties (properties sent with every event)
|
|
12
|
+
*/
|
|
13
|
+
export declare function getRegisteredProperties(): EventProperties;
|
|
14
|
+
/**
|
|
15
|
+
* Register properties to be sent with every event
|
|
16
|
+
*/
|
|
17
|
+
export declare function registerProperties(properties: EventProperties): void;
|
|
18
|
+
/**
|
|
19
|
+
* Register properties only if they don't already exist
|
|
20
|
+
*/
|
|
21
|
+
export declare function registerOnceProperties(properties: EventProperties): void;
|
|
22
|
+
/**
|
|
23
|
+
* Clear all registered properties
|
|
24
|
+
*/
|
|
25
|
+
export declare function clearRegisteredProperties(): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration management module
|
|
3
|
+
* Handles fetching, caching, and merging configuration
|
|
4
|
+
*/
|
|
5
|
+
import { SessionVisionConfig, ResolvedConfig, RemoteConfig } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* Resolve user config with defaults
|
|
8
|
+
*/
|
|
9
|
+
export declare function resolveConfig(projectToken: string, userConfig?: SessionVisionConfig): ResolvedConfig;
|
|
10
|
+
/**
|
|
11
|
+
* Fetch remote configuration from server
|
|
12
|
+
*/
|
|
13
|
+
export declare function fetchRemoteConfig(resolvedConfig: ResolvedConfig): Promise<RemoteConfig | null>;
|
|
14
|
+
/**
|
|
15
|
+
* Apply remote config settings
|
|
16
|
+
*/
|
|
17
|
+
export declare function applyRemoteConfig(remoteConfig: RemoteConfig): void;
|
|
18
|
+
/**
|
|
19
|
+
* Get default remote config for offline mode
|
|
20
|
+
*/
|
|
21
|
+
export declare function getDefaultRemoteConfig(): RemoteConfig;
|