@aranova/tracking-next 0.10.0 → 0.12.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 CHANGED
@@ -80,31 +80,12 @@ export default function RootLayout({ children }: { children: React.ReactNode })
80
80
 
81
81
  ### Multiple gtag IDs
82
82
 
83
- To install multiple Google Ads tags simultaneously (for example a production MCC and a test MCC for verifying conversion actions before they touch the live account), pass `gtagIds` instead of `gtagId`. Every entry fires `gtag('config', ...)` on every page — gtag natively supports multiple configured tags.
83
+ Pass `gtagIds` (instead of `gtagId`) to install several Google Ads tags at once — e.g. a real
84
+ account plus a test MCC. Each entry fires `gtag('config', …)` on every page; the labels surface in
85
+ the dashboard's SDK table. Pass `environment` to the factory to tag events for dashboard filtering.
84
86
 
85
87
  ```tsx
86
- <GoogleAdsTracking
87
- gtagIds={{
88
- production: 'AW-111111111', // real client account
89
- test: 'AW-222222222', // test MCC for development
90
- }}
91
- />
92
- ```
93
-
94
- The labels are arbitrary and surface in the Aranova dashboard's SDK versions table. Also pass `environment` to the factory so events are tagged with the deployment context for dashboard filtering:
95
-
96
- ```ts
97
- // lib/tracking.ts
98
- createTracking({
99
- apiKey: process.env.NEXT_PUBLIC_ARANOVA_TRACKING_API_KEY!,
100
- endpoint: process.env.NEXT_PUBLIC_ARANOVA_TRACKING_ENDPOINT!,
101
- environment: process.env.NEXT_PUBLIC_TRACKING_ENVIRONMENT, // 'production' | 'development'
102
- gtagIds: { // optional — reports the configured tags in heartbeat metadata
103
- production: process.env.NEXT_PUBLIC_GTAG_PROD!,
104
- test: process.env.NEXT_PUBLIC_GTAG_TEST!,
105
- },
106
- triggers: { /* ... */ },
107
- });
88
+ <GoogleAdsTracking gtagIds={{ production: 'AW-111111111', test: 'AW-222222222' }} />
108
89
  ```
109
90
 
110
91
  ## Manual Events
@@ -158,6 +139,23 @@ export function LeadForm() {
158
139
 
159
140
  `fields[].value` can be any JSON value: string, number, boolean, null, array, or object. Only send reviewed, allowlisted, non-sensitive values; do not send names, emails, phone numbers entered by the visitor, addresses, payment data, medical details, passwords, file contents, or free-text messages.
160
141
 
142
+ ## Phone Fields
143
+
144
+ Bundled `libphonenumber-js`: parse/format utils + a React input. Display is configurable; the
145
+ value sent to the backend is **always E.164**. Configure once via `createTracking({ phone: { defaultCountry: 'CA', display: 'national' } })`.
146
+
147
+ ```tsx
148
+ 'use client';
149
+ import { usePhoneField, PhoneField, toE164 } from '@aranova/tracking-next';
150
+
151
+ const phone = usePhoneField(); // phone.value (display), phone.e164 (wire), .isValid, .error
152
+ <input {...phone.inputProps} />; // or the batteries-included <PhoneField name="phone" />
153
+ ```
154
+
155
+ Pure, isomorphic utils (usable in Server Components / route handlers) are at
156
+ `@aranova/tracking-next/phone`. Full guide:
157
+ [phone.md](https://github.com/AranovaIO/aranova_internal/blob/master/docs/tracking-package/phone.md).
158
+
161
159
  ## Server Reads
162
160
 
163
161
  Read attribution cookies from Server Components or server actions.
@@ -199,16 +197,16 @@ const sales = createSalesClient<AranovaService>({
199
197
  apiKey: process.env.ARANOVA_TRACKING_SECRET_KEY!,
200
198
  endpoint: process.env.ARANOVA_TRACKING_ENDPOINT!,
201
199
  });
202
- const { items, next_cursor } = await sales.list({ limit: 50 });
203
- const summary = await sales.summary({ range: '30d' }); // currency-grouped aggregations
200
+ await sales.list({ sort: 'amount_total_cents', want_total: true }); // → { items, total_count, … }
201
+ await sales.summary({ range: 'mtd', timezone: 'America/Toronto', compare_to: 'previous_period' });
202
+ await sales.customers.list({ segment: 'returning', sort: 'total_spent' }); // phone-keyed roster
203
+ const cfg = await sales.business.config(); // tz / currencies / services
204
204
  ```
205
205
 
206
- `sales.summary({ range })` returns revenue and average order value per currency,
207
- distinct customers, by-service / by-currency / by-category breakdowns, and a
208
- revenue/count trend — a secret-key read scoped to the key's business.
209
-
210
- A public-key client calling `list`/`summary`/`get`/`update`/`delete` gets a `403`
211
- telling it to use a secret key server-side.
206
+ Dashboard reads are all currency-grouped (never summed). `summary()` gains tz-aware calendar/custom
207
+ ranges, `granularity`, and period-over-period `compare_to` (legacy `24h/7d/30d` unchanged); a
208
+ **customer is their phone (E.164)**, so `customers.*` is a live roster with no separate table.
209
+ A public-key client calling any read gets a `403`.
212
210
 
213
211
  Generate the typed `AranovaService` union from your dashboard services with the CLI
214
212
  (install it as a **devDependency**):
@@ -279,8 +277,9 @@ The hook handles localStorage persistence, gtag sync, and cross-tab propagation
279
277
 
280
278
  ## Exports
281
279
 
282
- - Root package: `createTracking`, `TrackingProvider`, `useTracking`, `GoogleAdsTracking`, `ConsentBanner` (+ `ConsentBannerProps`), `useConsent` (+ `UseConsentResult`), `useConsentState`, `useGclid`, `useTrackingParams`, standalone consent helpers (`getConsentState`, `setConsentState`, `resetConsent`), event types, and `createSalesClient()` (isomorphic sales client — public key writes, secret key reads/CRUD) + money helpers (`toMinor`/`fromMinor`/`formatMoney`)
280
+ - Root package: `createTracking`, `TrackingProvider`, `useTracking`, `GoogleAdsTracking`, `ConsentBanner` (+ `ConsentBannerProps`), consent hooks/helpers, attribution hooks, event types; `createSalesClient()` (isomorphic — public key writes; secret key reads/CRUD, `summary`, `customers.*`, `business.config`) + `toMinor`/`fromMinor`/`formatMoney`/`formatDateInTz`; phone (`parsePhone`/`toE164`/`formatPhone`/`phoneField`, `usePhoneField`, `PhoneField`)
283
281
  - `@aranova/tracking-next/middleware`: `createTrackingMiddleware()`
284
282
  - `@aranova/tracking-next/server`: `getTrackingParamsServer()`
283
+ - `@aranova/tracking-next/phone`: isomorphic phone utils (no React)
285
284
  - Codegen: [`@aranova/tracking-cli`](https://www.npmjs.com/package/@aranova/tracking-cli) — `gen` typed service unions (devDependency)
286
285