diff --git a/src/mixins/analytics-mixin.js b/src/mixins/analytics-mixin.js index feaa112f..135f6e9a 100644 --- a/src/mixins/analytics-mixin.js +++ b/src/mixins/analytics-mixin.js @@ -53,10 +53,10 @@ export default { } return ''; }, - validateSession() { + async validateSession() { if (this.noSession()) { - this.initSession(); + await this.initSession(); } updateSessionIdCookie(); @@ -64,7 +64,7 @@ export default { async logPageView(pageEvent) { const store = useMainStore(); const currentPageName = this.getPageNameByQueryString(); - this.validateSession(); + //await this.validateSession(); const payload = { userId: getUserIdValue(), @@ -85,7 +85,7 @@ export default { async logCustomEvent(category, action, label, value) { const store = useMainStore(); const currentPageName = this.getPageNameByQueryString(); - this.validateSession(); + //await this.validateSession(); const payload = { userId: getUserIdValue(), @@ -543,7 +543,7 @@ export default { store.logIssSessionData(sessionData); }, - initSession() { + async initSession() { regenerateDeviceId(); regenerateUserId(); @@ -561,7 +561,7 @@ export default { userAgent: navigator.userAgent }; - const response = useMainStore().initializeSession(payload); + const response = await useMainStore().initializeSession(payload); if (response?.data) { if (response?.data.sessionKey) { diff --git a/src/router/index.js b/src/router/index.js index 60e05e6d..791b23d6 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -35,6 +35,12 @@ const routes = [ return await GoToAccessIsDenied(next); } + if (analyticsMixin.methods.noSession()) { + await analyticsMixin.methods.initSession(); + } else { + updateSessionIdCookie(); + } + // Do not run these for the main entry page - as it is not part of the user flow. if (issPageToUse !== issPageValues.ENTRY_PAGE) { try { diff --git a/src/store/index.js b/src/store/index.js index 3bfe1a33..e0a6a097 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -2625,7 +2625,7 @@ export const useMainStore = defineStore({ this.logExperimentIfExists(issPage, experimentUniverses.ISS_FEATURETOGGLE_AREFEES_HIDDEN); this.logExperimentIfExists(issPage, experimentUniverses.ISS_FEATURETOGGLE_AREFEES_OVERRIDDEN); }, - initializeSession({ userId, sessionId, userAgent, referrer }) { + async initializeSession({ userId, sessionId, userAgent, referrer }) { const payload = { applicationName: applicationConfig.APPLICATION_NAME, userId,