@v-tilt/browser 1.0.8 → 1.0.9

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.
Files changed (48) hide show
  1. package/dist/array.js +1 -1
  2. package/dist/array.js.map +1 -1
  3. package/dist/array.no-external.js +1 -1
  4. package/dist/array.no-external.js.map +1 -1
  5. package/dist/constants.d.ts +0 -1
  6. package/dist/extensions/history-autocapture.d.ts +0 -2
  7. package/dist/main.js +1 -1
  8. package/dist/main.js.map +1 -1
  9. package/dist/module.d.ts +52 -132
  10. package/dist/module.js +1 -1
  11. package/dist/module.js.map +1 -1
  12. package/dist/module.no-external.d.ts +52 -132
  13. package/dist/module.no-external.js +1 -1
  14. package/dist/module.no-external.js.map +1 -1
  15. package/dist/session.d.ts +5 -5
  16. package/dist/types.d.ts +1 -0
  17. package/dist/user-manager.d.ts +30 -20
  18. package/dist/utils/event-utils.d.ts +7 -8
  19. package/dist/utils/index.d.ts +0 -5
  20. package/dist/utils/patch.d.ts +0 -1
  21. package/dist/vtilt.d.ts +54 -14
  22. package/dist/web-vitals.d.ts +3 -3
  23. package/lib/constants.d.ts +0 -1
  24. package/lib/constants.js +1 -23
  25. package/lib/extensions/history-autocapture.d.ts +0 -2
  26. package/lib/extensions/history-autocapture.js +3 -5
  27. package/lib/session.d.ts +5 -5
  28. package/lib/session.js +8 -8
  29. package/lib/types.d.ts +1 -0
  30. package/lib/user-manager.d.ts +30 -20
  31. package/lib/user-manager.js +103 -92
  32. package/lib/utils/event-utils.d.ts +7 -8
  33. package/lib/utils/event-utils.js +8 -9
  34. package/lib/utils/index.d.ts +0 -5
  35. package/lib/utils/index.js +0 -13
  36. package/lib/utils/patch.d.ts +0 -1
  37. package/lib/utils/patch.js +0 -1
  38. package/lib/vtilt.d.ts +54 -14
  39. package/lib/vtilt.js +328 -45
  40. package/lib/web-vitals.d.ts +3 -3
  41. package/lib/web-vitals.js +3 -3
  42. package/package.json +61 -61
  43. package/dist/tracking.d.ts +0 -120
  44. package/dist/utils/is-function.d.ts +0 -4
  45. package/lib/tracking.d.ts +0 -120
  46. package/lib/tracking.js +0 -338
  47. package/lib/utils/is-function.d.ts +0 -4
  48. package/lib/utils/is-function.js +0 -9
package/package.json CHANGED
@@ -1,61 +1,61 @@
1
- {
2
- "name": "@v-tilt/browser",
3
- "version": "1.0.8",
4
- "description": "vTilt browser tracking library",
5
- "main": "dist/main.js",
6
- "module": "dist/module.js",
7
- "types": "dist/module.d.ts",
8
- "files": [
9
- "lib/*",
10
- "dist/*"
11
- ],
12
- "publishConfig": {
13
- "access": "public"
14
- },
15
- "scripts": {
16
- "build": "tsc -b && rollup -c",
17
- "dev": "rollup -c -w",
18
- "type-check": "tsc --noEmit",
19
- "lint": "eslint src --ext .ts",
20
- "lint:fix": "eslint src --ext .ts --fix",
21
- "clean": "rimraf lib dist",
22
- "prepublishOnly": "pnpm run build"
23
- },
24
- "keywords": [
25
- "analytics",
26
- "tracking",
27
- "web-vitals",
28
- "performance"
29
- ],
30
- "author": "vTilt",
31
- "license": "MIT",
32
- "devDependencies": {
33
- "@babel/preset-env": "^7.28.3",
34
- "@rollup/plugin-babel": "^6.0.4",
35
- "@rollup/plugin-commonjs": "^25.0.8",
36
- "@rollup/plugin-json": "^6.1.0",
37
- "@rollup/plugin-node-resolve": "^15.3.1",
38
- "@rollup/plugin-terser": "^0.4.4",
39
- "@rollup/plugin-typescript": "^11.1.6",
40
- "@types/node": "^20.10.5",
41
- "@v-tilt/eslint-config": "workspace:*",
42
- "eslint": "^9.0.0",
43
- "rimraf": "^5.0.5",
44
- "rollup": "^4.9.1",
45
- "rollup-plugin-dts": "^6.2.3",
46
- "rollup-plugin-terser": "^7.0.2",
47
- "rollup-plugin-visualizer": "^6.0.3",
48
- "typescript": "^5.3.3"
49
- },
50
- "dependencies": {
51
- "web-vitals": "^3.5.0"
52
- },
53
- "peerDependencies": {
54
- "web-vitals": "^3.0.0"
55
- },
56
- "peerDependenciesMeta": {
57
- "web-vitals": {
58
- "optional": true
59
- }
60
- }
61
- }
1
+ {
2
+ "name": "@v-tilt/browser",
3
+ "version": "1.0.9",
4
+ "description": "vTilt browser tracking library",
5
+ "main": "dist/main.js",
6
+ "module": "dist/module.js",
7
+ "types": "dist/module.d.ts",
8
+ "files": [
9
+ "lib/*",
10
+ "dist/*"
11
+ ],
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "scripts": {
16
+ "build": "tsc -b && rollup -c",
17
+ "dev": "rollup -c -w",
18
+ "type-check": "tsc --noEmit",
19
+ "lint": "eslint src --ext .ts",
20
+ "lint:fix": "eslint src --ext .ts --fix",
21
+ "clean": "rimraf lib dist",
22
+ "prepublishOnly": "pnpm run build"
23
+ },
24
+ "keywords": [
25
+ "analytics",
26
+ "tracking",
27
+ "web-vitals",
28
+ "performance"
29
+ ],
30
+ "author": "vTilt",
31
+ "license": "MIT",
32
+ "devDependencies": {
33
+ "@babel/preset-env": "^7.28.3",
34
+ "@rollup/plugin-babel": "^6.0.4",
35
+ "@rollup/plugin-commonjs": "^25.0.8",
36
+ "@rollup/plugin-json": "^6.1.0",
37
+ "@rollup/plugin-node-resolve": "^15.3.1",
38
+ "@rollup/plugin-terser": "^0.4.4",
39
+ "@rollup/plugin-typescript": "^11.1.6",
40
+ "@types/node": "^20.10.5",
41
+ "@v-tilt/eslint-config": "workspace:*",
42
+ "eslint": "^9.0.0",
43
+ "rimraf": "^5.0.5",
44
+ "rollup": "^4.9.1",
45
+ "rollup-plugin-dts": "^6.2.3",
46
+ "rollup-plugin-terser": "^7.0.2",
47
+ "rollup-plugin-visualizer": "^6.0.3",
48
+ "typescript": "^5.3.3"
49
+ },
50
+ "dependencies": {
51
+ "web-vitals": "^3.5.0"
52
+ },
53
+ "peerDependencies": {
54
+ "web-vitals": "^3.0.0"
55
+ },
56
+ "peerDependenciesMeta": {
57
+ "web-vitals": {
58
+ "optional": true
59
+ }
60
+ }
61
+ }
@@ -1,120 +0,0 @@
1
- import { VTiltConfig, EventPayload } from "./types";
2
- interface QueuedRequest {
3
- url: string;
4
- event: any;
5
- }
6
- export declare class TrackingManager {
7
- private config;
8
- private sessionManager;
9
- private userManager;
10
- __request_queue: QueuedRequest[];
11
- private _hasWarnedAboutConfig;
12
- constructor(config: VTiltConfig);
13
- /**
14
- * Get current domain from location
15
- * Returns full URL format for consistency with dashboard
16
- */
17
- private getCurrentDomain;
18
- /**
19
- * Check if tracking is properly configured
20
- * Returns true if projectId and token are present, false otherwise
21
- * Logs a warning only once per instance if not configured
22
- */
23
- private _isConfigured;
24
- /**
25
- * Send event to endpoint
26
- * PostHog-style: Automatically adds common properties to all events
27
- * ($current_url, $host, $pathname, $referrer, $referring_domain, $browser_language, etc.)
28
- * Also adds title property for $pageview events only
29
- */
30
- sendEvent(name: string, payload: EventPayload): Promise<void>;
31
- /**
32
- * Build the tracking URL with token in query parameters (PostHog style)
33
- */
34
- private buildUrl;
35
- /**
36
- * Send HTTP request
37
- * This is the central entry point for all tracking requests
38
- */
39
- private sendRequest;
40
- /**
41
- * Send a queued request (called after DOM is loaded)
42
- */
43
- _send_retriable_request(item: QueuedRequest): void;
44
- /**
45
- * Get current session ID
46
- */
47
- getSessionId(): string | null;
48
- /**
49
- * Identify a user with PostHog-style property operations
50
- * Copied from PostHog's identify method signature
51
- */
52
- identify(distinctId?: string, userPropertiesToSet?: Record<string, any>, userPropertiesToSetOnce?: Record<string, any>): void;
53
- /**
54
- * Set user properties (PostHog-style)
55
- */
56
- setUserProperties(userPropertiesToSet?: Record<string, any>, userPropertiesToSetOnce?: Record<string, any>): void;
57
- /**
58
- * Reset user identity (logout)
59
- * PostHog behavior: Clears all user data, generates new anonymous ID, resets session
60
- *
61
- * @param reset_device_id - If true, also resets device_id. Default: false
62
- */
63
- resetUser(reset_device_id?: boolean): void;
64
- /**
65
- * Get current user identity
66
- */
67
- getUserIdentity(): import("./types").UserIdentity;
68
- /**
69
- * Get current device ID
70
- */
71
- getDeviceId(): string;
72
- /**
73
- * Get current user state
74
- */
75
- getUserState(): "anonymous" | "identified";
76
- /**
77
- * Create an alias to link two distinct IDs
78
- * PostHog behavior: Links anonymous session to account on signup
79
- *
80
- * @param alias - A unique identifier that you want to use for this user in the future
81
- * @param original - The current identifier being used for this user (optional, defaults to current distinct_id)
82
- *
83
- * @example
84
- * // Link anonymous user to account on signup
85
- * vtilt.createAlias('user_12345')
86
- *
87
- * @example
88
- * // Explicit alias with original ID
89
- * vtilt.createAlias('user_12345', 'anonymous_abc123')
90
- */
91
- createAlias(alias: string, original?: string): void;
92
- /**
93
- * Setup listener for identify, set, and alias events
94
- */
95
- private setupIdentifyListener;
96
- /**
97
- * Get session and window IDs (PostHog-style)
98
- * Both methods ensure IDs always exist (generate if needed)
99
- */
100
- private _getSessionAndWindowIds;
101
- /**
102
- * Create base tracking event structure
103
- */
104
- private _createTrackingEvent;
105
- /**
106
- * Send identify event for session merging
107
- */
108
- private sendIdentifyEvent;
109
- /**
110
- * Send $set event for property updates (PostHog behavior)
111
- * This notifies Tinybird when user properties are updated
112
- */
113
- private sendSetEvent;
114
- /**
115
- * Send alias event for identity linking
116
- * PostHog format: { alias: alias, distinct_id: original }
117
- */
118
- private sendAliasEvent;
119
- }
120
- export {};
@@ -1,4 +0,0 @@
1
- /**
2
- * Type guard to check if a value is a function
3
- */
4
- export declare function isFunction(value: any): value is (...args: any[]) => any;
package/lib/tracking.d.ts DELETED
@@ -1,120 +0,0 @@
1
- import { VTiltConfig, EventPayload } from "./types";
2
- interface QueuedRequest {
3
- url: string;
4
- event: any;
5
- }
6
- export declare class TrackingManager {
7
- private config;
8
- private sessionManager;
9
- private userManager;
10
- __request_queue: QueuedRequest[];
11
- private _hasWarnedAboutConfig;
12
- constructor(config: VTiltConfig);
13
- /**
14
- * Get current domain from location
15
- * Returns full URL format for consistency with dashboard
16
- */
17
- private getCurrentDomain;
18
- /**
19
- * Check if tracking is properly configured
20
- * Returns true if projectId and token are present, false otherwise
21
- * Logs a warning only once per instance if not configured
22
- */
23
- private _isConfigured;
24
- /**
25
- * Send event to endpoint
26
- * PostHog-style: Automatically adds common properties to all events
27
- * ($current_url, $host, $pathname, $referrer, $referring_domain, $browser_language, etc.)
28
- * Also adds title property for $pageview events only
29
- */
30
- sendEvent(name: string, payload: EventPayload): Promise<void>;
31
- /**
32
- * Build the tracking URL with token in query parameters (PostHog style)
33
- */
34
- private buildUrl;
35
- /**
36
- * Send HTTP request
37
- * This is the central entry point for all tracking requests
38
- */
39
- private sendRequest;
40
- /**
41
- * Send a queued request (called after DOM is loaded)
42
- */
43
- _send_retriable_request(item: QueuedRequest): void;
44
- /**
45
- * Get current session ID
46
- */
47
- getSessionId(): string | null;
48
- /**
49
- * Identify a user with PostHog-style property operations
50
- * Copied from PostHog's identify method signature
51
- */
52
- identify(distinctId?: string, userPropertiesToSet?: Record<string, any>, userPropertiesToSetOnce?: Record<string, any>): void;
53
- /**
54
- * Set user properties (PostHog-style)
55
- */
56
- setUserProperties(userPropertiesToSet?: Record<string, any>, userPropertiesToSetOnce?: Record<string, any>): void;
57
- /**
58
- * Reset user identity (logout)
59
- * PostHog behavior: Clears all user data, generates new anonymous ID, resets session
60
- *
61
- * @param reset_device_id - If true, also resets device_id. Default: false
62
- */
63
- resetUser(reset_device_id?: boolean): void;
64
- /**
65
- * Get current user identity
66
- */
67
- getUserIdentity(): import("./types").UserIdentity;
68
- /**
69
- * Get current device ID
70
- */
71
- getDeviceId(): string;
72
- /**
73
- * Get current user state
74
- */
75
- getUserState(): "anonymous" | "identified";
76
- /**
77
- * Create an alias to link two distinct IDs
78
- * PostHog behavior: Links anonymous session to account on signup
79
- *
80
- * @param alias - A unique identifier that you want to use for this user in the future
81
- * @param original - The current identifier being used for this user (optional, defaults to current distinct_id)
82
- *
83
- * @example
84
- * // Link anonymous user to account on signup
85
- * vtilt.createAlias('user_12345')
86
- *
87
- * @example
88
- * // Explicit alias with original ID
89
- * vtilt.createAlias('user_12345', 'anonymous_abc123')
90
- */
91
- createAlias(alias: string, original?: string): void;
92
- /**
93
- * Setup listener for identify, set, and alias events
94
- */
95
- private setupIdentifyListener;
96
- /**
97
- * Get session and window IDs (PostHog-style)
98
- * Both methods ensure IDs always exist (generate if needed)
99
- */
100
- private _getSessionAndWindowIds;
101
- /**
102
- * Create base tracking event structure
103
- */
104
- private _createTrackingEvent;
105
- /**
106
- * Send identify event for session merging
107
- */
108
- private sendIdentifyEvent;
109
- /**
110
- * Send $set event for property updates (PostHog behavior)
111
- * This notifies Tinybird when user properties are updated
112
- */
113
- private sendSetEvent;
114
- /**
115
- * Send alias event for identity linking
116
- * PostHog format: { alias: alias, distinct_id: original }
117
- */
118
- private sendAliasEvent;
119
- }
120
- export {};