@artisan-commerce/analytics-rn 0.3.0-canary.122 → 0.3.0-canary.124

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.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Account, Vendor, Store, Catalogue, ArtisnPlatform, CurrencyCodes, Product, ShoppingCart, CartProduct, PriceCategoryType, ShippingAddress, BillingData, Order, Category } from '@artisan-commerce/types';
1
+ import { Account, Vendor, Store, Catalogue, ArtisnPlatform, CurrencyCodes, ShoppingCart, CartProduct, PriceCategoryType, ShippingAddress, BillingData, Order, Product, Category } from '@artisan-commerce/types';
2
2
  import { SegmentClient, UserTraits } from '@segment/analytics-react-native';
3
3
 
4
4
  /**
@@ -167,23 +167,28 @@ interface GoogleAnalyticsCustomEventParams {
167
167
  [key: string]: any;
168
168
  }
169
169
  declare namespace Gtag {
170
- type Currency = string | number;
171
170
  interface Item {
172
- brand?: string;
173
- category?: string;
171
+ item_id: string;
172
+ item_name: string;
173
+ affiliation?: string;
174
+ coupon?: string;
174
175
  creative_name?: string;
175
176
  creative_slot?: string;
176
- currency?: string;
177
+ discount?: number;
177
178
  index?: number;
178
179
  item_brand?: string;
179
180
  item_category?: string;
180
- item_id?: string;
181
+ item_category2?: string;
182
+ item_category3?: string;
183
+ item_category4?: string;
184
+ item_category5?: string;
181
185
  item_list_id?: string;
182
186
  item_list_name?: string;
183
- item_name?: string;
184
187
  item_variant?: string;
185
188
  location_id?: string;
186
- price?: Currency;
189
+ price?: number;
190
+ promotion_id?: string;
191
+ promotion_name?: string;
187
192
  quantity?: number;
188
193
  }
189
194
  }
@@ -1023,6 +1028,7 @@ type ShareParams = ShareParams$3 & ShareParams$2 & ShareParams$1;
1023
1028
  * @extends ViewCartCommonParams
1024
1029
  */
1025
1030
  interface ViewCartParams$3 extends GoogleAnalyticsCommonEventParams, GoogleAnalyticsCustomEventParams, ViewCartCommonParams {
1031
+ shoppingCart: ShoppingCart;
1026
1032
  }
1027
1033
 
1028
1034
  /**
@@ -1050,7 +1056,7 @@ interface ViewCartParams$2 extends FacebookPixelCommonEventParams, FacebookPixel
1050
1056
  * @property {Product[]} products The products in the cart
1051
1057
  */
1052
1058
  interface ViewCartParams$1 extends SegmentCommonEventParams, SegmentCustomEventParams, ViewCartCommonParams {
1053
- products: Product[];
1059
+ shoppingCart: ShoppingCart;
1054
1060
  }
1055
1061
 
1056
1062
  /**
package/dist/bundle.mjs CHANGED
@@ -2,7 +2,7 @@ import { Settings, AppEventsLogger } from 'react-native-fbsdk-next';
2
2
  import { Platform } from 'react-native';
3
3
  import { createClient } from '@segment/analytics-react-native';
4
4
  import { getShoppingCartProducts, getShoppingCartTotal } from '@artisan-commerce/shopping-cart-core';
5
- import { getProductTotals } from '@artisan-commerce/products';
5
+ import { getProductTotals, transformers } from '@artisan-commerce/products';
6
6
  import analytics from '@react-native-firebase/analytics';
7
7
 
8
8
  var __defProp$41 = Object.defineProperty;
@@ -53,7 +53,7 @@ State$1._instance = null;
53
53
 
54
54
  var name = "@artisan-commerce/analytics-rn";
55
55
  var description = "Artisn commerce analytics react native library";
56
- var version = "0.3.0-canary.122";
56
+ var version = "0.3.0-canary.124";
57
57
  var type = "module";
58
58
  var main = "./dist/bundle.mjs";
59
59
  var module = "./dist/bundle.mjs";
@@ -88,10 +88,10 @@ var dependencies = {
88
88
  "snake-case": "^3.0.4"
89
89
  };
90
90
  var devDependencies = {
91
- "@artisan-commerce/products": "0.9.0-canary.71",
92
- "@artisan-commerce/shopping-cart-core": "0.12.0-canary.107",
93
- "@artisan-commerce/state": "0.3.0-canary.20",
94
- "@artisan-commerce/types": "0.14.0-canary.48",
91
+ "@artisan-commerce/products": "0.9.0-canary.72",
92
+ "@artisan-commerce/shopping-cart-core": "0.12.0-canary.108",
93
+ "@artisan-commerce/state": "0.3.0-canary.21",
94
+ "@artisan-commerce/types": "0.14.0-canary.49",
95
95
  "@babel/core": "^7.13.15",
96
96
  "@babel/preset-env": "^7.10.4",
97
97
  "@babel/preset-react": "^7.10.4",
@@ -136,7 +136,7 @@ var nx = {
136
136
  }
137
137
  }
138
138
  };
139
- var gitHead = "2b6418d5e5d73fe1b6e939dd0942e6dcce7b95fa";
139
+ var gitHead = "9f4490e5007c7159a610bd916f2b237038c46ce6";
140
140
  var packageJSON = {
141
141
  name: name,
142
142
  description: description,
@@ -843,20 +843,28 @@ const getProductContentForConversionAPI = (product) => {
843
843
  const facebookItem = { id, item_price: netPrice };
844
844
  return JSON.stringify(facebookItem);
845
845
  };
846
- const mapProductsToGoogleItems = (shoppingCart, currency) => {
846
+ const mapProductsToGoogleItems = (shoppingCart) => {
847
847
  const products = getShoppingCartProducts(shoppingCart);
848
- return products.map((product) => mapProductToGoogleItem(product, currency));
848
+ return products.map((product) => mapProductToGoogleItem(product));
849
849
  };
850
- const mapProductToGoogleItem = (product, currency) => {
850
+ const mapProductToGoogleItem = (product) => {
851
851
  const totals = getProductTotals(product);
852
- const { productId, name, amount } = product;
853
- return {
852
+ const { productId, name, amount, categories, addedFrom } = product;
853
+ const [category] = categories != null ? categories : [];
854
+ const { categoryId, name: categoryName } = category != null ? category : {};
855
+ const item = {
854
856
  item_id: productId,
855
857
  item_name: name,
856
858
  quantity: amount,
857
- price: totals.netPrice,
858
- currency
859
+ price: totals.netPrice
859
860
  };
861
+ if (categoryId)
862
+ item.item_list_id = `${categoryId}`;
863
+ if (categoryName)
864
+ item.item_category = categoryName;
865
+ if (addedFrom)
866
+ item.item_category2 = addedFrom;
867
+ return item;
860
868
  };
861
869
  const transformArrayParam = (param) => {
862
870
  return param.join(",");
@@ -3664,7 +3672,7 @@ const initiateCheckout$2 = (provider, params) => {
3664
3672
  const transformedMeta = eventParamsToSnakeCase(meta);
3665
3673
  const { total, totalPoints } = getShoppingCartTotal(shoppingCart);
3666
3674
  analytics().logEvent("begin_checkout", __spreadValues$33(__spreadValues$33({
3667
- items: mapProductsToGoogleItems(shoppingCart, selectedCurrency),
3675
+ items: mapProductsToGoogleItems(shoppingCart),
3668
3676
  value: total,
3669
3677
  points: totalPoints != null ? totalPoints : 0
3670
3678
  }, transformedParams), transformedMeta));
@@ -9927,12 +9935,14 @@ const viewProductDetails$2 = (provider, params) => {
9927
9935
  productName,
9928
9936
  currency: selectedCurrency
9929
9937
  });
9938
+ const cartProduct = transformers.toCartProduct(product);
9930
9939
  const total = getProductTotals(product);
9931
9940
  const transformedParams = eventParamsToSnakeCase(enhancedParams);
9932
9941
  const { meta } = State().state;
9933
9942
  const transformedMeta = eventParamsToSnakeCase(meta);
9934
9943
  analytics().logEvent("view_item", __spreadValues$1b(__spreadValues$1b({
9935
- value: total.netPrice
9944
+ value: total.netPrice,
9945
+ items: [mapProductToGoogleItem(cartProduct)]
9936
9946
  }, transformedParams), transformedMeta));
9937
9947
  };
9938
9948
 
@@ -10500,7 +10510,7 @@ const purchaseSuccess$2 = (provider, params) => {
10500
10510
  const { meta } = State().state;
10501
10511
  const transformedMeta = eventParamsToSnakeCase(meta);
10502
10512
  analytics().logEvent("purchase", __spreadValues$12(__spreadValues$12({
10503
- items: mapProductsToGoogleItems(shoppingCart, selectedCurrency),
10513
+ items: mapProductsToGoogleItems(shoppingCart),
10504
10514
  value: total,
10505
10515
  points: totalPoints != null ? totalPoints : 0,
10506
10516
  transaction_id: orderId,
@@ -11319,7 +11329,7 @@ const addProductToCart$2 = (provider, params) => {
11319
11329
  const totalPoints = finalPriceCategory === "POINTS" ? netPrice : 0;
11320
11330
  const transformedMeta = eventParamsToSnakeCase(meta);
11321
11331
  analytics().logEvent("add_to_cart", __spreadValues$P(__spreadValues$P({
11322
- items: [mapProductToGoogleItem(product, selectedCurrency)],
11332
+ items: [mapProductToGoogleItem(product)],
11323
11333
  value: totalPrice,
11324
11334
  points: totalPoints
11325
11335
  }, transformedParams), transformedMeta));
@@ -11531,7 +11541,7 @@ const addProductToWishlist$2 = (provider, params) => {
11531
11541
  const totalPoints = finalPriceCategory === "POINTS" ? netPrice : 0;
11532
11542
  const transformedMeta = eventParamsToSnakeCase(meta);
11533
11543
  analytics().logEvent("add_to_wishlist", __spreadValues$M(__spreadValues$M({
11534
- items: [mapProductToGoogleItem(product, selectedCurrency)],
11544
+ items: [mapProductToGoogleItem(product)],
11535
11545
  value: totalPrice,
11536
11546
  points: totalPoints
11537
11547
  }, transformedParams), transformedMeta));
@@ -12716,14 +12726,15 @@ var __objRest$t = (source, exclude) => {
12716
12726
  };
12717
12727
  const viewCart$2 = (provider, params) => {
12718
12728
  const { userId: providerUserId } = provider;
12719
- const _a = params, { userId } = _a, rest = __objRest$t(_a, ["userId"]);
12720
- delete rest.products;
12729
+ const _a = params, { userId, shoppingCart } = _a, rest = __objRest$t(_a, ["userId", "shoppingCart"]);
12721
12730
  const selectedUserId = userId != null ? userId : providerUserId;
12722
12731
  const enhancedParams = __spreadProps$h(__spreadValues$u({}, rest), { userId: selectedUserId });
12723
12732
  const transformedParams = eventParamsToSnakeCase(enhancedParams);
12724
12733
  const { meta } = State().state;
12725
12734
  const transformedMeta = eventParamsToSnakeCase(meta);
12726
- analytics().logEvent("view_cart", __spreadValues$u(__spreadValues$u({}, transformedParams), transformedMeta));
12735
+ analytics().logEvent("view_cart", __spreadValues$u(__spreadValues$u({
12736
+ items: mapProductsToGoogleItems(shoppingCart)
12737
+ }, transformedParams), transformedMeta));
12727
12738
  };
12728
12739
 
12729
12740
  var __defProp$t = Object.defineProperty;
@@ -12756,8 +12767,9 @@ var __objRest$s = (source, exclude) => {
12756
12767
  };
12757
12768
  const viewCart$1 = (provider, params) => {
12758
12769
  const { track } = provider;
12759
- const _a = params, { products } = _a, rest = __objRest$s(_a, ["products"]);
12770
+ const _a = params, { shoppingCart } = _a, rest = __objRest$s(_a, ["shoppingCart"]);
12760
12771
  delete rest.userId;
12772
+ const products = getShoppingCartProducts(shoppingCart);
12761
12773
  const enhancedParams = __spreadValues$t({}, rest);
12762
12774
  const transformedParams = eventParamsToSnakeCase(enhancedParams);
12763
12775
  const { meta, debug } = State().state;
@@ -12804,7 +12816,7 @@ const viewCart = (provider, params) => {
12804
12816
  const { isTrackingAllowed, withConversionsAPI } = provider;
12805
12817
  const _a = params, { contentType } = _a, rest = __objRest$r(_a, ["contentType"]);
12806
12818
  delete rest.userId;
12807
- delete rest.products;
12819
+ delete rest.shoppingCart;
12808
12820
  const enhancedParams = __spreadValues$s({}, rest);
12809
12821
  const transformedParams = eventParamsToSnakeCase(enhancedParams);
12810
12822
  const { meta } = State().state;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@artisan-commerce/analytics-rn",
3
3
  "description": "Artisn commerce analytics react native library",
4
- "version": "0.3.0-canary.122",
4
+ "version": "0.3.0-canary.124",
5
5
  "type": "module",
6
6
  "main": "./dist/bundle.mjs",
7
7
  "module": "./dist/bundle.mjs",
@@ -36,10 +36,10 @@
36
36
  "snake-case": "^3.0.4"
37
37
  },
38
38
  "devDependencies": {
39
- "@artisan-commerce/products": "0.9.0-canary.71",
40
- "@artisan-commerce/shopping-cart-core": "0.12.0-canary.107",
41
- "@artisan-commerce/state": "0.3.0-canary.20",
42
- "@artisan-commerce/types": "0.14.0-canary.48",
39
+ "@artisan-commerce/products": "0.9.0-canary.72",
40
+ "@artisan-commerce/shopping-cart-core": "0.12.0-canary.108",
41
+ "@artisan-commerce/state": "0.3.0-canary.21",
42
+ "@artisan-commerce/types": "0.14.0-canary.49",
43
43
  "@babel/core": "^7.13.15",
44
44
  "@babel/preset-env": "^7.10.4",
45
45
  "@babel/preset-react": "^7.10.4",
@@ -84,5 +84,5 @@
84
84
  }
85
85
  }
86
86
  },
87
- "gitHead": "2b6418d5e5d73fe1b6e939dd0942e6dcce7b95fa"
87
+ "gitHead": "9f4490e5007c7159a610bd916f2b237038c46ce6"
88
88
  }