@outlit/browser 1.1.0 → 1.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/dist/vue/index.d.mts +198 -0
- package/dist/vue/index.d.ts +198 -0
- package/dist/vue/index.js +1171 -0
- package/dist/vue/index.js.map +1 -0
- package/dist/vue/index.mjs +1149 -0
- package/dist/vue/index.mjs.map +1 -0
- package/package.json +20 -5
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { App, InjectionKey, ShallowRef, Ref } from 'vue';
|
|
2
|
+
import { f as OutlitOptions, O as Outlit, U as UserIdentity, B as BillingOptions } from '../tracker-BTkkFb0f.mjs';
|
|
3
|
+
import { BrowserTrackOptions, BrowserIdentifyOptions } from '@outlit/core';
|
|
4
|
+
|
|
5
|
+
interface OutlitPluginOptions extends Omit<OutlitOptions, "trackPageviews"> {
|
|
6
|
+
/**
|
|
7
|
+
* Whether to automatically track pageviews.
|
|
8
|
+
* @default true
|
|
9
|
+
*/
|
|
10
|
+
trackPageviews?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Whether to start tracking automatically.
|
|
13
|
+
* Set to false if you need to wait for user consent.
|
|
14
|
+
* @default true
|
|
15
|
+
*/
|
|
16
|
+
autoTrack?: boolean;
|
|
17
|
+
}
|
|
18
|
+
interface OutlitInstance {
|
|
19
|
+
outlit: ShallowRef<Outlit | null>;
|
|
20
|
+
isInitialized: Readonly<Ref<boolean>>;
|
|
21
|
+
isTrackingEnabled: Readonly<Ref<boolean>>;
|
|
22
|
+
enableTracking: () => void;
|
|
23
|
+
/**
|
|
24
|
+
* Set the current user. Automatically calls identify when user changes.
|
|
25
|
+
* Pass null to clear the user (logout).
|
|
26
|
+
*/
|
|
27
|
+
setUser: (user: UserIdentity | null) => void;
|
|
28
|
+
}
|
|
29
|
+
declare const OutlitKey: InjectionKey<OutlitInstance>;
|
|
30
|
+
/**
|
|
31
|
+
* Vue plugin to install Outlit.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* // main.ts
|
|
36
|
+
* import { createApp } from 'vue'
|
|
37
|
+
* import { OutlitPlugin } from '@outlit/browser/vue'
|
|
38
|
+
*
|
|
39
|
+
* const app = createApp(App)
|
|
40
|
+
* app.use(OutlitPlugin, { publicKey: 'pk_xxx' })
|
|
41
|
+
* app.mount('#app')
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
declare const OutlitPlugin: {
|
|
45
|
+
install(app: App, options: OutlitPluginOptions): void;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
interface UseOutlitReturn {
|
|
49
|
+
/**
|
|
50
|
+
* Track a custom event.
|
|
51
|
+
*/
|
|
52
|
+
track: (eventName: string, properties?: BrowserTrackOptions["properties"]) => void;
|
|
53
|
+
/**
|
|
54
|
+
* Identify the current visitor.
|
|
55
|
+
* Links the anonymous visitor to a known user.
|
|
56
|
+
*/
|
|
57
|
+
identify: (options: BrowserIdentifyOptions) => void;
|
|
58
|
+
/**
|
|
59
|
+
* Get the current visitor ID.
|
|
60
|
+
* Returns null if tracking is not enabled.
|
|
61
|
+
*/
|
|
62
|
+
getVisitorId: () => string | null;
|
|
63
|
+
/**
|
|
64
|
+
* Set the current user identity.
|
|
65
|
+
* Use this for persistent identity after login.
|
|
66
|
+
* Automatically calls identify().
|
|
67
|
+
*/
|
|
68
|
+
setUser: (identity: UserIdentity) => void;
|
|
69
|
+
/**
|
|
70
|
+
* Clear the current user identity (on logout).
|
|
71
|
+
*/
|
|
72
|
+
clearUser: () => void;
|
|
73
|
+
/**
|
|
74
|
+
* User namespace methods for contact journey stages.
|
|
75
|
+
*/
|
|
76
|
+
user: {
|
|
77
|
+
identify: (options: BrowserIdentifyOptions) => void;
|
|
78
|
+
activate: (properties?: Record<string, string | number | boolean | null>) => void;
|
|
79
|
+
engaged: (properties?: Record<string, string | number | boolean | null>) => void;
|
|
80
|
+
inactive: (properties?: Record<string, string | number | boolean | null>) => void;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Customer namespace methods for billing status.
|
|
84
|
+
*/
|
|
85
|
+
customer: {
|
|
86
|
+
trialing: (options: BillingOptions) => void;
|
|
87
|
+
paid: (options: BillingOptions) => void;
|
|
88
|
+
churned: (options: BillingOptions) => void;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Whether Outlit is initialized.
|
|
92
|
+
*/
|
|
93
|
+
isInitialized: Ref<boolean>;
|
|
94
|
+
/**
|
|
95
|
+
* Whether tracking is currently enabled.
|
|
96
|
+
*/
|
|
97
|
+
isTrackingEnabled: Ref<boolean>;
|
|
98
|
+
/**
|
|
99
|
+
* Enable tracking. Call this after obtaining user consent.
|
|
100
|
+
*/
|
|
101
|
+
enableTracking: () => void;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Composable to access the Outlit client.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```vue
|
|
108
|
+
* <script setup>
|
|
109
|
+
* import { useOutlit } from '@outlit/browser/vue'
|
|
110
|
+
*
|
|
111
|
+
* const { track, user } = useOutlit()
|
|
112
|
+
*
|
|
113
|
+
* const handleClick = () => {
|
|
114
|
+
* user.activate({ milestone: 'onboarding_complete' })
|
|
115
|
+
* }
|
|
116
|
+
* </script>
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
declare function useOutlit(): UseOutlitReturn;
|
|
120
|
+
/**
|
|
121
|
+
* Convenience composable that returns just the track function.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```vue
|
|
125
|
+
* <script setup>
|
|
126
|
+
* import { useTrack } from '@outlit/browser/vue'
|
|
127
|
+
*
|
|
128
|
+
* const track = useTrack()
|
|
129
|
+
* </script>
|
|
130
|
+
*
|
|
131
|
+
* <template>
|
|
132
|
+
* <button @click="track('button_clicked')">Click me</button>
|
|
133
|
+
* </template>
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
declare function useTrack(): (eventName: string, properties?: BrowserTrackOptions["properties"]) => void;
|
|
137
|
+
/**
|
|
138
|
+
* Convenience composable that returns just the identify function.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```vue
|
|
142
|
+
* <script setup>
|
|
143
|
+
* import { useIdentify } from '@outlit/browser/vue'
|
|
144
|
+
*
|
|
145
|
+
* const identify = useIdentify()
|
|
146
|
+
*
|
|
147
|
+
* const onLogin = (user) => {
|
|
148
|
+
* identify({ email: user.email, traits: { name: user.name } })
|
|
149
|
+
* }
|
|
150
|
+
* </script>
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
declare function useIdentify(): (options: BrowserIdentifyOptions) => void;
|
|
154
|
+
/**
|
|
155
|
+
* Composable that automatically syncs a reactive user ref with Outlit.
|
|
156
|
+
* When the user ref changes, it automatically calls setUser() or clearUser().
|
|
157
|
+
*
|
|
158
|
+
* This is the recommended way to handle auth state in Vue apps.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```vue
|
|
162
|
+
* <script setup>
|
|
163
|
+
* import { ref } from 'vue'
|
|
164
|
+
* import { useOutlitUser } from '@outlit/browser/vue'
|
|
165
|
+
*
|
|
166
|
+
* // Your auth state
|
|
167
|
+
* const currentUser = ref(null)
|
|
168
|
+
*
|
|
169
|
+
* // Auto-sync with Outlit
|
|
170
|
+
* useOutlitUser(currentUser)
|
|
171
|
+
*
|
|
172
|
+
* // When user logs in
|
|
173
|
+
* const onLogin = (user) => {
|
|
174
|
+
* currentUser.value = {
|
|
175
|
+
* email: user.email,
|
|
176
|
+
* userId: user.id,
|
|
177
|
+
* traits: { name: user.name, plan: user.plan }
|
|
178
|
+
* }
|
|
179
|
+
* }
|
|
180
|
+
*
|
|
181
|
+
* // When user logs out
|
|
182
|
+
* const onLogout = () => {
|
|
183
|
+
* currentUser.value = null
|
|
184
|
+
* }
|
|
185
|
+
* </script>
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
declare function useOutlitUser(userRef: Ref<UserIdentity | null | undefined>): void;
|
|
189
|
+
/**
|
|
190
|
+
* Return type of useTrack composable
|
|
191
|
+
*/
|
|
192
|
+
type UseTrackReturn = ReturnType<typeof useTrack>;
|
|
193
|
+
/**
|
|
194
|
+
* Return type of useIdentify composable
|
|
195
|
+
*/
|
|
196
|
+
type UseIdentifyReturn = ReturnType<typeof useIdentify>;
|
|
197
|
+
|
|
198
|
+
export { type OutlitInstance, OutlitKey, OutlitPlugin, type OutlitPluginOptions, type UseIdentifyReturn, type UseOutlitReturn, type UseTrackReturn, useIdentify, useOutlit, useOutlitUser, useTrack };
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { App, InjectionKey, ShallowRef, Ref } from 'vue';
|
|
2
|
+
import { f as OutlitOptions, O as Outlit, U as UserIdentity, B as BillingOptions } from '../tracker-BTkkFb0f.js';
|
|
3
|
+
import { BrowserTrackOptions, BrowserIdentifyOptions } from '@outlit/core';
|
|
4
|
+
|
|
5
|
+
interface OutlitPluginOptions extends Omit<OutlitOptions, "trackPageviews"> {
|
|
6
|
+
/**
|
|
7
|
+
* Whether to automatically track pageviews.
|
|
8
|
+
* @default true
|
|
9
|
+
*/
|
|
10
|
+
trackPageviews?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Whether to start tracking automatically.
|
|
13
|
+
* Set to false if you need to wait for user consent.
|
|
14
|
+
* @default true
|
|
15
|
+
*/
|
|
16
|
+
autoTrack?: boolean;
|
|
17
|
+
}
|
|
18
|
+
interface OutlitInstance {
|
|
19
|
+
outlit: ShallowRef<Outlit | null>;
|
|
20
|
+
isInitialized: Readonly<Ref<boolean>>;
|
|
21
|
+
isTrackingEnabled: Readonly<Ref<boolean>>;
|
|
22
|
+
enableTracking: () => void;
|
|
23
|
+
/**
|
|
24
|
+
* Set the current user. Automatically calls identify when user changes.
|
|
25
|
+
* Pass null to clear the user (logout).
|
|
26
|
+
*/
|
|
27
|
+
setUser: (user: UserIdentity | null) => void;
|
|
28
|
+
}
|
|
29
|
+
declare const OutlitKey: InjectionKey<OutlitInstance>;
|
|
30
|
+
/**
|
|
31
|
+
* Vue plugin to install Outlit.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* // main.ts
|
|
36
|
+
* import { createApp } from 'vue'
|
|
37
|
+
* import { OutlitPlugin } from '@outlit/browser/vue'
|
|
38
|
+
*
|
|
39
|
+
* const app = createApp(App)
|
|
40
|
+
* app.use(OutlitPlugin, { publicKey: 'pk_xxx' })
|
|
41
|
+
* app.mount('#app')
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
declare const OutlitPlugin: {
|
|
45
|
+
install(app: App, options: OutlitPluginOptions): void;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
interface UseOutlitReturn {
|
|
49
|
+
/**
|
|
50
|
+
* Track a custom event.
|
|
51
|
+
*/
|
|
52
|
+
track: (eventName: string, properties?: BrowserTrackOptions["properties"]) => void;
|
|
53
|
+
/**
|
|
54
|
+
* Identify the current visitor.
|
|
55
|
+
* Links the anonymous visitor to a known user.
|
|
56
|
+
*/
|
|
57
|
+
identify: (options: BrowserIdentifyOptions) => void;
|
|
58
|
+
/**
|
|
59
|
+
* Get the current visitor ID.
|
|
60
|
+
* Returns null if tracking is not enabled.
|
|
61
|
+
*/
|
|
62
|
+
getVisitorId: () => string | null;
|
|
63
|
+
/**
|
|
64
|
+
* Set the current user identity.
|
|
65
|
+
* Use this for persistent identity after login.
|
|
66
|
+
* Automatically calls identify().
|
|
67
|
+
*/
|
|
68
|
+
setUser: (identity: UserIdentity) => void;
|
|
69
|
+
/**
|
|
70
|
+
* Clear the current user identity (on logout).
|
|
71
|
+
*/
|
|
72
|
+
clearUser: () => void;
|
|
73
|
+
/**
|
|
74
|
+
* User namespace methods for contact journey stages.
|
|
75
|
+
*/
|
|
76
|
+
user: {
|
|
77
|
+
identify: (options: BrowserIdentifyOptions) => void;
|
|
78
|
+
activate: (properties?: Record<string, string | number | boolean | null>) => void;
|
|
79
|
+
engaged: (properties?: Record<string, string | number | boolean | null>) => void;
|
|
80
|
+
inactive: (properties?: Record<string, string | number | boolean | null>) => void;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Customer namespace methods for billing status.
|
|
84
|
+
*/
|
|
85
|
+
customer: {
|
|
86
|
+
trialing: (options: BillingOptions) => void;
|
|
87
|
+
paid: (options: BillingOptions) => void;
|
|
88
|
+
churned: (options: BillingOptions) => void;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Whether Outlit is initialized.
|
|
92
|
+
*/
|
|
93
|
+
isInitialized: Ref<boolean>;
|
|
94
|
+
/**
|
|
95
|
+
* Whether tracking is currently enabled.
|
|
96
|
+
*/
|
|
97
|
+
isTrackingEnabled: Ref<boolean>;
|
|
98
|
+
/**
|
|
99
|
+
* Enable tracking. Call this after obtaining user consent.
|
|
100
|
+
*/
|
|
101
|
+
enableTracking: () => void;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Composable to access the Outlit client.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```vue
|
|
108
|
+
* <script setup>
|
|
109
|
+
* import { useOutlit } from '@outlit/browser/vue'
|
|
110
|
+
*
|
|
111
|
+
* const { track, user } = useOutlit()
|
|
112
|
+
*
|
|
113
|
+
* const handleClick = () => {
|
|
114
|
+
* user.activate({ milestone: 'onboarding_complete' })
|
|
115
|
+
* }
|
|
116
|
+
* </script>
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
declare function useOutlit(): UseOutlitReturn;
|
|
120
|
+
/**
|
|
121
|
+
* Convenience composable that returns just the track function.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```vue
|
|
125
|
+
* <script setup>
|
|
126
|
+
* import { useTrack } from '@outlit/browser/vue'
|
|
127
|
+
*
|
|
128
|
+
* const track = useTrack()
|
|
129
|
+
* </script>
|
|
130
|
+
*
|
|
131
|
+
* <template>
|
|
132
|
+
* <button @click="track('button_clicked')">Click me</button>
|
|
133
|
+
* </template>
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
declare function useTrack(): (eventName: string, properties?: BrowserTrackOptions["properties"]) => void;
|
|
137
|
+
/**
|
|
138
|
+
* Convenience composable that returns just the identify function.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```vue
|
|
142
|
+
* <script setup>
|
|
143
|
+
* import { useIdentify } from '@outlit/browser/vue'
|
|
144
|
+
*
|
|
145
|
+
* const identify = useIdentify()
|
|
146
|
+
*
|
|
147
|
+
* const onLogin = (user) => {
|
|
148
|
+
* identify({ email: user.email, traits: { name: user.name } })
|
|
149
|
+
* }
|
|
150
|
+
* </script>
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
declare function useIdentify(): (options: BrowserIdentifyOptions) => void;
|
|
154
|
+
/**
|
|
155
|
+
* Composable that automatically syncs a reactive user ref with Outlit.
|
|
156
|
+
* When the user ref changes, it automatically calls setUser() or clearUser().
|
|
157
|
+
*
|
|
158
|
+
* This is the recommended way to handle auth state in Vue apps.
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```vue
|
|
162
|
+
* <script setup>
|
|
163
|
+
* import { ref } from 'vue'
|
|
164
|
+
* import { useOutlitUser } from '@outlit/browser/vue'
|
|
165
|
+
*
|
|
166
|
+
* // Your auth state
|
|
167
|
+
* const currentUser = ref(null)
|
|
168
|
+
*
|
|
169
|
+
* // Auto-sync with Outlit
|
|
170
|
+
* useOutlitUser(currentUser)
|
|
171
|
+
*
|
|
172
|
+
* // When user logs in
|
|
173
|
+
* const onLogin = (user) => {
|
|
174
|
+
* currentUser.value = {
|
|
175
|
+
* email: user.email,
|
|
176
|
+
* userId: user.id,
|
|
177
|
+
* traits: { name: user.name, plan: user.plan }
|
|
178
|
+
* }
|
|
179
|
+
* }
|
|
180
|
+
*
|
|
181
|
+
* // When user logs out
|
|
182
|
+
* const onLogout = () => {
|
|
183
|
+
* currentUser.value = null
|
|
184
|
+
* }
|
|
185
|
+
* </script>
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
declare function useOutlitUser(userRef: Ref<UserIdentity | null | undefined>): void;
|
|
189
|
+
/**
|
|
190
|
+
* Return type of useTrack composable
|
|
191
|
+
*/
|
|
192
|
+
type UseTrackReturn = ReturnType<typeof useTrack>;
|
|
193
|
+
/**
|
|
194
|
+
* Return type of useIdentify composable
|
|
195
|
+
*/
|
|
196
|
+
type UseIdentifyReturn = ReturnType<typeof useIdentify>;
|
|
197
|
+
|
|
198
|
+
export { type OutlitInstance, OutlitKey, OutlitPlugin, type OutlitPluginOptions, type UseIdentifyReturn, type UseOutlitReturn, type UseTrackReturn, useIdentify, useOutlit, useOutlitUser, useTrack };
|