@ikas/storefront 0.0.83 → 0.0.85
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 +359 -201
- package/build/index.js +359 -201
- 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,185 +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 = {};
|
|
20998
|
+
GoogleTagManager.productView = function (productDetail) {
|
|
20866
20999
|
try {
|
|
20867
|
-
|
|
20868
|
-
|
|
20869
|
-
|
|
20870
|
-
|
|
20871
|
-
|
|
20872
|
-
}
|
|
20873
|
-
|
|
20874
|
-
|
|
20875
|
-
|
|
20876
|
-
ecommerce: {
|
|
20877
|
-
items: [productToGTMItem(productDetail)],
|
|
20878
|
-
},
|
|
20879
|
-
};
|
|
20880
|
-
//@ts-ignore
|
|
20881
|
-
!isServer$2 && window.dataLayer && window.dataLayer.push(event);
|
|
20882
|
-
}
|
|
20883
|
-
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;
|
|
20884
21009
|
}
|
|
20885
21010
|
catch (err) {
|
|
20886
21011
|
console.error(err);
|
|
20887
21012
|
}
|
|
20888
21013
|
};
|
|
20889
|
-
|
|
20890
|
-
var serverRuntimeConfig = getConfig().serverRuntimeConfig;
|
|
20891
|
-
var gtmId = serverRuntimeConfig.GTM_ID;
|
|
20892
|
-
var fbpId = serverRuntimeConfig.FBP_ID;
|
|
20893
|
-
var event = {};
|
|
21014
|
+
GoogleTagManager.addToCart = function (item, quantity) {
|
|
20894
21015
|
try {
|
|
20895
|
-
|
|
20896
|
-
|
|
20897
|
-
|
|
20898
|
-
|
|
20899
|
-
|
|
20900
|
-
|
|
20901
|
-
|
|
20902
|
-
|
|
20903
|
-
|
|
20904
|
-
|
|
20905
|
-
|
|
20906
|
-
|
|
20907
|
-
|
|
20908
|
-
: orderLineItemToGTMItem(item, quantity),
|
|
20909
|
-
],
|
|
20910
|
-
},
|
|
20911
|
-
};
|
|
20912
|
-
//@ts-ignore
|
|
20913
|
-
!isServer$2 && window.dataLayer && window.dataLayer.push(event);
|
|
20914
|
-
}
|
|
20915
|
-
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;
|
|
20916
21029
|
}
|
|
20917
21030
|
catch (err) {
|
|
20918
21031
|
console.error(err);
|
|
20919
21032
|
}
|
|
20920
21033
|
};
|
|
20921
|
-
|
|
20922
|
-
var serverRuntimeConfig = getConfig().serverRuntimeConfig;
|
|
20923
|
-
var gtmId = serverRuntimeConfig.GTM_ID;
|
|
20924
|
-
serverRuntimeConfig.FBP_ID;
|
|
20925
|
-
var event = {};
|
|
21034
|
+
GoogleTagManager.removeFromCart = function (item, quantity) {
|
|
20926
21035
|
try {
|
|
20927
|
-
|
|
20928
|
-
event
|
|
20929
|
-
|
|
20930
|
-
|
|
20931
|
-
|
|
20932
|
-
item
|
|
20933
|
-
|
|
20934
|
-
|
|
20935
|
-
|
|
20936
|
-
|
|
20937
|
-
|
|
20938
|
-
|
|
20939
|
-
|
|
20940
|
-
}
|
|
20941
|
-
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;
|
|
20942
21049
|
}
|
|
20943
21050
|
catch (err) {
|
|
20944
21051
|
console.error(err);
|
|
20945
21052
|
}
|
|
20946
21053
|
};
|
|
20947
|
-
|
|
21054
|
+
GoogleTagManager.beginCheckout = function (checkout) {
|
|
20948
21055
|
var _a;
|
|
20949
|
-
var serverRuntimeConfig = getConfig().serverRuntimeConfig;
|
|
20950
|
-
var gtmId = serverRuntimeConfig.GTM_ID;
|
|
20951
|
-
var fbpId = serverRuntimeConfig.FBP_ID;
|
|
20952
|
-
var event = {};
|
|
20953
21056
|
try {
|
|
20954
|
-
var
|
|
20955
|
-
|
|
20956
|
-
|
|
20957
|
-
|
|
20958
|
-
|
|
20959
|
-
|
|
20960
|
-
|
|
20961
|
-
}
|
|
20962
|
-
|
|
20963
|
-
|
|
20964
|
-
|
|
20965
|
-
ecommerce: {
|
|
20966
|
-
items: (_a = checkout.cart) === null || _a === void 0 ? void 0 : _a.items.map(function (item) {
|
|
20967
|
-
return orderLineItemToGTMItem(item, item.quantity);
|
|
20968
|
-
}),
|
|
20969
|
-
},
|
|
20970
|
-
};
|
|
20971
|
-
//@ts-ignore
|
|
20972
|
-
!isServer$2 && window.dataLayer && window.dataLayer.push(event);
|
|
20973
|
-
}
|
|
20974
|
-
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;
|
|
20975
21068
|
}
|
|
20976
21069
|
catch (err) {
|
|
20977
21070
|
console.error(err);
|
|
20978
21071
|
}
|
|
20979
21072
|
};
|
|
20980
|
-
|
|
21073
|
+
GoogleTagManager.purchase = function (checkout, orderId) {
|
|
20981
21074
|
var _a, _b, _c;
|
|
20982
|
-
var serverRuntimeConfig = getConfig().serverRuntimeConfig;
|
|
20983
|
-
var gtmId = serverRuntimeConfig.GTM_ID;
|
|
20984
|
-
var fbpId = serverRuntimeConfig.FBP_ID;
|
|
20985
|
-
var event = {};
|
|
20986
21075
|
try {
|
|
20987
|
-
|
|
20988
|
-
|
|
20989
|
-
|
|
20990
|
-
|
|
20991
|
-
|
|
20992
|
-
|
|
20993
|
-
|
|
20994
|
-
|
|
20995
|
-
|
|
20996
|
-
|
|
20997
|
-
|
|
20998
|
-
|
|
20999
|
-
|
|
21000
|
-
|
|
21001
|
-
shipping: "" + checkout.shippingTotal,
|
|
21002
|
-
currency: (_b = checkout.cart) === null || _b === void 0 ? void 0 : _b.currencyCode,
|
|
21003
|
-
coupon: checkout.couponCode,
|
|
21004
|
-
items: (_c = checkout.cart) === null || _c === void 0 ? void 0 : _c.items.map(function (item) {
|
|
21005
|
-
return orderLineItemToGTMItem(item, item.quantity);
|
|
21006
|
-
}),
|
|
21007
|
-
},
|
|
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
|
+
}),
|
|
21008
21090
|
},
|
|
21009
|
-
}
|
|
21010
|
-
|
|
21011
|
-
|
|
21012
|
-
|
|
21013
|
-
return
|
|
21091
|
+
},
|
|
21092
|
+
};
|
|
21093
|
+
//@ts-ignore
|
|
21094
|
+
!isServer$3 && window.dataLayer && window.dataLayer.push(event_6);
|
|
21095
|
+
return event_6;
|
|
21014
21096
|
}
|
|
21015
21097
|
catch (err) {
|
|
21016
21098
|
console.error(err);
|
|
21017
21099
|
}
|
|
21018
21100
|
};
|
|
21019
|
-
|
|
21101
|
+
GoogleTagManager.checkoutStep = function (checkout, step) {
|
|
21020
21102
|
var _a;
|
|
21021
21103
|
var eventName = "";
|
|
21022
21104
|
if (step === CheckoutStep.INFO)
|
|
@@ -21028,7 +21110,7 @@ var Analytics = /** @class */ (function () {
|
|
|
21028
21110
|
else if (step === CheckoutStep.SUCCESS)
|
|
21029
21111
|
eventName = "checkout_success";
|
|
21030
21112
|
try {
|
|
21031
|
-
var
|
|
21113
|
+
var event_7 = {
|
|
21032
21114
|
event: eventName,
|
|
21033
21115
|
ecommerce: {
|
|
21034
21116
|
items: (_a = checkout.cart) === null || _a === void 0 ? void 0 : _a.items.map(function (item) {
|
|
@@ -21037,14 +21119,14 @@ var Analytics = /** @class */ (function () {
|
|
|
21037
21119
|
},
|
|
21038
21120
|
};
|
|
21039
21121
|
//@ts-ignore
|
|
21040
|
-
!isServer$
|
|
21041
|
-
return
|
|
21122
|
+
!isServer$3 && window.dataLayer && window.dataLayer.push(event_7);
|
|
21123
|
+
return event_7;
|
|
21042
21124
|
}
|
|
21043
21125
|
catch (err) {
|
|
21044
21126
|
console.error(err);
|
|
21045
21127
|
}
|
|
21046
21128
|
};
|
|
21047
|
-
|
|
21129
|
+
GoogleTagManager.disableHTML = function () {
|
|
21048
21130
|
try {
|
|
21049
21131
|
var data = {
|
|
21050
21132
|
"gtm.blocklist": [
|
|
@@ -21055,19 +21137,19 @@ var Analytics = /** @class */ (function () {
|
|
|
21055
21137
|
],
|
|
21056
21138
|
};
|
|
21057
21139
|
//@ts-ignore
|
|
21058
|
-
!isServer$
|
|
21140
|
+
!isServer$3 && window.dataLayer && window.dataLayer.push(data);
|
|
21059
21141
|
}
|
|
21060
21142
|
catch (err) {
|
|
21061
21143
|
console.error(err);
|
|
21062
21144
|
}
|
|
21063
21145
|
};
|
|
21064
|
-
|
|
21146
|
+
GoogleTagManager.addToWishlist = function (id) {
|
|
21065
21147
|
var serverRuntimeConfig = getConfig().serverRuntimeConfig;
|
|
21066
21148
|
var fbpId = serverRuntimeConfig.FBP_ID;
|
|
21067
21149
|
var event = {};
|
|
21068
21150
|
try {
|
|
21069
21151
|
if (fbpId) {
|
|
21070
|
-
!isServer$
|
|
21152
|
+
!isServer$3 &&
|
|
21071
21153
|
window.fbq("track", "AddToWishlist", {
|
|
21072
21154
|
content_ids: [id],
|
|
21073
21155
|
});
|
|
@@ -21078,13 +21160,13 @@ var Analytics = /** @class */ (function () {
|
|
|
21078
21160
|
console.error(err);
|
|
21079
21161
|
}
|
|
21080
21162
|
};
|
|
21081
|
-
|
|
21163
|
+
GoogleTagManager.search = function (searchKeyword) {
|
|
21082
21164
|
var serverRuntimeConfig = getConfig().serverRuntimeConfig;
|
|
21083
21165
|
var fbpId = serverRuntimeConfig.FBP_ID;
|
|
21084
21166
|
var event = {};
|
|
21085
21167
|
try {
|
|
21086
21168
|
if (fbpId) {
|
|
21087
|
-
!isServer$
|
|
21169
|
+
!isServer$3 &&
|
|
21088
21170
|
window.fbq("track", "Search", {
|
|
21089
21171
|
search_string: searchKeyword,
|
|
21090
21172
|
});
|
|
@@ -21095,13 +21177,13 @@ var Analytics = /** @class */ (function () {
|
|
|
21095
21177
|
console.error(err);
|
|
21096
21178
|
}
|
|
21097
21179
|
};
|
|
21098
|
-
|
|
21180
|
+
GoogleTagManager.completeRegistration = function () {
|
|
21099
21181
|
var serverRuntimeConfig = getConfig().serverRuntimeConfig;
|
|
21100
21182
|
var fbpId = serverRuntimeConfig.FBP_ID;
|
|
21101
21183
|
var event = {};
|
|
21102
21184
|
try {
|
|
21103
21185
|
if (fbpId) {
|
|
21104
|
-
!isServer$
|
|
21186
|
+
!isServer$3 &&
|
|
21105
21187
|
window.fbq("track", "CompleteRegistration", {
|
|
21106
21188
|
status: true,
|
|
21107
21189
|
});
|
|
@@ -21112,7 +21194,7 @@ var Analytics = /** @class */ (function () {
|
|
|
21112
21194
|
console.error(err);
|
|
21113
21195
|
}
|
|
21114
21196
|
};
|
|
21115
|
-
return
|
|
21197
|
+
return GoogleTagManager;
|
|
21116
21198
|
}());
|
|
21117
21199
|
function productToGTMItem(productDetail, quantity) {
|
|
21118
21200
|
var _a;
|
|
@@ -21143,51 +21225,6 @@ function productToGTMItem(productDetail, quantity) {
|
|
|
21143
21225
|
quantity: quantity,
|
|
21144
21226
|
};
|
|
21145
21227
|
}
|
|
21146
|
-
function productToFBPItem(productDetail, quantity) {
|
|
21147
|
-
if (quantity === void 0) { quantity = 1; }
|
|
21148
|
-
return {
|
|
21149
|
-
content_name: productDetail.product.name,
|
|
21150
|
-
content_category: productDetail.product.categories.length > 0
|
|
21151
|
-
? productDetail.product.categories[0].path
|
|
21152
|
-
.map(function (category) { return category.name; })
|
|
21153
|
-
.join(" > ")
|
|
21154
|
-
: "",
|
|
21155
|
-
content_ids: [productDetail.selectedVariant.id],
|
|
21156
|
-
content_type: "product",
|
|
21157
|
-
value: productDetail.selectedVariant.price.finalPrice,
|
|
21158
|
-
currency: productDetail.selectedVariant.price.currency === ""
|
|
21159
|
-
? "TRY"
|
|
21160
|
-
: productDetail.selectedVariant.price.currency,
|
|
21161
|
-
num_items: quantity,
|
|
21162
|
-
};
|
|
21163
|
-
}
|
|
21164
|
-
function beginCheckoutFBPItem(checkout) {
|
|
21165
|
-
var _a, _b, _c, _d;
|
|
21166
|
-
var contentIds = [];
|
|
21167
|
-
var contents = [];
|
|
21168
|
-
(_a = checkout.cart) === null || _a === void 0 ? void 0 : _a.items.map(function (item) {
|
|
21169
|
-
contentIds.push(item.id);
|
|
21170
|
-
contents.push({ id: item.id, quantity: item.quantity });
|
|
21171
|
-
});
|
|
21172
|
-
return {
|
|
21173
|
-
contents: contents,
|
|
21174
|
-
content_category: "",
|
|
21175
|
-
content_ids: contentIds,
|
|
21176
|
-
currency: (_b = checkout.cart) === null || _b === void 0 ? void 0 : _b.items[0].currencyCode,
|
|
21177
|
-
value: (_c = checkout.cart) === null || _c === void 0 ? void 0 : _c.totalPrice,
|
|
21178
|
-
num_items: (_d = checkout.cart) === null || _d === void 0 ? void 0 : _d.items.length,
|
|
21179
|
-
};
|
|
21180
|
-
}
|
|
21181
|
-
function orderLineItemToFBPItem(orderLineItem, quantity) {
|
|
21182
|
-
return {
|
|
21183
|
-
content_name: orderLineItem.variant.name,
|
|
21184
|
-
content_category: "",
|
|
21185
|
-
content_ids: [orderLineItem.variant.id],
|
|
21186
|
-
content_type: "product",
|
|
21187
|
-
value: orderLineItem.finalPrice,
|
|
21188
|
-
currency: orderLineItem.currencyCode,
|
|
21189
|
-
};
|
|
21190
|
-
}
|
|
21191
21228
|
function orderLineItemToGTMItem(orderLineItem, quantity) {
|
|
21192
21229
|
if (quantity === void 0) { quantity = 1; }
|
|
21193
21230
|
return {
|
|
@@ -21209,12 +21246,132 @@ function orderLineItemToGTMItem(orderLineItem, quantity) {
|
|
|
21209
21246
|
};
|
|
21210
21247
|
}
|
|
21211
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
|
+
|
|
21212
21370
|
var AnalyticsHead = function (_a) {
|
|
21213
21371
|
var blockHTML = _a.blockHTML;
|
|
21214
21372
|
var serverRuntimeConfig = getConfig().serverRuntimeConfig;
|
|
21215
21373
|
var gtmId = serverRuntimeConfig.GTM_ID;
|
|
21216
21374
|
var fbpId = serverRuntimeConfig.FBP_ID;
|
|
21217
|
-
console.log("fbp head", fbpId);
|
|
21218
21375
|
return (createElement(Fragment, null,
|
|
21219
21376
|
blockHTML && (createElement("script", { dangerouslySetInnerHTML: {
|
|
21220
21377
|
__html: "dataLayer = [{'gtm.blocklist': ['html']}];",
|
|
@@ -21230,7 +21387,6 @@ var AnalyticsBody = function () {
|
|
|
21230
21387
|
var serverRuntimeConfig = getConfig().serverRuntimeConfig;
|
|
21231
21388
|
var gtmId = serverRuntimeConfig.GTM_ID;
|
|
21232
21389
|
var fbpId = serverRuntimeConfig.FBP_ID;
|
|
21233
|
-
console.log("fbp body", fbpId);
|
|
21234
21390
|
return (createElement(Fragment, null,
|
|
21235
21391
|
gtmId && (createElement("noscript", { dangerouslySetInnerHTML: {
|
|
21236
21392
|
__html: "<iframe src=\"https://www.googletagmanager.com/ns.html?id=" + gtmId + "\" height=\"0\" width=\"0\" style=\"display:none;visibility:hidden\"></iframe>",
|
|
@@ -27970,11 +28126,13 @@ var Page$1 = function (_a) {
|
|
|
27970
28126
|
var _c = useState(initialPropValues), propValues = _c[0], setPropValues = _c[1];
|
|
27971
28127
|
useEffect(function () {
|
|
27972
28128
|
setIsBrowser(typeof window !== "undefined");
|
|
28129
|
+
if (isBrowser) {
|
|
28130
|
+
handleAnalytics(page, pageSpecificDataStr);
|
|
28131
|
+
}
|
|
27973
28132
|
}, []);
|
|
27974
28133
|
useEffect(function () {
|
|
27975
28134
|
setPropValues(IkasPageDataProvider.initPropValues(propValuesStr, router, isBrowser));
|
|
27976
28135
|
}, [isBrowser, propValuesStr]);
|
|
27977
|
-
handleGTM(page, pageSpecificDataStr);
|
|
27978
28136
|
return (createElement(IkasPage, { page: page, propValues: propValues, pageSpecificDataStr: pageSpecificDataStr, settingsStr: settingsStr, merchantSettings: merchantSettings, addOgpMetas: true }));
|
|
27979
28137
|
};
|
|
27980
28138
|
var index$1 = observer(Page$1);
|
|
@@ -28061,7 +28219,7 @@ var getStaticProps$1 = function (context) { return __awaiter(void 0, void 0, voi
|
|
|
28061
28219
|
}
|
|
28062
28220
|
});
|
|
28063
28221
|
}); };
|
|
28064
|
-
function
|
|
28222
|
+
function handleAnalytics(page, pageSpecificDataStr) {
|
|
28065
28223
|
var isServer = typeof window === "undefined";
|
|
28066
28224
|
if (!isServer) {
|
|
28067
28225
|
try {
|