@aranova/tracking-react 0.11.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 +35 -24
- package/dist/index.d.mts +304 -306
- package/dist/index.d.ts +304 -306
- package/dist/index.js +237 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +233 -17
- package/dist/index.mjs.map +1 -1
- package/dist/phone-utils-CVX7JmqB.d.mts +343 -0
- package/dist/phone-utils-CVX7JmqB.d.ts +343 -0
- package/dist/phone.d.mts +3 -0
- package/dist/phone.d.ts +3 -0
- package/dist/phone.js +318 -0
- package/dist/phone.js.map +1 -0
- package/dist/phone.mjs +286 -0
- package/dist/phone.mjs.map +1 -0
- package/package.json +7 -1
package/README.md
CHANGED
|
@@ -54,30 +54,16 @@ createRoot(document.getElementById('root')!).render(
|
|
|
54
54
|
|
|
55
55
|
### Multiple gtag IDs
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
Pass `gtagIds` (instead of `gtagId`) to install several Google Ads tags at once — e.g. a real
|
|
58
|
+
account plus a test MCC. Each entry fires `gtag('config', …)` on every page; the labels surface in
|
|
59
|
+
the dashboard's SDK table. Stamp events with `environment` to filter out test traffic.
|
|
58
60
|
|
|
59
61
|
```tsx
|
|
60
|
-
<TrackingProvider
|
|
61
|
-
gtagIds={{
|
|
62
|
-
production: 'AW-111111111', // real client account
|
|
63
|
-
test: 'AW-222222222', // test MCC for development
|
|
64
|
-
}}
|
|
65
|
-
>
|
|
62
|
+
<TrackingProvider gtagIds={{ production: 'AW-111111111', test: 'AW-222222222' }}>
|
|
66
63
|
<App />
|
|
67
64
|
</TrackingProvider>
|
|
68
65
|
```
|
|
69
66
|
|
|
70
|
-
The labels are arbitrary and surface in the Aranova dashboard's SDK versions table. You can also stamp events with a deployment environment so the dashboard can filter out test traffic:
|
|
71
|
-
|
|
72
|
-
```ts
|
|
73
|
-
createTracking({
|
|
74
|
-
apiKey: import.meta.env.VITE_ARANOVA_TRACKING_API_KEY,
|
|
75
|
-
endpoint: import.meta.env.VITE_ARANOVA_TRACKING_ENDPOINT,
|
|
76
|
-
environment: import.meta.env.MODE, // 'production' | 'development'
|
|
77
|
-
triggers: { /* ... */ },
|
|
78
|
-
});
|
|
79
|
-
```
|
|
80
|
-
|
|
81
67
|
## Manual Events
|
|
82
68
|
|
|
83
69
|
Manual events must be registered under `triggers.manual` before `trackEvent()` accepts them.
|
|
@@ -129,6 +115,23 @@ tracking.trackEvent('phone_click', {
|
|
|
129
115
|
});
|
|
130
116
|
```
|
|
131
117
|
|
|
118
|
+
## Phone Fields
|
|
119
|
+
|
|
120
|
+
Bundled `libphonenumber-js`: parse/format utils + a React input. Display is configurable; the
|
|
121
|
+
value sent to the backend is **always E.164**. Configure once via `createTracking({ phone: { defaultCountry: 'CA', display: 'national' } })`.
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
import { usePhoneField, PhoneField, toE164 } from '@aranova/tracking-react';
|
|
125
|
+
|
|
126
|
+
const phone = usePhoneField(); // phone.value (display), phone.e164 (wire), .isValid, .error
|
|
127
|
+
<input {...phone.inputProps} />; // or the batteries-included <PhoneField name="phone" />
|
|
128
|
+
|
|
129
|
+
toE164('416-555-0199'); // '+14165550199' (null if invalid)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Pure, isomorphic utils are also at `@aranova/tracking-react/phone` (no React). Full guide:
|
|
133
|
+
[phone.md](https://github.com/AranovaIO/aranova_internal/blob/master/docs/tracking-package/phone.md).
|
|
134
|
+
|
|
132
135
|
## Recording Sales
|
|
133
136
|
|
|
134
137
|
Record a sale / conversion (a first-class, mutable resource — not a fire-and-forget
|
|
@@ -162,12 +165,19 @@ export default async function handler(_req, res) {
|
|
|
162
165
|
}
|
|
163
166
|
```
|
|
164
167
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
+
Secret-key reads power dashboards (all currency-grouped — never summed across currencies):
|
|
169
|
+
|
|
170
|
+
```ts
|
|
171
|
+
await sales.summary({ range: 'mtd', timezone: 'America/Toronto', compare_to: 'previous_period' });
|
|
172
|
+
await sales.list({ sort: 'amount_total_cents', want_total: true }); // → { items, total_count, … }
|
|
173
|
+
await sales.customers.list({ segment: 'returning', sort: 'total_spent' }); // phone-keyed roster
|
|
174
|
+
await sales.customers.summary({ range: 'mtd' });
|
|
175
|
+
const cfg = await sales.business.config(); // tz / currencies / services (pk or sk)
|
|
176
|
+
```
|
|
168
177
|
|
|
169
|
-
|
|
170
|
-
|
|
178
|
+
`summary()` gains tz-aware calendar/custom ranges, `granularity`, and period-over-period
|
|
179
|
+
`compare_to`; legacy `24h/7d/30d` are unchanged. A **customer is their phone (E.164)** — `customers.*`
|
|
180
|
+
is a live roster, no separate table. A public-key client calling any read gets a `403`.
|
|
171
181
|
|
|
172
182
|
Generate the typed `AranovaService` union from your dashboard services with the CLI
|
|
173
183
|
(install it as a **devDependency**):
|
|
@@ -244,7 +254,8 @@ The hook handles localStorage persistence, gtag sync, and cross-tab propagation
|
|
|
244
254
|
- Consent hooks: `useConsent()` + `UseConsentResult` (headless); `useConsentState()` (read-only alias)
|
|
245
255
|
- Standalone consent helpers: `getConsentState()`, `setConsentState()`, `resetConsent()`
|
|
246
256
|
- Attribution hooks: `useTrackingParams()`, `useGclid()`
|
|
247
|
-
- `createSalesClient()` (isomorphic
|
|
257
|
+
- `createSalesClient()` (isomorphic — public key writes; secret key reads/CRUD, `summary`, `customers.*`, `business.config`) + money/date helpers (`toMinor`/`fromMinor`/`formatMoney`/`formatDateInTz`)
|
|
258
|
+
- Phone: `parsePhone`/`toE164`/`formatPhone`/`formatPhoneAsTyped`/`phoneField`, `usePhoneField`, `PhoneField` (utils also at `/phone`)
|
|
248
259
|
- Codegen: [`@aranova/tracking-cli`](https://www.npmjs.com/package/@aranova/tracking-cli) — `gen` typed service unions (devDependency)
|
|
249
260
|
- Event metadata/config types such as `FormSubmitMetadata`, `PhoneClickMetadata`, and `JsonValue`
|
|
250
261
|
|