@aranova/tracking-next 0.9.1 → 0.11.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/dist/index.d.ts CHANGED
@@ -1283,12 +1283,32 @@ declare const saleItemSchema: z.ZodObject<{
1283
1283
  category?: string | null | undefined;
1284
1284
  unit_cost_cents?: number | null | undefined;
1285
1285
  }>;
1286
- declare const saleCreateSchema: z.ZodObject<{
1286
+ declare const saleServiceSchema: z.ZodObject<{
1287
+ service: z.ZodString;
1288
+ amount_cents: z.ZodNumber;
1289
+ }, "strict", z.ZodTypeAny, {
1290
+ service: string;
1291
+ amount_cents: number;
1292
+ }, {
1293
+ service: string;
1294
+ amount_cents: number;
1295
+ }>;
1296
+ declare const saleCreateSchema: z.ZodEffects<z.ZodObject<{
1287
1297
  external_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1288
1298
  description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1289
1299
  service: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1300
+ services: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
1301
+ service: z.ZodString;
1302
+ amount_cents: z.ZodNumber;
1303
+ }, "strict", z.ZodTypeAny, {
1304
+ service: string;
1305
+ amount_cents: number;
1306
+ }, {
1307
+ service: string;
1308
+ amount_cents: number;
1309
+ }>, "many">>>;
1290
1310
  currency: z.ZodEnum<["USD", "CAD"]>;
1291
- amount_total_cents: z.ZodNumber;
1311
+ amount_total_cents: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
1292
1312
  occurred_at: z.ZodString;
1293
1313
  environment: z.ZodDefault<z.ZodEnum<["production", "development"]>>;
1294
1314
  items: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -1319,7 +1339,6 @@ declare const saleCreateSchema: z.ZodObject<{
1319
1339
  customer_email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1320
1340
  }, "strict", z.ZodTypeAny, {
1321
1341
  currency: "USD" | "CAD";
1322
- amount_total_cents: number;
1323
1342
  occurred_at: string;
1324
1343
  environment: "production" | "development";
1325
1344
  items: {
@@ -1331,20 +1350,77 @@ declare const saleCreateSchema: z.ZodObject<{
1331
1350
  unit_cost_cents?: number | null | undefined;
1332
1351
  }[];
1333
1352
  metadata?: Record<string, unknown> | null | undefined;
1353
+ service?: string | null | undefined;
1354
+ services?: {
1355
+ service: string;
1356
+ amount_cents: number;
1357
+ }[] | null | undefined;
1358
+ amount_total_cents?: number | null | undefined;
1334
1359
  external_id?: string | null | undefined;
1335
1360
  description?: string | null | undefined;
1336
- service?: string | null | undefined;
1337
1361
  customer_name?: string | null | undefined;
1338
1362
  customer_phone?: string | null | undefined;
1339
1363
  customer_email?: string | null | undefined;
1340
1364
  }, {
1341
1365
  currency: "USD" | "CAD";
1342
- amount_total_cents: number;
1343
1366
  occurred_at: string;
1344
1367
  metadata?: Record<string, unknown> | null | undefined;
1368
+ service?: string | null | undefined;
1369
+ services?: {
1370
+ service: string;
1371
+ amount_cents: number;
1372
+ }[] | null | undefined;
1373
+ amount_total_cents?: number | null | undefined;
1374
+ external_id?: string | null | undefined;
1375
+ description?: string | null | undefined;
1376
+ environment?: "production" | "development" | undefined;
1377
+ items?: {
1378
+ quantity: string;
1379
+ unit_price_cents: number;
1380
+ name?: string | null | undefined;
1381
+ external_item_id?: string | null | undefined;
1382
+ category?: string | null | undefined;
1383
+ unit_cost_cents?: number | null | undefined;
1384
+ }[] | undefined;
1385
+ customer_name?: string | null | undefined;
1386
+ customer_phone?: string | null | undefined;
1387
+ customer_email?: string | null | undefined;
1388
+ }>, {
1389
+ currency: "USD" | "CAD";
1390
+ occurred_at: string;
1391
+ environment: "production" | "development";
1392
+ items: {
1393
+ quantity: string;
1394
+ unit_price_cents: number;
1395
+ name?: string | null | undefined;
1396
+ external_item_id?: string | null | undefined;
1397
+ category?: string | null | undefined;
1398
+ unit_cost_cents?: number | null | undefined;
1399
+ }[];
1400
+ metadata?: Record<string, unknown> | null | undefined;
1401
+ service?: string | null | undefined;
1402
+ services?: {
1403
+ service: string;
1404
+ amount_cents: number;
1405
+ }[] | null | undefined;
1406
+ amount_total_cents?: number | null | undefined;
1345
1407
  external_id?: string | null | undefined;
1346
1408
  description?: string | null | undefined;
1409
+ customer_name?: string | null | undefined;
1410
+ customer_phone?: string | null | undefined;
1411
+ customer_email?: string | null | undefined;
1412
+ }, {
1413
+ currency: "USD" | "CAD";
1414
+ occurred_at: string;
1415
+ metadata?: Record<string, unknown> | null | undefined;
1347
1416
  service?: string | null | undefined;
1417
+ services?: {
1418
+ service: string;
1419
+ amount_cents: number;
1420
+ }[] | null | undefined;
1421
+ amount_total_cents?: number | null | undefined;
1422
+ external_id?: string | null | undefined;
1423
+ description?: string | null | undefined;
1348
1424
  environment?: "production" | "development" | undefined;
1349
1425
  items?: {
1350
1426
  quantity: string;
@@ -1358,9 +1434,19 @@ declare const saleCreateSchema: z.ZodObject<{
1358
1434
  customer_phone?: string | null | undefined;
1359
1435
  customer_email?: string | null | undefined;
1360
1436
  }>;
1361
- declare const saleUpdateSchema: z.ZodObject<{
1437
+ declare const saleUpdateSchema: z.ZodEffects<z.ZodObject<{
1362
1438
  description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1363
1439
  service: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1440
+ services: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
1441
+ service: z.ZodString;
1442
+ amount_cents: z.ZodNumber;
1443
+ }, "strict", z.ZodTypeAny, {
1444
+ service: string;
1445
+ amount_cents: number;
1446
+ }, {
1447
+ service: string;
1448
+ amount_cents: number;
1449
+ }>, "many">>>;
1364
1450
  currency: z.ZodOptional<z.ZodEnum<["USD", "CAD"]>>;
1365
1451
  amount_total_cents: z.ZodOptional<z.ZodNumber>;
1366
1452
  occurred_at: z.ZodOptional<z.ZodString>;
@@ -1392,10 +1478,14 @@ declare const saleUpdateSchema: z.ZodObject<{
1392
1478
  customer_email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1393
1479
  }, "strict", z.ZodTypeAny, {
1394
1480
  metadata?: Record<string, unknown> | null | undefined;
1395
- description?: string | null | undefined;
1396
1481
  service?: string | null | undefined;
1397
- currency?: "USD" | "CAD" | undefined;
1482
+ services?: {
1483
+ service: string;
1484
+ amount_cents: number;
1485
+ }[] | null | undefined;
1398
1486
  amount_total_cents?: number | undefined;
1487
+ description?: string | null | undefined;
1488
+ currency?: "USD" | "CAD" | undefined;
1399
1489
  occurred_at?: string | undefined;
1400
1490
  items?: {
1401
1491
  quantity: string;
@@ -1410,10 +1500,58 @@ declare const saleUpdateSchema: z.ZodObject<{
1410
1500
  customer_email?: string | null | undefined;
1411
1501
  }, {
1412
1502
  metadata?: Record<string, unknown> | null | undefined;
1503
+ service?: string | null | undefined;
1504
+ services?: {
1505
+ service: string;
1506
+ amount_cents: number;
1507
+ }[] | null | undefined;
1508
+ amount_total_cents?: number | undefined;
1413
1509
  description?: string | null | undefined;
1510
+ currency?: "USD" | "CAD" | undefined;
1511
+ occurred_at?: string | undefined;
1512
+ items?: {
1513
+ quantity: string;
1514
+ unit_price_cents: number;
1515
+ name?: string | null | undefined;
1516
+ external_item_id?: string | null | undefined;
1517
+ category?: string | null | undefined;
1518
+ unit_cost_cents?: number | null | undefined;
1519
+ }[] | undefined;
1520
+ customer_name?: string | null | undefined;
1521
+ customer_phone?: string | null | undefined;
1522
+ customer_email?: string | null | undefined;
1523
+ }>, {
1524
+ metadata?: Record<string, unknown> | null | undefined;
1414
1525
  service?: string | null | undefined;
1526
+ services?: {
1527
+ service: string;
1528
+ amount_cents: number;
1529
+ }[] | null | undefined;
1530
+ amount_total_cents?: number | undefined;
1531
+ description?: string | null | undefined;
1415
1532
  currency?: "USD" | "CAD" | undefined;
1533
+ occurred_at?: string | undefined;
1534
+ items?: {
1535
+ quantity: string;
1536
+ unit_price_cents: number;
1537
+ name?: string | null | undefined;
1538
+ external_item_id?: string | null | undefined;
1539
+ category?: string | null | undefined;
1540
+ unit_cost_cents?: number | null | undefined;
1541
+ }[] | undefined;
1542
+ customer_name?: string | null | undefined;
1543
+ customer_phone?: string | null | undefined;
1544
+ customer_email?: string | null | undefined;
1545
+ }, {
1546
+ metadata?: Record<string, unknown> | null | undefined;
1547
+ service?: string | null | undefined;
1548
+ services?: {
1549
+ service: string;
1550
+ amount_cents: number;
1551
+ }[] | null | undefined;
1416
1552
  amount_total_cents?: number | undefined;
1553
+ description?: string | null | undefined;
1554
+ currency?: "USD" | "CAD" | undefined;
1417
1555
  occurred_at?: string | undefined;
1418
1556
  items?: {
1419
1557
  quantity: string;
@@ -1428,6 +1566,7 @@ declare const saleUpdateSchema: z.ZodObject<{
1428
1566
  customer_email?: string | null | undefined;
1429
1567
  }>;
1430
1568
  type SaleItemInput = z.input<typeof saleItemSchema>;
1569
+ type SaleServiceInput = z.input<typeof saleServiceSchema>;
1431
1570
  type SaleInput = z.input<typeof saleCreateSchema>;
1432
1571
  type SaleUpdateInput = z.input<typeof saleUpdateSchema>;
1433
1572
  interface SaleItem {
@@ -1439,6 +1578,13 @@ interface SaleItem {
1439
1578
  unit_price_cents: number;
1440
1579
  unit_cost_cents: number | null;
1441
1580
  }
1581
+ interface SaleService {
1582
+ id: string;
1583
+ service_id: string;
1584
+ service_key: string;
1585
+ service_label: string;
1586
+ amount_cents: number;
1587
+ }
1442
1588
  interface Sale {
1443
1589
  id: string;
1444
1590
  business_id: string;
@@ -1450,6 +1596,7 @@ interface Sale {
1450
1596
  service_id: string | null;
1451
1597
  service_key?: string | null;
1452
1598
  service_label?: string | null;
1599
+ services: SaleService[];
1453
1600
  occurred_at: string;
1454
1601
  environment: (typeof TRACKING_ENVIRONMENTS)[number];
1455
1602
  metadata: Record<string, unknown> | null;
@@ -1503,6 +1650,61 @@ interface SaleListQuery extends SaleFilters {
1503
1650
  limit?: number;
1504
1651
  cursor?: string | null;
1505
1652
  }
1653
+ declare const TRACKING_RANGES: readonly ["24h", "7d", "30d"];
1654
+ type TrackingOverviewRange = (typeof TRACKING_RANGES)[number];
1655
+ /** Query input for `SalesClient.summary()` — filters + range + options. */
1656
+ interface SaleSummaryQuery extends SaleFilters {
1657
+ range: TrackingOverviewRange;
1658
+ /** Include the per-category line-item breakdown (extra join; default false). */
1659
+ include_categories?: boolean;
1660
+ /** Surface soft-deleted services individually (flagged "(deleted)") instead of
1661
+ * rolling them into a single "Deleted services" bucket. Default false. */
1662
+ include_deleted_services?: boolean;
1663
+ /** Cap on the by-service / by-category rows (1–50, default 10). */
1664
+ top_n?: number;
1665
+ }
1666
+ interface CurrencyRevenue {
1667
+ currency: SupportedCurrency;
1668
+ sale_count: number;
1669
+ revenue_cents: number;
1670
+ average_order_value_cents: number;
1671
+ }
1672
+ interface SalesServiceBreakdown {
1673
+ service_id: string | null;
1674
+ service_key: string | null;
1675
+ /** "Unassigned" when the sale has no service. */
1676
+ service_label: string | null;
1677
+ currency: SupportedCurrency;
1678
+ sale_count: number;
1679
+ revenue_cents: number;
1680
+ }
1681
+ interface SalesCategoryBreakdown {
1682
+ category: string | null;
1683
+ currency: SupportedCurrency;
1684
+ /** sum(unit_price_cents * quantity) — advisory, not authoritative. */
1685
+ revenue_cents: number;
1686
+ /** Decimal string. */
1687
+ quantity: string;
1688
+ }
1689
+ interface SalesTrendPoint {
1690
+ bucket_start: string;
1691
+ currency: SupportedCurrency;
1692
+ sale_count: number;
1693
+ revenue_cents: number;
1694
+ }
1695
+ interface SaleSummary {
1696
+ range: TrackingOverviewRange;
1697
+ business_id: string | null;
1698
+ metrics: {
1699
+ sale_count: number;
1700
+ distinct_customers: number;
1701
+ by_currency: CurrencyRevenue[];
1702
+ };
1703
+ by_service: SalesServiceBreakdown[];
1704
+ by_currency: CurrencyRevenue[];
1705
+ by_category: SalesCategoryBreakdown[];
1706
+ series: SalesTrendPoint[];
1707
+ }
1506
1708
 
1507
1709
  /** Shared config for every sales HTTP helper. */
1508
1710
  interface SalesTransportConfig {
@@ -1536,15 +1738,29 @@ interface SalesClientConfig extends SalesTransportConfig {
1536
1738
  * `@aranova/tracking-cli gen` for compile-time-checked `service` values.
1537
1739
  */
1538
1740
  interface SalesClient<TService extends string = string> {
1539
- record(input: Omit<SaleInput, 'currency' | 'occurred_at' | 'service'> & {
1741
+ record(input: Omit<SaleInput, 'currency' | 'occurred_at' | 'service' | 'services'> & {
1540
1742
  service?: TService | null;
1743
+ services?: Array<{
1744
+ service: TService;
1745
+ amount_cents: number;
1746
+ }>;
1541
1747
  currency?: SupportedCurrency;
1542
1748
  occurred_at?: string;
1543
1749
  }): Promise<Sale>;
1544
1750
  list(query?: SaleListQuery): Promise<SaleCursorPage>;
1751
+ /**
1752
+ * Currency-grouped aggregations for the key's business (revenue per currency,
1753
+ * AOV, distinct customers, by-service / by-currency / by-category breakdowns,
1754
+ * and a revenue/count trend). Secret key only — a public key gets a `403`.
1755
+ */
1756
+ summary(query: SaleSummaryQuery): Promise<SaleSummary>;
1545
1757
  get(id: string): Promise<Sale>;
1546
- update(id: string, patch: Omit<SaleUpdateInput, 'service'> & {
1758
+ update(id: string, patch: Omit<SaleUpdateInput, 'service' | 'services'> & {
1547
1759
  service?: TService | null;
1760
+ services?: Array<{
1761
+ service: TService;
1762
+ amount_cents: number;
1763
+ }>;
1548
1764
  }): Promise<Sale>;
1549
1765
  delete(id: string): Promise<void>;
1550
1766
  }
@@ -1803,4 +2019,4 @@ interface CreateTrackingResult<TRegistry extends TriggerRegistryConfig> {
1803
2019
  */
1804
2020
  declare function createTracking<TRegistry extends TriggerRegistryConfig>(options: CreateTrackingOptions<TRegistry>): CreateTrackingResult<TRegistry>;
1805
2021
 
1806
- export { AranovaApiError, type AutomaticEventName, ConsentBanner, type ConsentBannerProps, 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, TrackingClientContext, TrackingEventCreatePayload, TrackingInstallSurface, TrackingParams, type TrackingProviderProps, TrackingSessionUpsertPayload, type TriggerRegistryConfig, type TypedTrackEventOptions, type TypedTrackingClient, type UseConsentResult, captureTrackingParamsFromLocation, createSalesClient, createTracking, createTrackingClientContext, createTrackingEventCreatePayload, createTrackingSessionUpsertPayload, fetchServices, formatMoney, fromMinor, getConsentState, resetConsent, setConsentState, toMinor, useConsent, useConsentState, useGclid, useTrackingParams };
2022
+ export { AranovaApiError, type AutomaticEventName, ConsentBanner, type ConsentBannerProps, ConsentState, type CreateTrackingOptions, type CreateTrackingResult, type CtaClickConfig, type CtaClickMetadata, type CurrencyRevenue, 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 SaleService, type SaleServiceInput, type SaleSummary, type SaleSummaryQuery, type SaleUpdateInput, type SalesCategoryBreakdown, type SalesClient, type SalesClientConfig, type SalesServiceBreakdown, type SalesTransportConfig, type SalesTrendPoint, type ScrollDepthConfig, type ScrollDepthMetadata, type SpecificPageName, type SpecificPageVisitConfig, type SpecificPageVisitMetadata, type SupportedCurrency, TRACKING_PARAM_KEYS, type TimeOnSiteConfig, type TimeOnSiteMetadata, type TrackingClient, TrackingClientContext, TrackingEventCreatePayload, TrackingInstallSurface, type TrackingOverviewRange, TrackingParams, type TrackingProviderProps, TrackingSessionUpsertPayload, type TriggerRegistryConfig, type TypedTrackEventOptions, type TypedTrackingClient, type UseConsentResult, captureTrackingParamsFromLocation, createSalesClient, createTracking, createTrackingClientContext, createTrackingEventCreatePayload, createTrackingSessionUpsertPayload, fetchServices, formatMoney, fromMinor, getConsentState, resetConsent, setConsentState, toMinor, useConsent, useConsentState, useGclid, useTrackingParams };
package/dist/index.js CHANGED
@@ -1190,6 +1190,16 @@ function createSalesClient(config) {
1190
1190
  ...cursor !== void 0 ? { cursor } : {}
1191
1191
  });
1192
1192
  },
1193
+ async summary(query) {
1194
+ const { range, include_categories, include_deleted_services, top_n, ...filters } = query;
1195
+ return salesRequest(config, "POST", "/sales/summary", {
1196
+ filters,
1197
+ range,
1198
+ ...include_categories !== void 0 ? { include_categories } : {},
1199
+ ...include_deleted_services !== void 0 ? { include_deleted_services } : {},
1200
+ ...top_n !== void 0 ? { top_n } : {}
1201
+ });
1202
+ },
1193
1203
  async get(id) {
1194
1204
  return salesRequest(config, "GET", `/sales/${id}`);
1195
1205
  },
@@ -1494,7 +1504,7 @@ function GoogleAdsTracking(props) {
1494
1504
  var import_navigation = require("next/navigation");
1495
1505
 
1496
1506
  // package.json
1497
- var version = "0.9.1";
1507
+ var version = "0.11.0";
1498
1508
 
1499
1509
  // src/factory.tsx
1500
1510
  var import_react3 = require("react");