@entrolytics/vue-sdk 2.2.0 → 3.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/index.d.ts CHANGED
@@ -1,230 +1,9 @@
1
- import { Ref, InjectionKey, App } from 'vue';
2
-
3
- /**
4
- * Event payload type - mirrors @entrolytics/shared EventPayload
5
- * TODO: Import from @entrolytics/shared once published with EventPayload export
6
- */
7
- interface EventPayload {
8
- websiteId: string;
9
- sessionId: string;
10
- visitorId: string;
11
- url: string;
12
- referrer?: string;
13
- eventType: string;
14
- eventName?: string;
15
- properties?: Record<string, unknown>;
16
- screenWidth?: number;
17
- screenHeight?: number;
18
- loadTime?: number;
19
- domInteractive?: number;
20
- domComplete?: number;
21
- utmSource?: string;
22
- utmMedium?: string;
23
- utmCampaign?: string;
24
- utmTerm?: string;
25
- utmContent?: string;
26
- }
27
- type EventData = NonNullable<EventPayload['properties']>;
28
- interface EntrolyticsOptions {
29
- websiteId: string;
30
- host?: string;
31
- autoTrack?: boolean;
32
- respectDnt?: boolean;
33
- domains?: string[];
34
- /** Use edge runtime endpoints for faster response times (default: true) */
35
- useEdgeRuntime?: boolean;
36
- /** Custom tag for A/B testing */
37
- tag?: string;
38
- /** Strip query parameters from URLs */
39
- excludeSearch?: boolean;
40
- /** Strip hash from URLs */
41
- excludeHash?: boolean;
42
- /** Callback before sending data */
43
- beforeSend?: (type: string, payload: unknown) => unknown | null;
44
- }
45
- interface EntrolyticsInstance {
46
- track: (eventName: string, eventData?: EventData) => void;
47
- trackPageView: (url?: string, referrer?: string) => void;
48
- trackRevenue: (eventName: string, revenue: number, currency?: string, data?: EventData) => void;
49
- trackOutboundLink: (url: string, data?: EventData) => void;
50
- identify: (data: EventData) => void;
51
- identifyUser: (userId: string, traits?: EventData) => void;
52
- setTag: (tag: string) => void;
53
- config: EntrolyticsOptions;
54
- isLoaded: Ref<boolean>;
55
- isReady: Ref<boolean>;
56
- }
57
- declare global {
58
- interface Window {
59
- entrolytics?: {
60
- track: (eventName?: string | object, eventData?: Record<string, unknown>) => void;
61
- identify: (data: Record<string, unknown>) => void;
62
- };
63
- }
64
- }
65
- declare const EntrolyticsKey: InjectionKey<EntrolyticsInstance>;
66
- /**
67
- * Create Entrolytics Vue plugin
68
- *
69
- * @example
70
- * Zero-config (reads from import.meta.env):
71
- * ```ts
72
- * import { createApp } from 'vue';
73
- * import { createEntrolytics } from '@entrolytics/vue';
74
- *
75
- * const app = createApp(App);
76
- * app.use(createEntrolytics());
77
- * app.mount('#app');
78
- * ```
79
- *
80
- * @example
81
- * Explicit config:
82
- * ```ts
83
- * const app = createApp(App);
84
- * app.use(createEntrolytics({ websiteId: 'your-website-id' }));
85
- * app.mount('#app');
86
- * ```
87
- */
88
- declare function createEntrolytics(options?: Partial<EntrolyticsOptions>): {
89
- install(app: App): void;
90
- };
91
- /**
92
- * Use Entrolytics instance in composition API
93
- */
94
- declare function useEntrolyticsInstance(): EntrolyticsInstance;
95
-
96
- /**
97
- * Main composable for accessing Entrolytics functionality
98
- *
99
- * @example
100
- * ```vue
101
- * <script setup>
102
- * import { useEntrolytics } from '@entrolytics/vue';
103
- *
104
- * const { track, identify, isLoaded } = useEntrolytics();
105
- *
106
- * function handleClick() {
107
- * track('button_click', { variant: 'primary' });
108
- * }
109
- * </script>
110
- * ```
111
- */
112
- declare function useEntrolytics(): EntrolyticsInstance;
113
-
114
- /**
115
- * Composable for identifying users
116
- *
117
- * @example
118
- * ```vue
119
- * <script setup>
120
- * import { watch } from 'vue';
121
- * import { useIdentify } from '@entrolytics/vue';
122
- *
123
- * const { identify } = useIdentify();
124
- * const user = useUser(); // Your auth composable
125
- *
126
- * watch(user, (newUser) => {
127
- * if (newUser) {
128
- * identify(newUser.id, {
129
- * email: newUser.email,
130
- * plan: newUser.subscription
131
- * });
132
- * }
133
- * });
134
- * </script>
135
- * ```
136
- */
137
- declare function useIdentify(): {
138
- identify: (data: EventData) => void;
139
- };
140
-
141
- /**
142
- * Composable for tracking custom events
143
- *
144
- * @example
145
- * ```vue
146
- * <script setup>
147
- * import { useTrackEvent } from '@entrolytics/vue';
148
- *
149
- * const { track } = useTrackEvent();
150
- *
151
- * function handlePurchase() {
152
- * track('purchase', { revenue: 99.99, currency: 'USD' });
153
- * }
154
- * </script>
155
- * ```
156
- */
157
- declare function useTrackEvent(): {
158
- track: (eventName: string, eventData?: EventData) => void;
159
- };
160
-
161
- /**
162
- * Composable for tracking outbound link clicks
163
- *
164
- * @example
165
- * ```vue
166
- * <script setup>
167
- * import { useTrackOutboundLink } from '@entrolytics/vue';
168
- *
169
- * const trackOutboundLink = useTrackOutboundLink();
170
- *
171
- * const handleExternalClick = (url: string) => {
172
- * trackOutboundLink(url, { placement: 'footer' });
173
- * };
174
- * </script>
175
- * ```
176
- */
177
- declare function useTrackOutboundLink(): (url: string, data?: EventData) => void;
178
-
179
- /**
180
- * Composable for tracking page views with vue-router
181
- *
182
- * @example
183
- * ```vue
184
- * <script setup>
185
- * import { useRoute } from 'vue-router';
186
- * import { useTrackPageView } from '@entrolytics/vue';
187
- *
188
- * const route = useRoute();
189
- * useTrackPageView(() => route.path);
190
- * </script>
191
- * ```
192
- *
193
- * @example
194
- * ```vue
195
- * <script setup>
196
- * import { ref } from 'vue';
197
- * import { useTrackPageView } from '@entrolytics/vue';
198
- *
199
- * const currentPath = ref('/');
200
- * useTrackPageView(currentPath);
201
- * </script>
202
- * ```
203
- */
204
- declare function useTrackPageView(pathSource: Ref<string> | (() => string), options?: {
205
- immediate?: boolean;
206
- }): void;
207
-
208
- /**
209
- * Composable for tracking revenue events
210
- *
211
- * @example
212
- * ```vue
213
- * <script setup>
214
- * import { useTrackRevenue } from '@entrolytics/vue';
215
- *
216
- * const trackRevenue = useTrackRevenue();
217
- *
218
- * const handlePurchase = async (product) => {
219
- * await processPayment();
220
- * trackRevenue('purchase', product.price, 'USD', {
221
- * productId: product.id,
222
- * productName: product.name
223
- * });
224
- * };
225
- * </script>
226
- * ```
227
- */
228
- declare function useTrackRevenue(): (eventName: string, revenue: number, currency?: string, data?: EventData) => void;
229
-
230
- export { type EntrolyticsInstance, EntrolyticsKey, type EntrolyticsOptions, type EventData, createEntrolytics, useEntrolytics, useEntrolyticsInstance, useIdentify, useTrackEvent, useTrackOutboundLink, useTrackPageView, useTrackRevenue };
1
+ export { useEntrolytics } from './composables/useEntrolytics.js';
2
+ export { useIdentify } from './composables/useIdentify.js';
3
+ export { useTrackEvent } from './composables/useTrackEvent.js';
4
+ export { useTrackOutboundLink } from './composables/useTrackOutboundLink.js';
5
+ export { useTrackPageView } from './composables/useTrackPageView.js';
6
+ export { useTrackRevenue } from './composables/useTrackRevenue.js';
7
+ export type { EntrolyticsInstance, EntrolyticsOptions, EventData } from './plugin.js';
8
+ export { createEntrolytics, EntrolyticsKey, useEntrolyticsInstance } from './plugin.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACtF,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC"}