@artisan-commerce/analytics-web 0.1.0-canary.148.13 → 0.1.0-canary.148.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.cjs +31 -17
- package/dist/bundle.cjs.map +1 -1
- package/dist/bundle.d.ts +16 -9
- package/dist/bundle.mjs +31 -17
- package/dist/bundle.mjs.map +1 -1
- package/dist/bundle.umd.js +31 -17
- package/dist/bundle.umd.js.map +1 -1
- package/package.json +6 -6
package/dist/bundle.cjs
CHANGED
|
@@ -50,7 +50,7 @@ const _State = class {
|
|
|
50
50
|
let State$1 = _State;
|
|
51
51
|
State$1._instance = null;
|
|
52
52
|
|
|
53
|
-
var version = "0.1.0-canary.148.
|
|
53
|
+
var version = "0.1.0-canary.148.14";
|
|
54
54
|
var packageJSON = {
|
|
55
55
|
version: version};
|
|
56
56
|
|
|
@@ -846,18 +846,26 @@ const getProductContent = (product) => {
|
|
|
846
846
|
};
|
|
847
847
|
const mapProductsToGoogleItems = (shoppingCart, currency) => {
|
|
848
848
|
const products = shoppingCartCore.getShoppingCartProducts(shoppingCart);
|
|
849
|
-
return products.map((product) => mapProductToGoogleItem(product
|
|
849
|
+
return products.map((product) => mapProductToGoogleItem(product));
|
|
850
850
|
};
|
|
851
851
|
const mapProductToGoogleItem = (product, currency) => {
|
|
852
852
|
const totals = products.getProductTotals(product);
|
|
853
|
-
const { productId, name, amount } = product;
|
|
854
|
-
|
|
853
|
+
const { productId, name, amount, categories, addedFrom } = product;
|
|
854
|
+
const [category] = categories != null ? categories : [];
|
|
855
|
+
const { categoryId, name: categoryName } = category != null ? category : {};
|
|
856
|
+
const item = {
|
|
855
857
|
item_id: productId,
|
|
856
858
|
item_name: name,
|
|
857
859
|
quantity: amount,
|
|
858
|
-
price: totals.netPrice
|
|
859
|
-
currency
|
|
860
|
+
price: totals.netPrice
|
|
860
861
|
};
|
|
862
|
+
if (categoryId)
|
|
863
|
+
item.item_list_id = `${categoryId}`;
|
|
864
|
+
if (categoryName)
|
|
865
|
+
item.item_category = categoryName;
|
|
866
|
+
if (addedFrom)
|
|
867
|
+
item.item_category2 = addedFrom;
|
|
868
|
+
return item;
|
|
861
869
|
};
|
|
862
870
|
const transformArrayParam = (param) => {
|
|
863
871
|
return param.join(",");
|
|
@@ -3569,7 +3577,7 @@ const initiateCheckout$2 = (provider, params) => {
|
|
|
3569
3577
|
gtag("event", "begin_checkout", __spreadValues$33(__spreadValues$33({
|
|
3570
3578
|
send_to: trackingId,
|
|
3571
3579
|
event_callback: callback,
|
|
3572
|
-
items: mapProductsToGoogleItems(shoppingCart
|
|
3580
|
+
items: mapProductsToGoogleItems(shoppingCart),
|
|
3573
3581
|
value: total,
|
|
3574
3582
|
points: totalPoints != null ? totalPoints : 0
|
|
3575
3583
|
}, transformedParams), transformedMeta));
|
|
@@ -9881,7 +9889,7 @@ const purchaseAttempt$2 = (provider, params) => {
|
|
|
9881
9889
|
gtag("event", "purchase_attempt", __spreadValues$18(__spreadValues$18({
|
|
9882
9890
|
send_to: trackingId,
|
|
9883
9891
|
event_callback: callback,
|
|
9884
|
-
items: mapProductsToGoogleItems(shoppingCart
|
|
9892
|
+
items: mapProductsToGoogleItems(shoppingCart),
|
|
9885
9893
|
value: total,
|
|
9886
9894
|
points: totalPoints != null ? totalPoints : 0
|
|
9887
9895
|
}, transformedParams), transformedMeta));
|
|
@@ -10065,7 +10073,7 @@ const purchaseFail$2 = (provider, params) => {
|
|
|
10065
10073
|
gtag("event", "purchase_fail", __spreadValues$15(__spreadValues$15({
|
|
10066
10074
|
send_to: trackingId,
|
|
10067
10075
|
event_callback: callback,
|
|
10068
|
-
items: mapProductsToGoogleItems(shoppingCart
|
|
10076
|
+
items: mapProductsToGoogleItems(shoppingCart),
|
|
10069
10077
|
value: total,
|
|
10070
10078
|
points: totalPoints != null ? totalPoints : 0
|
|
10071
10079
|
}, transformedParams), transformedMeta));
|
|
@@ -10249,7 +10257,7 @@ const purchaseSuccess$2 = (provider, params) => {
|
|
|
10249
10257
|
gtag("event", "purchase", __spreadValues$12(__spreadValues$12({
|
|
10250
10258
|
send_to: trackingId,
|
|
10251
10259
|
event_callback: callback,
|
|
10252
|
-
items: mapProductsToGoogleItems(shoppingCart
|
|
10260
|
+
items: mapProductsToGoogleItems(shoppingCart),
|
|
10253
10261
|
value: total,
|
|
10254
10262
|
points: totalPoints != null ? totalPoints : 0,
|
|
10255
10263
|
transaction_id: orderId,
|
|
@@ -11039,7 +11047,7 @@ const addProductToCart$2 = (provider, params) => {
|
|
|
11039
11047
|
gtag("event", "add_to_cart", __spreadValues$P(__spreadValues$P({
|
|
11040
11048
|
send_to: trackingId,
|
|
11041
11049
|
event_callback: callback,
|
|
11042
|
-
items: [mapProductToGoogleItem(product
|
|
11050
|
+
items: [mapProductToGoogleItem(product)],
|
|
11043
11051
|
value: totalPrice,
|
|
11044
11052
|
points: totalPoints
|
|
11045
11053
|
}, transformedParams), transformedMeta));
|
|
@@ -11239,7 +11247,7 @@ const addProductToWishlist$2 = (provider, params) => {
|
|
|
11239
11247
|
gtag("event", "add_to_wishlist", __spreadValues$M(__spreadValues$M({
|
|
11240
11248
|
send_to: trackingId,
|
|
11241
11249
|
event_callback: callback,
|
|
11242
|
-
items: [mapProductToGoogleItem(product
|
|
11250
|
+
items: [mapProductToGoogleItem(product)],
|
|
11243
11251
|
value: totalPrice,
|
|
11244
11252
|
points: totalPoints
|
|
11245
11253
|
}, transformedParams), transformedMeta));
|
|
@@ -12360,7 +12368,8 @@ var __objRest$t = (source, exclude) => {
|
|
|
12360
12368
|
};
|
|
12361
12369
|
const viewCart$2 = (provider, params) => {
|
|
12362
12370
|
const { trackingId, userId: providerUserId } = provider;
|
|
12363
|
-
const
|
|
12371
|
+
const { currency: providerCurrency } = provider;
|
|
12372
|
+
const _a = params, { callback, userId, shoppingCart, currency } = _a, rest = __objRest$t(_a, ["callback", "userId", "shoppingCart", "currency"]);
|
|
12364
12373
|
const selectedUserId = userId != null ? userId : providerUserId;
|
|
12365
12374
|
const enhancedParams = __spreadProps$g(__spreadValues$u({}, rest), { userId: selectedUserId });
|
|
12366
12375
|
const transformedParams = eventParamsToSnakeCase(enhancedParams);
|
|
@@ -12368,7 +12377,8 @@ const viewCart$2 = (provider, params) => {
|
|
|
12368
12377
|
const transformedMeta = eventParamsToSnakeCase(meta);
|
|
12369
12378
|
gtag("event", "view_cart", __spreadValues$u(__spreadValues$u({
|
|
12370
12379
|
send_to: trackingId,
|
|
12371
|
-
event_callback: callback
|
|
12380
|
+
event_callback: callback,
|
|
12381
|
+
items: mapProductsToGoogleItems(shoppingCart)
|
|
12372
12382
|
}, transformedParams), transformedMeta));
|
|
12373
12383
|
};
|
|
12374
12384
|
|
|
@@ -12403,14 +12413,17 @@ var __objRest$s = (source, exclude) => {
|
|
|
12403
12413
|
const viewCart$1 = (provider, params) => {
|
|
12404
12414
|
const { trackingId, conversionsApiConfig } = provider;
|
|
12405
12415
|
const { isTrackingAllowed, withConversionsAPI } = provider;
|
|
12406
|
-
const rest = __objRest$s(
|
|
12416
|
+
const _a = params, { contentType } = _a, rest = __objRest$s(_a, ["contentType"]);
|
|
12407
12417
|
delete rest.userId;
|
|
12418
|
+
delete rest.shoppingCart;
|
|
12408
12419
|
const enhancedParams = __spreadValues$t({}, rest);
|
|
12409
12420
|
const transformedParams = eventParamsToSnakeCase(enhancedParams);
|
|
12410
12421
|
const { meta } = State().state;
|
|
12411
12422
|
const transformedMeta = eventParamsToSnakeCase(meta);
|
|
12412
12423
|
const eventName = "ViewCart";
|
|
12413
|
-
const customData = __spreadValues$t(__spreadValues$t({
|
|
12424
|
+
const customData = __spreadValues$t(__spreadValues$t({
|
|
12425
|
+
fb_content_type: contentType
|
|
12426
|
+
}, transformedParams), transformedMeta);
|
|
12414
12427
|
if (isTrackingAllowed) {
|
|
12415
12428
|
fbq("trackSingleCustom", trackingId, eventName, customData);
|
|
12416
12429
|
return;
|
|
@@ -12452,8 +12465,9 @@ var __objRest$r = (source, exclude) => {
|
|
|
12452
12465
|
return target;
|
|
12453
12466
|
};
|
|
12454
12467
|
const viewCart = (provider, params) => {
|
|
12455
|
-
const _a = params, {
|
|
12468
|
+
const _a = params, { shoppingCart } = _a, rest = __objRest$r(_a, ["shoppingCart"]);
|
|
12456
12469
|
delete rest.userId;
|
|
12470
|
+
const products = shoppingCartCore.getShoppingCartProducts(shoppingCart);
|
|
12457
12471
|
const enhancedParams = __spreadValues$s({}, rest);
|
|
12458
12472
|
const transformedParams = eventParamsToSnakeCase(enhancedParams);
|
|
12459
12473
|
const { meta } = State().state;
|