Merge pull request #266 from Safelite/feature/digital/SSR-426

added logic to prevent page crashing due to analytics service being un…
This commit is contained in:
Jason Wheeler 2023-04-25 13:32:56 -04:00 committed by GitHub
commit dc08ffa17c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 8 deletions

View file

@ -144,18 +144,18 @@ export default {
const response = await useMainStore().initializeSession(payload);
if (response.data) {
if (response.data.sessionKey && skey === 0) {
if (response?.data) {
if (response?.data.sessionKey && skey === 0) {
setCookieProperties(
{ [cookieNames.SESSION_KEY]: response.data.sessionKey },
{ [cookieNames.SESSION_KEY]: response?.data.sessionKey },
{
useDefaultFunnelCookieAttributes: false,
}
);
}
if (response.data.sessionId && sid === "00000000-0000-0000-0000-000000000000") {
if (response?.data.sessionId && sid === "00000000-0000-0000-0000-000000000000") {
setCookieProperties(
{ [cookieNames.SESSION_ID]: response.data.sessionId },
{ [cookieNames.SESSION_ID]: response?.data.sessionId },
{
maxAge: 60 * 30, // 30 minutes
}

View file

@ -973,7 +973,14 @@ export const useMainStore = defineStore({
endpoint: endpoints.LogPageView.url,
payload: payload,
logApiCall: false
});
}).then(
(response) => {
return response;
},
(error) => {
console.log("Analytics Service Error: " + error.data);
}
);
},
logCustomEvent({ userId, sessionKey, pageName, sessionId, category, action, label, value, shouldUseSessionId, experimentsForUser})
{
@ -999,7 +1006,14 @@ export const useMainStore = defineStore({
endpoint: endpoints.LogCustomEvent.url,
payload: payload,
logApiCall: false
});
}).then(
(response) => {
return response;
},
(error) => {
console.log("Analytics Service Error: " + error.data);
}
);
},
initializeSession({ userId, sessionId, userAgent, referrer }) {
var payload = {
@ -1018,7 +1032,14 @@ export const useMainStore = defineStore({
endpoint: endpoints.InitializeSession.url,
payload: payload,
logApiCall: false
});
}).then(
(response) => {
return response;
},
(error) => {
console.log("Analytics Service Error: " + error.data);
}
);
},
updateLastPageVisited(lastPageVisited) {