@v-tilt/browser 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/array.js +2 -0
- package/dist/array.js.map +1 -0
- package/dist/array.no-external.js +2 -0
- package/dist/array.no-external.js.map +1 -0
- package/dist/config.d.ts +17 -0
- package/dist/constants.d.ts +10 -0
- package/dist/entrypoints/array.d.ts +1 -0
- package/dist/entrypoints/array.no-external.d.ts +1 -0
- package/dist/entrypoints/main.cjs.d.ts +4 -0
- package/dist/entrypoints/module.es.d.ts +3 -0
- package/dist/entrypoints/module.no-external.es.d.ts +4 -0
- package/dist/geolocation.d.ts +5 -0
- package/dist/main.js +2 -0
- package/dist/main.js.map +1 -0
- package/dist/module.d.ts +214 -0
- package/dist/module.js +2 -0
- package/dist/module.js.map +1 -0
- package/dist/module.no-external.d.ts +214 -0
- package/dist/module.no-external.js +2 -0
- package/dist/module.no-external.js.map +1 -0
- package/dist/session.d.ts +26 -0
- package/dist/tracking.d.ts +112 -0
- package/dist/types.d.ts +67 -0
- package/dist/user-manager.d.ts +152 -0
- package/dist/utils/globals.d.ts +4 -0
- package/dist/utils/index.d.ts +30 -0
- package/dist/utils.d.ts +21 -0
- package/dist/vtilt.d.ts +178 -0
- package/dist/web-vitals.d.ts +11 -0
- package/lib/config.d.ts +17 -0
- package/lib/config.js +76 -0
- package/lib/constants.d.ts +10 -0
- package/lib/constants.js +463 -0
- package/lib/entrypoints/array.d.ts +1 -0
- package/lib/entrypoints/array.js +3 -0
- package/lib/entrypoints/array.no-external.d.ts +1 -0
- package/lib/entrypoints/array.no-external.js +4 -0
- package/lib/entrypoints/main.cjs.d.ts +4 -0
- package/lib/entrypoints/main.cjs.js +29 -0
- package/lib/entrypoints/module.es.d.ts +3 -0
- package/lib/entrypoints/module.es.js +22 -0
- package/lib/entrypoints/module.no-external.es.d.ts +4 -0
- package/lib/entrypoints/module.no-external.es.js +23 -0
- package/lib/geolocation.d.ts +5 -0
- package/lib/geolocation.js +26 -0
- package/lib/session.d.ts +26 -0
- package/lib/session.js +115 -0
- package/lib/tracking.d.ts +112 -0
- package/lib/tracking.js +326 -0
- package/lib/types.d.ts +67 -0
- package/lib/types.js +2 -0
- package/lib/user-manager.d.ts +152 -0
- package/lib/user-manager.js +565 -0
- package/lib/utils/globals.d.ts +4 -0
- package/lib/utils/globals.js +5 -0
- package/lib/utils/index.d.ts +30 -0
- package/lib/utils/index.js +89 -0
- package/lib/utils.d.ts +21 -0
- package/lib/utils.js +57 -0
- package/lib/vtilt.d.ts +178 -0
- package/lib/vtilt.js +403 -0
- package/lib/web-vitals.d.ts +11 -0
- package/lib/web-vitals.js +67 -0
- package/package.json +61 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { UserIdentity, StorageMethod } from "./types";
|
|
2
|
+
export declare class UserManager {
|
|
3
|
+
private storageMethod;
|
|
4
|
+
private domain?;
|
|
5
|
+
private userIdentity;
|
|
6
|
+
private _cachedPersonProperties;
|
|
7
|
+
constructor(storageMethod?: StorageMethod, domain?: string);
|
|
8
|
+
/**
|
|
9
|
+
* Get current user identity
|
|
10
|
+
*/
|
|
11
|
+
getUserIdentity(): UserIdentity;
|
|
12
|
+
/**
|
|
13
|
+
* Get current distinct ID (identified user ID)
|
|
14
|
+
*/
|
|
15
|
+
getDistinctId(): string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Get current anonymous ID
|
|
18
|
+
*/
|
|
19
|
+
getAnonymousId(): string;
|
|
20
|
+
/**
|
|
21
|
+
* Get current user properties
|
|
22
|
+
*/
|
|
23
|
+
getUserProperties(): Record<string, any>;
|
|
24
|
+
/**
|
|
25
|
+
* Identify a user with distinct ID and properties
|
|
26
|
+
* Copied from PostHog's identify method implementation
|
|
27
|
+
*/
|
|
28
|
+
identify(newDistinctId?: string, userPropertiesToSet?: Record<string, any>, userPropertiesToSetOnce?: Record<string, any>): void;
|
|
29
|
+
/**
|
|
30
|
+
* Set user properties without changing distinct ID (PostHog-style)
|
|
31
|
+
* Sets properties on the person profile associated with the current distinct_id
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```js
|
|
35
|
+
* // Set properties that can be updated
|
|
36
|
+
* vt.setUserProperties({ name: 'John Doe', email: 'john@example.com' })
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```js
|
|
41
|
+
* // Set properties with $set and $set_once operations
|
|
42
|
+
* vt.setUserProperties(
|
|
43
|
+
* { name: 'John Doe', last_login: new Date().toISOString() }, // $set properties
|
|
44
|
+
* { first_login: new Date().toISOString() } // $set_once properties
|
|
45
|
+
* )
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @param userPropertiesToSet Optional: Properties to set (can be updated)
|
|
49
|
+
* @param userPropertiesToSetOnce Optional: Properties to set once (preserves first value)
|
|
50
|
+
*/
|
|
51
|
+
setUserProperties(userPropertiesToSet?: Record<string, any>, userPropertiesToSetOnce?: Record<string, any>): void;
|
|
52
|
+
/**
|
|
53
|
+
* Get hash for person properties (PostHog behavior)
|
|
54
|
+
* Used for deduplication of identical setUserProperties calls
|
|
55
|
+
*/
|
|
56
|
+
private getPersonPropertiesHash;
|
|
57
|
+
/**
|
|
58
|
+
* Send $set event for property updates (PostHog behavior)
|
|
59
|
+
* This notifies the server when user properties are updated
|
|
60
|
+
*/
|
|
61
|
+
private sendSetEvent;
|
|
62
|
+
/**
|
|
63
|
+
* Reset user identity (logout)
|
|
64
|
+
* PostHog behavior: Generates new anonymous ID, clears user data, optionally resets device ID
|
|
65
|
+
*
|
|
66
|
+
* @param reset_device_id - If true, also resets device_id. Default: false (preserves device_id)
|
|
67
|
+
*/
|
|
68
|
+
reset(reset_device_id?: boolean): void;
|
|
69
|
+
/**
|
|
70
|
+
* Get the effective ID for event tracking
|
|
71
|
+
*/
|
|
72
|
+
getEffectiveId(): string;
|
|
73
|
+
/**
|
|
74
|
+
* Get current device ID
|
|
75
|
+
*/
|
|
76
|
+
getDeviceId(): string;
|
|
77
|
+
/**
|
|
78
|
+
* Get current user state
|
|
79
|
+
*/
|
|
80
|
+
getUserState(): "anonymous" | "identified";
|
|
81
|
+
/**
|
|
82
|
+
* Create an alias to link two distinct IDs
|
|
83
|
+
* PostHog behavior: If original is not provided, uses current distinct_id
|
|
84
|
+
* If alias matches original, just calls identify instead
|
|
85
|
+
*
|
|
86
|
+
* @param alias - A unique identifier that you want to use for this user in the future
|
|
87
|
+
* @param original - The current identifier being used for this user (optional, defaults to current distinct_id)
|
|
88
|
+
*/
|
|
89
|
+
createAlias(alias: string, original?: string): void;
|
|
90
|
+
/**
|
|
91
|
+
* Validate distinct ID to prevent hardcoded strings
|
|
92
|
+
* Copied from PostHog's validation logic
|
|
93
|
+
*/
|
|
94
|
+
private isValidDistinctId;
|
|
95
|
+
/**
|
|
96
|
+
* Check if distinct ID is string-like (hardcoded string)
|
|
97
|
+
* Copied from PostHog's isDistinctIdStringLike function
|
|
98
|
+
*/
|
|
99
|
+
private isDistinctIdStringLike;
|
|
100
|
+
/**
|
|
101
|
+
* Load user identity from storage
|
|
102
|
+
*/
|
|
103
|
+
private loadUserIdentity;
|
|
104
|
+
/**
|
|
105
|
+
* Save user identity to storage
|
|
106
|
+
*/
|
|
107
|
+
private saveUserIdentity;
|
|
108
|
+
/**
|
|
109
|
+
* Generate a new anonymous ID
|
|
110
|
+
*/
|
|
111
|
+
private generateAnonymousId;
|
|
112
|
+
/**
|
|
113
|
+
* Generate a new device ID
|
|
114
|
+
*/
|
|
115
|
+
private generateDeviceId;
|
|
116
|
+
/**
|
|
117
|
+
* Send identify event for session merging
|
|
118
|
+
*/
|
|
119
|
+
private sendIdentifyEvent;
|
|
120
|
+
/**
|
|
121
|
+
* Get stored value from storage
|
|
122
|
+
*/
|
|
123
|
+
private getStoredValue;
|
|
124
|
+
/**
|
|
125
|
+
* Set stored value in storage
|
|
126
|
+
*/
|
|
127
|
+
private setStoredValue;
|
|
128
|
+
/**
|
|
129
|
+
* Remove stored value from storage
|
|
130
|
+
*/
|
|
131
|
+
private removeStoredValue;
|
|
132
|
+
/**
|
|
133
|
+
* Get user properties from storage
|
|
134
|
+
*/
|
|
135
|
+
private getStoredUserProperties;
|
|
136
|
+
/**
|
|
137
|
+
* Set user properties in storage
|
|
138
|
+
*/
|
|
139
|
+
private setStoredUserProperties;
|
|
140
|
+
/**
|
|
141
|
+
* Get cookie value
|
|
142
|
+
*/
|
|
143
|
+
private getCookieValue;
|
|
144
|
+
/**
|
|
145
|
+
* Set cookie value
|
|
146
|
+
*/
|
|
147
|
+
private setCookieValue;
|
|
148
|
+
/**
|
|
149
|
+
* Remove cookie value
|
|
150
|
+
*/
|
|
151
|
+
private removeCookieValue;
|
|
152
|
+
}
|