@wapitee/typhoonx-hydrogen 0.4.6 → 0.5.0

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 +1 @@
1
- {"version":3,"file":"TyphoonX.d.ts","sourceRoot":"","sources":["../src/TyphoonX.tsx"],"names":[],"mappings":"AAKA,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AA0BD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,KAAK,EAAE,aAAa,sCAYpD"}
1
+ {"version":3,"file":"TyphoonX.d.ts","sourceRoot":"","sources":["../src/TyphoonX.tsx"],"names":[],"mappings":"AAKA,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AA2BD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,KAAK,EAAE,aAAa,sCAYpD"}
package/dist/TyphoonX.js CHANGED
@@ -44,9 +44,8 @@ function TyphoonXClient({ cookieDomain, merchantId, shopId }) {
44
44
  });
45
45
  subscribe('cart_viewed', (data) => {
46
46
  const { cart } = data;
47
- if (!cart?.lines) {
47
+ if (!cart?.lines)
48
48
  return;
49
- }
50
49
  const cartLines = flattenConnection(cart.lines);
51
50
  send({
52
51
  ...shared(data.url, data.shop?.currency),
@@ -63,9 +62,8 @@ function TyphoonXClient({ cookieDomain, merchantId, shopId }) {
63
62
  });
64
63
  subscribe('collection_viewed', (data) => {
65
64
  const { collection } = data;
66
- if (!collection.id) {
65
+ if (!collection.id)
67
66
  return;
68
- }
69
67
  send({
70
68
  ...shared(data.url, data.shop?.currency),
71
69
  event: 'view_item_list',
@@ -81,9 +79,8 @@ function TyphoonXClient({ cookieDomain, merchantId, shopId }) {
81
79
  });
82
80
  subscribe('product_added_to_cart', (data) => {
83
81
  const { currentLine } = data;
84
- if (currentLine === undefined) {
82
+ if (currentLine === undefined)
85
83
  return;
86
- }
87
84
  send({
88
85
  ...shared(window.location.href, data.shop?.currency),
89
86
  event: 'add_to_cart',
@@ -102,9 +99,8 @@ function TyphoonXClient({ cookieDomain, merchantId, shopId }) {
102
99
  subscribe('product_removed_from_cart', (data) => {
103
100
  const { currentLine, prevLine } = data;
104
101
  const quantity = (prevLine?.quantity ?? 0) - (currentLine?.quantity ?? 0);
105
- if (prevLine === undefined || quantity <= 0) {
102
+ if (prevLine === undefined || quantity <= 0)
106
103
  return;
107
- }
108
104
  send({
109
105
  ...shared(window.location.href, data.shop?.currency),
110
106
  event: 'remove_from_cart',
@@ -123,9 +119,8 @@ function TyphoonXClient({ cookieDomain, merchantId, shopId }) {
123
119
  });
124
120
  subscribe('product_viewed', (data) => {
125
121
  const product = data.products[0];
126
- if (product === undefined) {
122
+ if (product === undefined)
127
123
  return;
128
- }
129
124
  send({
130
125
  ...shared(data.url, data.shop?.currency),
131
126
  event: 'view_item',
@@ -141,6 +136,16 @@ function TyphoonXClient({ cookieDomain, merchantId, shopId }) {
141
136
  value: product.price,
142
137
  });
143
138
  });
139
+ subscribe('search_viewed', (data) => {
140
+ const { searchTerm } = data;
141
+ if (!searchTerm)
142
+ return;
143
+ send({
144
+ ...shared(data.url, data.shop?.currency),
145
+ event: 'search',
146
+ search_term: searchTerm,
147
+ });
148
+ });
144
149
  ready();
145
150
  }, [cookieDomain, merchantId, shopId, canTrack, ready, subscribe]);
146
151
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wapitee/typhoonx-hydrogen",
3
- "version": "0.4.6",
3
+ "version": "0.5.0",
4
4
  "description": "TyphoonX Hydrogen Analytics subscriber",
5
5
  "keywords": [
6
6
  "typhoonx",