@instockng/storefront-ui 1.0.70 → 1.0.71

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 (182) hide show
  1. package/dist/contexts/CartContext.d.ts.map +1 -1
  2. package/dist/index.mjs +65 -63
  3. package/dist/index100.mjs +2 -33
  4. package/dist/index101.mjs +34 -2
  5. package/dist/index102.mjs +43 -2
  6. package/dist/index106.mjs +2 -2
  7. package/dist/index107.mjs +2 -2
  8. package/dist/index140.mjs +1 -1
  9. package/dist/index142.mjs +2 -21
  10. package/dist/index143.mjs +19 -54
  11. package/dist/index144.mjs +55 -28
  12. package/dist/index145.mjs +28 -6
  13. package/dist/index146.mjs +6 -51
  14. package/dist/index147.mjs +51 -5
  15. package/dist/index148.mjs +6 -12
  16. package/dist/index149.mjs +12 -7
  17. package/dist/index15.mjs +1 -1
  18. package/dist/index150.mjs +6 -27
  19. package/dist/index151.mjs +28 -2
  20. package/dist/index152.mjs +2 -70
  21. package/dist/index153.mjs +67 -164
  22. package/dist/index154.mjs +167 -2
  23. package/dist/index158.mjs +1 -1
  24. package/dist/index159.mjs +1 -1
  25. package/dist/index160.mjs +1 -1
  26. package/dist/index161.mjs +1 -1
  27. package/dist/index162.mjs +1 -1
  28. package/dist/index164.mjs +3 -3
  29. package/dist/index165.mjs +1 -1
  30. package/dist/index167.mjs +2 -2
  31. package/dist/index168.mjs +1 -1
  32. package/dist/index173.mjs +2 -2
  33. package/dist/index175.mjs +1 -1
  34. package/dist/index177.mjs +2 -2
  35. package/dist/index178.mjs +5 -5
  36. package/dist/index181.mjs +1 -1
  37. package/dist/index184.mjs +1 -1
  38. package/dist/index187.mjs +1 -1
  39. package/dist/index188.mjs +1 -1
  40. package/dist/index192.mjs +1 -1
  41. package/dist/index194.mjs +1 -1
  42. package/dist/index198.mjs +1 -1
  43. package/dist/index2.mjs +1 -1
  44. package/dist/index200.mjs +1 -1
  45. package/dist/index209.mjs +2 -2
  46. package/dist/index211.mjs +1 -1
  47. package/dist/index212.mjs +1 -1
  48. package/dist/index213.mjs +2 -13
  49. package/dist/index214.mjs +2 -7
  50. package/dist/index215.mjs +2 -31
  51. package/dist/index216.mjs +2 -11
  52. package/dist/index217.mjs +2 -4
  53. package/dist/index218.mjs +2 -4
  54. package/dist/index219.mjs +2 -12
  55. package/dist/index22.mjs +10 -6
  56. package/dist/index220.mjs +2 -5
  57. package/dist/index221.mjs +37 -33
  58. package/dist/index222.mjs +2 -31
  59. package/dist/index223.mjs +2 -28
  60. package/dist/index224.mjs +2 -61
  61. package/dist/index225.mjs +2 -2
  62. package/dist/index226.mjs +2 -2
  63. package/dist/index227.mjs +244 -2
  64. package/dist/index228.mjs +2 -2
  65. package/dist/index229.mjs +28 -103
  66. package/dist/index23.mjs +13 -14
  67. package/dist/index230.mjs +65 -2
  68. package/dist/index231.mjs +25 -2
  69. package/dist/index232.mjs +2 -2
  70. package/dist/index233.mjs +2 -2
  71. package/dist/index234.mjs +2 -2
  72. package/dist/index235.mjs +108 -2
  73. package/dist/index236.mjs +2 -37
  74. package/dist/index238.mjs +2 -244
  75. package/dist/index239.mjs +4 -2
  76. package/dist/index240.mjs +30 -32
  77. package/dist/index241.mjs +10 -64
  78. package/dist/index242.mjs +3 -24
  79. package/dist/index243.mjs +4 -2
  80. package/dist/index244.mjs +13 -2
  81. package/dist/index245.mjs +7 -2
  82. package/dist/index246.mjs +2 -2
  83. package/dist/index247.mjs +2 -2
  84. package/dist/index248.mjs +12 -2
  85. package/dist/index249.mjs +5 -2
  86. package/dist/index250.mjs +33 -2
  87. package/dist/index251.mjs +31 -2
  88. package/dist/index252.mjs +28 -2
  89. package/dist/index253.mjs +61 -4
  90. package/dist/index254.mjs +2 -2
  91. package/dist/index256.mjs +2 -3
  92. package/dist/index257.mjs +18 -2
  93. package/dist/index258.mjs +47 -2
  94. package/dist/index259.mjs +2 -17
  95. package/dist/index260.mjs +2 -13
  96. package/dist/index261.mjs +2 -6
  97. package/dist/index262.mjs +2 -30
  98. package/dist/index263.mjs +91 -2
  99. package/dist/index264.mjs +2 -2
  100. package/dist/index265.mjs +2 -2
  101. package/dist/index266.mjs +3 -2
  102. package/dist/index267.mjs +2 -2
  103. package/dist/index268.mjs +2 -91
  104. package/dist/index269.mjs +17 -2
  105. package/dist/index27.mjs +17 -17
  106. package/dist/index270.mjs +12 -17
  107. package/dist/index271.mjs +6 -47
  108. package/dist/index272.mjs +30 -2
  109. package/dist/index273.mjs +2 -2
  110. package/dist/index275.mjs +2 -2
  111. package/dist/index28.mjs +58 -47
  112. package/dist/index29.mjs +11 -11
  113. package/dist/index3.mjs +141 -123
  114. package/dist/index30.mjs +4 -4
  115. package/dist/index31.mjs +5 -5
  116. package/dist/index33.mjs +21 -20
  117. package/dist/index35.mjs +36 -29
  118. package/dist/index36.mjs +8 -25
  119. package/dist/index37.mjs +1 -1
  120. package/dist/index38.mjs +26 -9
  121. package/dist/index39.mjs +9 -9
  122. package/dist/index4.mjs +58 -46
  123. package/dist/index40.mjs +2 -2
  124. package/dist/index42.mjs +2 -2
  125. package/dist/index45.mjs +3 -3
  126. package/dist/index46.mjs +1 -1
  127. package/dist/index49.mjs +1 -1
  128. package/dist/index54.mjs +17 -17
  129. package/dist/index55.mjs +2 -2
  130. package/dist/index56.mjs +1 -1
  131. package/dist/index57.mjs +1 -1
  132. package/dist/index58.mjs +1 -1
  133. package/dist/index59.mjs +1 -1
  134. package/dist/index60.mjs +1 -1
  135. package/dist/index61.mjs +1 -1
  136. package/dist/index62.mjs +1 -1
  137. package/dist/index63.mjs +1 -1
  138. package/dist/index64.mjs +1 -1
  139. package/dist/index65.mjs +1 -1
  140. package/dist/index66.mjs +1 -1
  141. package/dist/index67.mjs +1 -1
  142. package/dist/index68.mjs +23 -4
  143. package/dist/index69.mjs +149 -19
  144. package/dist/index7.mjs +1 -1
  145. package/dist/index70.mjs +2 -24
  146. package/dist/index71.mjs +19 -149
  147. package/dist/index72.mjs +75 -2
  148. package/dist/index73.mjs +14 -74
  149. package/dist/index74.mjs +62 -14
  150. package/dist/index75.mjs +4 -62
  151. package/dist/index76.mjs +2 -34
  152. package/dist/index77.mjs +5 -42
  153. package/dist/index78.mjs +1129 -230
  154. package/dist/index79.mjs +19 -5
  155. package/dist/index80.mjs +48 -127
  156. package/dist/index81.mjs +32 -67
  157. package/dist/index82.mjs +2 -87
  158. package/dist/index83.mjs +229 -23
  159. package/dist/index84.mjs +5 -8
  160. package/dist/index85.mjs +125 -66
  161. package/dist/index86.mjs +67 -3
  162. package/dist/index87.mjs +87 -2
  163. package/dist/index88.mjs +24 -78
  164. package/dist/index89.mjs +7 -52
  165. package/dist/index90.mjs +74 -5
  166. package/dist/index91.mjs +3 -4
  167. package/dist/index92.mjs +2 -179
  168. package/dist/index93.mjs +79 -49
  169. package/dist/index94.mjs +53 -68
  170. package/dist/index95.mjs +6 -2
  171. package/dist/index96.mjs +4 -5
  172. package/dist/index97.mjs +168 -1123
  173. package/dist/index98.mjs +53 -20
  174. package/dist/index99.mjs +69 -55
  175. package/dist/lib/utils.d.ts +5 -0
  176. package/dist/lib/utils.d.ts.map +1 -1
  177. package/dist/providers/MetaPixelProvider.d.ts +2 -1
  178. package/dist/providers/MetaPixelProvider.d.ts.map +1 -1
  179. package/package.json +2 -2
  180. package/src/contexts/CartContext.tsx +50 -22
  181. package/src/lib/utils.ts +11 -0
  182. package/src/providers/MetaPixelProvider.tsx +16 -3
package/dist/index98.mjs CHANGED
@@ -1,23 +1,56 @@
1
1
  'use client';
2
- import { __exports as e } from "./index138.mjs";
3
- import "./index96.mjs";
4
- import u from "react";
5
- import { __exports as n } from "./index101.mjs";
6
- var o;
7
- function d() {
8
- return o ? e : (o = 1, function(t) {
9
- Object.defineProperty(t, "__esModule", {
10
- value: !0
11
- }), Object.defineProperty(t, "RouterContext", {
12
- enumerable: !0,
13
- get: function() {
14
- return r;
15
- }
16
- });
17
- const r = (/* @__PURE__ */ n._(u)).default.createContext(null);
18
- process.env.NODE_ENV !== "production" && (r.displayName = "RouterContext");
19
- }(e), e);
20
- }
2
+ import s from "./index83.mjs";
3
+ import m from "./index152.mjs";
4
+ import u from "./index153.mjs";
5
+ import { getFetch as b } from "./index154.mjs";
6
+ import d from "./index94.mjs";
7
+ const p = {
8
+ http: m,
9
+ xhr: u,
10
+ fetch: {
11
+ get: b
12
+ }
13
+ };
14
+ s.forEach(p, (e, o) => {
15
+ if (e) {
16
+ try {
17
+ Object.defineProperty(e, "name", { value: o });
18
+ } catch {
19
+ }
20
+ Object.defineProperty(e, "adapterName", { value: o });
21
+ }
22
+ });
23
+ const f = (e) => `- ${e}`, g = (e) => s.isFunction(e) || e === null || e === !1, y = {
24
+ getAdapter: (e, o) => {
25
+ e = s.isArray(e) ? e : [e];
26
+ const { length: a } = e;
27
+ let i, t;
28
+ const c = {};
29
+ for (let r = 0; r < a; r++) {
30
+ i = e[r];
31
+ let n;
32
+ if (t = i, !g(i) && (t = p[(n = String(i)).toLowerCase()], t === void 0))
33
+ throw new d(`Unknown adapter '${n}'`);
34
+ if (t && (s.isFunction(t) || (t = t.get(o))))
35
+ break;
36
+ c[n || "#" + r] = t;
37
+ }
38
+ if (!t) {
39
+ const r = Object.entries(c).map(
40
+ ([l, h]) => `adapter ${l} ` + (h === !1 ? "is not supported by the environment" : "is not available in the build")
41
+ );
42
+ let n = a ? r.length > 1 ? `since :
43
+ ` + r.map(f).join(`
44
+ `) : " " + f(r[0]) : "as no adapter specified";
45
+ throw new d(
46
+ "There is no suitable adapter to dispatch the request " + n,
47
+ "ERR_NOT_SUPPORT"
48
+ );
49
+ }
50
+ return t;
51
+ },
52
+ adapters: p
53
+ };
21
54
  export {
22
- d as __require
55
+ y as default
23
56
  };
package/dist/index99.mjs CHANGED
@@ -1,58 +1,72 @@
1
1
  'use client';
2
- import { __exports as o } from "./index139.mjs";
3
- import { __require as p } from "./index140.mjs";
4
- var u;
5
- function m() {
6
- return u ? o : (u = 1, function(i) {
7
- Object.defineProperty(i, "__esModule", {
8
- value: !0
9
- });
10
- function f(e, r) {
11
- for (var t in r) Object.defineProperty(e, t, {
12
- enumerable: !0,
13
- get: r[t]
14
- });
15
- }
16
- f(i, {
17
- /**
18
- * Checks whether the given value is a NextError.
19
- * This can be used to print a more detailed error message with properties like `code` & `digest`.
20
- */
21
- default: function() {
22
- return s;
23
- },
24
- getProperError: function() {
25
- return a;
26
- }
27
- });
28
- const c = p();
29
- function s(e) {
30
- return typeof e == "object" && e !== null && "name" in e && "message" in e;
31
- }
32
- function d(e) {
33
- const r = /* @__PURE__ */ new WeakSet();
34
- return JSON.stringify(e, (t, n) => {
35
- if (typeof n == "object" && n !== null) {
36
- if (r.has(n))
37
- return "[Circular]";
38
- r.add(n);
39
- }
40
- return n;
41
- });
42
- }
43
- function a(e) {
44
- if (s(e))
45
- return e;
46
- if (process.env.NODE_ENV === "development") {
47
- if (typeof e > "u")
48
- return new Error("An undefined error was thrown, see here for more info: https://nextjs.org/docs/messages/threw-undefined");
49
- if (e === null)
50
- return new Error("A null error was thrown, see here for more info: https://nextjs.org/docs/messages/threw-undefined");
51
- }
52
- return new Error((0, c.isPlainObject)(e) ? d(e) : e + "");
53
- }
54
- }(o), o);
55
- }
2
+ const e = {
3
+ Continue: 100,
4
+ SwitchingProtocols: 101,
5
+ Processing: 102,
6
+ EarlyHints: 103,
7
+ Ok: 200,
8
+ Created: 201,
9
+ Accepted: 202,
10
+ NonAuthoritativeInformation: 203,
11
+ NoContent: 204,
12
+ ResetContent: 205,
13
+ PartialContent: 206,
14
+ MultiStatus: 207,
15
+ AlreadyReported: 208,
16
+ ImUsed: 226,
17
+ MultipleChoices: 300,
18
+ MovedPermanently: 301,
19
+ Found: 302,
20
+ SeeOther: 303,
21
+ NotModified: 304,
22
+ UseProxy: 305,
23
+ Unused: 306,
24
+ TemporaryRedirect: 307,
25
+ PermanentRedirect: 308,
26
+ BadRequest: 400,
27
+ Unauthorized: 401,
28
+ PaymentRequired: 402,
29
+ Forbidden: 403,
30
+ NotFound: 404,
31
+ MethodNotAllowed: 405,
32
+ NotAcceptable: 406,
33
+ ProxyAuthenticationRequired: 407,
34
+ RequestTimeout: 408,
35
+ Conflict: 409,
36
+ Gone: 410,
37
+ LengthRequired: 411,
38
+ PreconditionFailed: 412,
39
+ PayloadTooLarge: 413,
40
+ UriTooLong: 414,
41
+ UnsupportedMediaType: 415,
42
+ RangeNotSatisfiable: 416,
43
+ ExpectationFailed: 417,
44
+ ImATeapot: 418,
45
+ MisdirectedRequest: 421,
46
+ UnprocessableEntity: 422,
47
+ Locked: 423,
48
+ FailedDependency: 424,
49
+ TooEarly: 425,
50
+ UpgradeRequired: 426,
51
+ PreconditionRequired: 428,
52
+ TooManyRequests: 429,
53
+ RequestHeaderFieldsTooLarge: 431,
54
+ UnavailableForLegalReasons: 451,
55
+ InternalServerError: 500,
56
+ NotImplemented: 501,
57
+ BadGateway: 502,
58
+ ServiceUnavailable: 503,
59
+ GatewayTimeout: 504,
60
+ HttpVersionNotSupported: 505,
61
+ VariantAlsoNegotiates: 506,
62
+ InsufficientStorage: 507,
63
+ LoopDetected: 508,
64
+ NotExtended: 510,
65
+ NetworkAuthenticationRequired: 511
66
+ };
67
+ Object.entries(e).forEach(([t, o]) => {
68
+ e[o] = t;
69
+ });
56
70
  export {
57
- m as __require
71
+ e as default
58
72
  };
@@ -20,4 +20,9 @@ export declare function getTikTokCookies(): {
20
20
  ttp: string | undefined;
21
21
  ttclid: string | undefined;
22
22
  };
23
+ /**
24
+ * Generate a unique event ID for deduplication
25
+ * Matches the format used by the backend: {type}_{id}_{suffix}
26
+ */
27
+ export declare function generateClientEventId(type: 'cart' | 'order', id: string, suffix?: string): string;
23
28
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAQ,MAAM,MAAM,CAAA;AAG5C,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UA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E,MAAM,GAAG,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAK1F;AACD;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,GAAG,OAAO,EACtB,EAAE,EAAE,MAAM,EACV,MAAM,CAAC,EAAE,MAAM,GACd,MAAM,CAER"}
@@ -37,9 +37,10 @@ interface MetaPixelContextValue {
37
37
  * Track begin checkout event
38
38
  * @param cartTotal - Total cart value
39
39
  * @param itemCount - Number of items
40
+ * @param contents - Array of items in cart
40
41
  * @param eventID - Optional event ID for deduplication with CAPI
41
42
  */
42
- trackInitiateCheckout: (cartTotal: number, itemCount: number, eventID?: string) => void;
43
+ trackInitiateCheckout: (cartTotal: number, itemCount: number, contents?: PurchaseItem[], eventID?: string) => void;
43
44
  /**
44
45
  * Track purchase event
45
46
  * @param orderTotal - Total order value
@@ -1 +1 @@
1
- {"version":3,"file":"MetaPixelProvider.d.ts","sourceRoot":"","sources":["../../src/providers/MetaPixelProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAkD,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvF,UAAU,YAAY;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,qBAAqB;IAC7B;;OAEG;IACH,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAEjF;;OAEG;IACH,aAAa,EAAE,MAAM,IAAI,CAAC;IAE1B;;OAEG;IACH,gBAAgB,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;I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EAAE,sBAAsB,2CA8IrF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,0BAQ3B;AAED,YAAY,EAAE,YAAY,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instockng/storefront-ui",
3
- "version": "1.0.70",
3
+ "version": "1.0.71",
4
4
  "description": "Pre-built UI components for OMS e-commerce sites",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -45,7 +45,7 @@
45
45
  "author": "Ola Wale",
46
46
  "license": "MIT",
47
47
  "dependencies": {
48
- "@instockng/api-client": "^1.0.25",
48
+ "@instockng/api-client": "^1.0.27",
49
49
  "class-variance-authority": "^0.7.1",
50
50
  "clsx": "^2.1.0",
51
51
  "react-facebook-pixel": "^1.0.4",
@@ -19,6 +19,7 @@ import {
19
19
  useApplyDiscount,
20
20
  useRemoveDiscount,
21
21
  useCheckoutCart,
22
+ useInitiateCheckout,
22
23
  queryKeys,
23
24
  type Cart,
24
25
  } from '@instockng/api-client';
@@ -26,7 +27,7 @@ import { useQueryClient } from '@tanstack/react-query';
26
27
  import { ShoppingCart } from '../components/ShoppingCart';
27
28
  import { useMetaPixel } from '../providers/MetaPixelProvider';
28
29
  import { useTikTokPixel } from '../providers/TikTokPixelProvider';
29
- import { getFbCookies, getTikTokCookies } from '../lib/utils';
30
+ import { getFbCookies, getTikTokCookies, generateClientEventId } from '../lib/utils';
30
31
 
31
32
  const CART_ID_KEY = 'oms_cart_id';
32
33
 
@@ -242,6 +243,8 @@ export function CartProvider({ children, brandSlug, initialCartId, shoppingCartP
242
243
  },
243
244
  });
244
245
 
246
+ const initiateCheckoutMutation = useInitiateCheckout(cartId || '');
247
+
245
248
  // Store cartId in localStorage when it changes
246
249
  useEffect(() => {
247
250
  if (cartId && typeof window !== 'undefined') {
@@ -285,13 +288,13 @@ export function CartProvider({ children, brandSlug, initialCartId, shoppingCartP
285
288
  const eventID = `cart_${cartId}_item_${addedItem.id}`;
286
289
 
287
290
  // Track AddToCart event with Meta Pixel and matching event ID
288
- trackMetaAddToCart(productSlug, productName, price, quantity, eventID);
291
+ trackMetaAddToCart(sku, productName, price, quantity, eventID);
289
292
 
290
293
  // Track AddToCart event with TikTok Pixel and matching event ID
291
294
  trackTikTokAddToCart(productSlug, productName, price, quantity, eventID);
292
295
  } else {
293
296
  // Fallback without event ID if item not found
294
- trackMetaAddToCart(productSlug, productName, price, quantity);
297
+ trackMetaAddToCart(sku, productName, price, quantity);
295
298
  trackTikTokAddToCart(productSlug, productName, price, quantity);
296
299
  }
297
300
  },
@@ -355,31 +358,56 @@ export function CartProvider({ children, brandSlug, initialCartId, shoppingCartP
355
358
  setIsOpen(false);
356
359
  }, []);
357
360
 
358
- const trackCheckoutInitiated = useCallback(() => {
359
- if (!cart || !cartId) return;
361
+ const trackCheckoutInitiated = useCallback(async () => {
362
+ if (!cart || !cart.pricing) return;
360
363
 
361
- // Get cart total from pricing
362
- const cartTotal = Number(cart.pricing?.total || 0);
364
+ try {
365
+ const eventID = generateClientEventId('cart', cart.id, 'checkout');
366
+ const cartTotal = cart.pricing.total;
367
+ const itemCount = cart.items.reduce((sum, item) => sum + item.quantity, 0);
363
368
 
364
- // Calculate item count
365
- const itemCount = cart.items?.reduce((sum, item) => sum + item.quantity, 0) || 0;
369
+ // Prepare rich data for Pixel and CAPI
370
+ const contents = cart.items.map(item => ({
371
+ id: item.variant.sku,
372
+ quantity: item.quantity,
373
+ item_price: Number(item.variant.price),
374
+ }));
366
375
 
367
- // Generate event ID matching backend format: cart_{cartId}_checkout
368
- const eventID = `cart_${cartId}_checkout`;
376
+ // 1. Track Client-Side Pixel with Rich Data
377
+ if (trackMetaInitiateCheckout) {
378
+ trackMetaInitiateCheckout(cartTotal, itemCount, contents, eventID);
379
+ }
369
380
 
370
- // Prepare contents array for TikTok Pixel
371
- const contents = cart.items?.map((item) => ({
372
- content_id: item.variant.sku,
373
- quantity: item.quantity,
374
- price: Number(item.variant.price),
375
- })) || [];
381
+ // 2. Trigger Server-Side CAPI via API Client hook
382
+ // We fire and forget this request to not block the UI
383
+ if (cart.brand.metaPixelId || cart.brand.tiktokPixelId) {
384
+ // Get attribution cookies
385
+ const { fbc, fbp } = getFbCookies();
386
+ const { ttp, ttclid } = getTikTokCookies();
387
+
388
+ initiateCheckoutMutation.mutate({
389
+ email: cart.customerEmail,
390
+ phone: cart.customerPhone,
391
+ fbc,
392
+ fbp,
393
+ ttp,
394
+ ttclid,
395
+ });
396
+ }
376
397
 
377
- // Track InitiateCheckout event with Meta Pixel
378
- trackMetaInitiateCheckout(cartTotal, itemCount, eventID);
398
+ // Track TikTok Event
399
+ if (trackTikTokInitiateCheckout) {
400
+ trackTikTokInitiateCheckout(cartTotal, itemCount, eventID, contents.map(c => ({
401
+ content_id: c.id,
402
+ quantity: c.quantity,
403
+ price: c.item_price
404
+ })));
405
+ }
379
406
 
380
- // Track InitiateCheckout event with TikTok Pixel
381
- trackTikTokInitiateCheckout(cartTotal, itemCount, eventID, contents);
382
- }, [cart, cartId, trackMetaInitiateCheckout, trackTikTokInitiateCheckout]);
407
+ } catch (error) {
408
+ console.error('Error tracking initiate checkout:', error);
409
+ }
410
+ }, [cart, trackMetaInitiateCheckout, trackTikTokInitiateCheckout, initiateCheckoutMutation]);
383
411
 
384
412
  const value: CartContextValue = {
385
413
  cart: cart || null,
package/src/lib/utils.ts CHANGED
@@ -87,3 +87,14 @@ export function getTikTokCookies(): { ttp: string | undefined; ttclid: string |
87
87
  ttclid: getUrlParam('ttclid'),
88
88
  };
89
89
  }
90
+ /**
91
+ * Generate a unique event ID for deduplication
92
+ * Matches the format used by the backend: {type}_{id}_{suffix}
93
+ */
94
+ export function generateClientEventId(
95
+ type: 'cart' | 'order',
96
+ id: string,
97
+ suffix?: string
98
+ ): string {
99
+ return suffix ? `${type}_${id}_${suffix}` : `${type}_${id}`;
100
+ }
@@ -44,9 +44,10 @@ interface MetaPixelContextValue {
44
44
  * Track begin checkout event
45
45
  * @param cartTotal - Total cart value
46
46
  * @param itemCount - Number of items
47
+ * @param contents - Array of items in cart
47
48
  * @param eventID - Optional event ID for deduplication with CAPI
48
49
  */
49
- trackInitiateCheckout: (cartTotal: number, itemCount: number, eventID?: string) => void;
50
+ trackInitiateCheckout: (cartTotal: number, itemCount: number, contents?: PurchaseItem[], eventID?: string) => void;
50
51
 
51
52
  /**
52
53
  * Track purchase event
@@ -179,17 +180,29 @@ export function MetaPixelProvider({ children, pixelId, debug }: MetaPixelProvide
179
180
  content_ids: [productId],
180
181
  content_name: productName,
181
182
  content_type: 'product',
182
- value: price,
183
+ value: price * quantity,
183
184
  currency: 'NGN',
184
185
  num_items: quantity,
186
+ contents: [{
187
+ id: productId,
188
+ quantity: quantity,
189
+ item_price: price,
190
+ }],
185
191
  }, eventID);
186
192
  };
187
193
 
188
- const trackInitiateCheckout = (cartTotal: number, itemCount: number, eventID?: string) => {
194
+ const trackInitiateCheckout = (cartTotal: number, itemCount: number, contents: PurchaseItem[] = [], eventID?: string) => {
189
195
  track('InitiateCheckout', {
190
196
  value: cartTotal,
191
197
  currency: 'NGN',
192
198
  num_items: itemCount,
199
+ contents: contents.map((item) => ({
200
+ id: item.id,
201
+ quantity: item.quantity,
202
+ item_price: item.item_price,
203
+ })),
204
+ content_ids: contents.map((item) => item.id),
205
+ content_type: 'product',
193
206
  }, eventID);
194
207
  };
195
208