@reactionary/unomi 0.12.2 → 0.12.4

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.
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  AnalyticsProvider,
3
3
  productKey,
4
+ summarizePlacedOrder,
4
5
  searchOriginOf
5
6
  } from "@reactionary/core";
6
7
  import { hash } from "node:crypto";
@@ -88,18 +89,21 @@ class UnomiAnalyticsCapability extends AnalyticsProvider {
88
89
  ];
89
90
  }
90
91
  case "order-placed": {
91
- const order = event.payload.order;
92
+ const placed = summarizePlacedOrder(event.payload);
93
+ if (!placed) {
94
+ return [];
95
+ }
92
96
  return [
93
97
  {
94
98
  eventType: "purchaseComplete",
95
99
  scope,
96
- target: { itemId: order.identifier.key, itemType: "order" },
100
+ target: { itemId: placed.transactionId, itemType: "order" },
97
101
  properties: {
98
- orderId: order.identifier.key,
99
- totalAmount: order.price.grandTotal.value,
100
- currency: order.price.grandTotal.currency,
101
- itemCount: order.items.length,
102
- items: order.items.map((item) => ({
102
+ orderId: placed.transactionId,
103
+ totalAmount: placed.price.grandTotal.value,
104
+ currency: placed.price.grandTotal.currency,
105
+ itemCount: placed.items.length,
106
+ items: placed.items.map((item) => ({
103
107
  sku: item.variant.sku,
104
108
  quantity: item.quantity,
105
109
  price: item.price.unitPrice.value
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactionary/unomi",
3
- "version": "0.12.2",
3
+ "version": "0.12.4",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "types": "./src/index.d.ts",
@@ -9,7 +9,7 @@
9
9
  "url": "git+https://github.com/Solteq/reactionary.git"
10
10
  },
11
11
  "dependencies": {
12
- "@reactionary/core": "0.12.2",
12
+ "@reactionary/core": "0.12.4",
13
13
  "zod": "4.1.9"
14
14
  },
15
15
  "devDependencies": {