commit
83002df770
2 changed files with 31 additions and 31 deletions
|
|
@ -10,10 +10,6 @@ import baseMixin from "@/mixins/base-mixin";
|
||||||
export default {
|
export default {
|
||||||
methods: {
|
methods: {
|
||||||
logPageView(pageEvent) {
|
logPageView(pageEvent) {
|
||||||
if (getSessionKeyValue() === 0 || getSessionIdValue() === '00000000-0000-0000-0000-000000000000') {
|
|
||||||
this.initSession();
|
|
||||||
}
|
|
||||||
|
|
||||||
const currentPageName = getPageNameByQueryString();
|
const currentPageName = getPageNameByQueryString();
|
||||||
var payload = {
|
var payload = {
|
||||||
userId: getDeviceIdValue(),
|
userId: getDeviceIdValue(),
|
||||||
|
|
@ -29,10 +25,6 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
logCustomEvent(category, action, label, value) {
|
logCustomEvent(category, action, label, value) {
|
||||||
if (getSessionKeyValue() === 0 || getSessionIdValue() === '00000000-0000-0000-0000-000000000000') {
|
|
||||||
this.initSession();
|
|
||||||
}
|
|
||||||
|
|
||||||
const currentPageName = getPageNameByQueryString();
|
const currentPageName = getPageNameByQueryString();
|
||||||
|
|
||||||
var payload = {
|
var payload = {
|
||||||
|
|
@ -50,28 +42,6 @@ export default {
|
||||||
baseMixin.methods.dispatchStoreAction(storeActions.LOG_CUSTOM_EVENT, payload, false);
|
baseMixin.methods.dispatchStoreAction(storeActions.LOG_CUSTOM_EVENT, payload, false);
|
||||||
},
|
},
|
||||||
|
|
||||||
async initSession() {
|
|
||||||
const sid = getSessionIdValue();
|
|
||||||
const skey = getSessionKeyValue();
|
|
||||||
var payload = {
|
|
||||||
userId: getDeviceIdValue(),
|
|
||||||
sessionId: sid,
|
|
||||||
userAgent: navigator.userAgent,
|
|
||||||
referrer: document.referrer,
|
|
||||||
};
|
|
||||||
|
|
||||||
const response = await baseMixin.methods.dispatchStoreAction(storeActions.INITIALIZE_SESSION, payload, false);
|
|
||||||
|
|
||||||
if (response.data) {
|
|
||||||
if (response.data.sessionKey && skey === 0) {
|
|
||||||
setCookieProperties({ [cookieNames.SESSION_KEY]: response.data.sessionKey});
|
|
||||||
}
|
|
||||||
if (response.data.sessionId && sid === '00000000-0000-0000-0000-000000000000') {
|
|
||||||
setCookieProperties({ [cookieNames.SESSION_ID]: response.data.sessionId});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
pushEventToGA(category, action, label, pushToLogApp = false) {
|
pushEventToGA(category, action, label, pushToLogApp = false) {
|
||||||
const currentPageName = getPageNameByQueryString();
|
const currentPageName = getPageNameByQueryString();
|
||||||
const eventToBePushed = {
|
const eventToBePushed = {
|
||||||
|
|
@ -86,7 +56,7 @@ export default {
|
||||||
pushToDataLayerIfDefined(eventToBePushed);
|
pushToDataLayerIfDefined(eventToBePushed);
|
||||||
|
|
||||||
if (pushToLogApp) {
|
if (pushToLogApp) {
|
||||||
this.logCustomEvent(category, action, label, undefined);
|
this.logCustomEvent(category, action, label, undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
@ -136,6 +106,32 @@ export default {
|
||||||
return baseMethod.apply(object, arguments);
|
return baseMethod.apply(object, arguments);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async initSession() {
|
||||||
|
const sid = getSessionIdValue();
|
||||||
|
const skey = getSessionKeyValue();
|
||||||
|
var payload = {
|
||||||
|
userId: getDeviceIdValue(),
|
||||||
|
sessionId: sid,
|
||||||
|
userAgent: navigator.userAgent,
|
||||||
|
referrer: document.referrer,
|
||||||
|
};
|
||||||
|
|
||||||
|
const response = await baseMixin.methods.dispatchStoreAction(storeActions.INITIALIZE_SESSION, payload, false);
|
||||||
|
|
||||||
|
if (response.data) {
|
||||||
|
if (response.data.sessionKey && skey === 0) {
|
||||||
|
setCookieProperties({ [cookieNames.SESSION_KEY]: response.data.sessionKey});
|
||||||
|
}
|
||||||
|
if (response.data.sessionId && sid === '00000000-0000-0000-0000-000000000000') {
|
||||||
|
setCookieProperties({ [cookieNames.SESSION_ID]: response.data.sessionId});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
noSession() {
|
||||||
|
return getSessionKeyValue() === 0 || getSessionIdValue() === '00000000-0000-0000-0000-000000000000';
|
||||||
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
analyticsPageEvents() {
|
analyticsPageEvents() {
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,10 @@ const routes = [
|
||||||
async beforeEnter(to, from, next) {
|
async beforeEnter(to, from, next) {
|
||||||
// If we have no query string, or we don't have the FmgPage query string.
|
// If we have no query string, or we don't have the FmgPage query string.
|
||||||
try {
|
try {
|
||||||
|
if (analyticsMixin.methods.noSession()) {
|
||||||
|
await analyticsMixin.methods.initSession();
|
||||||
|
}
|
||||||
|
|
||||||
// If the saved session has timed out, clear the session, execute 404 logic.
|
// If the saved session has timed out, clear the session, execute 404 logic.
|
||||||
if (getFunnelCookie() !== null && !isSavedSessionStillActive()) {
|
if (getFunnelCookie() !== null && !isSavedSessionStillActive()) {
|
||||||
await GoToFunnelStartOn404(next);
|
await GoToFunnelStartOn404(next);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue