@outlit/browser 0.0.0-canary-202512180440-754f4ab-20251218044038 → 0.0.0-canary-202601161920-3feb1db-20260116192046

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.
@@ -45,6 +45,11 @@ interface OutlitOptions extends TrackerConfig {
45
45
  */
46
46
  idleTimeout?: number;
47
47
  }
48
+ interface UserIdentity {
49
+ email?: string;
50
+ userId?: string;
51
+ traits?: Record<string, string | number | boolean | null>;
52
+ }
48
53
  declare class Outlit {
49
54
  private publicKey;
50
55
  private apiHost;
@@ -57,6 +62,8 @@ declare class Outlit {
57
62
  private options;
58
63
  private hasHandledExit;
59
64
  private sessionTracker;
65
+ private currentUser;
66
+ private pendingUser;
60
67
  constructor(options: OutlitOptions);
61
68
  /**
62
69
  * Enable tracking. Call this after obtaining user consent.
@@ -79,8 +86,61 @@ declare class Outlit {
79
86
  /**
80
87
  * Identify the current visitor.
81
88
  * Links the anonymous visitor to a known user.
89
+ *
90
+ * When email or userId is provided, also sets the current user identity
91
+ * for stage events (activate, engaged, paid).
82
92
  */
83
93
  identify(options: BrowserIdentifyOptions): void;
94
+ /**
95
+ * Set the current user identity.
96
+ * This is useful for SPA applications where you know the user's identity
97
+ * after authentication. Calls identify() under the hood.
98
+ *
99
+ * If called before tracking is enabled, the identity is stored as pending
100
+ * and applied automatically when enableTracking() is called.
101
+ *
102
+ * Note: Both setUser() and identify() enable stage events. The difference is
103
+ * setUser() can be called before tracking is enabled (identity is queued),
104
+ * while identify() requires tracking to be enabled first.
105
+ */
106
+ setUser(identity: UserIdentity): void;
107
+ /**
108
+ * Clear the current user identity.
109
+ * Call this when the user logs out.
110
+ */
111
+ clearUser(): void;
112
+ /**
113
+ * Apply user identity and send identify event.
114
+ */
115
+ private applyUser;
116
+ /**
117
+ * Mark the current user as activated.
118
+ * This is typically called after a user completes onboarding or a key activation milestone.
119
+ * Requires the user to be identified (via setUser or identify with userId).
120
+ */
121
+ activate(properties?: Record<string, string | number | boolean | null>): void;
122
+ /**
123
+ * Mark the current user as engaged.
124
+ * This is typically called when a user reaches a usage milestone.
125
+ * Can also be computed automatically by the engagement cron.
126
+ */
127
+ engaged(properties?: Record<string, string | number | boolean | null>): void;
128
+ /**
129
+ * Mark the current user as paid.
130
+ * This is typically called after a successful payment/subscription.
131
+ * Can also be triggered by Stripe integration.
132
+ */
133
+ paid(properties?: Record<string, string | number | boolean | null>): void;
134
+ /**
135
+ * Mark the current user as churned.
136
+ * This is typically called when a subscription is cancelled.
137
+ * Can also be triggered by Stripe integration.
138
+ */
139
+ churned(properties?: Record<string, string | number | boolean | null>): void;
140
+ /**
141
+ * Internal method to send a stage event.
142
+ */
143
+ private sendStageEvent;
84
144
  /**
85
145
  * Get the current visitor ID.
86
146
  * Returns null if tracking is not enabled.
@@ -133,5 +193,35 @@ declare function enableTracking(): void;
133
193
  * Convenience method that uses the singleton instance.
134
194
  */
135
195
  declare function isTrackingEnabled(): boolean;
196
+ /**
197
+ * Set the current user identity.
198
+ * Convenience method that uses the singleton instance.
199
+ */
200
+ declare function setUser(identity: UserIdentity): void;
201
+ /**
202
+ * Clear the current user identity (on logout).
203
+ * Convenience method that uses the singleton instance.
204
+ */
205
+ declare function clearUser(): void;
206
+ /**
207
+ * Mark the current user as activated.
208
+ * Convenience method that uses the singleton instance.
209
+ */
210
+ declare function activate(properties?: Record<string, string | number | boolean | null>): void;
211
+ /**
212
+ * Mark the current user as engaged.
213
+ * Convenience method that uses the singleton instance.
214
+ */
215
+ declare function engaged(properties?: Record<string, string | number | boolean | null>): void;
216
+ /**
217
+ * Mark the current user as paid.
218
+ * Convenience method that uses the singleton instance.
219
+ */
220
+ declare function paid(properties?: Record<string, string | number | boolean | null>): void;
221
+ /**
222
+ * Mark the current user as churned.
223
+ * Convenience method that uses the singleton instance.
224
+ */
225
+ declare function churned(properties?: Record<string, string | number | boolean | null>): void;
136
226
 
137
- export { Outlit as O, identify as a, isTrackingEnabled as b, type OutlitOptions as c, enableTracking as e, getInstance as g, init as i, track as t };
227
+ export { Outlit as O, type UserIdentity as U, identify as a, isTrackingEnabled as b, clearUser as c, activate as d, enableTracking as e, engaged as f, getInstance as g, churned as h, init as i, type OutlitOptions as j, paid as p, setUser as s, track as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@outlit/browser",
3
- "version": "0.0.0-canary-202512180440-754f4ab-20251218044038",
3
+ "version": "0.0.0-canary-202601161920-3feb1db-20260116192046",
4
4
  "description": "Outlit browser tracking SDK with React bindings",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Outlit AI",
@@ -45,17 +45,21 @@
45
45
  "dist"
46
46
  ],
47
47
  "dependencies": {
48
- "@outlit/core": "0.0.0-canary-202512180440-754f4ab-20251218044038"
48
+ "@outlit/core": "0.0.0-canary-202601161920-3feb1db-20260116192046"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@playwright/test": "^1.48.0",
52
+ "@testing-library/react": "^14.0.0",
52
53
  "@types/node": "^20.0.0",
53
54
  "@types/react": "^18.2.0",
55
+ "jsdom": "^24.0.0",
54
56
  "react": "^18.2.0",
57
+ "react-dom": "^18.2.0",
55
58
  "tsup": "^8.0.1",
56
59
  "tsx": "^4.0.0",
57
60
  "typescript": "^5.3.3",
58
- "@outlit/typescript-config": "0.0.0-canary-202512180440-754f4ab-20251218044038"
61
+ "vitest": "^1.2.1",
62
+ "@outlit/typescript-config": "0.0.1"
59
63
  },
60
64
  "peerDependencies": {
61
65
  "react": ">=17.0.0"
@@ -73,6 +77,7 @@
73
77
  "format": "biome format --write .",
74
78
  "typecheck": "tsc --noEmit",
75
79
  "test": "playwright test",
80
+ "test:unit": "vitest run",
76
81
  "test:ui": "playwright test --ui",
77
82
  "test:headed": "playwright test --headed",
78
83
  "serve:test": "tsx ./__tests__/e2e/serve.ts",