@aranova/tracking-react 0.20.2 → 0.22.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.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +81 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +81 -21
- package/dist/index.mjs.map +1 -1
- package/dist/{phone-utils-B2vHJkNz.d.mts → phone-utils-BhWfNuPS.d.mts} +8 -0
- package/dist/{phone-utils-B2vHJkNz.d.ts → phone-utils-BhWfNuPS.d.ts} +8 -0
- package/dist/phone.d.mts +1 -1
- package/dist/phone.d.ts +1 -1
- package/dist/{sales-DrH6dY5F.d.mts → sales-BhCYJqDy.d.mts} +25 -23
- package/dist/{sales-DrH6dY5F.d.ts → sales-BhCYJqDy.d.ts} +25 -23
- package/dist/sales.d.mts +1 -1
- package/dist/sales.d.ts +1 -1
- package/dist/sales.js +29 -17
- package/dist/sales.js.map +1 -1
- package/dist/sales.mjs +29 -17
- package/dist/sales.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -287,6 +287,14 @@ interface TrackingClientContext {
|
|
|
287
287
|
environment: TrackingEnvironment;
|
|
288
288
|
/** All active gtag IDs loaded on this page, keyed by label. */
|
|
289
289
|
active_gtag_ids: Record<string, string> | null;
|
|
290
|
+
/**
|
|
291
|
+
* SDK capabilities constructed in this runtime, sorted.
|
|
292
|
+
*
|
|
293
|
+
* Rebuilt per batch rather than sent once at mount, so a client constructed
|
|
294
|
+
* later on a deeper route (a sales client on `/checkout`, a calendar client
|
|
295
|
+
* on `/book`) still reports. See `capabilities.ts`.
|
|
296
|
+
*/
|
|
297
|
+
capabilities: string[];
|
|
290
298
|
}
|
|
291
299
|
/**
|
|
292
300
|
* Session payload sent to `POST /tracking/events`.
|
|
@@ -287,6 +287,14 @@ interface TrackingClientContext {
|
|
|
287
287
|
environment: TrackingEnvironment;
|
|
288
288
|
/** All active gtag IDs loaded on this page, keyed by label. */
|
|
289
289
|
active_gtag_ids: Record<string, string> | null;
|
|
290
|
+
/**
|
|
291
|
+
* SDK capabilities constructed in this runtime, sorted.
|
|
292
|
+
*
|
|
293
|
+
* Rebuilt per batch rather than sent once at mount, so a client constructed
|
|
294
|
+
* later on a deeper route (a sales client on `/checkout`, a calendar client
|
|
295
|
+
* on `/book`) still reports. See `capabilities.ts`.
|
|
296
|
+
*/
|
|
297
|
+
capabilities: string[];
|
|
290
298
|
}
|
|
291
299
|
/**
|
|
292
300
|
* Session payload sent to `POST /tracking/events`.
|
package/dist/phone.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { l as DEFAULT_PHONE_COUNTRY, i as ParsedPhone, P as PhoneConfig, j as PhoneDisplayFormat, m as TrackedField, q as formatPhone, r as formatPhoneAsTyped, y as parsePhone, z as phoneField, E as toE164 } from './phone-utils-
|
|
1
|
+
export { l as DEFAULT_PHONE_COUNTRY, i as ParsedPhone, P as PhoneConfig, j as PhoneDisplayFormat, m as TrackedField, q as formatPhone, r as formatPhoneAsTyped, y as parsePhone, z as phoneField, E as toE164 } from './phone-utils-BhWfNuPS.mjs';
|
|
2
2
|
export { CountryCode } from 'libphonenumber-js';
|
|
3
3
|
import 'zod';
|
package/dist/phone.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { l as DEFAULT_PHONE_COUNTRY, i as ParsedPhone, P as PhoneConfig, j as PhoneDisplayFormat, m as TrackedField, q as formatPhone, r as formatPhoneAsTyped, y as parsePhone, z as phoneField, E as toE164 } from './phone-utils-
|
|
1
|
+
export { l as DEFAULT_PHONE_COUNTRY, i as ParsedPhone, P as PhoneConfig, j as PhoneDisplayFormat, m as TrackedField, q as formatPhone, r as formatPhoneAsTyped, y as parsePhone, z as phoneField, E as toE164 } from './phone-utils-BhWfNuPS.js';
|
|
2
2
|
export { CountryCode } from 'libphonenumber-js';
|
|
3
3
|
import 'zod';
|
|
@@ -388,8 +388,8 @@ declare const saleUpdateSchema: z.ZodEffects<z.ZodObject<{
|
|
|
388
388
|
customer_email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
389
389
|
sms_consent: z.ZodOptional<z.ZodBoolean>;
|
|
390
390
|
}, "strict", z.ZodTypeAny, {
|
|
391
|
-
currency?: "USD" | "CAD" | undefined;
|
|
392
391
|
metadata?: Record<string, unknown> | null | undefined;
|
|
392
|
+
currency?: "USD" | "CAD" | undefined;
|
|
393
393
|
services?: {
|
|
394
394
|
service: string;
|
|
395
395
|
amount_cents: number;
|
|
@@ -411,8 +411,8 @@ declare const saleUpdateSchema: z.ZodEffects<z.ZodObject<{
|
|
|
411
411
|
customer_email?: string | null | undefined;
|
|
412
412
|
sms_consent?: boolean | undefined;
|
|
413
413
|
}, {
|
|
414
|
-
currency?: "USD" | "CAD" | undefined;
|
|
415
414
|
metadata?: Record<string, unknown> | null | undefined;
|
|
415
|
+
currency?: "USD" | "CAD" | undefined;
|
|
416
416
|
services?: {
|
|
417
417
|
service: string;
|
|
418
418
|
amount_cents: number;
|
|
@@ -434,8 +434,8 @@ declare const saleUpdateSchema: z.ZodEffects<z.ZodObject<{
|
|
|
434
434
|
customer_email?: string | null | undefined;
|
|
435
435
|
sms_consent?: boolean | undefined;
|
|
436
436
|
}>, {
|
|
437
|
-
currency?: "USD" | "CAD" | undefined;
|
|
438
437
|
metadata?: Record<string, unknown> | null | undefined;
|
|
438
|
+
currency?: "USD" | "CAD" | undefined;
|
|
439
439
|
services?: {
|
|
440
440
|
service: string;
|
|
441
441
|
amount_cents: number;
|
|
@@ -457,8 +457,8 @@ declare const saleUpdateSchema: z.ZodEffects<z.ZodObject<{
|
|
|
457
457
|
customer_email?: string | null | undefined;
|
|
458
458
|
sms_consent?: boolean | undefined;
|
|
459
459
|
}, {
|
|
460
|
-
currency?: "USD" | "CAD" | undefined;
|
|
461
460
|
metadata?: Record<string, unknown> | null | undefined;
|
|
461
|
+
currency?: "USD" | "CAD" | undefined;
|
|
462
462
|
services?: {
|
|
463
463
|
service: string;
|
|
464
464
|
amount_cents: number;
|
|
@@ -815,14 +815,11 @@ interface BusinessConfig {
|
|
|
815
815
|
features: BusinessConfigFeatures;
|
|
816
816
|
}
|
|
817
817
|
|
|
818
|
-
/** Shared config for every
|
|
819
|
-
interface
|
|
818
|
+
/** Shared config for every awaited (non fire-and-forget) API helper. */
|
|
819
|
+
interface ApiTransportConfig {
|
|
820
820
|
/** Public (`aranv_pk_…`) or secret (`aranv_sk_…`) API key. */
|
|
821
821
|
apiKey: string;
|
|
822
|
-
/**
|
|
823
|
-
* Base tracking endpoint, e.g. `https://aranovainternal-production.up.railway.app/tracking`.
|
|
824
|
-
* The `/sales` path is appended by the helpers.
|
|
825
|
-
*/
|
|
822
|
+
/** Base tracking endpoint, e.g. `https://aranovainternal-production.up.railway.app/tracking`. */
|
|
826
823
|
endpoint: string;
|
|
827
824
|
/** Optional SDK identity headers (mirrors the event ingest client). */
|
|
828
825
|
sdkVersion?: string;
|
|
@@ -831,11 +828,13 @@ interface SalesTransportConfig {
|
|
|
831
828
|
environment?: string;
|
|
832
829
|
}
|
|
833
830
|
/**
|
|
834
|
-
* Single awaited request
|
|
835
|
-
*
|
|
836
|
-
* Returns `undefined` for 204 No Content.
|
|
831
|
+
* Single awaited request. Unlike the event queue, this surfaces failures: any
|
|
832
|
+
* non-2xx rejects with an {@link AranovaApiError}. Returns `undefined` for 204.
|
|
837
833
|
*/
|
|
838
|
-
declare function
|
|
834
|
+
declare function apiRequest<T>(config: ApiTransportConfig, method: string, path: string, body?: unknown, extraHeaders?: Record<string, string>): Promise<T>;
|
|
835
|
+
|
|
836
|
+
type SalesTransportConfig = ApiTransportConfig;
|
|
837
|
+
declare const salesRequest: typeof apiRequest;
|
|
839
838
|
|
|
840
839
|
/** Config for {@link createSalesClient}. */
|
|
841
840
|
interface SalesClientConfig extends SalesTransportConfig {
|
|
@@ -938,9 +937,11 @@ interface SalesClient<TService extends string = string, TConversion extends stri
|
|
|
938
937
|
declare function createSalesClient<TService extends string = string, TConversion extends string = string>(config: SalesClientConfig): SalesClient<TService, TConversion>;
|
|
939
938
|
|
|
940
939
|
/**
|
|
941
|
-
*
|
|
942
|
-
*
|
|
943
|
-
*
|
|
940
|
+
* Thrown on a non-2xx from any awaited Aranova API call.
|
|
941
|
+
*
|
|
942
|
+
* Lives here rather than inside one resource because more than one resource
|
|
943
|
+
* needs it, and a duplicate class would be a genuine hazard: a name star-exported
|
|
944
|
+
* from two modules is silently dropped unless both resolve to the same binding.
|
|
944
945
|
*/
|
|
945
946
|
declare class AranovaApiError extends Error {
|
|
946
947
|
readonly status: number;
|
|
@@ -953,6 +954,13 @@ declare class AranovaApiError extends Error {
|
|
|
953
954
|
});
|
|
954
955
|
}
|
|
955
956
|
|
|
957
|
+
/**
|
|
958
|
+
* Format an ISO timestamp in a specific IANA time zone (e.g. `America/Toronto`),
|
|
959
|
+
* so dashboards stop hand-rolling `Intl`. Defaults to a short date-time; pass
|
|
960
|
+
* `opts` to override fields. The `timeZone` is always forced to the argument.
|
|
961
|
+
*/
|
|
962
|
+
declare function formatDateInTz(iso: string, timeZone: string, opts?: Intl.DateTimeFormatOptions, locale?: string): string;
|
|
963
|
+
|
|
956
964
|
/**
|
|
957
965
|
* Convert a major amount (dollars `250.5`) to integer minor units (`25050`).
|
|
958
966
|
*
|
|
@@ -969,12 +977,6 @@ declare function fromMinor(cents: number, currency: SupportedCurrency): number;
|
|
|
969
977
|
* Uses the built-in `Intl.NumberFormat` — no extra dependency.
|
|
970
978
|
*/
|
|
971
979
|
declare function formatMoney(cents: number, currency: SupportedCurrency, locale?: string): string;
|
|
972
|
-
/**
|
|
973
|
-
* Format an ISO timestamp in a specific IANA time zone (e.g. `America/Toronto`),
|
|
974
|
-
* so dashboards stop hand-rolling `Intl`. Defaults to a short date-time; pass
|
|
975
|
-
* `opts` to override fields. The `timeZone` is always forced to the argument.
|
|
976
|
-
*/
|
|
977
|
-
declare function formatDateInTz(iso: string, timeZone: string, opts?: Intl.DateTimeFormatOptions, locale?: string): string;
|
|
978
980
|
|
|
979
981
|
/** A business's active service, as returned by `GET /tracking/services`. */
|
|
980
982
|
interface PublicServiceItem {
|
|
@@ -388,8 +388,8 @@ declare const saleUpdateSchema: z.ZodEffects<z.ZodObject<{
|
|
|
388
388
|
customer_email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
389
389
|
sms_consent: z.ZodOptional<z.ZodBoolean>;
|
|
390
390
|
}, "strict", z.ZodTypeAny, {
|
|
391
|
-
currency?: "USD" | "CAD" | undefined;
|
|
392
391
|
metadata?: Record<string, unknown> | null | undefined;
|
|
392
|
+
currency?: "USD" | "CAD" | undefined;
|
|
393
393
|
services?: {
|
|
394
394
|
service: string;
|
|
395
395
|
amount_cents: number;
|
|
@@ -411,8 +411,8 @@ declare const saleUpdateSchema: z.ZodEffects<z.ZodObject<{
|
|
|
411
411
|
customer_email?: string | null | undefined;
|
|
412
412
|
sms_consent?: boolean | undefined;
|
|
413
413
|
}, {
|
|
414
|
-
currency?: "USD" | "CAD" | undefined;
|
|
415
414
|
metadata?: Record<string, unknown> | null | undefined;
|
|
415
|
+
currency?: "USD" | "CAD" | undefined;
|
|
416
416
|
services?: {
|
|
417
417
|
service: string;
|
|
418
418
|
amount_cents: number;
|
|
@@ -434,8 +434,8 @@ declare const saleUpdateSchema: z.ZodEffects<z.ZodObject<{
|
|
|
434
434
|
customer_email?: string | null | undefined;
|
|
435
435
|
sms_consent?: boolean | undefined;
|
|
436
436
|
}>, {
|
|
437
|
-
currency?: "USD" | "CAD" | undefined;
|
|
438
437
|
metadata?: Record<string, unknown> | null | undefined;
|
|
438
|
+
currency?: "USD" | "CAD" | undefined;
|
|
439
439
|
services?: {
|
|
440
440
|
service: string;
|
|
441
441
|
amount_cents: number;
|
|
@@ -457,8 +457,8 @@ declare const saleUpdateSchema: z.ZodEffects<z.ZodObject<{
|
|
|
457
457
|
customer_email?: string | null | undefined;
|
|
458
458
|
sms_consent?: boolean | undefined;
|
|
459
459
|
}, {
|
|
460
|
-
currency?: "USD" | "CAD" | undefined;
|
|
461
460
|
metadata?: Record<string, unknown> | null | undefined;
|
|
461
|
+
currency?: "USD" | "CAD" | undefined;
|
|
462
462
|
services?: {
|
|
463
463
|
service: string;
|
|
464
464
|
amount_cents: number;
|
|
@@ -815,14 +815,11 @@ interface BusinessConfig {
|
|
|
815
815
|
features: BusinessConfigFeatures;
|
|
816
816
|
}
|
|
817
817
|
|
|
818
|
-
/** Shared config for every
|
|
819
|
-
interface
|
|
818
|
+
/** Shared config for every awaited (non fire-and-forget) API helper. */
|
|
819
|
+
interface ApiTransportConfig {
|
|
820
820
|
/** Public (`aranv_pk_…`) or secret (`aranv_sk_…`) API key. */
|
|
821
821
|
apiKey: string;
|
|
822
|
-
/**
|
|
823
|
-
* Base tracking endpoint, e.g. `https://aranovainternal-production.up.railway.app/tracking`.
|
|
824
|
-
* The `/sales` path is appended by the helpers.
|
|
825
|
-
*/
|
|
822
|
+
/** Base tracking endpoint, e.g. `https://aranovainternal-production.up.railway.app/tracking`. */
|
|
826
823
|
endpoint: string;
|
|
827
824
|
/** Optional SDK identity headers (mirrors the event ingest client). */
|
|
828
825
|
sdkVersion?: string;
|
|
@@ -831,11 +828,13 @@ interface SalesTransportConfig {
|
|
|
831
828
|
environment?: string;
|
|
832
829
|
}
|
|
833
830
|
/**
|
|
834
|
-
* Single awaited request
|
|
835
|
-
*
|
|
836
|
-
* Returns `undefined` for 204 No Content.
|
|
831
|
+
* Single awaited request. Unlike the event queue, this surfaces failures: any
|
|
832
|
+
* non-2xx rejects with an {@link AranovaApiError}. Returns `undefined` for 204.
|
|
837
833
|
*/
|
|
838
|
-
declare function
|
|
834
|
+
declare function apiRequest<T>(config: ApiTransportConfig, method: string, path: string, body?: unknown, extraHeaders?: Record<string, string>): Promise<T>;
|
|
835
|
+
|
|
836
|
+
type SalesTransportConfig = ApiTransportConfig;
|
|
837
|
+
declare const salesRequest: typeof apiRequest;
|
|
839
838
|
|
|
840
839
|
/** Config for {@link createSalesClient}. */
|
|
841
840
|
interface SalesClientConfig extends SalesTransportConfig {
|
|
@@ -938,9 +937,11 @@ interface SalesClient<TService extends string = string, TConversion extends stri
|
|
|
938
937
|
declare function createSalesClient<TService extends string = string, TConversion extends string = string>(config: SalesClientConfig): SalesClient<TService, TConversion>;
|
|
939
938
|
|
|
940
939
|
/**
|
|
941
|
-
*
|
|
942
|
-
*
|
|
943
|
-
*
|
|
940
|
+
* Thrown on a non-2xx from any awaited Aranova API call.
|
|
941
|
+
*
|
|
942
|
+
* Lives here rather than inside one resource because more than one resource
|
|
943
|
+
* needs it, and a duplicate class would be a genuine hazard: a name star-exported
|
|
944
|
+
* from two modules is silently dropped unless both resolve to the same binding.
|
|
944
945
|
*/
|
|
945
946
|
declare class AranovaApiError extends Error {
|
|
946
947
|
readonly status: number;
|
|
@@ -953,6 +954,13 @@ declare class AranovaApiError extends Error {
|
|
|
953
954
|
});
|
|
954
955
|
}
|
|
955
956
|
|
|
957
|
+
/**
|
|
958
|
+
* Format an ISO timestamp in a specific IANA time zone (e.g. `America/Toronto`),
|
|
959
|
+
* so dashboards stop hand-rolling `Intl`. Defaults to a short date-time; pass
|
|
960
|
+
* `opts` to override fields. The `timeZone` is always forced to the argument.
|
|
961
|
+
*/
|
|
962
|
+
declare function formatDateInTz(iso: string, timeZone: string, opts?: Intl.DateTimeFormatOptions, locale?: string): string;
|
|
963
|
+
|
|
956
964
|
/**
|
|
957
965
|
* Convert a major amount (dollars `250.5`) to integer minor units (`25050`).
|
|
958
966
|
*
|
|
@@ -969,12 +977,6 @@ declare function fromMinor(cents: number, currency: SupportedCurrency): number;
|
|
|
969
977
|
* Uses the built-in `Intl.NumberFormat` — no extra dependency.
|
|
970
978
|
*/
|
|
971
979
|
declare function formatMoney(cents: number, currency: SupportedCurrency, locale?: string): string;
|
|
972
|
-
/**
|
|
973
|
-
* Format an ISO timestamp in a specific IANA time zone (e.g. `America/Toronto`),
|
|
974
|
-
* so dashboards stop hand-rolling `Intl`. Defaults to a short date-time; pass
|
|
975
|
-
* `opts` to override fields. The `timeZone` is always forced to the argument.
|
|
976
|
-
*/
|
|
977
|
-
declare function formatDateInTz(iso: string, timeZone: string, opts?: Intl.DateTimeFormatOptions, locale?: string): string;
|
|
978
980
|
|
|
979
981
|
/** A business's active service, as returned by `GET /tracking/services`. */
|
|
980
982
|
interface PublicServiceItem {
|
package/dist/sales.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, c as CompareTo, f as CurrencyRevenue, g as CustomerCurrencyDelta, h as CustomerCurrencyTotal, i as CustomerGetOptions, j as CustomerGetResult, k as CustomerKpis, l as CustomerKpisDeltas, m as CustomerKpisPrevious, n as CustomerListPage, o as CustomerListQuery, p as CustomerProfile, q as CustomerSegment, r as CustomerSegmentCount, s as CustomerSortField, t as CustomerSummary, u as CustomerSummaryQuery, D as DistinctCustomersByCurrency, G as Granularity, N as NAMED_RANGES, v as NamedRange, P as PublicServiceItem, S as SUPPORTED_CURRENCIES, w as Sale, x as SaleCursorPage, y as SaleFilters, z as SaleInput, E as SaleItem, F as SaleItemInput, H as SaleKeysetSortField, I as SaleListPage, J as SaleListQuery, K as SaleListQueryV2, L as SaleService, M as SaleServiceInput, O as SaleSortField, Q as SaleSortOrder, R as SaleSummary, U as SaleSummaryPrevious, V as SaleSummaryQuery, W as SaleSummaryQueryV2, X as SaleSummaryV2, Y as SaleUpdateInput, Z as SalesBusinessClient, _ as SalesCategoryBreakdown, $ as SalesClient, a0 as SalesClientConfig, a1 as SalesCustomersClient, a2 as SalesServiceBreakdown, a3 as SalesTransportConfig, a4 as SalesTrendPoint, a5 as SummaryCurrencyDelta, a6 as SummaryDeltas, a7 as SummaryWindow, a8 as SupportedCurrency, a9 as TRACKING_RANGES, aa as TrackingOverviewRange, ac as createSalesClient, ad as fetchServices, ae as formatDateInTz, af as formatMoney, ag as fromMinor, aj as saleCreateSchema, ak as saleItemSchema, al as saleServiceSchema, am as saleUpdateSchema, an as salesRequest, ap as toMinor } from './sales-
|
|
1
|
+
export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, c as CompareTo, f as CurrencyRevenue, g as CustomerCurrencyDelta, h as CustomerCurrencyTotal, i as CustomerGetOptions, j as CustomerGetResult, k as CustomerKpis, l as CustomerKpisDeltas, m as CustomerKpisPrevious, n as CustomerListPage, o as CustomerListQuery, p as CustomerProfile, q as CustomerSegment, r as CustomerSegmentCount, s as CustomerSortField, t as CustomerSummary, u as CustomerSummaryQuery, D as DistinctCustomersByCurrency, G as Granularity, N as NAMED_RANGES, v as NamedRange, P as PublicServiceItem, S as SUPPORTED_CURRENCIES, w as Sale, x as SaleCursorPage, y as SaleFilters, z as SaleInput, E as SaleItem, F as SaleItemInput, H as SaleKeysetSortField, I as SaleListPage, J as SaleListQuery, K as SaleListQueryV2, L as SaleService, M as SaleServiceInput, O as SaleSortField, Q as SaleSortOrder, R as SaleSummary, U as SaleSummaryPrevious, V as SaleSummaryQuery, W as SaleSummaryQueryV2, X as SaleSummaryV2, Y as SaleUpdateInput, Z as SalesBusinessClient, _ as SalesCategoryBreakdown, $ as SalesClient, a0 as SalesClientConfig, a1 as SalesCustomersClient, a2 as SalesServiceBreakdown, a3 as SalesTransportConfig, a4 as SalesTrendPoint, a5 as SummaryCurrencyDelta, a6 as SummaryDeltas, a7 as SummaryWindow, a8 as SupportedCurrency, a9 as TRACKING_RANGES, aa as TrackingOverviewRange, ac as createSalesClient, ad as fetchServices, ae as formatDateInTz, af as formatMoney, ag as fromMinor, aj as saleCreateSchema, ak as saleItemSchema, al as saleServiceSchema, am as saleUpdateSchema, an as salesRequest, ap as toMinor } from './sales-BhCYJqDy.mjs';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import 'libphonenumber-js';
|
package/dist/sales.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, c as CompareTo, f as CurrencyRevenue, g as CustomerCurrencyDelta, h as CustomerCurrencyTotal, i as CustomerGetOptions, j as CustomerGetResult, k as CustomerKpis, l as CustomerKpisDeltas, m as CustomerKpisPrevious, n as CustomerListPage, o as CustomerListQuery, p as CustomerProfile, q as CustomerSegment, r as CustomerSegmentCount, s as CustomerSortField, t as CustomerSummary, u as CustomerSummaryQuery, D as DistinctCustomersByCurrency, G as Granularity, N as NAMED_RANGES, v as NamedRange, P as PublicServiceItem, S as SUPPORTED_CURRENCIES, w as Sale, x as SaleCursorPage, y as SaleFilters, z as SaleInput, E as SaleItem, F as SaleItemInput, H as SaleKeysetSortField, I as SaleListPage, J as SaleListQuery, K as SaleListQueryV2, L as SaleService, M as SaleServiceInput, O as SaleSortField, Q as SaleSortOrder, R as SaleSummary, U as SaleSummaryPrevious, V as SaleSummaryQuery, W as SaleSummaryQueryV2, X as SaleSummaryV2, Y as SaleUpdateInput, Z as SalesBusinessClient, _ as SalesCategoryBreakdown, $ as SalesClient, a0 as SalesClientConfig, a1 as SalesCustomersClient, a2 as SalesServiceBreakdown, a3 as SalesTransportConfig, a4 as SalesTrendPoint, a5 as SummaryCurrencyDelta, a6 as SummaryDeltas, a7 as SummaryWindow, a8 as SupportedCurrency, a9 as TRACKING_RANGES, aa as TrackingOverviewRange, ac as createSalesClient, ad as fetchServices, ae as formatDateInTz, af as formatMoney, ag as fromMinor, aj as saleCreateSchema, ak as saleItemSchema, al as saleServiceSchema, am as saleUpdateSchema, an as salesRequest, ap as toMinor } from './sales-
|
|
1
|
+
export { A as AranovaApiError, B as BusinessConfig, a as BusinessConfigFeatures, b as BusinessConfigService, c as CompareTo, f as CurrencyRevenue, g as CustomerCurrencyDelta, h as CustomerCurrencyTotal, i as CustomerGetOptions, j as CustomerGetResult, k as CustomerKpis, l as CustomerKpisDeltas, m as CustomerKpisPrevious, n as CustomerListPage, o as CustomerListQuery, p as CustomerProfile, q as CustomerSegment, r as CustomerSegmentCount, s as CustomerSortField, t as CustomerSummary, u as CustomerSummaryQuery, D as DistinctCustomersByCurrency, G as Granularity, N as NAMED_RANGES, v as NamedRange, P as PublicServiceItem, S as SUPPORTED_CURRENCIES, w as Sale, x as SaleCursorPage, y as SaleFilters, z as SaleInput, E as SaleItem, F as SaleItemInput, H as SaleKeysetSortField, I as SaleListPage, J as SaleListQuery, K as SaleListQueryV2, L as SaleService, M as SaleServiceInput, O as SaleSortField, Q as SaleSortOrder, R as SaleSummary, U as SaleSummaryPrevious, V as SaleSummaryQuery, W as SaleSummaryQueryV2, X as SaleSummaryV2, Y as SaleUpdateInput, Z as SalesBusinessClient, _ as SalesCategoryBreakdown, $ as SalesClient, a0 as SalesClientConfig, a1 as SalesCustomersClient, a2 as SalesServiceBreakdown, a3 as SalesTransportConfig, a4 as SalesTrendPoint, a5 as SummaryCurrencyDelta, a6 as SummaryDeltas, a7 as SummaryWindow, a8 as SupportedCurrency, a9 as TRACKING_RANGES, aa as TrackingOverviewRange, ac as createSalesClient, ad as fetchServices, ae as formatDateInTz, af as formatMoney, ag as fromMinor, aj as saleCreateSchema, ak as saleItemSchema, al as saleServiceSchema, am as saleUpdateSchema, an as salesRequest, ap as toMinor } from './sales-BhCYJqDy.js';
|
|
2
2
|
import 'zod';
|
|
3
3
|
import 'libphonenumber-js';
|
package/dist/sales.js
CHANGED
|
@@ -38,6 +38,12 @@ __export(sales_exports, {
|
|
|
38
38
|
});
|
|
39
39
|
module.exports = __toCommonJS(sales_exports);
|
|
40
40
|
|
|
41
|
+
// ../tracking-core/src/capabilities.ts
|
|
42
|
+
var registered = /* @__PURE__ */ new Set();
|
|
43
|
+
function registerCapability(capability) {
|
|
44
|
+
registered.add(capability);
|
|
45
|
+
}
|
|
46
|
+
|
|
41
47
|
// ../tracking-core/src/phone.ts
|
|
42
48
|
var import_libphonenumber_js = require("libphonenumber-js");
|
|
43
49
|
var DEFAULT_PHONE_COUNTRY = "CA";
|
|
@@ -234,7 +240,7 @@ var SDK_PACKAGE_HEADER = "X-Aranova-Sdk-Package";
|
|
|
234
240
|
var SDK_SURFACE_HEADER = "X-Aranova-Sdk-Surface";
|
|
235
241
|
var SDK_ENVIRONMENT_HEADER = "X-Aranova-Sdk-Environment";
|
|
236
242
|
|
|
237
|
-
// ../tracking-core/src/resources/
|
|
243
|
+
// ../tracking-core/src/resources/http/errors.ts
|
|
238
244
|
var AranovaApiError = class extends Error {
|
|
239
245
|
constructor(message, options) {
|
|
240
246
|
super(message);
|
|
@@ -245,7 +251,7 @@ var AranovaApiError = class extends Error {
|
|
|
245
251
|
}
|
|
246
252
|
};
|
|
247
253
|
|
|
248
|
-
// ../tracking-core/src/resources/
|
|
254
|
+
// ../tracking-core/src/resources/http/request.ts
|
|
249
255
|
function identityHeaders(config) {
|
|
250
256
|
const headers = { [API_KEY_HEADER]: config.apiKey };
|
|
251
257
|
if (config.sdkVersion) headers[SDK_VERSION_HEADER] = config.sdkVersion;
|
|
@@ -257,8 +263,8 @@ function identityHeaders(config) {
|
|
|
257
263
|
function joinUrl(endpoint, path) {
|
|
258
264
|
return `${endpoint.replace(/\/$/, "")}${path}`;
|
|
259
265
|
}
|
|
260
|
-
async function
|
|
261
|
-
const headers = identityHeaders(config);
|
|
266
|
+
async function apiRequest(config, method, path, body, extraHeaders) {
|
|
267
|
+
const headers = { ...identityHeaders(config), ...extraHeaders };
|
|
262
268
|
if (body !== void 0) headers["Content-Type"] = "application/json";
|
|
263
269
|
const response = await fetch(joinUrl(config.endpoint, path), {
|
|
264
270
|
method,
|
|
@@ -287,6 +293,24 @@ async function salesRequest(config, method, path, body) {
|
|
|
287
293
|
return await response.json();
|
|
288
294
|
}
|
|
289
295
|
|
|
296
|
+
// ../tracking-core/src/resources/sales/transport.ts
|
|
297
|
+
var salesRequest = apiRequest;
|
|
298
|
+
|
|
299
|
+
// ../tracking-core/src/resources/intl/date.ts
|
|
300
|
+
function formatDateInTz(iso, timeZone, opts, locale) {
|
|
301
|
+
const date = new Date(iso);
|
|
302
|
+
if (Number.isNaN(date.getTime())) return iso;
|
|
303
|
+
return new Intl.DateTimeFormat(locale, {
|
|
304
|
+
year: "numeric",
|
|
305
|
+
month: "short",
|
|
306
|
+
day: "2-digit",
|
|
307
|
+
hour: "2-digit",
|
|
308
|
+
minute: "2-digit",
|
|
309
|
+
...opts,
|
|
310
|
+
timeZone
|
|
311
|
+
}).format(date);
|
|
312
|
+
}
|
|
313
|
+
|
|
290
314
|
// ../tracking-core/src/resources/sales/money.ts
|
|
291
315
|
var MINOR_UNIT_EXPONENT = {
|
|
292
316
|
USD: 2,
|
|
@@ -306,19 +330,6 @@ function formatMoney(cents, currency, locale) {
|
|
|
306
330
|
fromMinor(cents, currency)
|
|
307
331
|
);
|
|
308
332
|
}
|
|
309
|
-
function formatDateInTz(iso, timeZone, opts, locale) {
|
|
310
|
-
const date = new Date(iso);
|
|
311
|
-
if (Number.isNaN(date.getTime())) return iso;
|
|
312
|
-
return new Intl.DateTimeFormat(locale, {
|
|
313
|
-
year: "numeric",
|
|
314
|
-
month: "short",
|
|
315
|
-
day: "2-digit",
|
|
316
|
-
hour: "2-digit",
|
|
317
|
-
minute: "2-digit",
|
|
318
|
-
...opts,
|
|
319
|
-
timeZone
|
|
320
|
-
}).format(date);
|
|
321
|
-
}
|
|
322
333
|
|
|
323
334
|
// ../tracking-core/src/resources/sales/client.ts
|
|
324
335
|
function fireRecordedConversions(firing, input, recorded, sale, currency) {
|
|
@@ -351,6 +362,7 @@ function fireRecordedConversions(firing, input, recorded, sale, currency) {
|
|
|
351
362
|
}
|
|
352
363
|
}
|
|
353
364
|
function createSalesClient(config) {
|
|
365
|
+
if (config.firing) registerCapability("conversion_goals_manual");
|
|
354
366
|
async function record(input) {
|
|
355
367
|
const currency = input.currency ?? config.defaultCurrency;
|
|
356
368
|
if (!currency) {
|