@ikas/storefront 0.0.82 → 0.0.84
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/build/analytics/analytics.d.ts +9 -28
- package/build/analytics/facebookPixel.d.ts +11 -0
- package/build/analytics/googleTagManager.d.ts +170 -0
- package/build/index.es.js +355 -194
- package/build/index.js +355 -194
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -19707,6 +19707,144 @@ function debounce(func, wait, options) {
|
|
|
19707
19707
|
|
|
19708
19708
|
var debounce_1 = debounce;
|
|
19709
19709
|
|
|
19710
|
+
var isServer = typeof window === "undefined";
|
|
19711
|
+
var FacebookPixel = /** @class */ (function () {
|
|
19712
|
+
function FacebookPixel() {
|
|
19713
|
+
mobx.makeAutoObservable(this);
|
|
19714
|
+
}
|
|
19715
|
+
FacebookPixel.productView = function (productDetail) {
|
|
19716
|
+
try {
|
|
19717
|
+
!isServer &&
|
|
19718
|
+
window.fbq &&
|
|
19719
|
+
window.fbq("track", "ViewContent", productToFBPItem(productDetail));
|
|
19720
|
+
return;
|
|
19721
|
+
}
|
|
19722
|
+
catch (err) {
|
|
19723
|
+
console.error(err);
|
|
19724
|
+
}
|
|
19725
|
+
};
|
|
19726
|
+
FacebookPixel.addToCart = function (item, quantity) {
|
|
19727
|
+
try {
|
|
19728
|
+
!isServer &&
|
|
19729
|
+
window.fbq &&
|
|
19730
|
+
window.fbq("track", "AddToCart", item instanceof IkasProductDetail
|
|
19731
|
+
? productToFBPItem(item, quantity)
|
|
19732
|
+
: orderLineItemToFBPItem(item, quantity));
|
|
19733
|
+
return;
|
|
19734
|
+
}
|
|
19735
|
+
catch (err) {
|
|
19736
|
+
console.error(err);
|
|
19737
|
+
}
|
|
19738
|
+
};
|
|
19739
|
+
FacebookPixel.beginCheckout = function (checkout) {
|
|
19740
|
+
try {
|
|
19741
|
+
!isServer &&
|
|
19742
|
+
window.fbq &&
|
|
19743
|
+
window.fbq("track", "InitiateCheckout", beginCheckoutFBPItem(checkout));
|
|
19744
|
+
return;
|
|
19745
|
+
}
|
|
19746
|
+
catch (err) {
|
|
19747
|
+
console.error(err);
|
|
19748
|
+
}
|
|
19749
|
+
};
|
|
19750
|
+
FacebookPixel.purchase = function (checkout, orderId) {
|
|
19751
|
+
try {
|
|
19752
|
+
!isServer &&
|
|
19753
|
+
window.fbq &&
|
|
19754
|
+
window.fbq("track", "Purchase", beginCheckoutFBPItem(checkout));
|
|
19755
|
+
return;
|
|
19756
|
+
}
|
|
19757
|
+
catch (err) {
|
|
19758
|
+
console.error(err);
|
|
19759
|
+
}
|
|
19760
|
+
};
|
|
19761
|
+
FacebookPixel.addToWishlist = function (id) {
|
|
19762
|
+
try {
|
|
19763
|
+
!isServer &&
|
|
19764
|
+
window.fbq &&
|
|
19765
|
+
window.fbq("track", "AddToWishlist", {
|
|
19766
|
+
content_ids: [id],
|
|
19767
|
+
});
|
|
19768
|
+
return;
|
|
19769
|
+
}
|
|
19770
|
+
catch (err) {
|
|
19771
|
+
console.error(err);
|
|
19772
|
+
}
|
|
19773
|
+
};
|
|
19774
|
+
FacebookPixel.search = function (searchKeyword) {
|
|
19775
|
+
try {
|
|
19776
|
+
!isServer &&
|
|
19777
|
+
window.fbq &&
|
|
19778
|
+
window.fbq("track", "Search", {
|
|
19779
|
+
search_string: searchKeyword,
|
|
19780
|
+
});
|
|
19781
|
+
return;
|
|
19782
|
+
}
|
|
19783
|
+
catch (err) {
|
|
19784
|
+
console.error(err);
|
|
19785
|
+
}
|
|
19786
|
+
};
|
|
19787
|
+
FacebookPixel.completeRegistration = function () {
|
|
19788
|
+
try {
|
|
19789
|
+
!isServer &&
|
|
19790
|
+
window.fbq &&
|
|
19791
|
+
window.fbq("track", "CompleteRegistration", {
|
|
19792
|
+
status: true,
|
|
19793
|
+
});
|
|
19794
|
+
return;
|
|
19795
|
+
}
|
|
19796
|
+
catch (err) {
|
|
19797
|
+
console.error(err);
|
|
19798
|
+
}
|
|
19799
|
+
};
|
|
19800
|
+
return FacebookPixel;
|
|
19801
|
+
}());
|
|
19802
|
+
function productToFBPItem(productDetail, quantity) {
|
|
19803
|
+
if (quantity === void 0) { quantity = 1; }
|
|
19804
|
+
return {
|
|
19805
|
+
content_name: productDetail.product.name,
|
|
19806
|
+
content_category: productDetail.product.categories.length > 0
|
|
19807
|
+
? productDetail.product.categories[0].path
|
|
19808
|
+
.map(function (category) { return category.name; })
|
|
19809
|
+
.join(" > ")
|
|
19810
|
+
: "",
|
|
19811
|
+
content_ids: [productDetail.selectedVariant.id],
|
|
19812
|
+
content_type: "product",
|
|
19813
|
+
value: productDetail.selectedVariant.price.finalPrice,
|
|
19814
|
+
currency: productDetail.selectedVariant.price.currency === ""
|
|
19815
|
+
? "TRY"
|
|
19816
|
+
: productDetail.selectedVariant.price.currency,
|
|
19817
|
+
num_items: quantity,
|
|
19818
|
+
};
|
|
19819
|
+
}
|
|
19820
|
+
function beginCheckoutFBPItem(checkout) {
|
|
19821
|
+
var _a, _b, _c, _d;
|
|
19822
|
+
var contentIds = [];
|
|
19823
|
+
var contents = [];
|
|
19824
|
+
(_a = checkout.cart) === null || _a === void 0 ? void 0 : _a.items.map(function (item) {
|
|
19825
|
+
contentIds.push(item.id);
|
|
19826
|
+
contents.push({ id: item.id, quantity: item.quantity });
|
|
19827
|
+
});
|
|
19828
|
+
return {
|
|
19829
|
+
contents: contents,
|
|
19830
|
+
content_category: "",
|
|
19831
|
+
content_ids: contentIds,
|
|
19832
|
+
currency: (_b = checkout.cart) === null || _b === void 0 ? void 0 : _b.items[0].currencyCode,
|
|
19833
|
+
value: (_c = checkout.cart) === null || _c === void 0 ? void 0 : _c.totalPrice,
|
|
19834
|
+
num_items: (_d = checkout.cart) === null || _d === void 0 ? void 0 : _d.items.length,
|
|
19835
|
+
};
|
|
19836
|
+
}
|
|
19837
|
+
function orderLineItemToFBPItem(orderLineItem, quantity) {
|
|
19838
|
+
return {
|
|
19839
|
+
content_name: orderLineItem.variant.name,
|
|
19840
|
+
content_category: "",
|
|
19841
|
+
content_ids: [orderLineItem.variant.id],
|
|
19842
|
+
content_type: "product",
|
|
19843
|
+
value: orderLineItem.finalPrice,
|
|
19844
|
+
currency: orderLineItem.currencyCode,
|
|
19845
|
+
};
|
|
19846
|
+
}
|
|
19847
|
+
|
|
19710
19848
|
var IkasPaymentMethodType;
|
|
19711
19849
|
(function (IkasPaymentMethodType) {
|
|
19712
19850
|
IkasPaymentMethodType["BUY_ONLINE_PAY_AT_STORE"] = "BUY_ONLINE_PAY_AT_STORE";
|
|
@@ -19718,7 +19856,7 @@ var IkasPaymentMethodType;
|
|
|
19718
19856
|
IkasPaymentMethodType["OTHER"] = "OTHER";
|
|
19719
19857
|
})(IkasPaymentMethodType || (IkasPaymentMethodType = {}));
|
|
19720
19858
|
|
|
19721
|
-
var isServer = typeof localStorage === "undefined";
|
|
19859
|
+
var isServer$1 = typeof localStorage === "undefined";
|
|
19722
19860
|
var LS_TOKEN_KEY = "customerToken";
|
|
19723
19861
|
var LS_TOKEN_EXPIRY = "customerTokenExpiry";
|
|
19724
19862
|
var LS_CUSTOMER_KEY = "customer";
|
|
@@ -19987,7 +20125,7 @@ var IkasCustomerStore = /** @class */ (function () {
|
|
|
19987
20125
|
return __generator(this, function (_a) {
|
|
19988
20126
|
switch (_a.label) {
|
|
19989
20127
|
case 0:
|
|
19990
|
-
if (isServer || !this.token)
|
|
20128
|
+
if (isServer$1 || !this.token)
|
|
19991
20129
|
return [2 /*return*/];
|
|
19992
20130
|
return [4 /*yield*/, IkasCustomerAPI.getCustomer()];
|
|
19993
20131
|
case 1:
|
|
@@ -20018,13 +20156,13 @@ var IkasCustomerStore = /** @class */ (function () {
|
|
|
20018
20156
|
});
|
|
20019
20157
|
};
|
|
20020
20158
|
IkasCustomerStore.prototype.setCustomer = function (customer) {
|
|
20021
|
-
if (!isServer) {
|
|
20159
|
+
if (!isServer$1) {
|
|
20022
20160
|
localStorage.setItem(LS_CUSTOMER_KEY, JSON.stringify(customer));
|
|
20023
20161
|
}
|
|
20024
20162
|
this.customer = new IkasCustomer(customer);
|
|
20025
20163
|
};
|
|
20026
20164
|
IkasCustomerStore.prototype.loadCustomer = function () {
|
|
20027
|
-
if (isServer)
|
|
20165
|
+
if (isServer$1)
|
|
20028
20166
|
return;
|
|
20029
20167
|
try {
|
|
20030
20168
|
var customerStr = localStorage.getItem(LS_CUSTOMER_KEY);
|
|
@@ -20035,7 +20173,7 @@ var IkasCustomerStore = /** @class */ (function () {
|
|
|
20035
20173
|
catch (err) { }
|
|
20036
20174
|
};
|
|
20037
20175
|
IkasCustomerStore.prototype.setToken = function (token, tokenExpiry) {
|
|
20038
|
-
if (isServer)
|
|
20176
|
+
if (isServer$1)
|
|
20039
20177
|
return;
|
|
20040
20178
|
this.token = token;
|
|
20041
20179
|
this.tokenExpiry = tokenExpiry;
|
|
@@ -20044,7 +20182,7 @@ var IkasCustomerStore = /** @class */ (function () {
|
|
|
20044
20182
|
apollo.setCustomerToken(token);
|
|
20045
20183
|
};
|
|
20046
20184
|
IkasCustomerStore.prototype.loadToken = function () {
|
|
20047
|
-
if (isServer)
|
|
20185
|
+
if (isServer$1)
|
|
20048
20186
|
return;
|
|
20049
20187
|
var token = localStorage.getItem(LS_TOKEN_KEY);
|
|
20050
20188
|
var tokenExpiry = localStorage.getItem(LS_TOKEN_EXPIRY);
|
|
@@ -20108,7 +20246,7 @@ var NUMBER_ONLY_REGEX = /^\d+$/;
|
|
|
20108
20246
|
var MAX_CARD_NUMBER_LENGTH = 16;
|
|
20109
20247
|
var MAX_CVC_LENGTH = 4;
|
|
20110
20248
|
var USE_DIFFERENT_ADDRESS_KEY = "sAddr";
|
|
20111
|
-
var isServer$
|
|
20249
|
+
var isServer$2 = typeof localStorage === "undefined";
|
|
20112
20250
|
var CheckoutViewModel = /** @class */ (function () {
|
|
20113
20251
|
function CheckoutViewModel(checkout, queryParams, router) {
|
|
20114
20252
|
var _this = this;
|
|
@@ -20660,7 +20798,7 @@ var CheckoutViewModel = /** @class */ (function () {
|
|
|
20660
20798
|
_this.cardData.installmentCount = count;
|
|
20661
20799
|
};
|
|
20662
20800
|
this.changeStep = function (step) {
|
|
20663
|
-
if (!isServer$
|
|
20801
|
+
if (!isServer$2) {
|
|
20664
20802
|
window.location.href = "/checkout/" + _this.checkout.id + "?step=" + step;
|
|
20665
20803
|
// this.router.push(`/checkout/${this.checkout.id}?step=${step}`);
|
|
20666
20804
|
}
|
|
@@ -20821,184 +20959,129 @@ var ErrorType;
|
|
|
20821
20959
|
ErrorType[ErrorType["NO_SHIPPING_ERROR"] = 4] = "NO_SHIPPING_ERROR";
|
|
20822
20960
|
})(ErrorType || (ErrorType = {}));
|
|
20823
20961
|
|
|
20824
|
-
var
|
|
20825
|
-
var
|
|
20826
|
-
|
|
20827
|
-
function Analytics() {
|
|
20962
|
+
var isServer$3 = typeof window === "undefined";
|
|
20963
|
+
var GoogleTagManager = /** @class */ (function () {
|
|
20964
|
+
function GoogleTagManager() {
|
|
20828
20965
|
mobx.makeAutoObservable(this);
|
|
20829
20966
|
}
|
|
20830
|
-
|
|
20967
|
+
GoogleTagManager.pageView = function (url) {
|
|
20831
20968
|
try {
|
|
20832
20969
|
var event_1 = {
|
|
20833
20970
|
event: "page-view",
|
|
20834
20971
|
page: url,
|
|
20835
20972
|
};
|
|
20836
20973
|
//@ts-ignore
|
|
20837
|
-
!isServer$
|
|
20974
|
+
!isServer$3 && window.dataLayer && window.dataLayer.push(event_1);
|
|
20838
20975
|
return event_1;
|
|
20839
20976
|
}
|
|
20840
20977
|
catch (err) {
|
|
20841
20978
|
console.error(err);
|
|
20842
20979
|
}
|
|
20843
20980
|
};
|
|
20844
|
-
|
|
20845
|
-
var serverRuntimeConfig = getConfig__default['default']().serverRuntimeConfig;
|
|
20846
|
-
var gtmId = serverRuntimeConfig.GTM_ID;
|
|
20847
|
-
var fbpId = serverRuntimeConfig.FBP_ID;
|
|
20848
|
-
var event = {};
|
|
20849
|
-
//window._fbq.push(['track', 'ViewContent']
|
|
20981
|
+
GoogleTagManager.productView = function (productDetail) {
|
|
20850
20982
|
try {
|
|
20851
|
-
|
|
20852
|
-
|
|
20853
|
-
|
|
20854
|
-
|
|
20855
|
-
|
|
20856
|
-
|
|
20857
|
-
|
|
20858
|
-
|
|
20859
|
-
|
|
20860
|
-
},
|
|
20861
|
-
};
|
|
20862
|
-
//@ts-ignore
|
|
20863
|
-
!isServer$2 && window.dataLayer && window.dataLayer.push(event);
|
|
20864
|
-
}
|
|
20865
|
-
return event;
|
|
20983
|
+
var event_2 = {
|
|
20984
|
+
event: "view_item",
|
|
20985
|
+
ecommerce: {
|
|
20986
|
+
items: [productToGTMItem(productDetail)],
|
|
20987
|
+
},
|
|
20988
|
+
};
|
|
20989
|
+
//@ts-ignore
|
|
20990
|
+
!isServer$3 && window.dataLayer && window.dataLayer.push(event_2);
|
|
20991
|
+
return event_2;
|
|
20866
20992
|
}
|
|
20867
20993
|
catch (err) {
|
|
20868
20994
|
console.error(err);
|
|
20869
20995
|
}
|
|
20870
20996
|
};
|
|
20871
|
-
|
|
20872
|
-
var serverRuntimeConfig = getConfig__default['default']().serverRuntimeConfig;
|
|
20873
|
-
var gtmId = serverRuntimeConfig.GTM_ID;
|
|
20874
|
-
var fbpId = serverRuntimeConfig.FBP_ID;
|
|
20875
|
-
var event = {};
|
|
20997
|
+
GoogleTagManager.addToCart = function (item, quantity) {
|
|
20876
20998
|
try {
|
|
20877
|
-
|
|
20878
|
-
|
|
20879
|
-
|
|
20880
|
-
|
|
20881
|
-
|
|
20882
|
-
|
|
20883
|
-
|
|
20884
|
-
|
|
20885
|
-
|
|
20886
|
-
|
|
20887
|
-
|
|
20888
|
-
|
|
20889
|
-
|
|
20890
|
-
: orderLineItemToGTMItem(item, quantity),
|
|
20891
|
-
],
|
|
20892
|
-
},
|
|
20893
|
-
};
|
|
20894
|
-
//@ts-ignore
|
|
20895
|
-
!isServer$2 && window.dataLayer && window.dataLayer.push(event);
|
|
20896
|
-
}
|
|
20897
|
-
return event;
|
|
20999
|
+
var event_3 = {
|
|
21000
|
+
event: "add_to_cart",
|
|
21001
|
+
ecommerce: {
|
|
21002
|
+
items: [
|
|
21003
|
+
item instanceof IkasProductDetail
|
|
21004
|
+
? productToGTMItem(item, quantity)
|
|
21005
|
+
: orderLineItemToGTMItem(item, quantity),
|
|
21006
|
+
],
|
|
21007
|
+
},
|
|
21008
|
+
};
|
|
21009
|
+
//@ts-ignore
|
|
21010
|
+
!isServer$3 && window.dataLayer && window.dataLayer.push(event_3);
|
|
21011
|
+
return event_3;
|
|
20898
21012
|
}
|
|
20899
21013
|
catch (err) {
|
|
20900
21014
|
console.error(err);
|
|
20901
21015
|
}
|
|
20902
21016
|
};
|
|
20903
|
-
|
|
20904
|
-
var serverRuntimeConfig = getConfig__default['default']().serverRuntimeConfig;
|
|
20905
|
-
var gtmId = serverRuntimeConfig.GTM_ID;
|
|
20906
|
-
serverRuntimeConfig.FBP_ID;
|
|
20907
|
-
var event = {};
|
|
21017
|
+
GoogleTagManager.removeFromCart = function (item, quantity) {
|
|
20908
21018
|
try {
|
|
20909
|
-
|
|
20910
|
-
event
|
|
20911
|
-
|
|
20912
|
-
|
|
20913
|
-
|
|
20914
|
-
item
|
|
20915
|
-
|
|
20916
|
-
|
|
20917
|
-
|
|
20918
|
-
|
|
20919
|
-
|
|
20920
|
-
|
|
20921
|
-
|
|
20922
|
-
}
|
|
20923
|
-
return event;
|
|
21019
|
+
var event_4 = {
|
|
21020
|
+
event: "remove_from_cart",
|
|
21021
|
+
ecommerce: {
|
|
21022
|
+
items: [
|
|
21023
|
+
item instanceof IkasProductDetail
|
|
21024
|
+
? productToGTMItem(item, quantity)
|
|
21025
|
+
: orderLineItemToGTMItem(item, quantity),
|
|
21026
|
+
],
|
|
21027
|
+
},
|
|
21028
|
+
};
|
|
21029
|
+
//@ts-ignore
|
|
21030
|
+
!isServer$3 && window.dataLayer && window.dataLayer.push(event_4);
|
|
21031
|
+
return event_4;
|
|
20924
21032
|
}
|
|
20925
21033
|
catch (err) {
|
|
20926
21034
|
console.error(err);
|
|
20927
21035
|
}
|
|
20928
21036
|
};
|
|
20929
|
-
|
|
21037
|
+
GoogleTagManager.beginCheckout = function (checkout) {
|
|
20930
21038
|
var _a;
|
|
20931
|
-
var serverRuntimeConfig = getConfig__default['default']().serverRuntimeConfig;
|
|
20932
|
-
var gtmId = serverRuntimeConfig.GTM_ID;
|
|
20933
|
-
var fbpId = serverRuntimeConfig.FBP_ID;
|
|
20934
|
-
var event = {};
|
|
20935
21039
|
try {
|
|
20936
|
-
var
|
|
20937
|
-
|
|
20938
|
-
|
|
20939
|
-
|
|
20940
|
-
|
|
20941
|
-
|
|
20942
|
-
|
|
20943
|
-
}
|
|
20944
|
-
|
|
20945
|
-
|
|
20946
|
-
|
|
20947
|
-
ecommerce: {
|
|
20948
|
-
items: (_a = checkout.cart) === null || _a === void 0 ? void 0 : _a.items.map(function (item) {
|
|
20949
|
-
return orderLineItemToGTMItem(item, item.quantity);
|
|
20950
|
-
}),
|
|
20951
|
-
},
|
|
20952
|
-
};
|
|
20953
|
-
//@ts-ignore
|
|
20954
|
-
!isServer$2 && window.dataLayer && window.dataLayer.push(event);
|
|
20955
|
-
}
|
|
20956
|
-
return event;
|
|
21040
|
+
var event_5 = {
|
|
21041
|
+
event: "begin_checkout",
|
|
21042
|
+
ecommerce: {
|
|
21043
|
+
items: (_a = checkout.cart) === null || _a === void 0 ? void 0 : _a.items.map(function (item) {
|
|
21044
|
+
return orderLineItemToGTMItem(item, item.quantity);
|
|
21045
|
+
}),
|
|
21046
|
+
},
|
|
21047
|
+
};
|
|
21048
|
+
//@ts-ignore
|
|
21049
|
+
!isServer$3 && window.dataLayer && window.dataLayer.push(event_5);
|
|
21050
|
+
return event_5;
|
|
20957
21051
|
}
|
|
20958
21052
|
catch (err) {
|
|
20959
21053
|
console.error(err);
|
|
20960
21054
|
}
|
|
20961
21055
|
};
|
|
20962
|
-
|
|
21056
|
+
GoogleTagManager.purchase = function (checkout, orderId) {
|
|
20963
21057
|
var _a, _b, _c;
|
|
20964
|
-
var serverRuntimeConfig = getConfig__default['default']().serverRuntimeConfig;
|
|
20965
|
-
var gtmId = serverRuntimeConfig.GTM_ID;
|
|
20966
|
-
var fbpId = serverRuntimeConfig.FBP_ID;
|
|
20967
|
-
var event = {};
|
|
20968
21058
|
try {
|
|
20969
|
-
|
|
20970
|
-
|
|
20971
|
-
|
|
20972
|
-
|
|
20973
|
-
|
|
20974
|
-
|
|
20975
|
-
|
|
20976
|
-
|
|
20977
|
-
|
|
20978
|
-
|
|
20979
|
-
|
|
20980
|
-
|
|
20981
|
-
|
|
20982
|
-
|
|
20983
|
-
shipping: "" + checkout.shippingTotal,
|
|
20984
|
-
currency: (_b = checkout.cart) === null || _b === void 0 ? void 0 : _b.currencyCode,
|
|
20985
|
-
coupon: checkout.couponCode,
|
|
20986
|
-
items: (_c = checkout.cart) === null || _c === void 0 ? void 0 : _c.items.map(function (item) {
|
|
20987
|
-
return orderLineItemToGTMItem(item, item.quantity);
|
|
20988
|
-
}),
|
|
20989
|
-
},
|
|
21059
|
+
var event_6 = {
|
|
21060
|
+
event: "purchase",
|
|
21061
|
+
ecommerce: {
|
|
21062
|
+
purchase: {
|
|
21063
|
+
transaction_id: orderId,
|
|
21064
|
+
affiliation: window.location.hostname,
|
|
21065
|
+
value: "" + checkout.totalFinalPrice,
|
|
21066
|
+
tax: "" + ((_a = checkout.cart) === null || _a === void 0 ? void 0 : _a.totalTax),
|
|
21067
|
+
shipping: "" + checkout.shippingTotal,
|
|
21068
|
+
currency: (_b = checkout.cart) === null || _b === void 0 ? void 0 : _b.currencyCode,
|
|
21069
|
+
coupon: checkout.couponCode,
|
|
21070
|
+
items: (_c = checkout.cart) === null || _c === void 0 ? void 0 : _c.items.map(function (item) {
|
|
21071
|
+
return orderLineItemToGTMItem(item, item.quantity);
|
|
21072
|
+
}),
|
|
20990
21073
|
},
|
|
20991
|
-
}
|
|
20992
|
-
|
|
20993
|
-
|
|
20994
|
-
|
|
20995
|
-
return
|
|
21074
|
+
},
|
|
21075
|
+
};
|
|
21076
|
+
//@ts-ignore
|
|
21077
|
+
!isServer$3 && window.dataLayer && window.dataLayer.push(event_6);
|
|
21078
|
+
return event_6;
|
|
20996
21079
|
}
|
|
20997
21080
|
catch (err) {
|
|
20998
21081
|
console.error(err);
|
|
20999
21082
|
}
|
|
21000
21083
|
};
|
|
21001
|
-
|
|
21084
|
+
GoogleTagManager.checkoutStep = function (checkout, step) {
|
|
21002
21085
|
var _a;
|
|
21003
21086
|
var eventName = "";
|
|
21004
21087
|
if (step === CheckoutStep.INFO)
|
|
@@ -21010,7 +21093,7 @@ var Analytics = /** @class */ (function () {
|
|
|
21010
21093
|
else if (step === CheckoutStep.SUCCESS)
|
|
21011
21094
|
eventName = "checkout_success";
|
|
21012
21095
|
try {
|
|
21013
|
-
var
|
|
21096
|
+
var event_7 = {
|
|
21014
21097
|
event: eventName,
|
|
21015
21098
|
ecommerce: {
|
|
21016
21099
|
items: (_a = checkout.cart) === null || _a === void 0 ? void 0 : _a.items.map(function (item) {
|
|
@@ -21019,14 +21102,14 @@ var Analytics = /** @class */ (function () {
|
|
|
21019
21102
|
},
|
|
21020
21103
|
};
|
|
21021
21104
|
//@ts-ignore
|
|
21022
|
-
!isServer$
|
|
21023
|
-
return
|
|
21105
|
+
!isServer$3 && window.dataLayer && window.dataLayer.push(event_7);
|
|
21106
|
+
return event_7;
|
|
21024
21107
|
}
|
|
21025
21108
|
catch (err) {
|
|
21026
21109
|
console.error(err);
|
|
21027
21110
|
}
|
|
21028
21111
|
};
|
|
21029
|
-
|
|
21112
|
+
GoogleTagManager.disableHTML = function () {
|
|
21030
21113
|
try {
|
|
21031
21114
|
var data = {
|
|
21032
21115
|
"gtm.blocklist": [
|
|
@@ -21037,19 +21120,19 @@ var Analytics = /** @class */ (function () {
|
|
|
21037
21120
|
],
|
|
21038
21121
|
};
|
|
21039
21122
|
//@ts-ignore
|
|
21040
|
-
!isServer$
|
|
21123
|
+
!isServer$3 && window.dataLayer && window.dataLayer.push(data);
|
|
21041
21124
|
}
|
|
21042
21125
|
catch (err) {
|
|
21043
21126
|
console.error(err);
|
|
21044
21127
|
}
|
|
21045
21128
|
};
|
|
21046
|
-
|
|
21129
|
+
GoogleTagManager.addToWishlist = function (id) {
|
|
21047
21130
|
var serverRuntimeConfig = getConfig__default['default']().serverRuntimeConfig;
|
|
21048
21131
|
var fbpId = serverRuntimeConfig.FBP_ID;
|
|
21049
21132
|
var event = {};
|
|
21050
21133
|
try {
|
|
21051
21134
|
if (fbpId) {
|
|
21052
|
-
!isServer$
|
|
21135
|
+
!isServer$3 &&
|
|
21053
21136
|
window.fbq("track", "AddToWishlist", {
|
|
21054
21137
|
content_ids: [id],
|
|
21055
21138
|
});
|
|
@@ -21060,13 +21143,13 @@ var Analytics = /** @class */ (function () {
|
|
|
21060
21143
|
console.error(err);
|
|
21061
21144
|
}
|
|
21062
21145
|
};
|
|
21063
|
-
|
|
21146
|
+
GoogleTagManager.search = function (searchKeyword) {
|
|
21064
21147
|
var serverRuntimeConfig = getConfig__default['default']().serverRuntimeConfig;
|
|
21065
21148
|
var fbpId = serverRuntimeConfig.FBP_ID;
|
|
21066
21149
|
var event = {};
|
|
21067
21150
|
try {
|
|
21068
21151
|
if (fbpId) {
|
|
21069
|
-
!isServer$
|
|
21152
|
+
!isServer$3 &&
|
|
21070
21153
|
window.fbq("track", "Search", {
|
|
21071
21154
|
search_string: searchKeyword,
|
|
21072
21155
|
});
|
|
@@ -21077,13 +21160,13 @@ var Analytics = /** @class */ (function () {
|
|
|
21077
21160
|
console.error(err);
|
|
21078
21161
|
}
|
|
21079
21162
|
};
|
|
21080
|
-
|
|
21163
|
+
GoogleTagManager.completeRegistration = function () {
|
|
21081
21164
|
var serverRuntimeConfig = getConfig__default['default']().serverRuntimeConfig;
|
|
21082
21165
|
var fbpId = serverRuntimeConfig.FBP_ID;
|
|
21083
21166
|
var event = {};
|
|
21084
21167
|
try {
|
|
21085
21168
|
if (fbpId) {
|
|
21086
|
-
!isServer$
|
|
21169
|
+
!isServer$3 &&
|
|
21087
21170
|
window.fbq("track", "CompleteRegistration", {
|
|
21088
21171
|
status: true,
|
|
21089
21172
|
});
|
|
@@ -21094,7 +21177,7 @@ var Analytics = /** @class */ (function () {
|
|
|
21094
21177
|
console.error(err);
|
|
21095
21178
|
}
|
|
21096
21179
|
};
|
|
21097
|
-
return
|
|
21180
|
+
return GoogleTagManager;
|
|
21098
21181
|
}());
|
|
21099
21182
|
function productToGTMItem(productDetail, quantity) {
|
|
21100
21183
|
var _a;
|
|
@@ -21125,49 +21208,6 @@ function productToGTMItem(productDetail, quantity) {
|
|
|
21125
21208
|
quantity: quantity,
|
|
21126
21209
|
};
|
|
21127
21210
|
}
|
|
21128
|
-
function productToFBPItem(productDetail, quantity) {
|
|
21129
|
-
if (quantity === void 0) { quantity = 1; }
|
|
21130
|
-
return {
|
|
21131
|
-
content_name: productDetail.product.name,
|
|
21132
|
-
content_category: productDetail.product.categories.length > 0
|
|
21133
|
-
? productDetail.product.categories[0].path
|
|
21134
|
-
.map(function (category) { return category.name; })
|
|
21135
|
-
.join(" > ")
|
|
21136
|
-
: "",
|
|
21137
|
-
content_ids: [productDetail.selectedVariant.id],
|
|
21138
|
-
content_type: "product",
|
|
21139
|
-
value: productDetail.selectedVariant.price.finalPrice,
|
|
21140
|
-
currency: productDetail.selectedVariant.price.currency,
|
|
21141
|
-
num_items: quantity,
|
|
21142
|
-
};
|
|
21143
|
-
}
|
|
21144
|
-
function beginCheckoutFBPItem(checkout) {
|
|
21145
|
-
var _a, _b, _c, _d;
|
|
21146
|
-
var contentIds = [];
|
|
21147
|
-
var contents = [];
|
|
21148
|
-
(_a = checkout.cart) === null || _a === void 0 ? void 0 : _a.items.map(function (item) {
|
|
21149
|
-
contentIds.push(item.id);
|
|
21150
|
-
contents.push({ id: item.id, quantity: item.quantity });
|
|
21151
|
-
});
|
|
21152
|
-
return {
|
|
21153
|
-
contents: contents,
|
|
21154
|
-
content_category: "",
|
|
21155
|
-
content_ids: contentIds,
|
|
21156
|
-
currency: (_b = checkout.cart) === null || _b === void 0 ? void 0 : _b.items[0].currencyCode,
|
|
21157
|
-
value: (_c = checkout.cart) === null || _c === void 0 ? void 0 : _c.totalPrice,
|
|
21158
|
-
num_items: (_d = checkout.cart) === null || _d === void 0 ? void 0 : _d.items.length,
|
|
21159
|
-
};
|
|
21160
|
-
}
|
|
21161
|
-
function orderLineItemToFBPItem(orderLineItem, quantity) {
|
|
21162
|
-
return {
|
|
21163
|
-
content_name: orderLineItem.variant.name,
|
|
21164
|
-
content_category: "",
|
|
21165
|
-
content_ids: [orderLineItem.variant.id],
|
|
21166
|
-
content_type: "product",
|
|
21167
|
-
value: orderLineItem.finalPrice,
|
|
21168
|
-
currency: orderLineItem.currencyCode,
|
|
21169
|
-
};
|
|
21170
|
-
}
|
|
21171
21211
|
function orderLineItemToGTMItem(orderLineItem, quantity) {
|
|
21172
21212
|
if (quantity === void 0) { quantity = 1; }
|
|
21173
21213
|
return {
|
|
@@ -21189,6 +21229,127 @@ function orderLineItemToGTMItem(orderLineItem, quantity) {
|
|
|
21189
21229
|
};
|
|
21190
21230
|
}
|
|
21191
21231
|
|
|
21232
|
+
var LS_BEGIN_CHECKOUT_KEY = "gtmBeginCheckout";
|
|
21233
|
+
var isServer$4 = typeof window === "undefined";
|
|
21234
|
+
var Analytics = /** @class */ (function () {
|
|
21235
|
+
function Analytics() {
|
|
21236
|
+
mobx.makeAutoObservable(this);
|
|
21237
|
+
}
|
|
21238
|
+
Analytics.pageView = function (url) {
|
|
21239
|
+
try {
|
|
21240
|
+
var event_1 = {
|
|
21241
|
+
event: "page-view",
|
|
21242
|
+
page: url,
|
|
21243
|
+
};
|
|
21244
|
+
//@ts-ignore
|
|
21245
|
+
!isServer$4 && window.dataLayer && window.dataLayer.push(event_1);
|
|
21246
|
+
return event_1;
|
|
21247
|
+
}
|
|
21248
|
+
catch (err) {
|
|
21249
|
+
console.error(err);
|
|
21250
|
+
}
|
|
21251
|
+
};
|
|
21252
|
+
Analytics.productView = function (productDetail) {
|
|
21253
|
+
try {
|
|
21254
|
+
FacebookPixel.productView(productDetail);
|
|
21255
|
+
GoogleTagManager.productView(productDetail);
|
|
21256
|
+
return;
|
|
21257
|
+
}
|
|
21258
|
+
catch (err) {
|
|
21259
|
+
console.error(err);
|
|
21260
|
+
}
|
|
21261
|
+
};
|
|
21262
|
+
Analytics.addToCart = function (item, quantity) {
|
|
21263
|
+
try {
|
|
21264
|
+
FacebookPixel.addToCart(item, quantity);
|
|
21265
|
+
GoogleTagManager.addToCart(item, quantity);
|
|
21266
|
+
return;
|
|
21267
|
+
}
|
|
21268
|
+
catch (err) {
|
|
21269
|
+
console.error(err);
|
|
21270
|
+
}
|
|
21271
|
+
};
|
|
21272
|
+
Analytics.removeFromCart = function (item, quantity) {
|
|
21273
|
+
try {
|
|
21274
|
+
GoogleTagManager.removeFromCart(item, quantity);
|
|
21275
|
+
return;
|
|
21276
|
+
}
|
|
21277
|
+
catch (err) {
|
|
21278
|
+
console.error(err);
|
|
21279
|
+
}
|
|
21280
|
+
};
|
|
21281
|
+
Analytics.beginCheckout = function (checkout) {
|
|
21282
|
+
try {
|
|
21283
|
+
var beginCheckout = localStorage.getItem(LS_BEGIN_CHECKOUT_KEY);
|
|
21284
|
+
if (beginCheckout && checkout.id === beginCheckout)
|
|
21285
|
+
return;
|
|
21286
|
+
localStorage.setItem(LS_BEGIN_CHECKOUT_KEY, checkout.id);
|
|
21287
|
+
FacebookPixel.beginCheckout(checkout);
|
|
21288
|
+
GoogleTagManager.beginCheckout(checkout);
|
|
21289
|
+
return;
|
|
21290
|
+
}
|
|
21291
|
+
catch (err) {
|
|
21292
|
+
console.error(err);
|
|
21293
|
+
}
|
|
21294
|
+
};
|
|
21295
|
+
Analytics.purchase = function (checkout, orderId) {
|
|
21296
|
+
try {
|
|
21297
|
+
localStorage.removeItem(LS_BEGIN_CHECKOUT_KEY);
|
|
21298
|
+
FacebookPixel.purchase(checkout, orderId);
|
|
21299
|
+
GoogleTagManager.purchase(checkout, orderId);
|
|
21300
|
+
return;
|
|
21301
|
+
}
|
|
21302
|
+
catch (err) {
|
|
21303
|
+
console.error(err);
|
|
21304
|
+
}
|
|
21305
|
+
};
|
|
21306
|
+
Analytics.checkoutStep = function (checkout, step) {
|
|
21307
|
+
try {
|
|
21308
|
+
GoogleTagManager.checkoutStep(checkout, step);
|
|
21309
|
+
return;
|
|
21310
|
+
}
|
|
21311
|
+
catch (err) {
|
|
21312
|
+
console.error(err);
|
|
21313
|
+
}
|
|
21314
|
+
};
|
|
21315
|
+
Analytics.disableHTML = function () {
|
|
21316
|
+
try {
|
|
21317
|
+
GoogleTagManager.disableHTML();
|
|
21318
|
+
}
|
|
21319
|
+
catch (err) {
|
|
21320
|
+
console.error(err);
|
|
21321
|
+
}
|
|
21322
|
+
};
|
|
21323
|
+
Analytics.addToWishlist = function (id) {
|
|
21324
|
+
try {
|
|
21325
|
+
FacebookPixel.addToWishlist(id);
|
|
21326
|
+
return;
|
|
21327
|
+
}
|
|
21328
|
+
catch (err) {
|
|
21329
|
+
console.error(err);
|
|
21330
|
+
}
|
|
21331
|
+
};
|
|
21332
|
+
Analytics.search = function (searchKeyword) {
|
|
21333
|
+
try {
|
|
21334
|
+
FacebookPixel.search(searchKeyword);
|
|
21335
|
+
return;
|
|
21336
|
+
}
|
|
21337
|
+
catch (err) {
|
|
21338
|
+
console.error(err);
|
|
21339
|
+
}
|
|
21340
|
+
};
|
|
21341
|
+
Analytics.completeRegistration = function () {
|
|
21342
|
+
try {
|
|
21343
|
+
FacebookPixel.completeRegistration();
|
|
21344
|
+
return;
|
|
21345
|
+
}
|
|
21346
|
+
catch (err) {
|
|
21347
|
+
console.error(err);
|
|
21348
|
+
}
|
|
21349
|
+
};
|
|
21350
|
+
return Analytics;
|
|
21351
|
+
}());
|
|
21352
|
+
|
|
21192
21353
|
var AnalyticsHead = function (_a) {
|
|
21193
21354
|
var blockHTML = _a.blockHTML;
|
|
21194
21355
|
var serverRuntimeConfig = getConfig__default['default']().serverRuntimeConfig;
|