@aranova/tracking-react 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
@@ -1505,12 +1505,32 @@ declare const saleItemSchema: z.ZodObject<{
1505
1505
  category?: string | null | undefined;
1506
1506
  unit_cost_cents?: number | null | undefined;
1507
1507
  }>;
1508
- declare const saleCreateSchema: z.ZodObject<{
1508
+ declare const saleServiceSchema: z.ZodObject<{
1509
+ service: z.ZodString;
1510
+ amount_cents: z.ZodNumber;
1511
+ }, "strict", z.ZodTypeAny, {
1512
+ service: string;
1513
+ amount_cents: number;
1514
+ }, {
1515
+ service: string;
1516
+ amount_cents: number;
1517
+ }>;
1518
+ declare const saleCreateSchema: z.ZodEffects<z.ZodObject<{
1509
1519
  external_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1510
1520
  description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1511
1521
  service: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1522
+ services: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
1523
+ service: z.ZodString;
1524
+ amount_cents: z.ZodNumber;
1525
+ }, "strict", z.ZodTypeAny, {
1526
+ service: string;
1527
+ amount_cents: number;
1528
+ }, {
1529
+ service: string;
1530
+ amount_cents: number;
1531
+ }>, "many">>>;
1512
1532
  currency: z.ZodEnum<["USD", "CAD"]>;
1513
- amount_total_cents: z.ZodNumber;
1533
+ amount_total_cents: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
1514
1534
  occurred_at: z.ZodString;
1515
1535
  environment: z.ZodDefault<z.ZodEnum<["production", "development"]>>;
1516
1536
  items: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -1541,7 +1561,6 @@ declare const saleCreateSchema: z.ZodObject<{
1541
1561
  customer_email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1542
1562
  }, "strict", z.ZodTypeAny, {
1543
1563
  currency: "USD" | "CAD";
1544
- amount_total_cents: number;
1545
1564
  occurred_at: string;
1546
1565
  environment: "production" | "development";
1547
1566
  items: {
@@ -1553,20 +1572,77 @@ declare const saleCreateSchema: z.ZodObject<{
1553
1572
  unit_cost_cents?: number | null | undefined;
1554
1573
  }[];
1555
1574
  metadata?: Record<string, unknown> | null | undefined;
1575
+ service?: string | null | undefined;
1576
+ services?: {
1577
+ service: string;
1578
+ amount_cents: number;
1579
+ }[] | null | undefined;
1580
+ amount_total_cents?: number | null | undefined;
1556
1581
  external_id?: string | null | undefined;
1557
1582
  description?: string | null | undefined;
1558
- service?: string | null | undefined;
1559
1583
  customer_name?: string | null | undefined;
1560
1584
  customer_phone?: string | null | undefined;
1561
1585
  customer_email?: string | null | undefined;
1562
1586
  }, {
1563
1587
  currency: "USD" | "CAD";
1564
- amount_total_cents: number;
1565
1588
  occurred_at: string;
1566
1589
  metadata?: Record<string, unknown> | null | undefined;
1590
+ service?: string | null | undefined;
1591
+ services?: {
1592
+ service: string;
1593
+ amount_cents: number;
1594
+ }[] | null | undefined;
1595
+ amount_total_cents?: number | null | undefined;
1596
+ external_id?: string | null | undefined;
1597
+ description?: string | null | undefined;
1598
+ environment?: "production" | "development" | undefined;
1599
+ items?: {
1600
+ quantity: string;
1601
+ unit_price_cents: number;
1602
+ name?: string | null | undefined;
1603
+ external_item_id?: string | null | undefined;
1604
+ category?: string | null | undefined;
1605
+ unit_cost_cents?: number | null | undefined;
1606
+ }[] | undefined;
1607
+ customer_name?: string | null | undefined;
1608
+ customer_phone?: string | null | undefined;
1609
+ customer_email?: string | null | undefined;
1610
+ }>, {
1611
+ currency: "USD" | "CAD";
1612
+ occurred_at: string;
1613
+ environment: "production" | "development";
1614
+ items: {
1615
+ quantity: string;
1616
+ unit_price_cents: number;
1617
+ name?: string | null | undefined;
1618
+ external_item_id?: string | null | undefined;
1619
+ category?: string | null | undefined;
1620
+ unit_cost_cents?: number | null | undefined;
1621
+ }[];
1622
+ metadata?: Record<string, unknown> | null | undefined;
1623
+ service?: string | null | undefined;
1624
+ services?: {
1625
+ service: string;
1626
+ amount_cents: number;
1627
+ }[] | null | undefined;
1628
+ amount_total_cents?: number | null | undefined;
1567
1629
  external_id?: string | null | undefined;
1568
1630
  description?: string | null | undefined;
1631
+ customer_name?: string | null | undefined;
1632
+ customer_phone?: string | null | undefined;
1633
+ customer_email?: string | null | undefined;
1634
+ }, {
1635
+ currency: "USD" | "CAD";
1636
+ occurred_at: string;
1637
+ metadata?: Record<string, unknown> | null | undefined;
1569
1638
  service?: string | null | undefined;
1639
+ services?: {
1640
+ service: string;
1641
+ amount_cents: number;
1642
+ }[] | null | undefined;
1643
+ amount_total_cents?: number | null | undefined;
1644
+ external_id?: string | null | undefined;
1645
+ description?: string | null | undefined;
1570
1646
  environment?: "production" | "development" | undefined;
1571
1647
  items?: {
1572
1648
  quantity: string;
@@ -1580,9 +1656,19 @@ declare const saleCreateSchema: z.ZodObject<{
1580
1656
  customer_phone?: string | null | undefined;
1581
1657
  customer_email?: string | null | undefined;
1582
1658
  }>;
1583
- declare const saleUpdateSchema: z.ZodObject<{
1659
+ declare const saleUpdateSchema: z.ZodEffects<z.ZodObject<{
1584
1660
  description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1585
1661
  service: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1662
+ services: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
1663
+ service: z.ZodString;
1664
+ amount_cents: z.ZodNumber;
1665
+ }, "strict", z.ZodTypeAny, {
1666
+ service: string;
1667
+ amount_cents: number;
1668
+ }, {
1669
+ service: string;
1670
+ amount_cents: number;
1671
+ }>, "many">>>;
1586
1672
  currency: z.ZodOptional<z.ZodEnum<["USD", "CAD"]>>;
1587
1673
  amount_total_cents: z.ZodOptional<z.ZodNumber>;
1588
1674
  occurred_at: z.ZodOptional<z.ZodString>;
@@ -1614,10 +1700,14 @@ declare const saleUpdateSchema: z.ZodObject<{
1614
1700
  customer_email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
1615
1701
  }, "strict", z.ZodTypeAny, {
1616
1702
  metadata?: Record<string, unknown> | null | undefined;
1617
- description?: string | null | undefined;
1618
1703
  service?: string | null | undefined;
1619
- currency?: "USD" | "CAD" | undefined;
1704
+ services?: {
1705
+ service: string;
1706
+ amount_cents: number;
1707
+ }[] | null | undefined;
1620
1708
  amount_total_cents?: number | undefined;
1709
+ description?: string | null | undefined;
1710
+ currency?: "USD" | "CAD" | undefined;
1621
1711
  occurred_at?: string | undefined;
1622
1712
  items?: {
1623
1713
  quantity: string;
@@ -1632,10 +1722,58 @@ declare const saleUpdateSchema: z.ZodObject<{
1632
1722
  customer_email?: string | null | undefined;
1633
1723
  }, {
1634
1724
  metadata?: Record<string, unknown> | null | undefined;
1725
+ service?: string | null | undefined;
1726
+ services?: {
1727
+ service: string;
1728
+ amount_cents: number;
1729
+ }[] | null | undefined;
1730
+ amount_total_cents?: number | undefined;
1635
1731
  description?: string | null | undefined;
1732
+ currency?: "USD" | "CAD" | undefined;
1733
+ occurred_at?: string | undefined;
1734
+ items?: {
1735
+ quantity: string;
1736
+ unit_price_cents: number;
1737
+ name?: string | null | undefined;
1738
+ external_item_id?: string | null | undefined;
1739
+ category?: string | null | undefined;
1740
+ unit_cost_cents?: number | null | undefined;
1741
+ }[] | undefined;
1742
+ customer_name?: string | null | undefined;
1743
+ customer_phone?: string | null | undefined;
1744
+ customer_email?: string | null | undefined;
1745
+ }>, {
1746
+ metadata?: Record<string, unknown> | null | undefined;
1636
1747
  service?: string | null | undefined;
1748
+ services?: {
1749
+ service: string;
1750
+ amount_cents: number;
1751
+ }[] | null | undefined;
1752
+ amount_total_cents?: number | undefined;
1753
+ description?: string | null | undefined;
1637
1754
  currency?: "USD" | "CAD" | undefined;
1755
+ occurred_at?: string | undefined;
1756
+ items?: {
1757
+ quantity: string;
1758
+ unit_price_cents: number;
1759
+ name?: string | null | undefined;
1760
+ external_item_id?: string | null | undefined;
1761
+ category?: string | null | undefined;
1762
+ unit_cost_cents?: number | null | undefined;
1763
+ }[] | undefined;
1764
+ customer_name?: string | null | undefined;
1765
+ customer_phone?: string | null | undefined;
1766
+ customer_email?: string | null | undefined;
1767
+ }, {
1768
+ metadata?: Record<string, unknown> | null | undefined;
1769
+ service?: string | null | undefined;
1770
+ services?: {
1771
+ service: string;
1772
+ amount_cents: number;
1773
+ }[] | null | undefined;
1638
1774
  amount_total_cents?: number | undefined;
1775
+ description?: string | null | undefined;
1776
+ currency?: "USD" | "CAD" | undefined;
1639
1777
  occurred_at?: string | undefined;
1640
1778
  items?: {
1641
1779
  quantity: string;
@@ -1650,6 +1788,7 @@ declare const saleUpdateSchema: z.ZodObject<{
1650
1788
  customer_email?: string | null | undefined;
1651
1789
  }>;
1652
1790
  type SaleItemInput = z.input<typeof saleItemSchema>;
1791
+ type SaleServiceInput = z.input<typeof saleServiceSchema>;
1653
1792
  type SaleInput = z.input<typeof saleCreateSchema>;
1654
1793
  type SaleUpdateInput = z.input<typeof saleUpdateSchema>;
1655
1794
  interface SaleItem {
@@ -1661,6 +1800,13 @@ interface SaleItem {
1661
1800
  unit_price_cents: number;
1662
1801
  unit_cost_cents: number | null;
1663
1802
  }
1803
+ interface SaleService {
1804
+ id: string;
1805
+ service_id: string;
1806
+ service_key: string;
1807
+ service_label: string;
1808
+ amount_cents: number;
1809
+ }
1664
1810
  interface Sale {
1665
1811
  id: string;
1666
1812
  business_id: string;
@@ -1672,6 +1818,7 @@ interface Sale {
1672
1818
  service_id: string | null;
1673
1819
  service_key?: string | null;
1674
1820
  service_label?: string | null;
1821
+ services: SaleService[];
1675
1822
  occurred_at: string;
1676
1823
  environment: (typeof TRACKING_ENVIRONMENTS)[number];
1677
1824
  metadata: Record<string, unknown> | null;
@@ -1725,6 +1872,61 @@ interface SaleListQuery extends SaleFilters {
1725
1872
  limit?: number;
1726
1873
  cursor?: string | null;
1727
1874
  }
1875
+ declare const TRACKING_RANGES: readonly ["24h", "7d", "30d"];
1876
+ type TrackingOverviewRange = (typeof TRACKING_RANGES)[number];
1877
+ /** Query input for `SalesClient.summary()` — filters + range + options. */
1878
+ interface SaleSummaryQuery extends SaleFilters {
1879
+ range: TrackingOverviewRange;
1880
+ /** Include the per-category line-item breakdown (extra join; default false). */
1881
+ include_categories?: boolean;
1882
+ /** Surface soft-deleted services individually (flagged "(deleted)") instead of
1883
+ * rolling them into a single "Deleted services" bucket. Default false. */
1884
+ include_deleted_services?: boolean;
1885
+ /** Cap on the by-service / by-category rows (1–50, default 10). */
1886
+ top_n?: number;
1887
+ }
1888
+ interface CurrencyRevenue {
1889
+ currency: SupportedCurrency;
1890
+ sale_count: number;
1891
+ revenue_cents: number;
1892
+ average_order_value_cents: number;
1893
+ }
1894
+ interface SalesServiceBreakdown {
1895
+ service_id: string | null;
1896
+ service_key: string | null;
1897
+ /** "Unassigned" when the sale has no service. */
1898
+ service_label: string | null;
1899
+ currency: SupportedCurrency;
1900
+ sale_count: number;
1901
+ revenue_cents: number;
1902
+ }
1903
+ interface SalesCategoryBreakdown {
1904
+ category: string | null;
1905
+ currency: SupportedCurrency;
1906
+ /** sum(unit_price_cents * quantity) — advisory, not authoritative. */
1907
+ revenue_cents: number;
1908
+ /** Decimal string. */
1909
+ quantity: string;
1910
+ }
1911
+ interface SalesTrendPoint {
1912
+ bucket_start: string;
1913
+ currency: SupportedCurrency;
1914
+ sale_count: number;
1915
+ revenue_cents: number;
1916
+ }
1917
+ interface SaleSummary {
1918
+ range: TrackingOverviewRange;
1919
+ business_id: string | null;
1920
+ metrics: {
1921
+ sale_count: number;
1922
+ distinct_customers: number;
1923
+ by_currency: CurrencyRevenue[];
1924
+ };
1925
+ by_service: SalesServiceBreakdown[];
1926
+ by_currency: CurrencyRevenue[];
1927
+ by_category: SalesCategoryBreakdown[];
1928
+ series: SalesTrendPoint[];
1929
+ }
1728
1930
 
1729
1931
  /** Shared config for every sales HTTP helper. */
1730
1932
  interface SalesTransportConfig {
@@ -1758,15 +1960,29 @@ interface SalesClientConfig extends SalesTransportConfig {
1758
1960
  * `@aranova/tracking-cli gen` for compile-time-checked `service` values.
1759
1961
  */
1760
1962
  interface SalesClient<TService extends string = string> {
1761
- record(input: Omit<SaleInput, 'currency' | 'occurred_at' | 'service'> & {
1963
+ record(input: Omit<SaleInput, 'currency' | 'occurred_at' | 'service' | 'services'> & {
1762
1964
  service?: TService | null;
1965
+ services?: Array<{
1966
+ service: TService;
1967
+ amount_cents: number;
1968
+ }>;
1763
1969
  currency?: SupportedCurrency;
1764
1970
  occurred_at?: string;
1765
1971
  }): Promise<Sale>;
1766
1972
  list(query?: SaleListQuery): Promise<SaleCursorPage>;
1973
+ /**
1974
+ * Currency-grouped aggregations for the key's business (revenue per currency,
1975
+ * AOV, distinct customers, by-service / by-currency / by-category breakdowns,
1976
+ * and a revenue/count trend). Secret key only — a public key gets a `403`.
1977
+ */
1978
+ summary(query: SaleSummaryQuery): Promise<SaleSummary>;
1767
1979
  get(id: string): Promise<Sale>;
1768
- update(id: string, patch: Omit<SaleUpdateInput, 'service'> & {
1980
+ update(id: string, patch: Omit<SaleUpdateInput, 'service' | 'services'> & {
1769
1981
  service?: TService | null;
1982
+ services?: Array<{
1983
+ service: TService;
1984
+ amount_cents: number;
1985
+ }>;
1770
1986
  }): Promise<Sale>;
1771
1987
  delete(id: string): Promise<void>;
1772
1988
  }
@@ -1963,4 +2179,4 @@ interface CreateTrackingResult<TRegistry extends TriggerRegistryConfig> {
1963
2179
  }
1964
2180
  declare function createTracking<TRegistry extends TriggerRegistryConfig>(options: CreateTrackingOptions<TRegistry>): CreateTrackingResult<TRegistry>;
1965
2181
 
1966
- export { AranovaApiError, type AutomaticEventName, ConsentBanner, type ConsentBannerProps, 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, type UseConsentResult, captureTrackingParamsFromLocation, createSalesClient, createTracking, createTrackingClientContext, createTrackingEventCreatePayload, createTrackingSessionUpsertPayload, fetchServices, formatMoney, fromMinor, getConsentState, resetConsent, setConsentState, toMinor, useConsent, useConsentState, useGclid, useTrackingParams };
2182
+ export { AranovaApiError, type AutomaticEventName, ConsentBanner, type ConsentBannerProps, type 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, type TrackingClientContext, type TrackingEventCreatePayload, type TrackingInitConfig, type TrackingInstallSurface, type TrackingOverviewRange, type TrackingParams, type TrackingProviderProps, type 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
@@ -1386,6 +1386,16 @@ function createSalesClient(config) {
1386
1386
  ...cursor !== void 0 ? { cursor } : {}
1387
1387
  });
1388
1388
  },
1389
+ async summary(query) {
1390
+ const { range, include_categories, include_deleted_services, top_n, ...filters } = query;
1391
+ return salesRequest(config, "POST", "/sales/summary", {
1392
+ filters,
1393
+ range,
1394
+ ...include_categories !== void 0 ? { include_categories } : {},
1395
+ ...include_deleted_services !== void 0 ? { include_deleted_services } : {},
1396
+ ...top_n !== void 0 ? { top_n } : {}
1397
+ });
1398
+ },
1389
1399
  async get(id) {
1390
1400
  return salesRequest(config, "GET", `/sales/${id}`);
1391
1401
  },
@@ -1681,7 +1691,7 @@ function GoogleAdsTracking(props) {
1681
1691
  var import_react4 = require("react");
1682
1692
 
1683
1693
  // package.json
1684
- var version = "0.9.1";
1694
+ var version = "0.11.0";
1685
1695
 
1686
1696
  // src/factory.tsx
1687
1697
  var import_jsx_runtime2 = require("react/jsx-runtime");