@od-oneapp/analytics 2026.1.1301
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/README.md +509 -0
- package/dist/ai-YMnynb-t.mjs +3347 -0
- package/dist/ai-YMnynb-t.mjs.map +1 -0
- package/dist/chunk-DQk6qfdC.mjs +18 -0
- package/dist/client-CTzJVFU5.mjs +9 -0
- package/dist/client-CTzJVFU5.mjs.map +1 -0
- package/dist/client-CcFTauAh.mjs +54 -0
- package/dist/client-CcFTauAh.mjs.map +1 -0
- package/dist/client-CeOLjbac.mjs +281 -0
- package/dist/client-CeOLjbac.mjs.map +1 -0
- package/dist/client-D339NFJS.mjs +267 -0
- package/dist/client-D339NFJS.mjs.map +1 -0
- package/dist/client-next.d.mts +62 -0
- package/dist/client-next.d.mts.map +1 -0
- package/dist/client-next.mjs +525 -0
- package/dist/client-next.mjs.map +1 -0
- package/dist/client.d.mts +30 -0
- package/dist/client.d.mts.map +1 -0
- package/dist/client.mjs +186 -0
- package/dist/client.mjs.map +1 -0
- package/dist/config-DPS6bSYo.d.mts +34 -0
- package/dist/config-DPS6bSYo.d.mts.map +1 -0
- package/dist/config-P6P5adJg.mjs +287 -0
- package/dist/config-P6P5adJg.mjs.map +1 -0
- package/dist/console-8bND3mMU.mjs +128 -0
- package/dist/console-8bND3mMU.mjs.map +1 -0
- package/dist/ecommerce-Cgu4wlux.mjs +993 -0
- package/dist/ecommerce-Cgu4wlux.mjs.map +1 -0
- package/dist/emitters-6-nKo8i-.mjs +208 -0
- package/dist/emitters-6-nKo8i-.mjs.map +1 -0
- package/dist/emitters-DldkVSPp.d.mts +12 -0
- package/dist/emitters-DldkVSPp.d.mts.map +1 -0
- package/dist/index-BfNWgfa5.d.mts +1494 -0
- package/dist/index-BfNWgfa5.d.mts.map +1 -0
- package/dist/index-BkIWe--N.d.mts +953 -0
- package/dist/index-BkIWe--N.d.mts.map +1 -0
- package/dist/index-jPzXRn52.d.mts +184 -0
- package/dist/index-jPzXRn52.d.mts.map +1 -0
- package/dist/manager-DvRRjza6.d.mts +76 -0
- package/dist/manager-DvRRjza6.d.mts.map +1 -0
- package/dist/posthog-bootstrap-CYfIy_WS.mjs +1769 -0
- package/dist/posthog-bootstrap-CYfIy_WS.mjs.map +1 -0
- package/dist/posthog-bootstrap-DWxFrxlt.d.mts +81 -0
- package/dist/posthog-bootstrap-DWxFrxlt.d.mts.map +1 -0
- package/dist/providers-http-client.d.mts +37 -0
- package/dist/providers-http-client.d.mts.map +1 -0
- package/dist/providers-http-client.mjs +320 -0
- package/dist/providers-http-client.mjs.map +1 -0
- package/dist/providers-http-server.d.mts +31 -0
- package/dist/providers-http-server.d.mts.map +1 -0
- package/dist/providers-http-server.mjs +297 -0
- package/dist/providers-http-server.mjs.map +1 -0
- package/dist/providers-http.d.mts +46 -0
- package/dist/providers-http.d.mts.map +1 -0
- package/dist/providers-http.mjs +4 -0
- package/dist/server-edge.d.mts +9 -0
- package/dist/server-edge.d.mts.map +1 -0
- package/dist/server-edge.mjs +373 -0
- package/dist/server-edge.mjs.map +1 -0
- package/dist/server-next.d.mts +67 -0
- package/dist/server-next.d.mts.map +1 -0
- package/dist/server-next.mjs +193 -0
- package/dist/server-next.mjs.map +1 -0
- package/dist/server.d.mts +10 -0
- package/dist/server.mjs +7 -0
- package/dist/service-cYtBBL8x.mjs +945 -0
- package/dist/service-cYtBBL8x.mjs.map +1 -0
- package/dist/shared.d.mts +16 -0
- package/dist/shared.d.mts.map +1 -0
- package/dist/shared.mjs +93 -0
- package/dist/shared.mjs.map +1 -0
- package/dist/types-BxBnNQ0V.d.mts +354 -0
- package/dist/types-BxBnNQ0V.d.mts.map +1 -0
- package/dist/types-CBvxUEaF.d.mts +216 -0
- package/dist/types-CBvxUEaF.d.mts.map +1 -0
- package/dist/types.d.mts +4 -0
- package/dist/types.mjs +0 -0
- package/dist/vercel-types-lwakUfoI.d.mts +102 -0
- package/dist/vercel-types-lwakUfoI.d.mts.map +1 -0
- package/package.json +129 -0
- package/src/client/index.ts +164 -0
- package/src/client/manager.ts +71 -0
- package/src/client/next/components.tsx +270 -0
- package/src/client/next/hooks.ts +217 -0
- package/src/client/next/manager.ts +141 -0
- package/src/client/next.ts +144 -0
- package/src/client-next.ts +101 -0
- package/src/client.ts +89 -0
- package/src/examples/ai-sdk-patterns.ts +583 -0
- package/src/examples/emitter-patterns.ts +476 -0
- package/src/examples/nextjs-emitter-patterns.tsx +403 -0
- package/src/next/app-router.tsx +564 -0
- package/src/next/client.ts +419 -0
- package/src/next/index.ts +84 -0
- package/src/next/middleware.ts +429 -0
- package/src/next/rsc.tsx +300 -0
- package/src/next/server.ts +253 -0
- package/src/next/types.d.ts +220 -0
- package/src/providers/base-provider.ts +419 -0
- package/src/providers/console/client.ts +10 -0
- package/src/providers/console/index.ts +152 -0
- package/src/providers/console/server.ts +6 -0
- package/src/providers/console/types.ts +15 -0
- package/src/providers/http/client.ts +464 -0
- package/src/providers/http/index.ts +30 -0
- package/src/providers/http/server.ts +396 -0
- package/src/providers/http/types.ts +135 -0
- package/src/providers/posthog/client.ts +518 -0
- package/src/providers/posthog/index.ts +11 -0
- package/src/providers/posthog/server.ts +329 -0
- package/src/providers/posthog/types.ts +104 -0
- package/src/providers/segment/client.ts +113 -0
- package/src/providers/segment/index.ts +11 -0
- package/src/providers/segment/server.ts +115 -0
- package/src/providers/segment/types.ts +51 -0
- package/src/providers/vercel/client.ts +102 -0
- package/src/providers/vercel/index.ts +11 -0
- package/src/providers/vercel/server.ts +89 -0
- package/src/providers/vercel/types.ts +27 -0
- package/src/server/index.ts +103 -0
- package/src/server/manager.ts +62 -0
- package/src/server/next.ts +210 -0
- package/src/server-edge.ts +442 -0
- package/src/server-next.ts +39 -0
- package/src/server.ts +106 -0
- package/src/shared/emitters/ai/README.md +981 -0
- package/src/shared/emitters/ai/events/agent.ts +130 -0
- package/src/shared/emitters/ai/events/artifacts.ts +167 -0
- package/src/shared/emitters/ai/events/chat.ts +126 -0
- package/src/shared/emitters/ai/events/chatbot-ecommerce.ts +133 -0
- package/src/shared/emitters/ai/events/completion.ts +103 -0
- package/src/shared/emitters/ai/events/content-generation.ts +347 -0
- package/src/shared/emitters/ai/events/conversation.ts +332 -0
- package/src/shared/emitters/ai/events/product-features.ts +1402 -0
- package/src/shared/emitters/ai/events/streaming.ts +114 -0
- package/src/shared/emitters/ai/events/tool.ts +93 -0
- package/src/shared/emitters/ai/index.ts +69 -0
- package/src/shared/emitters/ai/track-ai-sdk.ts +74 -0
- package/src/shared/emitters/ai/track-ai.ts +50 -0
- package/src/shared/emitters/ai/types.ts +1041 -0
- package/src/shared/emitters/ai/utils.ts +468 -0
- package/src/shared/emitters/ecommerce/events/cart-checkout.ts +106 -0
- package/src/shared/emitters/ecommerce/events/coupon.ts +49 -0
- package/src/shared/emitters/ecommerce/events/engagement.ts +61 -0
- package/src/shared/emitters/ecommerce/events/marketplace.ts +119 -0
- package/src/shared/emitters/ecommerce/events/order.ts +199 -0
- package/src/shared/emitters/ecommerce/events/product.ts +205 -0
- package/src/shared/emitters/ecommerce/events/registry.ts +123 -0
- package/src/shared/emitters/ecommerce/events/wishlist-sharing.ts +140 -0
- package/src/shared/emitters/ecommerce/index.ts +46 -0
- package/src/shared/emitters/ecommerce/track-ecommerce.ts +53 -0
- package/src/shared/emitters/ecommerce/types.ts +314 -0
- package/src/shared/emitters/ecommerce/utils.ts +216 -0
- package/src/shared/emitters/emitter-types.ts +974 -0
- package/src/shared/emitters/emitters.ts +292 -0
- package/src/shared/emitters/helpers.ts +419 -0
- package/src/shared/emitters/index.ts +66 -0
- package/src/shared/index.ts +142 -0
- package/src/shared/ingestion/index.ts +66 -0
- package/src/shared/ingestion/schemas.ts +386 -0
- package/src/shared/ingestion/service.ts +628 -0
- package/src/shared/node22-features.ts +848 -0
- package/src/shared/providers/console-provider.ts +160 -0
- package/src/shared/types/base-types.ts +54 -0
- package/src/shared/types/console-types.ts +19 -0
- package/src/shared/types/posthog-types.ts +131 -0
- package/src/shared/types/segment-types.ts +15 -0
- package/src/shared/types/types.ts +397 -0
- package/src/shared/types/vercel-types.ts +19 -0
- package/src/shared/utils/config-client.ts +19 -0
- package/src/shared/utils/config.ts +250 -0
- package/src/shared/utils/emitter-adapter.ts +212 -0
- package/src/shared/utils/manager.test.ts +36 -0
- package/src/shared/utils/manager.ts +1322 -0
- package/src/shared/utils/posthog-bootstrap.ts +136 -0
- package/src/shared/utils/posthog-client-utils.ts +48 -0
- package/src/shared/utils/posthog-next-utils.ts +282 -0
- package/src/shared/utils/posthog-server-utils.ts +210 -0
- package/src/shared/utils/rate-limit.ts +289 -0
- package/src/shared/utils/security.ts +545 -0
- package/src/shared/utils/validation-client.ts +161 -0
- package/src/shared/utils/validation.ts +399 -0
- package/src/shared.ts +155 -0
- package/src/types/index.ts +62 -0
|
@@ -0,0 +1,993 @@
|
|
|
1
|
+
import { t as __exportAll } from "./chunk-DQk6qfdC.mjs";
|
|
2
|
+
import { o as track } from "./emitters-6-nKo8i-.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/shared/emitters/ecommerce/types.ts
|
|
5
|
+
const ECOMMERCE_EVENTS = {
|
|
6
|
+
PRODUCT_CLICKED: "Product Clicked",
|
|
7
|
+
PRODUCT_COMPARED: "Product Compared",
|
|
8
|
+
PRODUCT_LIST_FILTERED: "Product List Filtered",
|
|
9
|
+
PRODUCT_LIST_VIEWED: "Product List Viewed",
|
|
10
|
+
PRODUCT_RECOMMENDATION_CLICKED: "Product Recommendation Clicked",
|
|
11
|
+
PRODUCT_RECOMMENDATION_VIEWED: "Product Recommendation Viewed",
|
|
12
|
+
PRODUCT_SEARCHED: "Product Searched",
|
|
13
|
+
PRODUCT_VIEWED: "Product Viewed",
|
|
14
|
+
SEARCH_RESULTS_VIEWED: "Search Results Viewed",
|
|
15
|
+
CART_ABANDONED: "Cart Abandoned",
|
|
16
|
+
CART_UPDATED: "Cart Updated",
|
|
17
|
+
CART_VIEWED: "Cart Viewed",
|
|
18
|
+
CHECKOUT_PROGRESSED: "Checkout Progressed",
|
|
19
|
+
ORDER_CANCELLED: "Order Cancelled",
|
|
20
|
+
ORDER_COMPLETED: "Order Completed",
|
|
21
|
+
ORDER_FAILED: "Order Failed",
|
|
22
|
+
ORDER_REFUNDED: "Order Refunded",
|
|
23
|
+
ORDER_STATUS_UPDATED: "Order Status Updated",
|
|
24
|
+
COUPON_APPLIED: "Coupon Applied",
|
|
25
|
+
COUPON_REMOVED: "Coupon Removed",
|
|
26
|
+
PRODUCT_ADDED_TO_WISHLIST: "Product Added to Wishlist",
|
|
27
|
+
PRODUCT_REMOVED_FROM_WISHLIST: "Product Removed from Wishlist",
|
|
28
|
+
WISHLIST_PRODUCT_ADDED_TO_CART: "Wishlist Product Added to Cart",
|
|
29
|
+
CART_SHARED: "Cart Shared",
|
|
30
|
+
PRODUCT_SHARED: "Product Shared",
|
|
31
|
+
PRODUCT_REVIEWED: "Product Reviewed",
|
|
32
|
+
AFFILIATE_CONVERSION_TRACKED: "Affiliate Conversion Tracked",
|
|
33
|
+
AFFILIATE_LINK_CLICKED: "Affiliate Link Clicked",
|
|
34
|
+
MERCHANT_SELECTED: "Merchant Selected",
|
|
35
|
+
PRICE_COMPARISON_VIEWED: "Price Comparison Viewed",
|
|
36
|
+
REGISTRY_ITEM_MANAGED: "Registry Item Managed",
|
|
37
|
+
REGISTRY_MANAGED: "Registry Managed",
|
|
38
|
+
REGISTRY_SHARED: "Registry Shared",
|
|
39
|
+
REGISTRY_VIEWED: "Registry Viewed",
|
|
40
|
+
RETURN_COMPLETED: "Return Completed",
|
|
41
|
+
RETURN_REQUESTED: "Return Requested",
|
|
42
|
+
BACK_IN_STOCK_REQUESTED: "Back In Stock Requested",
|
|
43
|
+
PRICE_ALERT_SET: "Price Alert Set"
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/shared/emitters/ecommerce/utils.ts
|
|
48
|
+
/**
|
|
49
|
+
* Normalizes product properties to ensure consistent naming
|
|
50
|
+
* Handles common variations like productId vs product_id
|
|
51
|
+
*/
|
|
52
|
+
function normalizeProductProperties(product) {
|
|
53
|
+
if (!product || typeof product !== "object") throw new Error("Product properties are required");
|
|
54
|
+
const p = product;
|
|
55
|
+
const product_id = p.product_id ?? p.productId ?? p.id;
|
|
56
|
+
if (!product_id) throw new Error("Product must have an id (product_id, productId, or id)");
|
|
57
|
+
const normalized = {
|
|
58
|
+
product_id,
|
|
59
|
+
name: p.name ?? p.title ?? p.productName,
|
|
60
|
+
image_url: p.image_url ?? p.imageUrl ?? p.image,
|
|
61
|
+
url: p.url ?? p.link ?? p.product_url,
|
|
62
|
+
brand: p.brand ?? p.manufacturer,
|
|
63
|
+
category: p.category,
|
|
64
|
+
coupon: p.coupon ?? p.couponCode ?? p.coupon_code,
|
|
65
|
+
position: normalizePosition(p.position),
|
|
66
|
+
price: normalizePrice(p.price),
|
|
67
|
+
quantity: normalizeQuantity(p.quantity),
|
|
68
|
+
variant: p.variant ?? p.variation
|
|
69
|
+
};
|
|
70
|
+
const result = { product_id };
|
|
71
|
+
Object.entries(normalized).forEach(([key, value]) => {
|
|
72
|
+
if (value !== void 0 && value !== null && Object.hasOwn(normalized, key) && key !== "product_id") result[key] = value;
|
|
73
|
+
});
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Normalizes an array of products
|
|
78
|
+
*/
|
|
79
|
+
function normalizeProducts(products) {
|
|
80
|
+
if (!Array.isArray(products)) return [];
|
|
81
|
+
return products.map((product) => normalizeProductProperties(product));
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* ES2022 enhanced product validation with Error.cause
|
|
85
|
+
*/
|
|
86
|
+
function validateProductWithContext(product, context) {
|
|
87
|
+
try {
|
|
88
|
+
normalizeProductProperties(product);
|
|
89
|
+
} catch (error) {
|
|
90
|
+
throw new Error(`Product validation failed${context ? ` in ${context}` : ""}`, { cause: error });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Normalizes price to a number
|
|
95
|
+
*/
|
|
96
|
+
function normalizePrice(price) {
|
|
97
|
+
if (price === void 0 || price === null) return;
|
|
98
|
+
const normalized = typeof price === "string" ? Number.parseFloat(price) : Number(price);
|
|
99
|
+
return Number.isNaN(normalized) ? void 0 : normalized;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Normalizes quantity to a positive integer
|
|
103
|
+
*/
|
|
104
|
+
function normalizeQuantity(quantity) {
|
|
105
|
+
if (quantity === void 0 || quantity === null) return;
|
|
106
|
+
const normalized = Number.parseInt(String(quantity), 10);
|
|
107
|
+
return Number.isNaN(normalized) || normalized < 0 ? void 0 : normalized;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Normalizes position to a positive integer
|
|
111
|
+
*/
|
|
112
|
+
function normalizePosition(position) {
|
|
113
|
+
if (position === void 0 || position === null) return;
|
|
114
|
+
const normalized = Number.parseInt(String(position), 10);
|
|
115
|
+
return Number.isNaN(normalized) || normalized < 0 ? void 0 : normalized;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Validates required properties for an event
|
|
119
|
+
*/
|
|
120
|
+
function validateRequiredProperties(properties, required) {
|
|
121
|
+
const missing = required.filter((prop) => {
|
|
122
|
+
const value = properties[prop];
|
|
123
|
+
return value === void 0 || value === null || value === "";
|
|
124
|
+
});
|
|
125
|
+
if (missing.length > 0) throw new Error(`Missing required properties: ${missing.join(", ")}`);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Removes undefined values from an object
|
|
129
|
+
*/
|
|
130
|
+
function cleanProperties(obj) {
|
|
131
|
+
const cleaned = {};
|
|
132
|
+
for (const [key, value] of Object.entries(obj)) if (value !== void 0) cleaned[key] = value;
|
|
133
|
+
return cleaned;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Merges common fields with event-specific properties
|
|
137
|
+
*/
|
|
138
|
+
function mergeEventProperties(specific, common) {
|
|
139
|
+
return {
|
|
140
|
+
...common,
|
|
141
|
+
...specific
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Validates currency code (ISO 4217)
|
|
146
|
+
*/
|
|
147
|
+
function validateCurrency(currency) {
|
|
148
|
+
if (!currency || typeof currency !== "string") return void 0;
|
|
149
|
+
const normalized = currency.toUpperCase();
|
|
150
|
+
if (!/^[A-Z]{3}$/.test(normalized)) return;
|
|
151
|
+
return normalized;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Creates a consistent context object for ecommerce events
|
|
155
|
+
*/
|
|
156
|
+
function createEcommerceContext(additionalContext) {
|
|
157
|
+
return {
|
|
158
|
+
...additionalContext,
|
|
159
|
+
category: "ecommerce"
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region src/shared/emitters/ecommerce/track-ecommerce.ts
|
|
165
|
+
/**
|
|
166
|
+
* @fileoverview Ecommerce tracking wrapper that integrates with the core emitter system
|
|
167
|
+
* Ecommerce tracking wrapper that integrates with the core emitter system
|
|
168
|
+
*/
|
|
169
|
+
/**
|
|
170
|
+
* Convert an ecommerce event specification to a track payload
|
|
171
|
+
*
|
|
172
|
+
* @param eventSpec - The ecommerce event specification
|
|
173
|
+
* @param options - Optional emitter options
|
|
174
|
+
* @returns Track payload ready to be sent to analytics providers
|
|
175
|
+
*/
|
|
176
|
+
function trackEcommerce(eventSpec, options) {
|
|
177
|
+
const enrichedOptions = {
|
|
178
|
+
...options,
|
|
179
|
+
context: {
|
|
180
|
+
...options?.context,
|
|
181
|
+
...eventSpec.category && { traits: {
|
|
182
|
+
...options?.context?.traits,
|
|
183
|
+
event_category: eventSpec.category
|
|
184
|
+
} }
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
return track(eventSpec.name, eventSpec.properties, enrichedOptions);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Helper to create a tracking function for a specific ecommerce event
|
|
191
|
+
* This allows for cleaner usage in applications
|
|
192
|
+
*/
|
|
193
|
+
function createEcommerceTracker(eventFactory) {
|
|
194
|
+
return (properties, options) => {
|
|
195
|
+
return trackEcommerce(eventFactory(properties), options);
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
//#endregion
|
|
200
|
+
//#region src/shared/emitters/ecommerce/events/cart-checkout.ts
|
|
201
|
+
/**
|
|
202
|
+
* @fileoverview Cart and checkout-related ecommerce events
|
|
203
|
+
* Cart and checkout-related ecommerce events
|
|
204
|
+
*/
|
|
205
|
+
/**
|
|
206
|
+
* Track cart updates (add, remove, update) with a single event
|
|
207
|
+
*/
|
|
208
|
+
function cartUpdated(properties, options) {
|
|
209
|
+
const { cart_id, action, cart_total, product, quantity_change } = properties;
|
|
210
|
+
const normalizedProduct = normalizeProductProperties(product);
|
|
211
|
+
validateRequiredProperties(properties, ["action"]);
|
|
212
|
+
validateRequiredProperties(normalizedProduct, ["product_id"]);
|
|
213
|
+
return trackEcommerce({
|
|
214
|
+
name: ECOMMERCE_EVENTS.CART_UPDATED,
|
|
215
|
+
category: "ecommerce",
|
|
216
|
+
properties: cleanProperties({
|
|
217
|
+
action,
|
|
218
|
+
...normalizedProduct,
|
|
219
|
+
cart_id,
|
|
220
|
+
cart_total,
|
|
221
|
+
quantity_change
|
|
222
|
+
}),
|
|
223
|
+
requiredProperties: ["action", "product_id"]
|
|
224
|
+
}, options);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Track when a user views their shopping cart
|
|
228
|
+
*/
|
|
229
|
+
function cartViewed(properties) {
|
|
230
|
+
const normalizedProps = {
|
|
231
|
+
cart_id: properties.cart_id,
|
|
232
|
+
products: properties.products ? normalizeProducts(properties.products) : void 0
|
|
233
|
+
};
|
|
234
|
+
return {
|
|
235
|
+
name: ECOMMERCE_EVENTS.CART_VIEWED,
|
|
236
|
+
category: "ecommerce",
|
|
237
|
+
properties: cleanProperties(normalizedProps),
|
|
238
|
+
requiredProperties: []
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Track when a cart is abandoned
|
|
243
|
+
*/
|
|
244
|
+
function cartAbandoned(properties) {
|
|
245
|
+
validateRequiredProperties(properties, ["cart_id", "cart_value"]);
|
|
246
|
+
const normalizedProps = {
|
|
247
|
+
...properties,
|
|
248
|
+
products: normalizeProducts(properties.products)
|
|
249
|
+
};
|
|
250
|
+
return {
|
|
251
|
+
name: ECOMMERCE_EVENTS.CART_ABANDONED,
|
|
252
|
+
category: "ecommerce",
|
|
253
|
+
properties: cleanProperties(normalizedProps),
|
|
254
|
+
requiredProperties: ["cart_id", "cart_value"]
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Track checkout progression with a single event
|
|
259
|
+
*/
|
|
260
|
+
function checkoutProgressed(properties) {
|
|
261
|
+
validateRequiredProperties(properties, [
|
|
262
|
+
"step",
|
|
263
|
+
"step_name",
|
|
264
|
+
"action"
|
|
265
|
+
]);
|
|
266
|
+
const normalizedProps = {
|
|
267
|
+
...properties,
|
|
268
|
+
products: properties.products ? normalizeProducts(properties.products) : void 0
|
|
269
|
+
};
|
|
270
|
+
return {
|
|
271
|
+
name: ECOMMERCE_EVENTS.CHECKOUT_PROGRESSED,
|
|
272
|
+
category: "ecommerce",
|
|
273
|
+
properties: cleanProperties(normalizedProps),
|
|
274
|
+
requiredProperties: [
|
|
275
|
+
"step",
|
|
276
|
+
"step_name",
|
|
277
|
+
"action"
|
|
278
|
+
]
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
//#endregion
|
|
283
|
+
//#region src/shared/emitters/ecommerce/events/coupon.ts
|
|
284
|
+
/**
|
|
285
|
+
* @fileoverview Coupon-related ecommerce events
|
|
286
|
+
* Coupon-related ecommerce events
|
|
287
|
+
*/
|
|
288
|
+
/**
|
|
289
|
+
* Track when a coupon is successfully applied
|
|
290
|
+
*/
|
|
291
|
+
function couponApplied(properties) {
|
|
292
|
+
const normalizedProps = {
|
|
293
|
+
cart_id: properties.cart_id,
|
|
294
|
+
coupon_id: properties.coupon_id,
|
|
295
|
+
order_id: properties.order_id,
|
|
296
|
+
coupon_name: properties.coupon_name,
|
|
297
|
+
discount: properties.discount,
|
|
298
|
+
reason: properties.reason
|
|
299
|
+
};
|
|
300
|
+
return {
|
|
301
|
+
name: ECOMMERCE_EVENTS.COUPON_APPLIED,
|
|
302
|
+
category: "ecommerce",
|
|
303
|
+
properties: cleanProperties(normalizedProps),
|
|
304
|
+
requiredProperties: []
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Track when a coupon is removed
|
|
309
|
+
*/
|
|
310
|
+
function couponRemoved(properties) {
|
|
311
|
+
const normalizedProps = {
|
|
312
|
+
cart_id: properties.cart_id,
|
|
313
|
+
coupon_id: properties.coupon_id,
|
|
314
|
+
order_id: properties.order_id,
|
|
315
|
+
coupon_name: properties.coupon_name,
|
|
316
|
+
discount: properties.discount,
|
|
317
|
+
reason: properties.reason
|
|
318
|
+
};
|
|
319
|
+
return {
|
|
320
|
+
name: ECOMMERCE_EVENTS.COUPON_REMOVED,
|
|
321
|
+
category: "ecommerce",
|
|
322
|
+
properties: cleanProperties(normalizedProps),
|
|
323
|
+
requiredProperties: []
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
//#endregion
|
|
328
|
+
//#region src/shared/emitters/ecommerce/events/engagement.ts
|
|
329
|
+
/**
|
|
330
|
+
* @fileoverview Customer engagement events for ecommerce
|
|
331
|
+
* Customer engagement events for ecommerce
|
|
332
|
+
* Track user interactions that indicate interest but aren't direct purchases
|
|
333
|
+
*/
|
|
334
|
+
/**
|
|
335
|
+
* Track when a user sets a price alert for a product
|
|
336
|
+
*/
|
|
337
|
+
function priceAlertSet(properties) {
|
|
338
|
+
const { currency, notification_method, threshold_price, ...productProps } = properties;
|
|
339
|
+
const normalizedProduct = normalizeProductProperties(productProps);
|
|
340
|
+
validateRequiredProperties(normalizedProduct, ["product_id"]);
|
|
341
|
+
validateRequiredProperties({ threshold_price }, ["threshold_price"]);
|
|
342
|
+
return {
|
|
343
|
+
name: ECOMMERCE_EVENTS.PRICE_ALERT_SET,
|
|
344
|
+
category: "ecommerce",
|
|
345
|
+
properties: cleanProperties({
|
|
346
|
+
...normalizedProduct,
|
|
347
|
+
action_type: "price_alert",
|
|
348
|
+
currency,
|
|
349
|
+
notification_method,
|
|
350
|
+
threshold_price
|
|
351
|
+
}),
|
|
352
|
+
requiredProperties: ["product_id", "threshold_price"]
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Track when a user requests notification for out-of-stock items
|
|
357
|
+
*/
|
|
358
|
+
function backInStockRequested(properties) {
|
|
359
|
+
const { notification_method, ...productProps } = properties;
|
|
360
|
+
const normalizedProduct = normalizeProductProperties(productProps);
|
|
361
|
+
validateRequiredProperties(normalizedProduct, ["product_id"]);
|
|
362
|
+
return {
|
|
363
|
+
name: ECOMMERCE_EVENTS.BACK_IN_STOCK_REQUESTED,
|
|
364
|
+
category: "ecommerce",
|
|
365
|
+
properties: cleanProperties({
|
|
366
|
+
...normalizedProduct,
|
|
367
|
+
action_type: "back_in_stock",
|
|
368
|
+
notification_method
|
|
369
|
+
}),
|
|
370
|
+
requiredProperties: ["product_id"]
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
//#endregion
|
|
375
|
+
//#region src/shared/emitters/ecommerce/events/marketplace.ts
|
|
376
|
+
/**
|
|
377
|
+
* @fileoverview Marketplace and affiliate-specific ecommerce events
|
|
378
|
+
* Marketplace and affiliate-specific ecommerce events
|
|
379
|
+
* These events track user interactions unique to marketplace/affiliate models
|
|
380
|
+
*/
|
|
381
|
+
/**
|
|
382
|
+
* Track when a user views price comparisons across multiple merchants
|
|
383
|
+
*/
|
|
384
|
+
function priceComparisonViewed(properties) {
|
|
385
|
+
validateRequiredProperties(properties, ["product_id", "merchants"]);
|
|
386
|
+
return {
|
|
387
|
+
name: ECOMMERCE_EVENTS.PRICE_COMPARISON_VIEWED,
|
|
388
|
+
category: "ecommerce",
|
|
389
|
+
properties: cleanProperties(properties),
|
|
390
|
+
requiredProperties: ["product_id", "merchants"]
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Track when a user selects a specific merchant from multiple options
|
|
395
|
+
*/
|
|
396
|
+
function merchantSelected(properties) {
|
|
397
|
+
const normalizedProps = normalizeProductProperties(properties);
|
|
398
|
+
validateRequiredProperties(properties, ["product_id", "selected_merchant_id"]);
|
|
399
|
+
return {
|
|
400
|
+
name: ECOMMERCE_EVENTS.MERCHANT_SELECTED,
|
|
401
|
+
category: "ecommerce",
|
|
402
|
+
properties: cleanProperties({
|
|
403
|
+
...normalizedProps,
|
|
404
|
+
selected_merchant_id: properties.selected_merchant_id,
|
|
405
|
+
selected_merchant_name: properties.selected_merchant_name,
|
|
406
|
+
compared_merchants: properties.compared_merchants,
|
|
407
|
+
selection_reason: properties.selection_reason
|
|
408
|
+
}),
|
|
409
|
+
requiredProperties: ["product_id", "selected_merchant_id"]
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Track when a user clicks an affiliate link to visit merchant site
|
|
414
|
+
*/
|
|
415
|
+
function affiliateLinkClicked(properties) {
|
|
416
|
+
const normalizedProps = normalizeProductProperties(properties);
|
|
417
|
+
validateRequiredProperties(properties, ["product_id", "destination_url"]);
|
|
418
|
+
return {
|
|
419
|
+
name: ECOMMERCE_EVENTS.AFFILIATE_LINK_CLICKED,
|
|
420
|
+
category: "ecommerce",
|
|
421
|
+
properties: cleanProperties({
|
|
422
|
+
...normalizedProps,
|
|
423
|
+
destination_url: properties.destination_url,
|
|
424
|
+
deep_link: properties.deep_link,
|
|
425
|
+
tracking_code: properties.tracking_code
|
|
426
|
+
}),
|
|
427
|
+
requiredProperties: ["product_id", "destination_url"]
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Track when an affiliate conversion is confirmed
|
|
432
|
+
* This is typically fired via webhook or after confirmation from affiliate network
|
|
433
|
+
*/
|
|
434
|
+
function affiliateConversionTracked(properties) {
|
|
435
|
+
validateRequiredProperties(properties, [
|
|
436
|
+
"product_id",
|
|
437
|
+
"order_id",
|
|
438
|
+
"merchant_id"
|
|
439
|
+
]);
|
|
440
|
+
return {
|
|
441
|
+
name: ECOMMERCE_EVENTS.AFFILIATE_CONVERSION_TRACKED,
|
|
442
|
+
category: "ecommerce",
|
|
443
|
+
properties: cleanProperties(properties),
|
|
444
|
+
requiredProperties: [
|
|
445
|
+
"product_id",
|
|
446
|
+
"order_id",
|
|
447
|
+
"merchant_id"
|
|
448
|
+
]
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
//#endregion
|
|
453
|
+
//#region src/shared/emitters/ecommerce/events/order.ts
|
|
454
|
+
/**
|
|
455
|
+
* @fileoverview Order-related ecommerce events
|
|
456
|
+
* Order-related ecommerce events
|
|
457
|
+
*/
|
|
458
|
+
/**
|
|
459
|
+
* Track when a user completes an order
|
|
460
|
+
*/
|
|
461
|
+
function orderCompleted(properties, options) {
|
|
462
|
+
validateRequiredProperties(properties, ["order_id"]);
|
|
463
|
+
const normalizedProps = {
|
|
464
|
+
order_id: properties.order_id,
|
|
465
|
+
affiliation: properties.affiliation,
|
|
466
|
+
coupon: properties.coupon,
|
|
467
|
+
currency: validateCurrency(properties.currency),
|
|
468
|
+
discount: properties.discount,
|
|
469
|
+
products: properties.products ? normalizeProducts(properties.products) : void 0,
|
|
470
|
+
revenue: properties.revenue,
|
|
471
|
+
shipping: properties.shipping,
|
|
472
|
+
tax: properties.tax,
|
|
473
|
+
total: properties.total
|
|
474
|
+
};
|
|
475
|
+
return trackEcommerce({
|
|
476
|
+
name: ECOMMERCE_EVENTS.ORDER_COMPLETED,
|
|
477
|
+
category: "ecommerce",
|
|
478
|
+
properties: cleanProperties(normalizedProps),
|
|
479
|
+
requiredProperties: ["order_id"]
|
|
480
|
+
}, options);
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Track when an order fails (payment declined, validation error, etc.)
|
|
484
|
+
*/
|
|
485
|
+
function orderFailed(properties) {
|
|
486
|
+
validateRequiredProperties(properties, ["order_id"]);
|
|
487
|
+
const { error_code, failure_reason, ...orderProps } = properties;
|
|
488
|
+
const normalizedProps = {
|
|
489
|
+
order_id: orderProps.order_id,
|
|
490
|
+
affiliation: orderProps.affiliation,
|
|
491
|
+
coupon: orderProps.coupon,
|
|
492
|
+
currency: validateCurrency(orderProps.currency),
|
|
493
|
+
discount: orderProps.discount,
|
|
494
|
+
error_code,
|
|
495
|
+
failure_reason,
|
|
496
|
+
products: orderProps.products ? normalizeProducts(orderProps.products) : void 0,
|
|
497
|
+
revenue: orderProps.revenue,
|
|
498
|
+
shipping: orderProps.shipping,
|
|
499
|
+
tax: orderProps.tax,
|
|
500
|
+
total: orderProps.total
|
|
501
|
+
};
|
|
502
|
+
return {
|
|
503
|
+
name: ECOMMERCE_EVENTS.ORDER_FAILED,
|
|
504
|
+
category: "ecommerce",
|
|
505
|
+
properties: cleanProperties(normalizedProps),
|
|
506
|
+
requiredProperties: ["order_id"]
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
/**
|
|
510
|
+
* Track when an order is refunded
|
|
511
|
+
*/
|
|
512
|
+
function orderRefunded(properties) {
|
|
513
|
+
validateRequiredProperties(properties, ["order_id"]);
|
|
514
|
+
const normalizedProps = {
|
|
515
|
+
order_id: properties.order_id,
|
|
516
|
+
affiliation: properties.affiliation,
|
|
517
|
+
coupon: properties.coupon,
|
|
518
|
+
currency: validateCurrency(properties.currency),
|
|
519
|
+
discount: properties.discount,
|
|
520
|
+
products: properties.products ? normalizeProducts(properties.products) : void 0,
|
|
521
|
+
revenue: properties.revenue,
|
|
522
|
+
shipping: properties.shipping,
|
|
523
|
+
tax: properties.tax,
|
|
524
|
+
total: properties.total
|
|
525
|
+
};
|
|
526
|
+
return {
|
|
527
|
+
name: ECOMMERCE_EVENTS.ORDER_REFUNDED,
|
|
528
|
+
category: "ecommerce",
|
|
529
|
+
properties: cleanProperties(normalizedProps),
|
|
530
|
+
requiredProperties: ["order_id"]
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Track when an order is cancelled
|
|
535
|
+
*/
|
|
536
|
+
function orderCancelled(properties) {
|
|
537
|
+
validateRequiredProperties(properties, ["order_id"]);
|
|
538
|
+
const normalizedProps = {
|
|
539
|
+
order_id: properties.order_id,
|
|
540
|
+
affiliation: properties.affiliation,
|
|
541
|
+
coupon: properties.coupon,
|
|
542
|
+
currency: validateCurrency(properties.currency),
|
|
543
|
+
discount: properties.discount,
|
|
544
|
+
products: properties.products ? normalizeProducts(properties.products) : void 0,
|
|
545
|
+
revenue: properties.revenue,
|
|
546
|
+
shipping: properties.shipping,
|
|
547
|
+
tax: properties.tax,
|
|
548
|
+
total: properties.total
|
|
549
|
+
};
|
|
550
|
+
return {
|
|
551
|
+
name: ECOMMERCE_EVENTS.ORDER_CANCELLED,
|
|
552
|
+
category: "ecommerce",
|
|
553
|
+
properties: cleanProperties(normalizedProps),
|
|
554
|
+
requiredProperties: ["order_id"]
|
|
555
|
+
};
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Track order status changes (shipping, delivery, etc.)
|
|
559
|
+
*/
|
|
560
|
+
function orderStatusUpdated(properties) {
|
|
561
|
+
validateRequiredProperties(properties, ["order_id", "status"]);
|
|
562
|
+
return {
|
|
563
|
+
name: ECOMMERCE_EVENTS.ORDER_STATUS_UPDATED,
|
|
564
|
+
category: "ecommerce",
|
|
565
|
+
properties: cleanProperties(properties),
|
|
566
|
+
requiredProperties: ["order_id", "status"]
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Track when a return is requested
|
|
571
|
+
*/
|
|
572
|
+
function returnRequested(properties) {
|
|
573
|
+
validateRequiredProperties(properties, ["order_id", "reason"]);
|
|
574
|
+
const normalizedProps = {
|
|
575
|
+
...properties,
|
|
576
|
+
products: normalizeProducts(properties.products)
|
|
577
|
+
};
|
|
578
|
+
return {
|
|
579
|
+
name: ECOMMERCE_EVENTS.RETURN_REQUESTED,
|
|
580
|
+
category: "ecommerce",
|
|
581
|
+
properties: cleanProperties(normalizedProps),
|
|
582
|
+
requiredProperties: ["order_id", "reason"]
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* Track when a return is completed
|
|
587
|
+
*/
|
|
588
|
+
function returnCompleted(properties) {
|
|
589
|
+
validateRequiredProperties(properties, ["order_id", "return_id"]);
|
|
590
|
+
const normalizedProps = {
|
|
591
|
+
...properties,
|
|
592
|
+
products: normalizeProducts(properties.products)
|
|
593
|
+
};
|
|
594
|
+
return {
|
|
595
|
+
name: ECOMMERCE_EVENTS.RETURN_COMPLETED,
|
|
596
|
+
category: "ecommerce",
|
|
597
|
+
properties: cleanProperties(normalizedProps),
|
|
598
|
+
requiredProperties: ["order_id", "return_id"]
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
//#endregion
|
|
603
|
+
//#region src/shared/emitters/ecommerce/events/product.ts
|
|
604
|
+
/**
|
|
605
|
+
* @fileoverview Product-related ecommerce events
|
|
606
|
+
* Product-related ecommerce events
|
|
607
|
+
*/
|
|
608
|
+
/**
|
|
609
|
+
* Track when a user searches for products
|
|
610
|
+
*/
|
|
611
|
+
function productSearched(properties, options) {
|
|
612
|
+
validateRequiredProperties(properties, ["query"]);
|
|
613
|
+
return trackEcommerce({
|
|
614
|
+
name: ECOMMERCE_EVENTS.PRODUCT_SEARCHED,
|
|
615
|
+
category: "ecommerce",
|
|
616
|
+
properties: cleanProperties(properties),
|
|
617
|
+
requiredProperties: ["query"]
|
|
618
|
+
}, options);
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Track when search results are displayed
|
|
622
|
+
*/
|
|
623
|
+
function searchResultsViewed(properties) {
|
|
624
|
+
validateRequiredProperties(properties, ["query", "results_count"]);
|
|
625
|
+
const normalizedProps = {
|
|
626
|
+
...properties,
|
|
627
|
+
products: properties.products ? normalizeProducts(properties.products) : void 0
|
|
628
|
+
};
|
|
629
|
+
return {
|
|
630
|
+
name: ECOMMERCE_EVENTS.SEARCH_RESULTS_VIEWED,
|
|
631
|
+
category: "ecommerce",
|
|
632
|
+
properties: cleanProperties(normalizedProps),
|
|
633
|
+
requiredProperties: ["query", "results_count"]
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
/**
|
|
637
|
+
* Track when a user views a product list or category
|
|
638
|
+
*/
|
|
639
|
+
function productListViewed(properties) {
|
|
640
|
+
const normalizedProps = {
|
|
641
|
+
list_id: properties.list_id,
|
|
642
|
+
category: properties.category,
|
|
643
|
+
products: properties.products ? normalizeProducts(properties.products) : void 0
|
|
644
|
+
};
|
|
645
|
+
return {
|
|
646
|
+
name: ECOMMERCE_EVENTS.PRODUCT_LIST_VIEWED,
|
|
647
|
+
category: "ecommerce",
|
|
648
|
+
properties: cleanProperties(normalizedProps),
|
|
649
|
+
requiredProperties: []
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Track when a user filters a product list
|
|
654
|
+
*/
|
|
655
|
+
function productListFiltered(properties) {
|
|
656
|
+
const normalizedProps = {
|
|
657
|
+
list_id: properties.list_id,
|
|
658
|
+
category: properties.category,
|
|
659
|
+
filters: properties.filters,
|
|
660
|
+
products: properties.products ? normalizeProducts(properties.products) : void 0
|
|
661
|
+
};
|
|
662
|
+
return {
|
|
663
|
+
name: ECOMMERCE_EVENTS.PRODUCT_LIST_FILTERED,
|
|
664
|
+
category: "ecommerce",
|
|
665
|
+
properties: cleanProperties(normalizedProps),
|
|
666
|
+
requiredProperties: []
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Track when a user clicks on a product
|
|
671
|
+
*/
|
|
672
|
+
function productClicked(properties) {
|
|
673
|
+
const normalizedProps = normalizeProductProperties(properties);
|
|
674
|
+
validateRequiredProperties(normalizedProps, ["product_id"]);
|
|
675
|
+
return {
|
|
676
|
+
name: ECOMMERCE_EVENTS.PRODUCT_CLICKED,
|
|
677
|
+
category: "ecommerce",
|
|
678
|
+
properties: cleanProperties(normalizedProps),
|
|
679
|
+
requiredProperties: ["product_id"]
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
/**
|
|
683
|
+
* Track when a user views a product detail page
|
|
684
|
+
*/
|
|
685
|
+
function productViewed(properties, options) {
|
|
686
|
+
const normalizedProps = normalizeProductProperties(properties);
|
|
687
|
+
validateRequiredProperties(normalizedProps, ["product_id"]);
|
|
688
|
+
return trackEcommerce({
|
|
689
|
+
name: ECOMMERCE_EVENTS.PRODUCT_VIEWED,
|
|
690
|
+
category: "ecommerce",
|
|
691
|
+
properties: cleanProperties(normalizedProps),
|
|
692
|
+
requiredProperties: ["product_id"]
|
|
693
|
+
}, options);
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* Track when a user compares products
|
|
697
|
+
*/
|
|
698
|
+
function productCompared(properties) {
|
|
699
|
+
const { action, comparison_list, product } = properties;
|
|
700
|
+
const normalizedProduct = normalizeProductProperties(product);
|
|
701
|
+
validateRequiredProperties(normalizedProduct, ["product_id"]);
|
|
702
|
+
return {
|
|
703
|
+
name: ECOMMERCE_EVENTS.PRODUCT_COMPARED,
|
|
704
|
+
category: "ecommerce",
|
|
705
|
+
properties: cleanProperties({
|
|
706
|
+
action,
|
|
707
|
+
...normalizedProduct,
|
|
708
|
+
comparison_list: comparison_list ? normalizeProducts(comparison_list) : void 0
|
|
709
|
+
}),
|
|
710
|
+
requiredProperties: ["product_id"]
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
/**
|
|
714
|
+
* Track when product recommendations are viewed
|
|
715
|
+
*/
|
|
716
|
+
function productRecommendationViewed(properties) {
|
|
717
|
+
validateRequiredProperties(properties, ["recommendation_type", "source"]);
|
|
718
|
+
const normalizedProps = {
|
|
719
|
+
...properties,
|
|
720
|
+
products: normalizeProducts(properties.products)
|
|
721
|
+
};
|
|
722
|
+
return {
|
|
723
|
+
name: ECOMMERCE_EVENTS.PRODUCT_RECOMMENDATION_VIEWED,
|
|
724
|
+
category: "ecommerce",
|
|
725
|
+
properties: cleanProperties(normalizedProps),
|
|
726
|
+
requiredProperties: ["recommendation_type", "source"]
|
|
727
|
+
};
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* Track when a recommended product is clicked
|
|
731
|
+
*/
|
|
732
|
+
function productRecommendationClicked(properties) {
|
|
733
|
+
const { recommendation_type, position, source, ...productProps } = properties;
|
|
734
|
+
const normalizedProduct = normalizeProductProperties(productProps);
|
|
735
|
+
validateRequiredProperties(normalizedProduct, ["product_id"]);
|
|
736
|
+
return {
|
|
737
|
+
name: ECOMMERCE_EVENTS.PRODUCT_RECOMMENDATION_CLICKED,
|
|
738
|
+
category: "ecommerce",
|
|
739
|
+
properties: cleanProperties({
|
|
740
|
+
...normalizedProduct,
|
|
741
|
+
recommendation_type,
|
|
742
|
+
position,
|
|
743
|
+
source
|
|
744
|
+
}),
|
|
745
|
+
requiredProperties: ["product_id"]
|
|
746
|
+
};
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
//#endregion
|
|
750
|
+
//#region src/shared/emitters/ecommerce/events/registry.ts
|
|
751
|
+
/**
|
|
752
|
+
* @fileoverview Universal registry events for gift registries, wishlists, and similar features
|
|
753
|
+
* Universal registry events for gift registries, wishlists, and similar features
|
|
754
|
+
* Uses action-based patterns for efficient tracking
|
|
755
|
+
*/
|
|
756
|
+
/**
|
|
757
|
+
* Track registry management actions (create, update, delete)
|
|
758
|
+
*/
|
|
759
|
+
function registryManaged(properties) {
|
|
760
|
+
validateRequiredProperties(properties, ["registry_id", "action"]);
|
|
761
|
+
return {
|
|
762
|
+
name: ECOMMERCE_EVENTS.REGISTRY_MANAGED,
|
|
763
|
+
category: "ecommerce",
|
|
764
|
+
properties: cleanProperties(properties),
|
|
765
|
+
requiredProperties: ["registry_id", "action"]
|
|
766
|
+
};
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* Track when someone views a registry
|
|
770
|
+
*/
|
|
771
|
+
function registryViewed(properties) {
|
|
772
|
+
validateRequiredProperties(properties, ["registry_id"]);
|
|
773
|
+
return {
|
|
774
|
+
name: ECOMMERCE_EVENTS.REGISTRY_VIEWED,
|
|
775
|
+
category: "ecommerce",
|
|
776
|
+
properties: cleanProperties(properties),
|
|
777
|
+
requiredProperties: ["registry_id"]
|
|
778
|
+
};
|
|
779
|
+
}
|
|
780
|
+
/**
|
|
781
|
+
* Track when a registry is shared
|
|
782
|
+
*/
|
|
783
|
+
function registryShared(properties) {
|
|
784
|
+
validateRequiredProperties(properties, ["registry_id", "share_method"]);
|
|
785
|
+
return {
|
|
786
|
+
name: ECOMMERCE_EVENTS.REGISTRY_SHARED,
|
|
787
|
+
category: "ecommerce",
|
|
788
|
+
properties: cleanProperties(properties),
|
|
789
|
+
requiredProperties: ["registry_id", "share_method"]
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
/**
|
|
793
|
+
* Track registry item management (add, remove, update, purchase)
|
|
794
|
+
*/
|
|
795
|
+
function registryItemManaged(properties) {
|
|
796
|
+
const { purchaser_id, registry_id, purchaser_name, action, anonymous_gift, gift_wrap, purchase_message, purchase_quantity, updated_fields, ...productProps } = properties;
|
|
797
|
+
const normalizedProduct = normalizeProductProperties(productProps);
|
|
798
|
+
validateRequiredProperties(properties, [
|
|
799
|
+
"registry_id",
|
|
800
|
+
"product_id",
|
|
801
|
+
"action"
|
|
802
|
+
]);
|
|
803
|
+
return {
|
|
804
|
+
name: ECOMMERCE_EVENTS.REGISTRY_ITEM_MANAGED,
|
|
805
|
+
category: "ecommerce",
|
|
806
|
+
properties: cleanProperties({
|
|
807
|
+
purchaser_id,
|
|
808
|
+
registry_id,
|
|
809
|
+
purchaser_name,
|
|
810
|
+
action,
|
|
811
|
+
anonymous_gift,
|
|
812
|
+
gift_wrap,
|
|
813
|
+
purchase_message,
|
|
814
|
+
purchase_quantity,
|
|
815
|
+
updated_fields,
|
|
816
|
+
...normalizedProduct
|
|
817
|
+
}),
|
|
818
|
+
requiredProperties: [
|
|
819
|
+
"registry_id",
|
|
820
|
+
"product_id",
|
|
821
|
+
"action"
|
|
822
|
+
]
|
|
823
|
+
};
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
//#endregion
|
|
827
|
+
//#region src/shared/emitters/ecommerce/events/wishlist-sharing.ts
|
|
828
|
+
/**
|
|
829
|
+
* @fileoverview Wishlist, sharing, and review-related ecommerce events
|
|
830
|
+
* Wishlist, sharing, and review-related ecommerce events
|
|
831
|
+
*/
|
|
832
|
+
/**
|
|
833
|
+
* Track when a product is added to wishlist
|
|
834
|
+
*/
|
|
835
|
+
function productAddedToWishlist(properties) {
|
|
836
|
+
const { wishlist_id, wishlist_name, ...productProps } = properties;
|
|
837
|
+
const normalizedProduct = normalizeProductProperties(productProps);
|
|
838
|
+
validateRequiredProperties(normalizedProduct, ["product_id"]);
|
|
839
|
+
return {
|
|
840
|
+
name: ECOMMERCE_EVENTS.PRODUCT_ADDED_TO_WISHLIST,
|
|
841
|
+
category: "ecommerce",
|
|
842
|
+
properties: cleanProperties({
|
|
843
|
+
wishlist_id,
|
|
844
|
+
wishlist_name,
|
|
845
|
+
...normalizedProduct
|
|
846
|
+
}),
|
|
847
|
+
requiredProperties: ["product_id"]
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
/**
|
|
851
|
+
* Track when a product is removed from wishlist
|
|
852
|
+
*/
|
|
853
|
+
function productRemovedFromWishlist(properties) {
|
|
854
|
+
const { wishlist_id, wishlist_name, ...productProps } = properties;
|
|
855
|
+
const normalizedProduct = normalizeProductProperties(productProps);
|
|
856
|
+
validateRequiredProperties(normalizedProduct, ["product_id"]);
|
|
857
|
+
return {
|
|
858
|
+
name: ECOMMERCE_EVENTS.PRODUCT_REMOVED_FROM_WISHLIST,
|
|
859
|
+
category: "ecommerce",
|
|
860
|
+
properties: cleanProperties({
|
|
861
|
+
wishlist_id,
|
|
862
|
+
wishlist_name,
|
|
863
|
+
...normalizedProduct
|
|
864
|
+
}),
|
|
865
|
+
requiredProperties: ["product_id"]
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* Track when a wishlist product is added to cart
|
|
870
|
+
*/
|
|
871
|
+
function wishlistProductAddedToCart(properties) {
|
|
872
|
+
const { cart_id, wishlist_id, wishlist_name, ...productProps } = properties;
|
|
873
|
+
const normalizedProduct = normalizeProductProperties(productProps);
|
|
874
|
+
validateRequiredProperties(normalizedProduct, ["product_id"]);
|
|
875
|
+
return {
|
|
876
|
+
name: ECOMMERCE_EVENTS.WISHLIST_PRODUCT_ADDED_TO_CART,
|
|
877
|
+
category: "ecommerce",
|
|
878
|
+
properties: cleanProperties({
|
|
879
|
+
cart_id,
|
|
880
|
+
wishlist_id,
|
|
881
|
+
wishlist_name,
|
|
882
|
+
...normalizedProduct
|
|
883
|
+
}),
|
|
884
|
+
requiredProperties: ["product_id"]
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
/**
|
|
888
|
+
* Track when a product is shared
|
|
889
|
+
*/
|
|
890
|
+
function productShared(properties) {
|
|
891
|
+
const { recipient, share_message, share_via, ...productProps } = properties;
|
|
892
|
+
const normalizedProduct = normalizeProductProperties(productProps);
|
|
893
|
+
validateRequiredProperties(normalizedProduct, ["product_id"]);
|
|
894
|
+
return {
|
|
895
|
+
name: ECOMMERCE_EVENTS.PRODUCT_SHARED,
|
|
896
|
+
category: "ecommerce",
|
|
897
|
+
properties: cleanProperties({
|
|
898
|
+
recipient,
|
|
899
|
+
share_message,
|
|
900
|
+
share_via,
|
|
901
|
+
...normalizedProduct
|
|
902
|
+
}),
|
|
903
|
+
requiredProperties: ["product_id"]
|
|
904
|
+
};
|
|
905
|
+
}
|
|
906
|
+
/**
|
|
907
|
+
* Track when a cart is shared
|
|
908
|
+
*/
|
|
909
|
+
function cartShared(properties) {
|
|
910
|
+
const { cart_id, products, recipient, share_message, share_via } = properties;
|
|
911
|
+
return {
|
|
912
|
+
name: ECOMMERCE_EVENTS.CART_SHARED,
|
|
913
|
+
category: "ecommerce",
|
|
914
|
+
properties: cleanProperties({
|
|
915
|
+
cart_id,
|
|
916
|
+
products: products ? normalizeProducts(products) : void 0,
|
|
917
|
+
recipient,
|
|
918
|
+
share_message,
|
|
919
|
+
share_via
|
|
920
|
+
}),
|
|
921
|
+
requiredProperties: []
|
|
922
|
+
};
|
|
923
|
+
}
|
|
924
|
+
/**
|
|
925
|
+
* Track when a product is reviewed
|
|
926
|
+
*/
|
|
927
|
+
function productReviewed(properties) {
|
|
928
|
+
validateRequiredProperties(properties, ["product_id"]);
|
|
929
|
+
return {
|
|
930
|
+
name: ECOMMERCE_EVENTS.PRODUCT_REVIEWED,
|
|
931
|
+
category: "ecommerce",
|
|
932
|
+
properties: cleanProperties(properties),
|
|
933
|
+
requiredProperties: ["product_id"]
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
//#endregion
|
|
938
|
+
//#region src/shared/emitters/ecommerce/index.ts
|
|
939
|
+
var ecommerce_exports = /* @__PURE__ */ __exportAll({
|
|
940
|
+
ECOMMERCE_EVENTS: () => ECOMMERCE_EVENTS,
|
|
941
|
+
affiliateConversionTracked: () => affiliateConversionTracked,
|
|
942
|
+
affiliateLinkClicked: () => affiliateLinkClicked,
|
|
943
|
+
backInStockRequested: () => backInStockRequested,
|
|
944
|
+
cartAbandoned: () => cartAbandoned,
|
|
945
|
+
cartShared: () => cartShared,
|
|
946
|
+
cartUpdated: () => cartUpdated,
|
|
947
|
+
cartViewed: () => cartViewed,
|
|
948
|
+
checkoutProgressed: () => checkoutProgressed,
|
|
949
|
+
cleanProperties: () => cleanProperties,
|
|
950
|
+
couponApplied: () => couponApplied,
|
|
951
|
+
couponRemoved: () => couponRemoved,
|
|
952
|
+
createEcommerceContext: () => createEcommerceContext,
|
|
953
|
+
createEcommerceTracker: () => createEcommerceTracker,
|
|
954
|
+
merchantSelected: () => merchantSelected,
|
|
955
|
+
mergeEventProperties: () => mergeEventProperties,
|
|
956
|
+
normalizeProductProperties: () => normalizeProductProperties,
|
|
957
|
+
normalizeProducts: () => normalizeProducts,
|
|
958
|
+
orderCancelled: () => orderCancelled,
|
|
959
|
+
orderCompleted: () => orderCompleted,
|
|
960
|
+
orderFailed: () => orderFailed,
|
|
961
|
+
orderRefunded: () => orderRefunded,
|
|
962
|
+
orderStatusUpdated: () => orderStatusUpdated,
|
|
963
|
+
priceAlertSet: () => priceAlertSet,
|
|
964
|
+
priceComparisonViewed: () => priceComparisonViewed,
|
|
965
|
+
productAddedToWishlist: () => productAddedToWishlist,
|
|
966
|
+
productClicked: () => productClicked,
|
|
967
|
+
productCompared: () => productCompared,
|
|
968
|
+
productListFiltered: () => productListFiltered,
|
|
969
|
+
productListViewed: () => productListViewed,
|
|
970
|
+
productRecommendationClicked: () => productRecommendationClicked,
|
|
971
|
+
productRecommendationViewed: () => productRecommendationViewed,
|
|
972
|
+
productRemovedFromWishlist: () => productRemovedFromWishlist,
|
|
973
|
+
productReviewed: () => productReviewed,
|
|
974
|
+
productSearched: () => productSearched,
|
|
975
|
+
productShared: () => productShared,
|
|
976
|
+
productViewed: () => productViewed,
|
|
977
|
+
registryItemManaged: () => registryItemManaged,
|
|
978
|
+
registryManaged: () => registryManaged,
|
|
979
|
+
registryShared: () => registryShared,
|
|
980
|
+
registryViewed: () => registryViewed,
|
|
981
|
+
returnCompleted: () => returnCompleted,
|
|
982
|
+
returnRequested: () => returnRequested,
|
|
983
|
+
searchResultsViewed: () => searchResultsViewed,
|
|
984
|
+
trackEcommerce: () => trackEcommerce,
|
|
985
|
+
validateCurrency: () => validateCurrency,
|
|
986
|
+
validateProductWithContext: () => validateProductWithContext,
|
|
987
|
+
validateRequiredProperties: () => validateRequiredProperties,
|
|
988
|
+
wishlistProductAddedToCart: () => wishlistProductAddedToCart
|
|
989
|
+
});
|
|
990
|
+
|
|
991
|
+
//#endregion
|
|
992
|
+
export { ecommerce_exports as t };
|
|
993
|
+
//# sourceMappingURL=ecommerce-Cgu4wlux.mjs.map
|