@replohq/sdk 1.22.0 → 2.0.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.
Files changed (117) hide show
  1. package/_vendor/replo-utils/lib/json.mjs +4 -5
  2. package/_vendor/replo-utils/lib/misc.mjs +4 -3
  3. package/_vendor/replo-utils/lib/object.d.ts +16 -1
  4. package/_vendor/replo-utils/lib/object.mjs +3 -4
  5. package/_vendor/schemas/contentEntry.mjs +3 -3
  6. package/_vendor/schemas/contentManifest.mjs +6 -6
  7. package/_vendor/schemas/errors.d.ts +3 -43
  8. package/_vendor/schemas/{money.d.ts → moneyFormat.d.ts} +1 -8
  9. package/_vendor/schemas/{money.mjs → moneyFormat.mjs} +5 -16
  10. package/_vendor/schemas/reploError.d.ts +43 -0
  11. package/_vendor/schemas/routing/locale.mjs +6 -4
  12. package/_vendor/schemas/routing/rules.mjs +6 -4
  13. package/analytics/analytics-sink.d.ts +126 -14
  14. package/analytics/combine-sinks.js +36 -13
  15. package/analytics/hooks/use-product-viewed-analytics.d.ts +1 -17
  16. package/analytics/hooks/use-product-viewed-analytics.js +5 -14
  17. package/analytics/legacy-checkout.d.ts +2 -0
  18. package/analytics/legacy-checkout.js +26 -0
  19. package/analytics/sinks/converge-event-mapper.d.ts +10 -11
  20. package/analytics/sinks/converge-event-mapper.js +50 -133
  21. package/analytics/sinks/converge-sink.d.ts +8 -7
  22. package/analytics/sinks/converge-sink.js +21 -3
  23. package/analytics/sinks/elevar-sink.d.ts +9 -7
  24. package/analytics/sinks/elevar-sink.js +37 -128
  25. package/analytics/sinks/ga4-sink.d.ts +9 -8
  26. package/analytics/sinks/ga4-sink.js +9 -8
  27. package/analytics/sinks/intelligems-sink.d.ts +9 -8
  28. package/analytics/sinks/intelligems-sink.js +3 -1
  29. package/analytics/sinks/meta-sink.d.ts +5 -4
  30. package/analytics/sinks/meta-sink.js +7 -3
  31. package/analytics/sinks/northbeam-sink.d.ts +1 -0
  32. package/analytics/sinks/northbeam-sink.js +2 -0
  33. package/analytics/sinks/pinterest-sink.d.ts +7 -6
  34. package/analytics/sinks/pinterest-sink.js +14 -20
  35. package/analytics/sinks/reddit-sink.d.ts +8 -7
  36. package/analytics/sinks/reddit-sink.js +13 -20
  37. package/analytics/sinks/replo-sink.d.ts +21 -9
  38. package/analytics/sinks/replo-sink.js +37 -39
  39. package/analytics/sinks/snapchat-sink.d.ts +6 -5
  40. package/analytics/sinks/snapchat-sink.js +8 -8
  41. package/analytics/sinks/tiktok-sink.d.ts +8 -7
  42. package/analytics/sinks/tiktok-sink.js +10 -15
  43. package/analytics/sinks/window-sink.d.ts +11 -9
  44. package/analytics/sinks/window-sink.js +5 -1
  45. package/analytics/sinks/x-sink.d.ts +5 -4
  46. package/analytics/sinks/x-sink.js +19 -50
  47. package/analytics/test-fixtures.d.ts +5 -0
  48. package/analytics/test-fixtures.js +18 -0
  49. package/analytics/utils/analytics-products.d.ts +0 -30
  50. package/analytics/utils/analytics-products.js +1 -51
  51. package/analytics/utils/collection-analytics.d.ts +2 -15
  52. package/analytics/utils/collection-analytics.js +14 -18
  53. package/analytics/utils/product-analytics.d.ts +23 -0
  54. package/analytics/utils/product-analytics.js +21 -0
  55. package/cart/hooks/use-add-to-cart.js +1 -1
  56. package/cart/utils/cart-analytics.d.ts +3 -23
  57. package/cart/utils/cart-analytics.js +1 -1
  58. package/cart/utils/cart-utils.js +1 -1
  59. package/cart/utils/variant-to-cart-line.js +1 -1
  60. package/chunk-CKRRL66R.mjs +28 -0
  61. package/{chunk-VVB7BEDE.mjs → chunk-O4QBR4QC.mjs} +9 -4
  62. package/{chunk-EUIVDITZ.mjs → chunk-OPKMOW43.mjs} +1 -1
  63. package/{chunk-C37TXOGI.mjs → chunk-PSYP2DYM.mjs} +1 -1
  64. package/{chunk-ACQS4AG5.mjs → chunk-TTEBDCWT.mjs} +272 -109
  65. package/{chunk-HFKL4ZR5.mjs → chunk-XGXJOHUY.mjs} +2 -1
  66. package/{chunk-AQG3256R.mjs → chunk-XSMYSAKY.mjs} +0 -26
  67. package/{chunk-SSBIMQES.mjs → chunk-XWWFRIXV.mjs} +36 -99
  68. package/chunk-ZPDXVFCR.mjs +66 -0
  69. package/hooks/use-formatted-price.js +1 -1
  70. package/lib/buildMetadata.js +3 -3
  71. package/loaders/collection-loader.js +8 -6
  72. package/loaders/collection-products-loader.js +8 -6
  73. package/loaders/contentful-entries-loader.js +5 -3
  74. package/loaders/contentful-entry-loader.js +5 -3
  75. package/loaders/integration-loader-schemas.d.ts +260 -0
  76. package/loaders/integration-loader-schemas.js +55 -0
  77. package/loaders/invoke-loader.d.ts +5 -0
  78. package/loaders/invoke-loader.js +1 -1
  79. package/loaders/judgeme-review-aggregate-loader.d.ts +1 -1
  80. package/loaders/judgeme-review-aggregate-loader.js +10 -6
  81. package/loaders/judgeme-reviews-loader.d.ts +1 -1
  82. package/loaders/judgeme-reviews-loader.js +5 -3
  83. package/loaders/kaching-bundles-loader.js +5 -3
  84. package/loaders/levanta-product-loader.js +8 -6
  85. package/loaders/loox-review-aggregate-loader.d.ts +1 -1
  86. package/loaders/loox-review-aggregate-loader.js +10 -6
  87. package/loaders/loox-reviews-loader.d.ts +1 -1
  88. package/loaders/loox-reviews-loader.js +8 -6
  89. package/loaders/metaobject-loader.js +5 -3
  90. package/loaders/metaobjects-loader.js +5 -3
  91. package/loaders/okendo-review-aggregate-loader.d.ts +2 -7
  92. package/loaders/okendo-review-aggregate-loader.js +8 -12
  93. package/loaders/okendo-reviews-loader.d.ts +2 -42
  94. package/loaders/okendo-reviews-loader.js +5 -8
  95. package/loaders/product-loader.js +5 -3
  96. package/loaders/rebuy-recommendations-loader.d.ts +2 -167
  97. package/loaders/rebuy-recommendations-loader.js +8 -10
  98. package/loaders/reviews-io-review-aggregate-loader.d.ts +1 -1
  99. package/loaders/reviews-io-review-aggregate-loader.js +5 -3
  100. package/loaders/reviews-io-reviews-loader.d.ts +1 -1
  101. package/loaders/reviews-io-reviews-loader.js +7 -3
  102. package/loaders/shopify-integration-details-loader.js +10 -6
  103. package/loaders/smile-earning-rules-loader.d.ts +2 -8
  104. package/loaders/smile-earning-rules-loader.js +8 -16
  105. package/loaders/smile-rewards-loader.d.ts +2 -8
  106. package/loaders/smile-rewards-loader.js +8 -16
  107. package/loaders/smile-vip-tiers-loader.d.ts +2 -7
  108. package/loaders/smile-vip-tiers-loader.js +8 -15
  109. package/loaders/statsig-experiment-loader.js +5 -3
  110. package/loaders/yotpo-review-aggregate-loader.d.ts +1 -1
  111. package/loaders/yotpo-review-aggregate-loader.js +10 -6
  112. package/loaders/yotpo-reviews-loader.d.ts +1 -1
  113. package/loaders/yotpo-reviews-loader.js +5 -3
  114. package/money.d.ts +1 -1
  115. package/money.js +1 -1
  116. package/package.json +8 -4
  117. package/chunk-CQYCPDPI.mjs +0 -166
@@ -1,54 +1,21 @@
1
1
  import { filterUndefined } from "../../_vendor/replo-utils/lib/object.mjs";
2
- import * as z from "zod";
3
2
  import { isXEventIdForPixel } from "../../consent/script-snippets";
3
+ import { toCheckoutStartedData } from "../legacy-checkout";
4
4
  import { legacyResourceId } from "../utils/analytics-products";
5
5
  import { createEventQueue } from "../utils/analytics-utils";
6
- const analyticsRecordSchema = z.record(z.string(), z.unknown());
7
- const nonEmptyStringSchema = z.union([
8
- z.string().min(1),
9
- z.number().finite().transform(String)
10
- ]);
11
- const finiteNumberSchema = z.union([
12
- z.number().finite(),
13
- z.string().trim().min(1).transform(Number).pipe(z.number().finite())
14
- ]);
15
- function parseRecord(value) {
16
- const result = analyticsRecordSchema.safeParse(value);
17
- return result.success ? result.data : {};
18
- }
19
- function parseString(value) {
20
- const result = nonEmptyStringSchema.safeParse(value);
21
- return result.success ? result.data : void 0;
22
- }
23
- function parseNumber(value) {
24
- const result = finiteNumberSchema.safeParse(value);
25
- return result.success ? result.data : void 0;
26
- }
27
- function mapContent(value, defaultQuantity) {
28
- const line = parseRecord(value);
29
- const variant = parseRecord(line.variant);
30
- const product = parseRecord(variant.product);
31
- const productId = parseString(line.productId) ?? parseString(product.id);
32
- if (!productId) {
33
- return null;
34
- }
6
+ function mapContent(line, defaultQuantity) {
35
7
  return filterUndefined({
36
- content_id: legacyResourceId(productId),
37
- content_name: parseString(line.productTitle) ?? parseString(product.title) ?? parseString(line.title),
38
- content_price: parseNumber(line.price) ?? parseNumber(parseRecord(variant.price).amount),
39
- num_items: parseNumber(line.quantity) ?? defaultQuantity
8
+ content_id: legacyResourceId(line.productId),
9
+ content_name: line.productTitle || void 0,
10
+ content_price: line.price,
11
+ num_items: line.quantity ?? defaultQuantity
40
12
  });
41
13
  }
42
14
  function mapContents(lines) {
43
- const result = z.array(z.unknown()).safeParse(lines);
44
- if (!result.success) {
45
- return void 0;
46
- }
47
- const contents = result.data.map((line) => mapContent(line, void 0)).filter((content) => content !== null);
48
- return contents.length > 0 ? contents : void 0;
15
+ return lines && lines.length > 0 ? lines.map((line) => mapContent(line, void 0)) : void 0;
49
16
  }
50
17
  function lineValue(content) {
51
- if (content?.content_price === void 0) {
18
+ if (content.content_price === void 0) {
52
19
  return void 0;
53
20
  }
54
21
  return content.content_price * (content.num_items ?? 1);
@@ -74,6 +41,8 @@ class XSink {
74
41
  this.send(eventId, filterUndefined(parameters));
75
42
  }
76
43
  }
44
+ async customEvent() {
45
+ }
77
46
  async pageView(metadata) {
78
47
  if (metadata?.navigationType === "initial") {
79
48
  return;
@@ -84,7 +53,7 @@ class XSink {
84
53
  this.track("purchase", {
85
54
  value: amount,
86
55
  currency,
87
- conversion_id: parseString(data.order_id) ?? parseString(data.orderId) ?? parseString(data.id),
56
+ conversion_id: data.orderId,
88
57
  contents: mapContents(data.lineItems)
89
58
  });
90
59
  }
@@ -94,27 +63,27 @@ class XSink {
94
63
  const content = mapContent(data, 1);
95
64
  this.track("productViewed", {
96
65
  value: lineValue(content),
97
- currency: parseString(data.currency),
98
- contents: content ? [content] : void 0
66
+ currency: data.currency || void 0,
67
+ contents: [content]
99
68
  });
100
69
  }
101
70
  async addToCart({ data }) {
102
71
  const content = mapContent(data, 1);
103
72
  this.track("addToCart", {
104
73
  value: lineValue(content),
105
- currency: parseString(data.currency),
106
- contents: content ? [content] : void 0
74
+ currency: data.currency || void 0,
75
+ contents: [content]
107
76
  });
108
77
  }
109
78
  async removeFromCart() {
110
79
  }
111
80
  async viewCart() {
112
81
  }
113
- async startCheckout({ data }) {
114
- const totalPrice = parseRecord(data.totalPrice);
82
+ async startCheckout(payload) {
83
+ const data = toCheckoutStartedData(payload.data);
115
84
  this.track("startCheckout", {
116
- value: parseNumber(totalPrice.amount),
117
- currency: parseString(data.currencyCode) ?? parseString(totalPrice.currencyCode),
85
+ value: data.total,
86
+ currency: data.currency,
118
87
  contents: mapContents(data.lineItems)
119
88
  });
120
89
  }
@@ -0,0 +1,5 @@
1
+ import type { CartLineData, CartViewedData, CheckoutStartedData, CollectionViewedData } from "./analytics-sink";
2
+ export declare function cartLine(overrides?: Partial<CartLineData>): CartLineData;
3
+ export declare function cartView(overrides?: Partial<CartViewedData>): CartViewedData;
4
+ export declare function checkoutStarted(overrides?: Partial<CheckoutStartedData>): CheckoutStartedData;
5
+ export declare function collectionViewed(overrides?: Partial<CollectionViewedData>): CollectionViewedData;
@@ -0,0 +1,18 @@
1
+ function cartLine(overrides = {}) {
2
+ return { productId: "1", price: 1, quantity: 1, ...overrides };
3
+ }
4
+ function cartView(overrides = {}) {
5
+ return { itemCount: 0, subtotal: 0, lineItems: [], ...overrides };
6
+ }
7
+ function checkoutStarted(overrides = {}) {
8
+ return { itemCount: 0, subtotal: 0, total: 0, lineItems: [], ...overrides };
9
+ }
10
+ function collectionViewed(overrides = {}) {
11
+ return { collectionId: "c1", products: [], ...overrides };
12
+ }
13
+ export {
14
+ cartLine,
15
+ cartView,
16
+ checkoutStarted,
17
+ collectionViewed
18
+ };
@@ -1,36 +1,6 @@
1
- import * as z from "zod";
2
- /**
3
- * The flat per-product line the cart provider and the viewed hooks emit.
4
- * Prices are decimal major units.
5
- */
6
- declare const analyticsProductLineSchema: z.ZodObject<{
7
- productId: z.ZodCatch<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodNumber, z.ZodTransform<string, number>>]>>>;
8
- productTitle: z.ZodCatch<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodNumber, z.ZodTransform<string, number>>]>>>;
9
- variantId: z.ZodCatch<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodNumber, z.ZodTransform<string, number>>]>>>;
10
- variantTitle: z.ZodCatch<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodNumber, z.ZodTransform<string, number>>]>>>;
11
- variantSku: z.ZodCatch<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodNumber, z.ZodTransform<string, number>>]>>>;
12
- price: z.ZodCatch<z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>]>>>;
13
- currency: z.ZodCatch<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodPipe<z.ZodNumber, z.ZodTransform<string, number>>]>>>;
14
- quantity: z.ZodCatch<z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>, z.ZodNumber>]>>>;
15
- }, z.core.$strip>;
16
- export type AnalyticsProductLine = z.infer<typeof analyticsProductLineSchema> & {
17
- productId: string;
18
- };
19
- export declare function parseAnalyticsProductLines(value: unknown): AnalyticsProductLine[];
20
- /**
21
- * Separates a collection-view payload's `products` list from the scalar
22
- * fields, so a sink can map the list into its own item shape and forward the
23
- * rest untouched.
24
- */
25
- export declare function splitCollectionProducts(data: Record<string, unknown>): {
26
- products: AnalyticsProductLine[];
27
- rest: Record<string, unknown>;
28
- };
29
1
  /**
30
2
  * Shopify catalogs synced into ad platforms key on legacy numeric ids, while
31
3
  * the Storefront API hands sites GIDs (`gid://shopify/Product/123`). Pixel
32
4
  * catalog matching is an exact string match, so ids are sent bare.
33
5
  */
34
6
  export declare function legacyResourceId(id: string): string;
35
- export declare function withoutUndefined<RecordType extends Record<string, unknown>>(record: RecordType): Partial<RecordType>;
36
- export {};
@@ -1,56 +1,6 @@
1
- import * as z from "zod";
2
- const nonEmptyStringSchema = z.union([z.string().min(1), z.number().finite().transform(String)]).optional().catch(void 0);
3
- const finiteNumberSchema = z.union([
4
- z.number().finite(),
5
- z.string().trim().min(1).transform(Number).pipe(z.number().finite())
6
- ]).optional().catch(void 0);
7
- const analyticsProductLineSchema = z.object({
8
- productId: nonEmptyStringSchema,
9
- productTitle: nonEmptyStringSchema,
10
- variantId: nonEmptyStringSchema,
11
- variantTitle: nonEmptyStringSchema,
12
- variantSku: nonEmptyStringSchema,
13
- price: finiteNumberSchema,
14
- currency: nonEmptyStringSchema,
15
- quantity: finiteNumberSchema
16
- });
17
- function parseAnalyticsProductLines(value) {
18
- if (!Array.isArray(value)) {
19
- return [];
20
- }
21
- return value.flatMap((item) => {
22
- const parsed = analyticsProductLineSchema.safeParse(item);
23
- if (!parsed.success || !parsed.data.productId) {
24
- return [];
25
- }
26
- return [{ ...parsed.data, productId: parsed.data.productId }];
27
- });
28
- }
29
- function splitCollectionProducts(data) {
30
- const { products, ...rest } = data;
31
- const lines = parseAnalyticsProductLines(products);
32
- if (Array.isArray(products) && products.length > 0 && lines.length === 0) {
33
- console.warn(
34
- "[analytics] collection view products did not match the per-line shape and were dropped"
35
- );
36
- }
37
- return { products: lines, rest };
38
- }
39
1
  function legacyResourceId(id) {
40
2
  return id.replace(/^gid:\/\/shopify\/\w+\//, "");
41
3
  }
42
- function withoutUndefined(record) {
43
- const compacted = {};
44
- for (const key in record) {
45
- if (record[key] !== void 0) {
46
- compacted[key] = record[key];
47
- }
48
- }
49
- return compacted;
50
- }
51
4
  export {
52
- legacyResourceId,
53
- parseAnalyticsProductLines,
54
- splitCollectionProducts,
55
- withoutUndefined
5
+ legacyResourceId
56
6
  };
@@ -1,3 +1,4 @@
1
+ import type { CollectionViewedData } from "../analytics-sink";
1
2
  export interface AnalyticsMoney {
2
3
  amount: number | string;
3
4
  currencyCode: string;
@@ -27,18 +28,4 @@ export interface AnalyticsCollectionProduct {
27
28
  export declare function buildCollectionViewedAnalyticsData({ collection, products, }: {
28
29
  collection: AnalyticsCollection;
29
30
  products: AnalyticsCollectionProduct[];
30
- }): {
31
- collectionTitle?: string | undefined;
32
- collectionHandle?: string | undefined;
33
- currency?: string | undefined;
34
- collectionId: string;
35
- products: {
36
- productTitle?: string | undefined;
37
- variantId?: string | undefined;
38
- variantTitle?: string | undefined;
39
- variantSku?: string | undefined;
40
- price?: number | undefined;
41
- currency?: string | undefined;
42
- productId: string;
43
- }[];
44
- };
31
+ }): CollectionViewedData;
@@ -1,4 +1,4 @@
1
- import { withoutUndefined } from "./analytics-products";
1
+ import { filterUndefined } from "../../_vendor/replo-utils/lib/object.mjs";
2
2
  function parseAmount(money) {
3
3
  if (!money) {
4
4
  return void 0;
@@ -9,32 +9,28 @@ function parseAmount(money) {
9
9
  function buildCollectionProductLine(product) {
10
10
  const variant = product.variants?.[0];
11
11
  const money = variant?.price ?? product.minPrice ?? void 0;
12
- return {
12
+ return filterUndefined({
13
13
  productId: product.id,
14
- ...withoutUndefined({
15
- productTitle: product.title ?? void 0,
16
- variantId: variant?.id,
17
- variantTitle: variant?.title ?? void 0,
18
- variantSku: variant?.sku ?? void 0,
19
- price: parseAmount(money),
20
- currency: money?.currencyCode
21
- })
22
- };
14
+ productTitle: product.title ?? void 0,
15
+ variantId: variant?.id,
16
+ variantTitle: variant?.title ?? void 0,
17
+ variantSku: variant?.sku ?? void 0,
18
+ price: parseAmount(money),
19
+ currency: money?.currencyCode
20
+ });
23
21
  }
24
22
  function buildCollectionViewedAnalyticsData({
25
23
  collection,
26
24
  products
27
25
  }) {
28
26
  const lines = products.map(buildCollectionProductLine);
29
- return {
27
+ return filterUndefined({
30
28
  collectionId: collection.id,
31
29
  products: lines,
32
- ...withoutUndefined({
33
- collectionTitle: collection.title ?? void 0,
34
- collectionHandle: collection.handle ?? void 0,
35
- currency: lines.find((line) => line.currency)?.currency
36
- })
37
- };
30
+ collectionTitle: collection.title ?? void 0,
31
+ collectionHandle: collection.handle ?? void 0,
32
+ currency: lines.find((line) => line.currency)?.currency
33
+ });
38
34
  }
39
35
  export {
40
36
  buildCollectionViewedAnalyticsData
@@ -0,0 +1,23 @@
1
+ import type { ProductViewedData } from "../analytics-sink";
2
+ export interface AnalyticsProduct {
3
+ id: string;
4
+ title: string;
5
+ slug?: string;
6
+ description?: string;
7
+ }
8
+ export interface AnalyticsProductVariant {
9
+ id: string;
10
+ title?: string;
11
+ sku?: string;
12
+ price?: number | {
13
+ amount: number | string;
14
+ currencyCode: string;
15
+ };
16
+ currency?: string;
17
+ priceCurrencyCode?: string | null;
18
+ }
19
+ /** The `productViewed` payload for a product and its selected variant. */
20
+ export declare function buildProductViewedAnalyticsData({ product, selectedVariant, }: {
21
+ product: AnalyticsProduct;
22
+ selectedVariant: AnalyticsProductVariant;
23
+ }): ProductViewedData;
@@ -0,0 +1,21 @@
1
+ function buildProductViewedAnalyticsData({
2
+ product,
3
+ selectedVariant
4
+ }) {
5
+ const price = typeof selectedVariant.price === "object" ? Number(selectedVariant.price.amount) : selectedVariant.price ?? 0;
6
+ const currency = typeof selectedVariant.price === "object" ? selectedVariant.price.currencyCode : selectedVariant.currency ?? selectedVariant.priceCurrencyCode ?? void 0;
7
+ return {
8
+ productId: product.id,
9
+ productTitle: product.title,
10
+ productSlug: product.slug,
11
+ productDescription: product.description,
12
+ variantId: selectedVariant.id,
13
+ variantTitle: selectedVariant.title ?? "",
14
+ variantSku: selectedVariant.sku ?? "",
15
+ price,
16
+ currency
17
+ };
18
+ }
19
+ export {
20
+ buildProductViewedAnalyticsData
21
+ };
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import React from "react";
3
3
  import { useQueryClient } from "@tanstack/react-query";
4
- import { fromMajorUnitsToMinorUnits } from "../../_vendor/schemas/money.mjs";
4
+ import { fromMajorUnitsToMinorUnits } from "../../_vendor/schemas/moneyFormat.mjs";
5
5
  import { DATA_LOADER_KEYS } from "../../loaders/loader-keys";
6
6
  import { useCartInternal } from "../cart-provider";
7
7
  import { REPLO_ATTRIBUTION_PROPERTY } from "../cart-types";
@@ -1,3 +1,4 @@
1
+ import type { CartLineData, CartViewedData } from "../../analytics/analytics-sink";
1
2
  import type { Cart, CartLineMerchandise } from "../cart-types";
2
3
  /**
3
4
  * The per-line payload every cart event carries. Cart amounts are integer
@@ -8,27 +9,6 @@ export declare function buildCartLineAnalyticsData({ merchandise, quantity, curr
8
9
  merchandise: CartLineMerchandise;
9
10
  quantity: number;
10
11
  currencyCode: string | undefined;
11
- }): {
12
- productId: string;
13
- variantId: string;
14
- quantity: number;
15
- price: number;
16
- currency: string | undefined;
17
- productTitle: string;
18
- variantTitle: string;
19
- };
12
+ }): CartLineData;
20
13
  /** The cart-view payload, built from whichever cart snapshot the caller passes. */
21
- export declare function buildCartViewAnalyticsData(cart: Cart | null): {
22
- itemCount: number;
23
- subtotal: number;
24
- currency: string | undefined;
25
- lineItems: {
26
- productId: string;
27
- variantId: string;
28
- quantity: number;
29
- price: number;
30
- currency: string | undefined;
31
- productTitle: string;
32
- variantTitle: string;
33
- }[];
34
- };
14
+ export declare function buildCartViewAnalyticsData(cart: Cart | null): CartViewedData;
@@ -1,4 +1,4 @@
1
- import { fromMinorUnitsToMajorUnits } from "../../_vendor/schemas/money.mjs";
1
+ import { fromMinorUnitsToMajorUnits } from "../../_vendor/schemas/moneyFormat.mjs";
2
2
  const FALLBACK_CURRENCY_CODE = "USD";
3
3
  function buildCartLineAnalyticsData({
4
4
  merchandise,
@@ -1,4 +1,4 @@
1
- import { formatAmount } from "../../_vendor/schemas/money.mjs";
1
+ import { formatAmount } from "../../_vendor/schemas/moneyFormat.mjs";
2
2
  import { CanopyError } from "../../lib/canopy-error";
3
3
  import { getCartLinePricing } from "./variant-to-cart-line";
4
4
  class CartReconciliationMismatchError extends CanopyError {
@@ -1,4 +1,4 @@
1
- import { fromMajorUnitsToMinorUnits } from "../../_vendor/schemas/money.mjs";
1
+ import { fromMajorUnitsToMinorUnits } from "../../_vendor/schemas/moneyFormat.mjs";
2
2
  function applyPriceAdjustment(variantPrice, adjustment, currencyCode) {
3
3
  switch (adjustment.valueType) {
4
4
  case "price":
@@ -0,0 +1,28 @@
1
+ import { v4 } from 'uuid';
2
+
3
+ function randomUUID() {
4
+ return v4();
5
+ }
6
+
7
+ var ReploError = class _ReploError extends Error {
8
+ config;
9
+ id;
10
+ constructor(config) {
11
+ super(config.message);
12
+ this.message = config.message ?? this.constructor.name;
13
+ this.config = config;
14
+ this.id = randomUUID();
15
+ const cause = config.cause;
16
+ if (cause) {
17
+ this.cause = cause;
18
+ if (cause instanceof _ReploError) {
19
+ this.config.additionalData = {
20
+ ...this.config.additionalData,
21
+ ...cause.config.additionalData
22
+ };
23
+ }
24
+ }
25
+ }
26
+ };
27
+
28
+ export { ReploError };
@@ -1,6 +1,5 @@
1
- import { pickBy_default } from './chunk-ACQS4AG5.mjs';
2
- import { isString_default, isNumber_default } from './chunk-EUIVDITZ.mjs';
3
- import { isObject_default } from './chunk-SSBIMQES.mjs';
1
+ import { isString_default, isNumber_default } from './chunk-OPKMOW43.mjs';
2
+ import { isObject_default } from './chunk-ZPDXVFCR.mjs';
4
3
 
5
4
  var has = Object.prototype.hasOwnProperty;
6
5
  function dequal(foo, bar) {
@@ -75,7 +74,13 @@ function omit(obj, keysToOmit) {
75
74
  return result;
76
75
  }
77
76
  function filterUndefined(data) {
78
- return pickBy_default(data, (value) => value !== void 0);
77
+ const result = {};
78
+ for (const [key, value] of Object.entries(data)) {
79
+ if (value !== void 0) {
80
+ result[key] = value;
81
+ }
82
+ }
83
+ return result;
79
84
  }
80
85
  function toNullableIfDefined(value) {
81
86
  return value === void 0 ? void 0 : value ?? null;
@@ -1,4 +1,4 @@
1
- import { isObjectLike_default, baseGetTag_default, isArray_default } from './chunk-SSBIMQES.mjs';
1
+ import { isObjectLike_default, baseGetTag_default, isArray_default } from './chunk-ZPDXVFCR.mjs';
2
2
 
3
3
  var numberTag = "[object Number]";
4
4
  function isNumber(value) {
@@ -1,4 +1,4 @@
1
- import { omit } from './chunk-VVB7BEDE.mjs';
1
+ import { omit } from './chunk-O4QBR4QC.mjs';
2
2
 
3
3
  function parseJsonOrNull(json) {
4
4
  try {