@aranova/tracking-react 0.7.2 → 0.9.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 +49 -0
- package/dist/index.d.mts +348 -1
- package/dist/index.d.ts +348 -1
- package/dist/index.js +131 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +125 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -129,6 +129,53 @@ tracking.trackEvent('phone_click', {
|
|
|
129
129
|
});
|
|
130
130
|
```
|
|
131
131
|
|
|
132
|
+
## Recording Sales
|
|
133
|
+
|
|
134
|
+
Record a sale / conversion (a first-class, mutable resource — not a fire-and-forget
|
|
135
|
+
event). Money is integer minor units (cents); `currency` is a required ISO-4217 enum.
|
|
136
|
+
|
|
137
|
+
One isomorphic `createSalesClient` (on the root entry) serves both sides — what a
|
|
138
|
+
key may do is enforced by the backend, not by hiding methods. Browser write with
|
|
139
|
+
your **public** key:
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
import { createSalesClient, toMinor } from '@aranova/tracking-react';
|
|
143
|
+
|
|
144
|
+
const sales = createSalesClient({ apiKey: import.meta.env.VITE_ARANOVA_TRACKING_API_KEY, endpoint });
|
|
145
|
+
await sales.record({ currency: 'CAD', amount_total_cents: toMinor(250, 'CAD'), service: 'tires' });
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Reads / full CRUD require a **secret** key and must run server-side — never ship a
|
|
149
|
+
secret key in the browser bundle. In a Vite + Vercel app, hold it in a serverless
|
|
150
|
+
function (same import, secret key):
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
// api/sales.ts (Vercel serverless function — runs on the server)
|
|
154
|
+
import { createSalesClient } from '@aranova/tracking-react';
|
|
155
|
+
|
|
156
|
+
const sales = createSalesClient({
|
|
157
|
+
apiKey: process.env.ARANOVA_TRACKING_SECRET_KEY!,
|
|
158
|
+
endpoint: process.env.ARANOVA_TRACKING_ENDPOINT!,
|
|
159
|
+
});
|
|
160
|
+
export default async function handler(_req, res) {
|
|
161
|
+
res.json(await sales.list({ limit: 50 }));
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
A public-key client calling `list`/`get`/`update`/`delete` gets a `403` telling it
|
|
166
|
+
to use a secret key server-side.
|
|
167
|
+
|
|
168
|
+
Generate the typed `AranovaService` union from your dashboard services with the CLI
|
|
169
|
+
(install it as a **devDependency**):
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
npm install --save-dev @aranova/tracking-cli
|
|
173
|
+
npx @aranova/tracking-cli gen # reads ARANOVA_TRACKING_SECRET_KEY from .env
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
See the full guide: [sales-tracking.md](https://github.com/AranovaIO/aranova_internal/blob/master/docs/tracking-package/sales-tracking.md)
|
|
177
|
+
and the CLI reference: [cli.md](https://github.com/AranovaIO/aranova_internal/blob/master/docs/tracking-package/cli.md).
|
|
178
|
+
|
|
132
179
|
## Exports
|
|
133
180
|
|
|
134
181
|
- `createTracking()`
|
|
@@ -136,5 +183,7 @@ tracking.trackEvent('phone_click', {
|
|
|
136
183
|
- `GoogleAdsTracking`
|
|
137
184
|
- `ConsentBanner`
|
|
138
185
|
- `useTrackingParams()`, `useGclid()`, `useConsentState()`
|
|
186
|
+
- `createSalesClient()` (isomorphic sales client — public key writes, secret key reads/CRUD) + money helpers (`toMinor`/`fromMinor`/`formatMoney`)
|
|
187
|
+
- Codegen: [`@aranova/tracking-cli`](https://www.npmjs.com/package/@aranova/tracking-cli) — `gen` typed service unions (devDependency)
|
|
139
188
|
- Event metadata/config types such as `FormSubmitMetadata`, `PhoneClickMetadata`, and `JsonValue`
|
|
140
189
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1398,6 +1398,353 @@ interface TypedTrackingClient<TRegistry extends TriggerRegistryConfig> {
|
|
|
1398
1398
|
getVisitorId(): string;
|
|
1399
1399
|
}
|
|
1400
1400
|
|
|
1401
|
+
/**
|
|
1402
|
+
* Sales / Conversions wire schemas — the client-side source of truth.
|
|
1403
|
+
*
|
|
1404
|
+
* `saleCreateSchema` is mirrored by `SaleCreateSchema` in
|
|
1405
|
+
* `apps/api/src/schemas/tracking_sales.py` and enforced by the backend drift
|
|
1406
|
+
* test (the `resources` section of `events.schema.json`). Keep them in lockstep.
|
|
1407
|
+
*
|
|
1408
|
+
* Money is **integer minor units (cents)**; `quantity` is a decimal string;
|
|
1409
|
+
* `currency` is the required `SupportedCurrency` enum.
|
|
1410
|
+
*/
|
|
1411
|
+
declare const SUPPORTED_CURRENCIES: readonly ["USD", "CAD"];
|
|
1412
|
+
type SupportedCurrency = (typeof SUPPORTED_CURRENCIES)[number];
|
|
1413
|
+
declare const TRACKING_ENVIRONMENTS: readonly ["production", "development"];
|
|
1414
|
+
declare const saleItemSchema: z.ZodObject<{
|
|
1415
|
+
external_item_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1416
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1417
|
+
category: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1418
|
+
quantity: z.ZodString;
|
|
1419
|
+
unit_price_cents: z.ZodNumber;
|
|
1420
|
+
unit_cost_cents: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
1421
|
+
}, "strict", z.ZodTypeAny, {
|
|
1422
|
+
quantity: string;
|
|
1423
|
+
unit_price_cents: number;
|
|
1424
|
+
name?: string | null | undefined;
|
|
1425
|
+
external_item_id?: string | null | undefined;
|
|
1426
|
+
category?: string | null | undefined;
|
|
1427
|
+
unit_cost_cents?: number | null | undefined;
|
|
1428
|
+
}, {
|
|
1429
|
+
quantity: string;
|
|
1430
|
+
unit_price_cents: number;
|
|
1431
|
+
name?: string | null | undefined;
|
|
1432
|
+
external_item_id?: string | null | undefined;
|
|
1433
|
+
category?: string | null | undefined;
|
|
1434
|
+
unit_cost_cents?: number | null | undefined;
|
|
1435
|
+
}>;
|
|
1436
|
+
declare const saleCreateSchema: z.ZodObject<{
|
|
1437
|
+
external_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1438
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1439
|
+
service: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1440
|
+
currency: z.ZodEnum<["USD", "CAD"]>;
|
|
1441
|
+
amount_total_cents: z.ZodNumber;
|
|
1442
|
+
occurred_at: z.ZodString;
|
|
1443
|
+
environment: z.ZodDefault<z.ZodEnum<["production", "development"]>>;
|
|
1444
|
+
items: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
1445
|
+
external_item_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1446
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1447
|
+
category: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1448
|
+
quantity: z.ZodString;
|
|
1449
|
+
unit_price_cents: z.ZodNumber;
|
|
1450
|
+
unit_cost_cents: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
1451
|
+
}, "strict", z.ZodTypeAny, {
|
|
1452
|
+
quantity: string;
|
|
1453
|
+
unit_price_cents: number;
|
|
1454
|
+
name?: string | null | undefined;
|
|
1455
|
+
external_item_id?: string | null | undefined;
|
|
1456
|
+
category?: string | null | undefined;
|
|
1457
|
+
unit_cost_cents?: number | null | undefined;
|
|
1458
|
+
}, {
|
|
1459
|
+
quantity: string;
|
|
1460
|
+
unit_price_cents: number;
|
|
1461
|
+
name?: string | null | undefined;
|
|
1462
|
+
external_item_id?: string | null | undefined;
|
|
1463
|
+
category?: string | null | undefined;
|
|
1464
|
+
unit_cost_cents?: number | null | undefined;
|
|
1465
|
+
}>, "many">>;
|
|
1466
|
+
metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
1467
|
+
customer_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1468
|
+
customer_phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1469
|
+
customer_email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1470
|
+
}, "strict", z.ZodTypeAny, {
|
|
1471
|
+
currency: "USD" | "CAD";
|
|
1472
|
+
amount_total_cents: number;
|
|
1473
|
+
occurred_at: string;
|
|
1474
|
+
environment: "production" | "development";
|
|
1475
|
+
items: {
|
|
1476
|
+
quantity: string;
|
|
1477
|
+
unit_price_cents: number;
|
|
1478
|
+
name?: string | null | undefined;
|
|
1479
|
+
external_item_id?: string | null | undefined;
|
|
1480
|
+
category?: string | null | undefined;
|
|
1481
|
+
unit_cost_cents?: number | null | undefined;
|
|
1482
|
+
}[];
|
|
1483
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
1484
|
+
external_id?: string | null | undefined;
|
|
1485
|
+
description?: string | null | undefined;
|
|
1486
|
+
service?: string | null | undefined;
|
|
1487
|
+
customer_name?: string | null | undefined;
|
|
1488
|
+
customer_phone?: string | null | undefined;
|
|
1489
|
+
customer_email?: string | null | undefined;
|
|
1490
|
+
}, {
|
|
1491
|
+
currency: "USD" | "CAD";
|
|
1492
|
+
amount_total_cents: number;
|
|
1493
|
+
occurred_at: string;
|
|
1494
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
1495
|
+
external_id?: string | null | undefined;
|
|
1496
|
+
description?: string | null | undefined;
|
|
1497
|
+
service?: string | null | undefined;
|
|
1498
|
+
environment?: "production" | "development" | undefined;
|
|
1499
|
+
items?: {
|
|
1500
|
+
quantity: string;
|
|
1501
|
+
unit_price_cents: number;
|
|
1502
|
+
name?: string | null | undefined;
|
|
1503
|
+
external_item_id?: string | null | undefined;
|
|
1504
|
+
category?: string | null | undefined;
|
|
1505
|
+
unit_cost_cents?: number | null | undefined;
|
|
1506
|
+
}[] | undefined;
|
|
1507
|
+
customer_name?: string | null | undefined;
|
|
1508
|
+
customer_phone?: string | null | undefined;
|
|
1509
|
+
customer_email?: string | null | undefined;
|
|
1510
|
+
}>;
|
|
1511
|
+
declare const saleUpdateSchema: z.ZodObject<{
|
|
1512
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1513
|
+
service: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1514
|
+
currency: z.ZodOptional<z.ZodEnum<["USD", "CAD"]>>;
|
|
1515
|
+
amount_total_cents: z.ZodOptional<z.ZodNumber>;
|
|
1516
|
+
occurred_at: z.ZodOptional<z.ZodString>;
|
|
1517
|
+
items: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1518
|
+
external_item_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1519
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1520
|
+
category: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1521
|
+
quantity: z.ZodString;
|
|
1522
|
+
unit_price_cents: z.ZodNumber;
|
|
1523
|
+
unit_cost_cents: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
1524
|
+
}, "strict", z.ZodTypeAny, {
|
|
1525
|
+
quantity: string;
|
|
1526
|
+
unit_price_cents: number;
|
|
1527
|
+
name?: string | null | undefined;
|
|
1528
|
+
external_item_id?: string | null | undefined;
|
|
1529
|
+
category?: string | null | undefined;
|
|
1530
|
+
unit_cost_cents?: number | null | undefined;
|
|
1531
|
+
}, {
|
|
1532
|
+
quantity: string;
|
|
1533
|
+
unit_price_cents: number;
|
|
1534
|
+
name?: string | null | undefined;
|
|
1535
|
+
external_item_id?: string | null | undefined;
|
|
1536
|
+
category?: string | null | undefined;
|
|
1537
|
+
unit_cost_cents?: number | null | undefined;
|
|
1538
|
+
}>, "many">>;
|
|
1539
|
+
metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
1540
|
+
customer_name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1541
|
+
customer_phone: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1542
|
+
customer_email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1543
|
+
}, "strict", z.ZodTypeAny, {
|
|
1544
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
1545
|
+
description?: string | null | undefined;
|
|
1546
|
+
service?: string | null | undefined;
|
|
1547
|
+
currency?: "USD" | "CAD" | undefined;
|
|
1548
|
+
amount_total_cents?: number | undefined;
|
|
1549
|
+
occurred_at?: string | undefined;
|
|
1550
|
+
items?: {
|
|
1551
|
+
quantity: string;
|
|
1552
|
+
unit_price_cents: number;
|
|
1553
|
+
name?: string | null | undefined;
|
|
1554
|
+
external_item_id?: string | null | undefined;
|
|
1555
|
+
category?: string | null | undefined;
|
|
1556
|
+
unit_cost_cents?: number | null | undefined;
|
|
1557
|
+
}[] | undefined;
|
|
1558
|
+
customer_name?: string | null | undefined;
|
|
1559
|
+
customer_phone?: string | null | undefined;
|
|
1560
|
+
customer_email?: string | null | undefined;
|
|
1561
|
+
}, {
|
|
1562
|
+
metadata?: Record<string, unknown> | null | undefined;
|
|
1563
|
+
description?: string | null | undefined;
|
|
1564
|
+
service?: string | null | undefined;
|
|
1565
|
+
currency?: "USD" | "CAD" | undefined;
|
|
1566
|
+
amount_total_cents?: number | undefined;
|
|
1567
|
+
occurred_at?: string | undefined;
|
|
1568
|
+
items?: {
|
|
1569
|
+
quantity: string;
|
|
1570
|
+
unit_price_cents: number;
|
|
1571
|
+
name?: string | null | undefined;
|
|
1572
|
+
external_item_id?: string | null | undefined;
|
|
1573
|
+
category?: string | null | undefined;
|
|
1574
|
+
unit_cost_cents?: number | null | undefined;
|
|
1575
|
+
}[] | undefined;
|
|
1576
|
+
customer_name?: string | null | undefined;
|
|
1577
|
+
customer_phone?: string | null | undefined;
|
|
1578
|
+
customer_email?: string | null | undefined;
|
|
1579
|
+
}>;
|
|
1580
|
+
type SaleItemInput = z.input<typeof saleItemSchema>;
|
|
1581
|
+
type SaleInput = z.input<typeof saleCreateSchema>;
|
|
1582
|
+
type SaleUpdateInput = z.input<typeof saleUpdateSchema>;
|
|
1583
|
+
interface SaleItem {
|
|
1584
|
+
id: string;
|
|
1585
|
+
external_item_id: string | null;
|
|
1586
|
+
name: string | null;
|
|
1587
|
+
category: string | null;
|
|
1588
|
+
quantity: string;
|
|
1589
|
+
unit_price_cents: number;
|
|
1590
|
+
unit_cost_cents: number | null;
|
|
1591
|
+
}
|
|
1592
|
+
interface Sale {
|
|
1593
|
+
id: string;
|
|
1594
|
+
business_id: string;
|
|
1595
|
+
business_name?: string | null;
|
|
1596
|
+
external_id: string | null;
|
|
1597
|
+
currency: SupportedCurrency;
|
|
1598
|
+
amount_total_cents: number;
|
|
1599
|
+
description: string | null;
|
|
1600
|
+
service_id: string | null;
|
|
1601
|
+
service_key?: string | null;
|
|
1602
|
+
service_label?: string | null;
|
|
1603
|
+
occurred_at: string;
|
|
1604
|
+
environment: (typeof TRACKING_ENVIRONMENTS)[number];
|
|
1605
|
+
metadata: Record<string, unknown> | null;
|
|
1606
|
+
customer_name: string | null;
|
|
1607
|
+
customer_phone: string | null;
|
|
1608
|
+
customer_email: string | null;
|
|
1609
|
+
created_at: string;
|
|
1610
|
+
updated_at: string;
|
|
1611
|
+
items: SaleItem[];
|
|
1612
|
+
}
|
|
1613
|
+
interface SaleListPage {
|
|
1614
|
+
items: Sale[];
|
|
1615
|
+
total: number;
|
|
1616
|
+
}
|
|
1617
|
+
interface SaleCursorPage {
|
|
1618
|
+
items: Sale[];
|
|
1619
|
+
next_cursor: string | null;
|
|
1620
|
+
}
|
|
1621
|
+
/**
|
|
1622
|
+
* Comprehensive filter shape mirrored from the backend's `SaleQueryFilters`.
|
|
1623
|
+
*
|
|
1624
|
+
* `search` runs case-insensitively across `customer_name`, `customer_phone`,
|
|
1625
|
+
* `customer_email`, `description`, and `external_id` — the human-facing
|
|
1626
|
+
* columns. `service_id` is the resolved per-business service UUID (different
|
|
1627
|
+
* from the create-time `service` *key*).
|
|
1628
|
+
*/
|
|
1629
|
+
interface SaleFilters {
|
|
1630
|
+
business_id?: string;
|
|
1631
|
+
external_id?: string;
|
|
1632
|
+
service_id?: string;
|
|
1633
|
+
currency?: SupportedCurrency;
|
|
1634
|
+
environment?: (typeof TRACKING_ENVIRONMENTS)[number];
|
|
1635
|
+
since?: string;
|
|
1636
|
+
until?: string;
|
|
1637
|
+
min_amount_cents?: number;
|
|
1638
|
+
max_amount_cents?: number;
|
|
1639
|
+
search?: string;
|
|
1640
|
+
}
|
|
1641
|
+
/**
|
|
1642
|
+
* Full query input for `SalesClient.list()` — filters + pagination.
|
|
1643
|
+
*
|
|
1644
|
+
* Pagination is **keyset (cursor)**: `next_cursor` returned by one page is
|
|
1645
|
+
* passed back as `cursor` on the next. `null` / undefined cursor = first page.
|
|
1646
|
+
*
|
|
1647
|
+
* Ordering on this endpoint is fixed at **`occurred_at DESC, id DESC`** — the
|
|
1648
|
+
* cursor encodes a position in that index, so a different sort would
|
|
1649
|
+
* invalidate cursors mid-pagination. For ad-hoc sorted reads use the
|
|
1650
|
+
* dashboard admin endpoint, which is offset-paginated.
|
|
1651
|
+
*/
|
|
1652
|
+
interface SaleListQuery extends SaleFilters {
|
|
1653
|
+
limit?: number;
|
|
1654
|
+
cursor?: string | null;
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
/** Shared config for every sales HTTP helper. */
|
|
1658
|
+
interface SalesTransportConfig {
|
|
1659
|
+
/** Public (`aranv_pk_…`) or secret (`aranv_sk_…`) API key. */
|
|
1660
|
+
apiKey: string;
|
|
1661
|
+
/**
|
|
1662
|
+
* Base tracking endpoint, e.g. `https://aranovainternal-production.up.railway.app/tracking`.
|
|
1663
|
+
* The `/sales` path is appended by the helpers.
|
|
1664
|
+
*/
|
|
1665
|
+
endpoint: string;
|
|
1666
|
+
/** Optional SDK identity headers (mirrors the event ingest client). */
|
|
1667
|
+
sdkVersion?: string;
|
|
1668
|
+
packageName?: string;
|
|
1669
|
+
surface?: string;
|
|
1670
|
+
environment?: string;
|
|
1671
|
+
}
|
|
1672
|
+
|
|
1673
|
+
/** Config for {@link createSalesClient}. */
|
|
1674
|
+
interface SalesClientConfig extends SalesTransportConfig {
|
|
1675
|
+
/** Applied when an individual `record()` call omits `currency`. */
|
|
1676
|
+
defaultCurrency?: SupportedCurrency;
|
|
1677
|
+
}
|
|
1678
|
+
/**
|
|
1679
|
+
* One isomorphic sales client — what a key may *do* is enforced by the backend,
|
|
1680
|
+
* not by hiding methods. A **public** key (`aranv_pk_…`) may `record` (the
|
|
1681
|
+
* backend rejects reads/CRUD from it with a `403`); a **secret** key
|
|
1682
|
+
* (`aranv_sk_…`), used **server-side only**, gets full read/list/update/delete.
|
|
1683
|
+
* Never ship a secret key in a browser bundle.
|
|
1684
|
+
*
|
|
1685
|
+
* Generic over the service-key union `TService`: bind the type emitted by
|
|
1686
|
+
* `@aranova/tracking-cli gen` for compile-time-checked `service` values.
|
|
1687
|
+
*/
|
|
1688
|
+
interface SalesClient<TService extends string = string> {
|
|
1689
|
+
record(input: Omit<SaleInput, 'currency' | 'occurred_at' | 'service'> & {
|
|
1690
|
+
service?: TService | null;
|
|
1691
|
+
currency?: SupportedCurrency;
|
|
1692
|
+
occurred_at?: string;
|
|
1693
|
+
}): Promise<Sale>;
|
|
1694
|
+
list(query?: SaleListQuery): Promise<SaleCursorPage>;
|
|
1695
|
+
get(id: string): Promise<Sale>;
|
|
1696
|
+
update(id: string, patch: Omit<SaleUpdateInput, 'service'> & {
|
|
1697
|
+
service?: TService | null;
|
|
1698
|
+
}): Promise<Sale>;
|
|
1699
|
+
delete(id: string): Promise<void>;
|
|
1700
|
+
}
|
|
1701
|
+
declare function createSalesClient<TService extends string = string>(config: SalesClientConfig): SalesClient<TService>;
|
|
1702
|
+
|
|
1703
|
+
/** A business's active service, as returned by `GET /tracking/services`. */
|
|
1704
|
+
interface PublicServiceItem {
|
|
1705
|
+
key: string;
|
|
1706
|
+
label: string;
|
|
1707
|
+
}
|
|
1708
|
+
/**
|
|
1709
|
+
* Fetch the caller's business's active service taxonomy. Accepts a public or
|
|
1710
|
+
* secret key (the taxonomy is low-sensitivity category names). Powers the
|
|
1711
|
+
* `@aranova/tracking-cli gen` codegen.
|
|
1712
|
+
*/
|
|
1713
|
+
declare function fetchServices(config: SalesTransportConfig): Promise<PublicServiceItem[]>;
|
|
1714
|
+
|
|
1715
|
+
/**
|
|
1716
|
+
* Convert a major amount (dollars `250.5`) to integer minor units (`25050`).
|
|
1717
|
+
*
|
|
1718
|
+
* Convenience only — the wire is always integer cents. Uses float multiply +
|
|
1719
|
+
* `Math.round`, so values that aren't exactly representable in binary float
|
|
1720
|
+
* (e.g. `1.005`) can round to the neighbouring cent. If you already hold an
|
|
1721
|
+
* exact cents integer, pass it straight through and skip this helper.
|
|
1722
|
+
*/
|
|
1723
|
+
declare function toMinor(amount: number, currency: SupportedCurrency): number;
|
|
1724
|
+
/** Convert integer minor units (`25050`) to a major amount (`250.5`). */
|
|
1725
|
+
declare function fromMinor(cents: number, currency: SupportedCurrency): number;
|
|
1726
|
+
/**
|
|
1727
|
+
* Format integer minor units as a localized currency string (e.g. `"$250.50"`).
|
|
1728
|
+
* Uses the built-in `Intl.NumberFormat` — no extra dependency.
|
|
1729
|
+
*/
|
|
1730
|
+
declare function formatMoney(cents: number, currency: SupportedCurrency, locale?: string): string;
|
|
1731
|
+
|
|
1732
|
+
/**
|
|
1733
|
+
* Error thrown by the sales client (`createSalesClient`) on a
|
|
1734
|
+
* non-2xx response. Unlike the fire-and-forget event queue (which swallows
|
|
1735
|
+
* failures), a sale is a transaction the caller must be able to react to.
|
|
1736
|
+
*/
|
|
1737
|
+
declare class AranovaApiError extends Error {
|
|
1738
|
+
readonly status: number;
|
|
1739
|
+
readonly code: string | undefined;
|
|
1740
|
+
readonly requestId: string | undefined;
|
|
1741
|
+
constructor(message: string, options: {
|
|
1742
|
+
status: number;
|
|
1743
|
+
code?: string;
|
|
1744
|
+
requestId?: string;
|
|
1745
|
+
});
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1401
1748
|
/**
|
|
1402
1749
|
* Props for the Google Ads tracking component.
|
|
1403
1750
|
*
|
|
@@ -1506,4 +1853,4 @@ interface CreateTrackingResult<TRegistry extends TriggerRegistryConfig> {
|
|
|
1506
1853
|
}
|
|
1507
1854
|
declare function createTracking<TRegistry extends TriggerRegistryConfig>(options: CreateTrackingOptions<TRegistry>): CreateTrackingResult<TRegistry>;
|
|
1508
1855
|
|
|
1509
|
-
export { type AutomaticEventName, ConsentBanner, type ConsentState, type CreateTrackingOptions, type CreateTrackingResult, type CtaClickConfig, type CtaClickMetadata, type EventConfig, type EventMetadata, type EventName, type FormStartConfig, type FormStartMetadata, type FormSubmitConfig, type FormSubmitMetadata, GoogleAdsTracking, type GoogleAdsTrackingProps, type JsonValue, type ManualEventName, type MultiPageSessionConfig, type MultiPageSessionMetadata, type PageViewConfig, type PageViewMetadata, type PhoneClickConfig, type PhoneClickMetadata, type RegisteredAutomaticEvents, type RegisteredManualEvents, type ScrollDepthConfig, type ScrollDepthMetadata, type SpecificPageName, type SpecificPageVisitConfig, type SpecificPageVisitMetadata, TRACKING_PARAM_KEYS, type TimeOnSiteConfig, type TimeOnSiteMetadata, type TrackingClient, type TrackingClientContext, type TrackingEventCreatePayload, type TrackingInitConfig, type TrackingInstallSurface, type TrackingParams, type TrackingProviderProps, type TrackingSessionUpsertPayload, type TriggerRegistryConfig, type TypedTrackEventOptions, type TypedTrackingClient, captureTrackingParamsFromLocation, createTracking, createTrackingClientContext, createTrackingEventCreatePayload, createTrackingSessionUpsertPayload, getConsentState, setConsentState, useConsentState, useGclid, useTrackingParams };
|
|
1856
|
+
export { AranovaApiError, type AutomaticEventName, ConsentBanner, type ConsentState, type CreateTrackingOptions, type CreateTrackingResult, type CtaClickConfig, type CtaClickMetadata, type EventConfig, type EventMetadata, type EventName, type FormStartConfig, type FormStartMetadata, type FormSubmitConfig, type FormSubmitMetadata, GoogleAdsTracking, type GoogleAdsTrackingProps, type JsonValue, type ManualEventName, type MultiPageSessionConfig, type MultiPageSessionMetadata, type PageViewConfig, type PageViewMetadata, type PhoneClickConfig, type PhoneClickMetadata, type PublicServiceItem, type RegisteredAutomaticEvents, type RegisteredManualEvents, type Sale, type SaleCursorPage, type SaleInput, type SaleItem, type SaleItemInput, type SaleListPage, type SaleListQuery, type SaleUpdateInput, type SalesClient, type SalesClientConfig, type SalesTransportConfig, type ScrollDepthConfig, type ScrollDepthMetadata, type SpecificPageName, type SpecificPageVisitConfig, type SpecificPageVisitMetadata, type SupportedCurrency, TRACKING_PARAM_KEYS, type TimeOnSiteConfig, type TimeOnSiteMetadata, type TrackingClient, type TrackingClientContext, type TrackingEventCreatePayload, type TrackingInitConfig, type TrackingInstallSurface, type TrackingParams, type TrackingProviderProps, type TrackingSessionUpsertPayload, type TriggerRegistryConfig, type TypedTrackEventOptions, type TypedTrackingClient, captureTrackingParamsFromLocation, createSalesClient, createTracking, createTrackingClientContext, createTrackingEventCreatePayload, createTrackingSessionUpsertPayload, fetchServices, formatMoney, fromMinor, getConsentState, setConsentState, toMinor, useConsentState, useGclid, useTrackingParams };
|