@ikas/storefront 0.0.146 → 0.0.147

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.
@@ -14,6 +14,8 @@ export declare class Analytics {
14
14
  static addToWishlist(id: string): void;
15
15
  static search(searchKeyword: string): void;
16
16
  static completeRegistration(): void;
17
+ static customerLogin(email: string): void;
18
+ static customerVisit(email: string): void;
17
19
  static viewCart(cart: IkasCart | null | undefined): void;
18
20
  static viewCategory(categoryPath: string, category: IkasCategory): void;
19
21
  static contactForm(): void;
@@ -12,7 +12,11 @@ export declare class GoogleTagManager {
12
12
  items: {
13
13
  item_name: string;
14
14
  item_id: string;
15
+ parent_id: string;
15
16
  price: number;
17
+ currency: string;
18
+ url: string;
19
+ item_image: string;
16
20
  item_brand: string;
17
21
  item_category: string;
18
22
  item_category_2: string;
@@ -32,7 +36,11 @@ export declare class GoogleTagManager {
32
36
  items: ({
33
37
  item_name: string;
34
38
  item_id: string;
39
+ parent_id: string;
35
40
  price: number;
41
+ currency: string;
42
+ url: string;
43
+ item_image: string;
36
44
  item_brand: string;
37
45
  item_category: string;
38
46
  item_category_2: string;
@@ -66,7 +74,11 @@ export declare class GoogleTagManager {
66
74
  items: ({
67
75
  item_name: string;
68
76
  item_id: string;
77
+ parent_id: string;
69
78
  price: number;
79
+ currency: string;
80
+ url: string;
81
+ item_image: string;
70
82
  item_brand: string;
71
83
  item_category: string;
72
84
  item_category_2: string;
@@ -184,4 +196,12 @@ export declare class GoogleTagManager {
184
196
  }[];
185
197
  };
186
198
  } | undefined;
199
+ static customerLogin(email: string): {
200
+ event: string;
201
+ email: string;
202
+ } | undefined;
203
+ static customerVisit(email: string): {
204
+ event: string;
205
+ email: string;
206
+ } | undefined;
187
207
  }
package/build/index.es.js CHANGED
@@ -17182,16 +17182,48 @@ var GoogleTagManager = /** @class */ (function () {
17182
17182
  console.error(err);
17183
17183
  }
17184
17184
  };
17185
+ GoogleTagManager.customerLogin = function (email) {
17186
+ try {
17187
+ var event_11 = {
17188
+ event: "customer_login",
17189
+ email: email,
17190
+ };
17191
+ //@ts-ignore
17192
+ !isServer$2 && window.dataLayer && window.dataLayer.push(event_11);
17193
+ return event_11;
17194
+ }
17195
+ catch (err) {
17196
+ console.error(err);
17197
+ }
17198
+ };
17199
+ GoogleTagManager.customerVisit = function (email) {
17200
+ try {
17201
+ var event_12 = {
17202
+ event: "customer_visit",
17203
+ email: email,
17204
+ };
17205
+ //@ts-ignore
17206
+ !isServer$2 && window.dataLayer && window.dataLayer.push(event_12);
17207
+ return event_12;
17208
+ }
17209
+ catch (err) {
17210
+ console.error(err);
17211
+ }
17212
+ };
17185
17213
  return GoogleTagManager;
17186
17214
  }());
17187
17215
  function productToGTMItem(productDetail, quantity) {
17188
- var _a;
17216
+ var _a, _b;
17189
17217
  if (quantity === void 0) { quantity = 1; }
17190
17218
  return {
17191
17219
  item_name: productDetail.product.name,
17192
17220
  item_id: productDetail.selectedVariant.id,
17221
+ parent_id: productDetail.product.id,
17193
17222
  price: productDetail.selectedVariant.price.finalPrice,
17194
- item_brand: ((_a = productDetail.product.brand) === null || _a === void 0 ? void 0 : _a.name) || "",
17223
+ currency: productDetail.selectedVariant.price.currency,
17224
+ url: "https://" + window.location.hostname + productDetail.href,
17225
+ item_image: ((_a = productDetail.selectedVariant.mainImage) === null || _a === void 0 ? void 0 : _a.src) || "",
17226
+ item_brand: ((_b = productDetail.product.brand) === null || _b === void 0 ? void 0 : _b.name) || "",
17195
17227
  item_category: productDetail.product.categories.length
17196
17228
  ? productDetail.product.categories[0].name
17197
17229
  : "",
@@ -17338,6 +17370,22 @@ var Analytics = /** @class */ (function () {
17338
17370
  console.error(err);
17339
17371
  }
17340
17372
  };
17373
+ Analytics.customerLogin = function (email) {
17374
+ try {
17375
+ GoogleTagManager.customerLogin(email);
17376
+ }
17377
+ catch (err) {
17378
+ console.error(err);
17379
+ }
17380
+ };
17381
+ Analytics.customerVisit = function (email) {
17382
+ try {
17383
+ GoogleTagManager.customerVisit(email);
17384
+ }
17385
+ catch (err) {
17386
+ console.error(err);
17387
+ }
17388
+ };
17341
17389
  Analytics.viewCart = function (cart) {
17342
17390
  try {
17343
17391
  if (cart) {
@@ -17418,6 +17466,8 @@ var IkasCustomerStore = /** @class */ (function () {
17418
17466
  if (!response) return [3 /*break*/, 4];
17419
17467
  this.setToken(response.token, response.tokenExpiry);
17420
17468
  this.setCustomer(response.customer);
17469
+ if (this.customer)
17470
+ Analytics.customerLogin(this.customer.email);
17421
17471
  cart = (_a = this.baseStore) === null || _a === void 0 ? void 0 : _a.cartStore.cart;
17422
17472
  if (!cart) return [3 /*break*/, 3];
17423
17473
  return [4 /*yield*/, this.baseStore.cartStore.changeItemQuantity(cart.items[0], cart.items[0].quantity)];
@@ -17660,6 +17710,8 @@ var IkasCustomerStore = /** @class */ (function () {
17660
17710
  case 2:
17661
17711
  _a.sent();
17662
17712
  this._initialized = true;
17713
+ if (this.customer)
17714
+ Analytics.customerVisit(this.customer.email);
17663
17715
  return [2 /*return*/];
17664
17716
  }
17665
17717
  });
package/build/index.js CHANGED
@@ -17188,16 +17188,48 @@ var GoogleTagManager = /** @class */ (function () {
17188
17188
  console.error(err);
17189
17189
  }
17190
17190
  };
17191
+ GoogleTagManager.customerLogin = function (email) {
17192
+ try {
17193
+ var event_11 = {
17194
+ event: "customer_login",
17195
+ email: email,
17196
+ };
17197
+ //@ts-ignore
17198
+ !isServer$2 && window.dataLayer && window.dataLayer.push(event_11);
17199
+ return event_11;
17200
+ }
17201
+ catch (err) {
17202
+ console.error(err);
17203
+ }
17204
+ };
17205
+ GoogleTagManager.customerVisit = function (email) {
17206
+ try {
17207
+ var event_12 = {
17208
+ event: "customer_visit",
17209
+ email: email,
17210
+ };
17211
+ //@ts-ignore
17212
+ !isServer$2 && window.dataLayer && window.dataLayer.push(event_12);
17213
+ return event_12;
17214
+ }
17215
+ catch (err) {
17216
+ console.error(err);
17217
+ }
17218
+ };
17191
17219
  return GoogleTagManager;
17192
17220
  }());
17193
17221
  function productToGTMItem(productDetail, quantity) {
17194
- var _a;
17222
+ var _a, _b;
17195
17223
  if (quantity === void 0) { quantity = 1; }
17196
17224
  return {
17197
17225
  item_name: productDetail.product.name,
17198
17226
  item_id: productDetail.selectedVariant.id,
17227
+ parent_id: productDetail.product.id,
17199
17228
  price: productDetail.selectedVariant.price.finalPrice,
17200
- item_brand: ((_a = productDetail.product.brand) === null || _a === void 0 ? void 0 : _a.name) || "",
17229
+ currency: productDetail.selectedVariant.price.currency,
17230
+ url: "https://" + window.location.hostname + productDetail.href,
17231
+ item_image: ((_a = productDetail.selectedVariant.mainImage) === null || _a === void 0 ? void 0 : _a.src) || "",
17232
+ item_brand: ((_b = productDetail.product.brand) === null || _b === void 0 ? void 0 : _b.name) || "",
17201
17233
  item_category: productDetail.product.categories.length
17202
17234
  ? productDetail.product.categories[0].name
17203
17235
  : "",
@@ -17344,6 +17376,22 @@ var Analytics = /** @class */ (function () {
17344
17376
  console.error(err);
17345
17377
  }
17346
17378
  };
17379
+ Analytics.customerLogin = function (email) {
17380
+ try {
17381
+ GoogleTagManager.customerLogin(email);
17382
+ }
17383
+ catch (err) {
17384
+ console.error(err);
17385
+ }
17386
+ };
17387
+ Analytics.customerVisit = function (email) {
17388
+ try {
17389
+ GoogleTagManager.customerVisit(email);
17390
+ }
17391
+ catch (err) {
17392
+ console.error(err);
17393
+ }
17394
+ };
17347
17395
  Analytics.viewCart = function (cart) {
17348
17396
  try {
17349
17397
  if (cart) {
@@ -17424,6 +17472,8 @@ var IkasCustomerStore = /** @class */ (function () {
17424
17472
  if (!response) return [3 /*break*/, 4];
17425
17473
  this.setToken(response.token, response.tokenExpiry);
17426
17474
  this.setCustomer(response.customer);
17475
+ if (this.customer)
17476
+ Analytics.customerLogin(this.customer.email);
17427
17477
  cart = (_a = this.baseStore) === null || _a === void 0 ? void 0 : _a.cartStore.cart;
17428
17478
  if (!cart) return [3 /*break*/, 3];
17429
17479
  return [4 /*yield*/, this.baseStore.cartStore.changeItemQuantity(cart.items[0], cart.items[0].quantity)];
@@ -17666,6 +17716,8 @@ var IkasCustomerStore = /** @class */ (function () {
17666
17716
  case 2:
17667
17717
  _a.sent();
17668
17718
  this._initialized = true;
17719
+ if (this.customer)
17720
+ Analytics.customerVisit(this.customer.email);
17669
17721
  return [2 /*return*/];
17670
17722
  }
17671
17723
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "0.0.146",
3
+ "version": "0.0.147",
4
4
  "main": "./build/index.js",
5
5
  "module": "./build/index.es.js",
6
6
  "author": "Umut Ozan Yıldırım",