From 43954352a0b757ba1e6a3896e2fc648b471797ff Mon Sep 17 00:00:00 2001 From: CarlNation Date: Tue, 25 Apr 2023 09:18:56 -0400 Subject: [PATCH 1/2] CSR-1339 Allow site to function when analytic service calls fail --- src/mixins/analytics-mixin.js | 10 +++++----- src/store/index.js | 24 +++++++++++++++++++++--- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/mixins/analytics-mixin.js b/src/mixins/analytics-mixin.js index 3fbc9501d..29eb76c3d 100644 --- a/src/mixins/analytics-mixin.js +++ b/src/mixins/analytics-mixin.js @@ -146,18 +146,18 @@ export default { false ); - 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 } diff --git a/src/store/index.js b/src/store/index.js index f42a950ea..70f6cf3a2 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -720,7 +720,13 @@ export const actions = { endpoint: endpoints.LogPageView.url, payload: payload, logApiCall: false, - }); + }).then((response) => { + return response; + }, + (error) => { + console.log("Analytics Service Error: " + error.data); + } + ); }, logCustomEvent( context, @@ -756,7 +762,13 @@ export const actions = { endpoint: endpoints.LogCustomEvent.url, payload: payload, logApiCall: false, - }); + }).then((response) => { + return response; + }, + (error) => { + console.log("Analytics Service Error: " + error.data); + } + ); }, initializeSession(context, { userId, sessionId, userAgent, referrer }) { var payload = { @@ -775,7 +787,13 @@ export const actions = { endpoint: endpoints.InitializeSession.url, payload: payload, logApiCall: false, - }); + }).then((response) => { + return response; + }, + (error) => { + console.log("Analytics Service Error: " + error.data); + } + ); }, // Misc Actions From f18e00caedbda0ff9319882fc8668cb3af08aa20 Mon Sep 17 00:00:00 2001 From: CarlNation Date: Tue, 25 Apr 2023 09:26:41 -0400 Subject: [PATCH 2/2] CSR-1339 Add GA event to show what button options displayed --- .../button-question/button-question.vue | 25 ++++++ src/constants/analytics.js | 1 + src/layouts/estimate/estimate.vue | 3 +- src/store/index.js | 81 ++++++++++--------- 4 files changed, 73 insertions(+), 37 deletions(-) diff --git a/src/common-components/button-question/button-question.vue b/src/common-components/button-question/button-question.vue index 646b244be..b96b99bb4 100644 --- a/src/common-components/button-question/button-question.vue +++ b/src/common-components/button-question/button-question.vue @@ -79,6 +79,7 @@ import listButtonHorizontal from "@/ux-components/list-button-horizontal/list-bu import listCard from "@/ux-components/list-card/list-card"; import radio from "@/ux-components/radio/radio"; import { ErrorMessage } from "vee-validate"; +import { queryStrings } from "@/constants/query-strings"; export default { name: "buttonQuestion", @@ -119,6 +120,10 @@ export default { useTextForValue: Boolean, valueToLogType: String, additionalButtonStyling: String, + logDisplayedValuesEvent: { + type: Boolean, + default: false, + }, }, beforeMount() { if (this.buttonTypeObject) { @@ -130,6 +135,26 @@ export default { lastValuePushedToGa: null, }; }, + watch: { + answers() { + //once we get the answers to display from parent, see if we need a GA event to log what we showed + if (this.logDisplayedValuesEvent && this.answers.length > 0) { + var eventLabel = ""; + //build comma separated list of all items in button list that we are going to display on page + this.answers.forEach((item) => { + eventLabel += item.Name + ","; + }); + + eventLabel = eventLabel.slice(0, -1); //remove the last comma + this.pushEventToGA( + this.$route.query[queryStrings.FMG_PAGE], + this.GaActions.DISPLAYED, + eventLabel, + true + ); + } + }, + }, computed: { getFieldSetClasses() { if (this.isOverflowScrollable) { diff --git a/src/constants/analytics.js b/src/constants/analytics.js index eed7da2fe..b5b24660d 100644 --- a/src/constants/analytics.js +++ b/src/constants/analytics.js @@ -19,6 +19,7 @@ const GaActions = { CLICKED: "Clicked", VIF: "vif", SUBMITTED: "Submitted", + DISPLAYED: "Displayed", }; const GaLabels = { diff --git a/src/layouts/estimate/estimate.vue b/src/layouts/estimate/estimate.vue index b9929813a..17135b1aa 100644 --- a/src/layouts/estimate/estimate.vue +++ b/src/layouts/estimate/estimate.vue @@ -18,7 +18,8 @@ buttonTypeString="listButton" v-model="selectedVinLookupMethod" isRequired - validationRules="option-required" /> + validationRules="option-required" + :logDisplayedValuesEvent="true" />
{ - return response; - }, - (error) => { - console.log("Analytics Service Error: " + error.data); - } - ); + return globalMethods + .callHttpClient({ + method: endpoints.LogPageView.method, + endpoint: endpoints.LogPageView.url, + payload: payload, + logApiCall: false, + }) + .then( + (response) => { + return response; + }, + (error) => { + console.log("Analytics Service Error: " + error.data); + } + ); }, logCustomEvent( context, @@ -757,18 +760,21 @@ export const actions = { experimentsForUser: experimentsForUser, }; - return globalMethods.callHttpClient({ - method: endpoints.LogCustomEvent.method, - endpoint: endpoints.LogCustomEvent.url, - payload: payload, - logApiCall: false, - }).then((response) => { - return response; - }, - (error) => { - console.log("Analytics Service Error: " + error.data); - } - ); + return globalMethods + .callHttpClient({ + method: endpoints.LogCustomEvent.method, + endpoint: endpoints.LogCustomEvent.url, + payload: payload, + logApiCall: false, + }) + .then( + (response) => { + return response; + }, + (error) => { + console.log("Analytics Service Error: " + error.data); + } + ); }, initializeSession(context, { userId, sessionId, userAgent, referrer }) { var payload = { @@ -782,18 +788,21 @@ export const actions = { referrer: referrer, }; - return globalMethods.callHttpClient({ - method: endpoints.InitializeSession.method, - endpoint: endpoints.InitializeSession.url, - payload: payload, - logApiCall: false, - }).then((response) => { - return response; - }, - (error) => { - console.log("Analytics Service Error: " + error.data); - } - ); + return globalMethods + .callHttpClient({ + method: endpoints.InitializeSession.method, + endpoint: endpoints.InitializeSession.url, + payload: payload, + logApiCall: false, + }) + .then( + (response) => { + return response; + }, + (error) => { + console.log("Analytics Service Error: " + error.data); + } + ); }, // Misc Actions