@builtonveya/analytics-web 4.0.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/README.md ADDED
@@ -0,0 +1,81 @@
1
+ # @builtonveya/analytics-web
2
+
3
+ Veya Analytics SDK for the web. Auto-detects page types, product impressions and cart changes on
4
+ restaurant ordering sites, and ships events to the Veya analytics pipeline in batches.
5
+
6
+ Shares its core with `@builtonveya/analytics-react-native` (same event taxonomy, same version line).
7
+
8
+ ## Install
9
+
10
+ **npm / yarn / pnpm**
11
+
12
+ ```bash
13
+ npm install @builtonveya/analytics-web
14
+ ```
15
+
16
+ ```ts
17
+ import veya from '@builtonveya/analytics-web';
18
+
19
+ await veya.init({ tenantSlug: 'your-tenant-slug' });
20
+ ```
21
+
22
+ **Script tag** (the package ships a self-contained browser bundle that sets `window.veya`)
23
+
24
+ ```html
25
+ <script src="https://cdn.jsdelivr.net/npm/@builtonveya/analytics-web@4/dist/veya-analytics.min.js"></script>
26
+ <script>
27
+ veya.init({ tenantSlug: 'your-tenant-slug' });
28
+ </script>
29
+ ```
30
+
31
+ Pin the major (`@4`) for automatic patch updates, or an exact version (`@4.0.0`) for a frozen build.
32
+
33
+ ## Configure
34
+
35
+ ```ts
36
+ await veya.init({
37
+ tenantSlug: 'your-tenant-slug', // required
38
+ endpoint: 'https://analytics.builtonveya.com/v1/events',
39
+ storeId: 'store-81', // if known at init; otherwise call veya.setStore(id, name)
40
+ debug: false,
41
+ autoDetect: true, // page-type detection on navigation
42
+ autoTrackProducts: true, // product impressions
43
+ autoTrackCart: true, // cart change detection
44
+ interceptOloApi: true, // reads Olo checkout responses for orders
45
+ batchSize: 10,
46
+ flushInterval: 5000,
47
+ sessionTimeout: 1800000, // 30 minutes
48
+ });
49
+ ```
50
+
51
+ ## Track
52
+
53
+ Everything the core SDK offers is on the default export: `track`, `pageView`, `productView`,
54
+ `productClick`, `addToCart`, `removeFromCart`, `updateCartQuantity`, `setCart`, `checkoutStart`,
55
+ `checkoutStep`, `checkoutComplete`, `loginAttempt`, `loginSuccess`, `loginFailure`, `logout`, `identify`,
56
+ `storeSelect`, `setStore`, `search`, `loyaltyLogin`, `rewardView`, `rewardApply`, `rewardRemove`, `promoApply`,
57
+ `promoRemove`, `setExperiment`, `error`, `flush`, `getSessionId`, `getVisitorId`, `getCustomerId`.
58
+
59
+ ```ts
60
+ veya.setStore('81', 'Earthbar Flagship - West Hollywood');
61
+ veya.addToCart({ id: 'olo:item:106702642', name: 'The Workout Smoothie', price: 12.95 }, 1);
62
+ veya.checkoutComplete({ order_id: '46749…', total: 12.95, items: [...] });
63
+ ```
64
+
65
+ ## Server-side rendering
66
+
67
+ Importing the package on the server is safe: module load only registers `window.veya` when a
68
+ `window` exists, and nothing touches the DOM until `init()` runs. Call `init()` from a client-side
69
+ effect.
70
+
71
+ ## Build & publish
72
+
73
+ ```bash
74
+ cd sdk/web
75
+ npm ci
76
+ npm run build # dist/esm (ESM + types), dist/cjs, dist/veya-analytics[.min].js
77
+ npm run smoke # loads all three outputs and checks the public surface
78
+ npm publish # prepublishOnly runs build + smoke; scope @builtonveya is public
79
+ ```
80
+
81
+ Bump `version` in `package.json` in step with the React Native package when the shared core changes.