This commit is contained in:
Kulbhushan Kaushik 2023-01-11 14:00:30 -05:00
parent 19cdc0ed86
commit c9352ccf6d

View file

@ -18,9 +18,18 @@ import { cookieNames } from "@/constants/cookie-names";
import { useMainStore } from "@/store"; import { useMainStore } from "@/store";
export default { export default {
methods: { methods: {
getPageNameByQueryString() {
const params = new URLSearchParams(location.search);
if (params.has(queryStrings.ISS_PAGE)) {
return params.get(queryStrings.ISS_PAGE);
} else {
return "";
}
},
logPageView(pageEvent) { logPageView(pageEvent) {
const currentPageName = getPageNameByQueryString(); const currentPageName = this.getPageNameByQueryString();
var payload = { var payload = {
userId: getDeviceIdValue(), userId: getDeviceIdValue(),
sessionKey: getSessionKeyValue(), sessionKey: getSessionKeyValue(),
@ -36,7 +45,7 @@ export default {
}, },
logCustomEvent(category, action, label, value) { logCustomEvent(category, action, label, value) {
const currentPageName = getPageNameByQueryString(); const currentPageName = this.getPageNameByQueryString();
var payload = { var payload = {
userId: getDeviceIdValue(), userId: getDeviceIdValue(),
@ -55,7 +64,7 @@ export default {
}, },
pushEventToGA(category, action, label, pushToLogApp = false, valueToLogType = null) { pushEventToGA(category, action, label, pushToLogApp = false, valueToLogType = null) {
const currentPageName = getPageNameByQueryString(); const currentPageName = this.getPageNameByQueryString();
const labelToLog = getValueToLog(label, valueToLogType); const labelToLog = getValueToLog(label, valueToLogType);
const eventToBePushed = { const eventToBePushed = {
@ -75,7 +84,7 @@ export default {
}, },
pushPageViewToGA() { pushPageViewToGA() {
const currentPageName = getPageNameByQueryString(); const currentPageName = this.getPageNameByQueryString();
const pageViewEvent = { const pageViewEvent = {
event: GaEvents.PAGE_VIEW_EVENT, event: GaEvents.PAGE_VIEW_EVENT,
pagePath: `/iss/?${queryStrings.ISS_PAGE}=${currentPageName}`, pagePath: `/iss/?${queryStrings.ISS_PAGE}=${currentPageName}`,
@ -187,15 +196,7 @@ function pushToDataLayerIfDefined(data) {
} }
} }
function getPageNameByQueryString() {
const params = new URLSearchParams(location.search);
if (params.has(queryStrings.ISS_PAGE)) {
return params.get(queryStrings.ISS_PAGE);
} else {
return "";
}
}
function getValueToLog(value, valueToLogType) { function getValueToLog(value, valueToLogType) {
if (valueToLogType != null && valueToLogType === ValueToLogTypes.LAST_5) { if (valueToLogType != null && valueToLogType === ValueToLogTypes.LAST_5) {