@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.es.js
CHANGED
|
@@ -19724,6 +19724,144 @@ function debounce(func, wait, options) {
|
|
|
19724
19724
|
|
|
19725
19725
|
var debounce_1 = debounce;
|
|
19726
19726
|
|
|
19727
|
+
var isServer = typeof window === "undefined";
|
|
19728
|
+
var FacebookPixel = /** @class */ (function () {
|
|
19729
|
+
function FacebookPixel() {
|
|
19730
|
+
makeAutoObservable(this);
|
|
19731
|
+
}
|
|
19732
|
+
FacebookPixel.productView = function (productDetail) {
|
|
19733
|
+
try {
|
|
19734
|
+
!isServer &&
|
|
19735
|
+
window.fbq &&
|
|
19736
|
+
window.fbq("track", "ViewContent", productToFBPItem(productDetail));
|
|
19737
|
+
return;
|
|
19738
|
+
}
|
|
19739
|
+
catch (err) {
|
|
19740
|
+
console.error(err);
|
|
19741
|
+
}
|
|
19742
|
+
};
|
|
19743
|
+
FacebookPixel.addToCart = function (item, quantity) {
|
|
19744
|
+
try {
|
|
19745
|
+
!isServer &&
|
|
19746
|
+
window.fbq &&
|
|
19747
|
+
window.fbq("track", "AddToCart", item instanceof IkasProductDetail
|
|
19748
|
+
? productToFBPItem(item, quantity)
|
|
19749
|
+
: orderLineItemToFBPItem(item, quantity));
|
|
19750
|
+
return;
|
|
19751
|
+
}
|
|
19752
|
+
catch (err) {
|
|
19753
|
+
console.error(err);
|
|
19754
|
+
}
|
|
19755
|
+
};
|
|
19756
|
+
FacebookPixel.beginCheckout = function (checkout) {
|
|
19757
|
+
try {
|
|
19758
|
+
!isServer &&
|
|
19759
|
+
window.fbq &&
|
|
19760
|
+
window.fbq("track", "InitiateCheckout", beginCheckoutFBPItem(checkout));
|
|
19761
|
+
return;
|
|
19762
|
+
}
|
|
19763
|
+
catch (err) {
|
|
19764
|
+
console.error(err);
|
|
19765
|
+
}
|
|
19766
|
+
};
|
|
19767
|
+
FacebookPixel.purchase = function (checkout, orderId) {
|
|
19768
|
+
try {
|
|
19769
|
+
!isServer &&
|
|
19770
|
+
window.fbq &&
|
|
19771
|
+
window.fbq("track", "Purchase", beginCheckoutFBPItem(checkout));
|
|
19772
|
+
return;
|
|
19773
|
+
}
|
|
19774
|
+
catch (err) {
|
|
19775
|
+
console.error(err);
|
|
19776
|
+
}
|
|
19777
|
+
};
|
|
19778
|
+
FacebookPixel.addToWishlist = function (id) {
|
|
19779
|
+
try {
|
|
19780
|
+
!isServer &&
|
|
19781
|
+
window.fbq &&
|
|
19782
|
+
window.fbq("track", "AddToWishlist", {
|
|
19783
|
+
content_ids: [id],
|
|
19784
|
+
});
|
|
19785
|
+
return;
|
|
19786
|
+
}
|
|
19787
|
+
catch (err) {
|
|
19788
|
+
console.error(err);
|
|
19789
|
+
}
|
|
19790
|
+
};
|
|
19791
|
+
FacebookPixel.search = function (searchKeyword) {
|
|
19792
|
+
try {
|
|
19793
|
+
!isServer &&
|
|
19794
|
+
window.fbq &&
|
|
19795
|
+
window.fbq("track", "Search", {
|
|
19796
|
+
search_string: searchKeyword,
|
|
19797
|
+
});
|
|
19798
|
+
return;
|
|
19799
|
+
}
|
|
19800
|
+
catch (err) {
|
|
19801
|
+
console.error(err);
|
|
19802
|
+
}
|
|
19803
|
+
};
|
|
19804
|
+
FacebookPixel.completeRegistration = function () {
|
|
19805
|
+
try {
|
|
19806
|
+
!isServer &&
|
|
19807
|
+
window.fbq &&
|
|
19808
|
+
window.fbq("track", "CompleteRegistration", {
|
|
19809
|
+
status: true,
|
|
19810
|
+
});
|
|
19811
|
+
return;
|
|
19812
|
+
}
|
|
19813
|
+
catch (err) {
|
|
19814
|
+
console.error(err);
|
|
19815
|
+
}
|
|
19816
|
+
};
|
|
19817
|
+
return FacebookPixel;
|
|
19818
|
+
}());
|
|
19819
|
+
function productToFBPItem(productDetail, quantity) {
|
|
19820
|
+
if (quantity === void 0) { quantity = 1; }
|
|
19821
|
+
return {
|
|
19822
|
+
content_name: productDetail.product.name,
|
|
19823
|
+
content_category: productDetail.product.categories.length > 0
|
|
19824
|
+
? productDetail.product.categories[0].path
|
|
19825
|
+
.map(function (category) { return category.name; })
|
|
19826
|
+
.join(" > ")
|
|
19827
|
+
: "",
|
|
19828
|
+
content_ids: [productDetail.selectedVariant.id],
|
|
19829
|
+
content_type: "product",
|
|
19830
|
+
value: productDetail.selectedVariant.price.finalPrice,
|
|
19831
|
+
currency: productDetail.selectedVariant.price.currency === ""
|
|
19832
|
+
? "TRY"
|
|
19833
|
+
: productDetail.selectedVariant.price.currency,
|
|
19834
|
+
num_items: quantity,
|
|
19835
|
+
};
|
|
19836
|
+
}
|
|
19837
|
+
function beginCheckoutFBPItem(checkout) {
|
|
19838
|
+
var _a, _b, _c, _d;
|
|
19839
|
+
var contentIds = [];
|
|
19840
|
+
var contents = [];
|
|
19841
|
+
(_a = checkout.cart) === null || _a === void 0 ? void 0 : _a.items.map(function (item) {
|
|
19842
|
+
contentIds.push(item.id);
|
|
19843
|
+
contents.push({ id: item.id, quantity: item.quantity });
|
|
19844
|
+
});
|
|
19845
|
+
return {
|
|
19846
|
+
contents: contents,
|
|
19847
|
+
content_category: "",
|
|
19848
|
+
content_ids: contentIds,
|
|
19849
|
+
currency: (_b = checkout.cart) === null || _b === void 0 ? void 0 : _b.items[0].currencyCode,
|
|
19850
|
+
value: (_c = checkout.cart) === null || _c === void 0 ? void 0 : _c.totalPrice,
|
|
19851
|
+
num_items: (_d = checkout.cart) === null || _d === void 0 ? void 0 : _d.items.length,
|
|
19852
|
+
};
|
|
19853
|
+
}
|
|
19854
|
+
function orderLineItemToFBPItem(orderLineItem, quantity) {
|
|
19855
|
+
return {
|
|
19856
|
+
content_name: orderLineItem.variant.name,
|
|
19857
|
+
content_category: "",
|
|
19858
|
+
content_ids: [orderLineItem.variant.id],
|
|
19859
|
+
content_type: "product",
|
|
19860
|
+
value: orderLineItem.finalPrice,
|
|
19861
|
+
currency: orderLineItem.currencyCode,
|
|
19862
|
+
};
|
|
19863
|
+
}
|
|
19864
|
+
|
|
19727
19865
|
var IkasPaymentMethodType;
|
|
19728
19866
|
(function (IkasPaymentMethodType) {
|
|
19729
19867
|
IkasPaymentMethodType["BUY_ONLINE_PAY_AT_STORE"] = "BUY_ONLINE_PAY_AT_STORE";
|
|
@@ -19735,7 +19873,7 @@ var IkasPaymentMethodType;
|
|
|
19735
19873
|
IkasPaymentMethodType["OTHER"] = "OTHER";
|
|
19736
19874
|
})(IkasPaymentMethodType || (IkasPaymentMethodType = {}));
|
|
19737
19875
|
|
|
19738
|
-
var isServer = typeof localStorage === "undefined";
|
|
19876
|
+
var isServer$1 = typeof localStorage === "undefined";
|
|
19739
19877
|
var LS_TOKEN_KEY = "customerToken";
|
|
19740
19878
|
var LS_TOKEN_EXPIRY = "customerTokenExpiry";
|
|
19741
19879
|
var LS_CUSTOMER_KEY = "customer";
|
|
@@ -20004,7 +20142,7 @@ var IkasCustomerStore = /** @class */ (function () {
|
|
|
20004
20142
|
return __generator(this, function (_a) {
|
|
20005
20143
|
switch (_a.label) {
|
|
20006
20144
|
case 0:
|
|
20007
|
-
if (isServer || !this.token)
|
|
20145
|
+
if (isServer$1 || !this.token)
|
|
20008
20146
|
return [2 /*return*/];
|
|
20009
20147
|
return [4 /*yield*/, IkasCustomerAPI.getCustomer()];
|
|
20010
20148
|
case 1:
|
|
@@ -20035,13 +20173,13 @@ var IkasCustomerStore = /** @class */ (function () {
|
|
|
20035
20173
|
});
|
|
20036
20174
|
};
|
|
20037
20175
|
IkasCustomerStore.prototype.setCustomer = function (customer) {
|
|
20038
|
-
if (!isServer) {
|
|
20176
|
+
if (!isServer$1) {
|
|
20039
20177
|
localStorage.setItem(LS_CUSTOMER_KEY, JSON.stringify(customer));
|
|
20040
20178
|
}
|
|
20041
20179
|
this.customer = new IkasCustomer(customer);
|
|
20042
20180
|
};
|
|
20043
20181
|
IkasCustomerStore.prototype.loadCustomer = function () {
|
|
20044
|
-
if (isServer)
|
|
20182
|
+
if (isServer$1)
|
|
20045
20183
|
return;
|
|
20046
20184
|
try {
|
|
20047
20185
|
var customerStr = localStorage.getItem(LS_CUSTOMER_KEY);
|
|
@@ -20052,7 +20190,7 @@ var IkasCustomerStore = /** @class */ (function () {
|
|
|
20052
20190
|
catch (err) { }
|
|
20053
20191
|
};
|
|
20054
20192
|
IkasCustomerStore.prototype.setToken = function (token, tokenExpiry) {
|
|
20055
|
-
if (isServer)
|
|
20193
|
+
if (isServer$1)
|
|
20056
20194
|
return;
|
|
20057
20195
|
this.token = token;
|
|
20058
20196
|
this.tokenExpiry = tokenExpiry;
|
|
@@ -20061,7 +20199,7 @@ var IkasCustomerStore = /** @class */ (function () {
|
|
|
20061
20199
|
apollo.setCustomerToken(token);
|
|
20062
20200
|
};
|
|
20063
20201
|
IkasCustomerStore.prototype.loadToken = function () {
|
|
20064
|
-
if (isServer)
|
|
20202
|
+
if (isServer$1)
|
|
20065
20203
|
return;
|
|
20066
20204
|
var token = localStorage.getItem(LS_TOKEN_KEY);
|
|
20067
20205
|
var tokenExpiry = localStorage.getItem(LS_TOKEN_EXPIRY);
|
|
@@ -20125,7 +20263,7 @@ var NUMBER_ONLY_REGEX = /^\d+$/;
|
|
|
20125
20263
|
var MAX_CARD_NUMBER_LENGTH = 16;
|
|
20126
20264
|
var MAX_CVC_LENGTH = 4;
|
|
20127
20265
|
var USE_DIFFERENT_ADDRESS_KEY = "sAddr";
|
|
20128
|
-
var isServer$
|
|
20266
|
+
var isServer$2 = typeof localStorage === "undefined";
|
|
20129
20267
|
var CheckoutViewModel = /** @class */ (function () {
|
|
20130
20268
|
function CheckoutViewModel(checkout, queryParams, router) {
|
|
20131
20269
|
var _this = this;
|
|
@@ -20677,7 +20815,7 @@ var CheckoutViewModel = /** @class */ (function () {
|
|
|
20677
20815
|
_this.cardData.installmentCount = count;
|
|
20678
20816
|
};
|
|
20679
20817
|
this.changeStep = function (step) {
|
|
20680
|
-
if (!isServer$
|
|
20818
|
+
if (!isServer$2) {
|
|
20681
20819
|
window.location.href = "/checkout/" + _this.checkout.id + "?step=" + step;
|
|
20682
20820
|
// this.router.push(`/checkout/${this.checkout.id}?step=${step}`);
|
|
20683
20821
|
}
|
|
@@ -20838,184 +20976,129 @@ var ErrorType;
|
|
|
20838
20976
|
ErrorType[ErrorType["NO_SHIPPING_ERROR"] = 4] = "NO_SHIPPING_ERROR";
|
|
20839
20977
|
})(ErrorType || (ErrorType = {}));
|
|
20840
20978
|
|
|
20841
|
-
var
|
|
20842
|
-
var
|
|
20843
|
-
|
|
20844
|
-
function Analytics() {
|
|
20979
|
+
var isServer$3 = typeof window === "undefined";
|
|
20980
|
+
var GoogleTagManager = /** @class */ (function () {
|
|
20981
|
+
function GoogleTagManager() {
|
|
20845
20982
|
makeAutoObservable(this);
|
|
20846
20983
|
}
|
|
20847
|
-
|
|
20984
|
+
GoogleTagManager.pageView = function (url) {
|
|
20848
20985
|
try {
|
|
20849
20986
|
var event_1 = {
|
|
20850
20987
|
event: "page-view",
|
|
20851
20988
|
page: url,
|
|
20852
20989
|
};
|
|
20853
20990
|
//@ts-ignore
|
|
20854
|
-
!isServer$
|
|
20991
|
+
!isServer$3 && window.dataLayer && window.dataLayer.push(event_1);
|
|
20855
20992
|
return event_1;
|
|
20856
20993
|
}
|
|
20857
20994
|
catch (err) {
|
|
20858
20995
|
console.error(err);
|
|
20859
20996
|
}
|
|
20860
20997
|
};
|
|
20861
|
-
|
|
20862
|
-
var serverRuntimeConfig = getConfig().serverRuntimeConfig;
|
|
20863
|
-
var gtmId = serverRuntimeConfig.GTM_ID;
|
|
20864
|
-
var fbpId = serverRuntimeConfig.FBP_ID;
|
|
20865
|
-
var event = {};
|
|
20866
|
-
//window._fbq.push(['track', 'ViewContent']
|
|
20998
|
+
GoogleTagManager.productView = function (productDetail) {
|
|
20867
20999
|
try {
|
|
20868
|
-
|
|
20869
|
-
|
|
20870
|
-
|
|
20871
|
-
|
|
20872
|
-
|
|
20873
|
-
|
|
20874
|
-
|
|
20875
|
-
|
|
20876
|
-
|
|
20877
|
-
},
|
|
20878
|
-
};
|
|
20879
|
-
//@ts-ignore
|
|
20880
|
-
!isServer$2 && window.dataLayer && window.dataLayer.push(event);
|
|
20881
|
-
}
|
|
20882
|
-
return event;
|
|
21000
|
+
var event_2 = {
|
|
21001
|
+
event: "view_item",
|
|
21002
|
+
ecommerce: {
|
|
21003
|
+
items: [productToGTMItem(productDetail)],
|
|
21004
|
+
},
|
|
21005
|
+
};
|
|
21006
|
+
//@ts-ignore
|
|
21007
|
+
!isServer$3 && window.dataLayer && window.dataLayer.push(event_2);
|
|
21008
|
+
return event_2;
|
|
20883
21009
|
}
|
|
20884
21010
|
catch (err) {
|
|
20885
21011
|
console.error(err);
|
|
20886
21012
|
}
|
|
20887
21013
|
};
|
|
20888
|
-
|
|
20889
|
-
var serverRuntimeConfig = getConfig().serverRuntimeConfig;
|
|
20890
|
-
var gtmId = serverRuntimeConfig.GTM_ID;
|
|
20891
|
-
var fbpId = serverRuntimeConfig.FBP_ID;
|
|
20892
|
-
var event = {};
|
|
21014
|
+
GoogleTagManager.addToCart = function (item, quantity) {
|
|
20893
21015
|
try {
|
|
20894
|
-
|
|
20895
|
-
|
|
20896
|
-
|
|
20897
|
-
|
|
20898
|
-
|
|
20899
|
-
|
|
20900
|
-
|
|
20901
|
-
|
|
20902
|
-
|
|
20903
|
-
|
|
20904
|
-
|
|
20905
|
-
|
|
20906
|
-
|
|
20907
|
-
: orderLineItemToGTMItem(item, quantity),
|
|
20908
|
-
],
|
|
20909
|
-
},
|
|
20910
|
-
};
|
|
20911
|
-
//@ts-ignore
|
|
20912
|
-
!isServer$2 && window.dataLayer && window.dataLayer.push(event);
|
|
20913
|
-
}
|
|
20914
|
-
return event;
|
|
21016
|
+
var event_3 = {
|
|
21017
|
+
event: "add_to_cart",
|
|
21018
|
+
ecommerce: {
|
|
21019
|
+
items: [
|
|
21020
|
+
item instanceof IkasProductDetail
|
|
21021
|
+
? productToGTMItem(item, quantity)
|
|
21022
|
+
: orderLineItemToGTMItem(item, quantity),
|
|
21023
|
+
],
|
|
21024
|
+
},
|
|
21025
|
+
};
|
|
21026
|
+
//@ts-ignore
|
|
21027
|
+
!isServer$3 && window.dataLayer && window.dataLayer.push(event_3);
|
|
21028
|
+
return event_3;
|
|
20915
21029
|
}
|
|
20916
21030
|
catch (err) {
|
|
20917
21031
|
console.error(err);
|
|
20918
21032
|
}
|
|
20919
21033
|
};
|
|
20920
|
-
|
|
20921
|
-
var serverRuntimeConfig = getConfig().serverRuntimeConfig;
|
|
20922
|
-
var gtmId = serverRuntimeConfig.GTM_ID;
|
|
20923
|
-
serverRuntimeConfig.FBP_ID;
|
|
20924
|
-
var event = {};
|
|
21034
|
+
GoogleTagManager.removeFromCart = function (item, quantity) {
|
|
20925
21035
|
try {
|
|
20926
|
-
|
|
20927
|
-
event
|
|
20928
|
-
|
|
20929
|
-
|
|
20930
|
-
|
|
20931
|
-
item
|
|
20932
|
-
|
|
20933
|
-
|
|
20934
|
-
|
|
20935
|
-
|
|
20936
|
-
|
|
20937
|
-
|
|
20938
|
-
|
|
20939
|
-
}
|
|
20940
|
-
return event;
|
|
21036
|
+
var event_4 = {
|
|
21037
|
+
event: "remove_from_cart",
|
|
21038
|
+
ecommerce: {
|
|
21039
|
+
items: [
|
|
21040
|
+
item instanceof IkasProductDetail
|
|
21041
|
+
? productToGTMItem(item, quantity)
|
|
21042
|
+
: orderLineItemToGTMItem(item, quantity),
|
|
21043
|
+
],
|
|
21044
|
+
},
|
|
21045
|
+
};
|
|
21046
|
+
//@ts-ignore
|
|
21047
|
+
!isServer$3 && window.dataLayer && window.dataLayer.push(event_4);
|
|
21048
|
+
return event_4;
|
|
20941
21049
|
}
|
|
20942
21050
|
catch (err) {
|
|
20943
21051
|
console.error(err);
|
|
20944
21052
|
}
|
|
20945
21053
|
};
|
|
20946
|
-
|
|
21054
|
+
GoogleTagManager.beginCheckout = function (checkout) {
|
|
20947
21055
|
var _a;
|
|
20948
|
-
var serverRuntimeConfig = getConfig().serverRuntimeConfig;
|
|
20949
|
-
var gtmId = serverRuntimeConfig.GTM_ID;
|
|
20950
|
-
var fbpId = serverRuntimeConfig.FBP_ID;
|
|
20951
|
-
var event = {};
|
|
20952
21056
|
try {
|
|
20953
|
-
var
|
|
20954
|
-
|
|
20955
|
-
|
|
20956
|
-
|
|
20957
|
-
|
|
20958
|
-
|
|
20959
|
-
|
|
20960
|
-
}
|
|
20961
|
-
|
|
20962
|
-
|
|
20963
|
-
|
|
20964
|
-
ecommerce: {
|
|
20965
|
-
items: (_a = checkout.cart) === null || _a === void 0 ? void 0 : _a.items.map(function (item) {
|
|
20966
|
-
return orderLineItemToGTMItem(item, item.quantity);
|
|
20967
|
-
}),
|
|
20968
|
-
},
|
|
20969
|
-
};
|
|
20970
|
-
//@ts-ignore
|
|
20971
|
-
!isServer$2 && window.dataLayer && window.dataLayer.push(event);
|
|
20972
|
-
}
|
|
20973
|
-
return event;
|
|
21057
|
+
var event_5 = {
|
|
21058
|
+
event: "begin_checkout",
|
|
21059
|
+
ecommerce: {
|
|
21060
|
+
items: (_a = checkout.cart) === null || _a === void 0 ? void 0 : _a.items.map(function (item) {
|
|
21061
|
+
return orderLineItemToGTMItem(item, item.quantity);
|
|
21062
|
+
}),
|
|
21063
|
+
},
|
|
21064
|
+
};
|
|
21065
|
+
//@ts-ignore
|
|
21066
|
+
!isServer$3 && window.dataLayer && window.dataLayer.push(event_5);
|
|
21067
|
+
return event_5;
|
|
20974
21068
|
}
|
|
20975
21069
|
catch (err) {
|
|
20976
21070
|
console.error(err);
|
|
20977
21071
|
}
|
|
20978
21072
|
};
|
|
20979
|
-
|
|
21073
|
+
GoogleTagManager.purchase = function (checkout, orderId) {
|
|
20980
21074
|
var _a, _b, _c;
|
|
20981
|
-
var serverRuntimeConfig = getConfig().serverRuntimeConfig;
|
|
20982
|
-
var gtmId = serverRuntimeConfig.GTM_ID;
|
|
20983
|
-
var fbpId = serverRuntimeConfig.FBP_ID;
|
|
20984
|
-
var event = {};
|
|
20985
21075
|
try {
|
|
20986
|
-
|
|
20987
|
-
|
|
20988
|
-
|
|
20989
|
-
|
|
20990
|
-
|
|
20991
|
-
|
|
20992
|
-
|
|
20993
|
-
|
|
20994
|
-
|
|
20995
|
-
|
|
20996
|
-
|
|
20997
|
-
|
|
20998
|
-
|
|
20999
|
-
|
|
21000
|
-
shipping: "" + checkout.shippingTotal,
|
|
21001
|
-
currency: (_b = checkout.cart) === null || _b === void 0 ? void 0 : _b.currencyCode,
|
|
21002
|
-
coupon: checkout.couponCode,
|
|
21003
|
-
items: (_c = checkout.cart) === null || _c === void 0 ? void 0 : _c.items.map(function (item) {
|
|
21004
|
-
return orderLineItemToGTMItem(item, item.quantity);
|
|
21005
|
-
}),
|
|
21006
|
-
},
|
|
21076
|
+
var event_6 = {
|
|
21077
|
+
event: "purchase",
|
|
21078
|
+
ecommerce: {
|
|
21079
|
+
purchase: {
|
|
21080
|
+
transaction_id: orderId,
|
|
21081
|
+
affiliation: window.location.hostname,
|
|
21082
|
+
value: "" + checkout.totalFinalPrice,
|
|
21083
|
+
tax: "" + ((_a = checkout.cart) === null || _a === void 0 ? void 0 : _a.totalTax),
|
|
21084
|
+
shipping: "" + checkout.shippingTotal,
|
|
21085
|
+
currency: (_b = checkout.cart) === null || _b === void 0 ? void 0 : _b.currencyCode,
|
|
21086
|
+
coupon: checkout.couponCode,
|
|
21087
|
+
items: (_c = checkout.cart) === null || _c === void 0 ? void 0 : _c.items.map(function (item) {
|
|
21088
|
+
return orderLineItemToGTMItem(item, item.quantity);
|
|
21089
|
+
}),
|
|
21007
21090
|
},
|
|
21008
|
-
}
|
|
21009
|
-
|
|
21010
|
-
|
|
21011
|
-
|
|
21012
|
-
return
|
|
21091
|
+
},
|
|
21092
|
+
};
|
|
21093
|
+
//@ts-ignore
|
|
21094
|
+
!isServer$3 && window.dataLayer && window.dataLayer.push(event_6);
|
|
21095
|
+
return event_6;
|
|
21013
21096
|
}
|
|
21014
21097
|
catch (err) {
|
|
21015
21098
|
console.error(err);
|
|
21016
21099
|
}
|
|
21017
21100
|
};
|
|
21018
|
-
|
|
21101
|
+
GoogleTagManager.checkoutStep = function (checkout, step) {
|
|
21019
21102
|
var _a;
|
|
21020
21103
|
var eventName = "";
|
|
21021
21104
|
if (step === CheckoutStep.INFO)
|
|
@@ -21027,7 +21110,7 @@ var Analytics = /** @class */ (function () {
|
|
|
21027
21110
|
else if (step === CheckoutStep.SUCCESS)
|
|
21028
21111
|
eventName = "checkout_success";
|
|
21029
21112
|
try {
|
|
21030
|
-
var
|
|
21113
|
+
var event_7 = {
|
|
21031
21114
|
event: eventName,
|
|
21032
21115
|
ecommerce: {
|
|
21033
21116
|
items: (_a = checkout.cart) === null || _a === void 0 ? void 0 : _a.items.map(function (item) {
|
|
@@ -21036,14 +21119,14 @@ var Analytics = /** @class */ (function () {
|
|
|
21036
21119
|
},
|
|
21037
21120
|
};
|
|
21038
21121
|
//@ts-ignore
|
|
21039
|
-
!isServer$
|
|
21040
|
-
return
|
|
21122
|
+
!isServer$3 && window.dataLayer && window.dataLayer.push(event_7);
|
|
21123
|
+
return event_7;
|
|
21041
21124
|
}
|
|
21042
21125
|
catch (err) {
|
|
21043
21126
|
console.error(err);
|
|
21044
21127
|
}
|
|
21045
21128
|
};
|
|
21046
|
-
|
|
21129
|
+
GoogleTagManager.disableHTML = function () {
|
|
21047
21130
|
try {
|
|
21048
21131
|
var data = {
|
|
21049
21132
|
"gtm.blocklist": [
|
|
@@ -21054,19 +21137,19 @@ var Analytics = /** @class */ (function () {
|
|
|
21054
21137
|
],
|
|
21055
21138
|
};
|
|
21056
21139
|
//@ts-ignore
|
|
21057
|
-
!isServer$
|
|
21140
|
+
!isServer$3 && window.dataLayer && window.dataLayer.push(data);
|
|
21058
21141
|
}
|
|
21059
21142
|
catch (err) {
|
|
21060
21143
|
console.error(err);
|
|
21061
21144
|
}
|
|
21062
21145
|
};
|
|
21063
|
-
|
|
21146
|
+
GoogleTagManager.addToWishlist = function (id) {
|
|
21064
21147
|
var serverRuntimeConfig = getConfig().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", "AddToWishlist", {
|
|
21071
21154
|
content_ids: [id],
|
|
21072
21155
|
});
|
|
@@ -21077,13 +21160,13 @@ var Analytics = /** @class */ (function () {
|
|
|
21077
21160
|
console.error(err);
|
|
21078
21161
|
}
|
|
21079
21162
|
};
|
|
21080
|
-
|
|
21163
|
+
GoogleTagManager.search = function (searchKeyword) {
|
|
21081
21164
|
var serverRuntimeConfig = getConfig().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", "Search", {
|
|
21088
21171
|
search_string: searchKeyword,
|
|
21089
21172
|
});
|
|
@@ -21094,13 +21177,13 @@ var Analytics = /** @class */ (function () {
|
|
|
21094
21177
|
console.error(err);
|
|
21095
21178
|
}
|
|
21096
21179
|
};
|
|
21097
|
-
|
|
21180
|
+
GoogleTagManager.completeRegistration = function () {
|
|
21098
21181
|
var serverRuntimeConfig = getConfig().serverRuntimeConfig;
|
|
21099
21182
|
var fbpId = serverRuntimeConfig.FBP_ID;
|
|
21100
21183
|
var event = {};
|
|
21101
21184
|
try {
|
|
21102
21185
|
if (fbpId) {
|
|
21103
|
-
!isServer$
|
|
21186
|
+
!isServer$3 &&
|
|
21104
21187
|
window.fbq("track", "CompleteRegistration", {
|
|
21105
21188
|
status: true,
|
|
21106
21189
|
});
|
|
@@ -21111,7 +21194,7 @@ var Analytics = /** @class */ (function () {
|
|
|
21111
21194
|
console.error(err);
|
|
21112
21195
|
}
|
|
21113
21196
|
};
|
|
21114
|
-
return
|
|
21197
|
+
return GoogleTagManager;
|
|
21115
21198
|
}());
|
|
21116
21199
|
function productToGTMItem(productDetail, quantity) {
|
|
21117
21200
|
var _a;
|
|
@@ -21142,49 +21225,6 @@ function productToGTMItem(productDetail, quantity) {
|
|
|
21142
21225
|
quantity: quantity,
|
|
21143
21226
|
};
|
|
21144
21227
|
}
|
|
21145
|
-
function productToFBPItem(productDetail, quantity) {
|
|
21146
|
-
if (quantity === void 0) { quantity = 1; }
|
|
21147
|
-
return {
|
|
21148
|
-
content_name: productDetail.product.name,
|
|
21149
|
-
content_category: productDetail.product.categories.length > 0
|
|
21150
|
-
? productDetail.product.categories[0].path
|
|
21151
|
-
.map(function (category) { return category.name; })
|
|
21152
|
-
.join(" > ")
|
|
21153
|
-
: "",
|
|
21154
|
-
content_ids: [productDetail.selectedVariant.id],
|
|
21155
|
-
content_type: "product",
|
|
21156
|
-
value: productDetail.selectedVariant.price.finalPrice,
|
|
21157
|
-
currency: productDetail.selectedVariant.price.currency,
|
|
21158
|
-
num_items: quantity,
|
|
21159
|
-
};
|
|
21160
|
-
}
|
|
21161
|
-
function beginCheckoutFBPItem(checkout) {
|
|
21162
|
-
var _a, _b, _c, _d;
|
|
21163
|
-
var contentIds = [];
|
|
21164
|
-
var contents = [];
|
|
21165
|
-
(_a = checkout.cart) === null || _a === void 0 ? void 0 : _a.items.map(function (item) {
|
|
21166
|
-
contentIds.push(item.id);
|
|
21167
|
-
contents.push({ id: item.id, quantity: item.quantity });
|
|
21168
|
-
});
|
|
21169
|
-
return {
|
|
21170
|
-
contents: contents,
|
|
21171
|
-
content_category: "",
|
|
21172
|
-
content_ids: contentIds,
|
|
21173
|
-
currency: (_b = checkout.cart) === null || _b === void 0 ? void 0 : _b.items[0].currencyCode,
|
|
21174
|
-
value: (_c = checkout.cart) === null || _c === void 0 ? void 0 : _c.totalPrice,
|
|
21175
|
-
num_items: (_d = checkout.cart) === null || _d === void 0 ? void 0 : _d.items.length,
|
|
21176
|
-
};
|
|
21177
|
-
}
|
|
21178
|
-
function orderLineItemToFBPItem(orderLineItem, quantity) {
|
|
21179
|
-
return {
|
|
21180
|
-
content_name: orderLineItem.variant.name,
|
|
21181
|
-
content_category: "",
|
|
21182
|
-
content_ids: [orderLineItem.variant.id],
|
|
21183
|
-
content_type: "product",
|
|
21184
|
-
value: orderLineItem.finalPrice,
|
|
21185
|
-
currency: orderLineItem.currencyCode,
|
|
21186
|
-
};
|
|
21187
|
-
}
|
|
21188
21228
|
function orderLineItemToGTMItem(orderLineItem, quantity) {
|
|
21189
21229
|
if (quantity === void 0) { quantity = 1; }
|
|
21190
21230
|
return {
|
|
@@ -21206,6 +21246,127 @@ function orderLineItemToGTMItem(orderLineItem, quantity) {
|
|
|
21206
21246
|
};
|
|
21207
21247
|
}
|
|
21208
21248
|
|
|
21249
|
+
var LS_BEGIN_CHECKOUT_KEY = "gtmBeginCheckout";
|
|
21250
|
+
var isServer$4 = typeof window === "undefined";
|
|
21251
|
+
var Analytics = /** @class */ (function () {
|
|
21252
|
+
function Analytics() {
|
|
21253
|
+
makeAutoObservable(this);
|
|
21254
|
+
}
|
|
21255
|
+
Analytics.pageView = function (url) {
|
|
21256
|
+
try {
|
|
21257
|
+
var event_1 = {
|
|
21258
|
+
event: "page-view",
|
|
21259
|
+
page: url,
|
|
21260
|
+
};
|
|
21261
|
+
//@ts-ignore
|
|
21262
|
+
!isServer$4 && window.dataLayer && window.dataLayer.push(event_1);
|
|
21263
|
+
return event_1;
|
|
21264
|
+
}
|
|
21265
|
+
catch (err) {
|
|
21266
|
+
console.error(err);
|
|
21267
|
+
}
|
|
21268
|
+
};
|
|
21269
|
+
Analytics.productView = function (productDetail) {
|
|
21270
|
+
try {
|
|
21271
|
+
FacebookPixel.productView(productDetail);
|
|
21272
|
+
GoogleTagManager.productView(productDetail);
|
|
21273
|
+
return;
|
|
21274
|
+
}
|
|
21275
|
+
catch (err) {
|
|
21276
|
+
console.error(err);
|
|
21277
|
+
}
|
|
21278
|
+
};
|
|
21279
|
+
Analytics.addToCart = function (item, quantity) {
|
|
21280
|
+
try {
|
|
21281
|
+
FacebookPixel.addToCart(item, quantity);
|
|
21282
|
+
GoogleTagManager.addToCart(item, quantity);
|
|
21283
|
+
return;
|
|
21284
|
+
}
|
|
21285
|
+
catch (err) {
|
|
21286
|
+
console.error(err);
|
|
21287
|
+
}
|
|
21288
|
+
};
|
|
21289
|
+
Analytics.removeFromCart = function (item, quantity) {
|
|
21290
|
+
try {
|
|
21291
|
+
GoogleTagManager.removeFromCart(item, quantity);
|
|
21292
|
+
return;
|
|
21293
|
+
}
|
|
21294
|
+
catch (err) {
|
|
21295
|
+
console.error(err);
|
|
21296
|
+
}
|
|
21297
|
+
};
|
|
21298
|
+
Analytics.beginCheckout = function (checkout) {
|
|
21299
|
+
try {
|
|
21300
|
+
var beginCheckout = localStorage.getItem(LS_BEGIN_CHECKOUT_KEY);
|
|
21301
|
+
if (beginCheckout && checkout.id === beginCheckout)
|
|
21302
|
+
return;
|
|
21303
|
+
localStorage.setItem(LS_BEGIN_CHECKOUT_KEY, checkout.id);
|
|
21304
|
+
FacebookPixel.beginCheckout(checkout);
|
|
21305
|
+
GoogleTagManager.beginCheckout(checkout);
|
|
21306
|
+
return;
|
|
21307
|
+
}
|
|
21308
|
+
catch (err) {
|
|
21309
|
+
console.error(err);
|
|
21310
|
+
}
|
|
21311
|
+
};
|
|
21312
|
+
Analytics.purchase = function (checkout, orderId) {
|
|
21313
|
+
try {
|
|
21314
|
+
localStorage.removeItem(LS_BEGIN_CHECKOUT_KEY);
|
|
21315
|
+
FacebookPixel.purchase(checkout, orderId);
|
|
21316
|
+
GoogleTagManager.purchase(checkout, orderId);
|
|
21317
|
+
return;
|
|
21318
|
+
}
|
|
21319
|
+
catch (err) {
|
|
21320
|
+
console.error(err);
|
|
21321
|
+
}
|
|
21322
|
+
};
|
|
21323
|
+
Analytics.checkoutStep = function (checkout, step) {
|
|
21324
|
+
try {
|
|
21325
|
+
GoogleTagManager.checkoutStep(checkout, step);
|
|
21326
|
+
return;
|
|
21327
|
+
}
|
|
21328
|
+
catch (err) {
|
|
21329
|
+
console.error(err);
|
|
21330
|
+
}
|
|
21331
|
+
};
|
|
21332
|
+
Analytics.disableHTML = function () {
|
|
21333
|
+
try {
|
|
21334
|
+
GoogleTagManager.disableHTML();
|
|
21335
|
+
}
|
|
21336
|
+
catch (err) {
|
|
21337
|
+
console.error(err);
|
|
21338
|
+
}
|
|
21339
|
+
};
|
|
21340
|
+
Analytics.addToWishlist = function (id) {
|
|
21341
|
+
try {
|
|
21342
|
+
FacebookPixel.addToWishlist(id);
|
|
21343
|
+
return;
|
|
21344
|
+
}
|
|
21345
|
+
catch (err) {
|
|
21346
|
+
console.error(err);
|
|
21347
|
+
}
|
|
21348
|
+
};
|
|
21349
|
+
Analytics.search = function (searchKeyword) {
|
|
21350
|
+
try {
|
|
21351
|
+
FacebookPixel.search(searchKeyword);
|
|
21352
|
+
return;
|
|
21353
|
+
}
|
|
21354
|
+
catch (err) {
|
|
21355
|
+
console.error(err);
|
|
21356
|
+
}
|
|
21357
|
+
};
|
|
21358
|
+
Analytics.completeRegistration = function () {
|
|
21359
|
+
try {
|
|
21360
|
+
FacebookPixel.completeRegistration();
|
|
21361
|
+
return;
|
|
21362
|
+
}
|
|
21363
|
+
catch (err) {
|
|
21364
|
+
console.error(err);
|
|
21365
|
+
}
|
|
21366
|
+
};
|
|
21367
|
+
return Analytics;
|
|
21368
|
+
}());
|
|
21369
|
+
|
|
21209
21370
|
var AnalyticsHead = function (_a) {
|
|
21210
21371
|
var blockHTML = _a.blockHTML;
|
|
21211
21372
|
var serverRuntimeConfig = getConfig().serverRuntimeConfig;
|