diff --git a/src/common-components/button-question/button-question.vue b/src/common-components/button-question/button-question.vue index c2eb72971..07efe470e 100644 --- a/src/common-components/button-question/button-question.vue +++ b/src/common-components/button-question/button-question.vue @@ -52,7 +52,6 @@ import listButtonHorizontal from "@/ux-components/list-button-horizontal/list-bu import listCard from "@/ux-components/list-card/list-card"; import { ErrorMessage } from 'vee-validate'; import radio from "@/ux-components/radio/radio"; -import { queryStrings } from "@/constants/query-strings"; export default { name: "buttonQuestion", @@ -135,8 +134,6 @@ export default { }, handleCheckedChanged(val) { - this.pushEventToGA(this.$route.query[queryStrings.FMG_PAGE], this.GaActions.CLICKED, val.value, true); - if(this.isMultiSelect && this.selectedValues) { // Add or remove item to array of data to emit const newSelectedValues = this.selectedValues; diff --git a/src/mixins/analytics-mixin.js b/src/mixins/analytics-mixin.js index 133187797..ca5a24a3e 100644 --- a/src/mixins/analytics-mixin.js +++ b/src/mixins/analytics-mixin.js @@ -9,12 +9,18 @@ import baseMixin from "@/mixins/base-mixin"; export default { methods: { logPageView(pageEvent) { + // if the user does not have a session id from the content site, do not log. + const sid = getSessionIdValue(); + if (sid === '00000000-0000-0000-0000-000000000000' || sid == null) { + return; + } + const currentPageName = getPageNameByQueryString(); var payload = { userId: getDeviceIdValue(), sessionKey: getSessionKeyValue(), pageName: currentPageName, - sessionId: getSessionIdValue(), + sessionId: sid, action: '', event: pageEvent, shouldUseSessionId: true, @@ -24,12 +30,18 @@ export default { }, logCustomEvent(category, action, label, value) { + // if the user does not have a session id from the content site, do not log. + const sid = getSessionIdValue(); + if (sid === '00000000-0000-0000-0000-000000000000' || sid == null) { + return; + } + const currentPageName = getPageNameByQueryString(); var payload = { userId: getDeviceIdValue(), sessionKey: getSessionKeyValue(), pageName: currentPageName, - sessionId: getSessionIdValue(), + sessionId: sid, category: category, action: action, label: label, diff --git a/src/mixins/analytics-mixin.spec.js b/src/mixins/analytics-mixin.spec.js index 8dd49045d..db773da56 100644 --- a/src/mixins/analytics-mixin.spec.js +++ b/src/mixins/analytics-mixin.spec.js @@ -1,5 +1,5 @@ import analyticsMixin from "@/mixins/analytics-mixin"; -import { setupMocksForJsFiles } from "@/helpers/unit-test-helper.js"; +import { setupMocksForJsFiles, setupCookies } from "@/helpers/unit-test-helper.js"; import { storeActions } from "@/constants/store-actions"; describe("analyticsMixin.js", () => { @@ -14,6 +14,12 @@ describe("analyticsMixin.js", () => { } const mocks = setupMocksForJsFiles(mockData); + const testCookieValue = { + sid: '10000000-0000-0000-0000-000000000001' + } + + setupCookies({ funnelCookieValue: JSON.stringify(testCookieValue) }); + analyticsMixin.methods.logPageView(type, payload); expect(mocks.baseMixin.methods.dispatchStoreAction).toBeCalled(); diff --git a/src/ux-components/list-button-horizontal/list-button-horizontal.spec.js b/src/ux-components/list-button-horizontal/list-button-horizontal.spec.js index cbd757a88..5c288f660 100644 --- a/src/ux-components/list-button-horizontal/list-button-horizontal.spec.js +++ b/src/ux-components/list-button-horizontal/list-button-horizontal.spec.js @@ -1,6 +1,7 @@ import { shallowMount } from "@vue/test-utils"; import listButtonHorizontal from "./list-button-horizontal"; import { nextTick } from "vue"; +import { GaActions } from "@/constants/analytics"; describe("list-button-horizontal.vue", () => { it("Should return input type checkbox if isMultiSelect is true", async () => { @@ -90,6 +91,13 @@ describe("list-button-horizontal.vue", () => { it("Should return loader enabled true", async () => { // Act const wrapper = shallowMount(listButtonHorizontal, { + global: { + mocks: { + '$route': { query: { fmgPage: 'page-name' } }, + GaActions: GaActions, + pushEventToGA: jest.fn(), + } + }, propsData: { selectingInitiatesLoad: true, }, @@ -112,6 +120,13 @@ describe("list-button-horizontal.vue", () => { it("Should return loader color", async () => { // Act const wrapper = shallowMount(listButtonHorizontal, { + global: { + mocks: { + '$route': { query: { fmgPage: 'page-name' } }, + GaActions: GaActions, + pushEventToGA: jest.fn(), + } + }, propsData: { loaderColor: "blue", selectingInitiatesLoad: true, @@ -135,6 +150,13 @@ describe("list-button-horizontal.vue", () => { it("Should return loader position", async () => { // Act const wrapper = shallowMount(listButtonHorizontal, { + global: { + mocks: { + '$route': { query: { fmgPage: 'page-name' } }, + GaActions: GaActions, + pushEventToGA: jest.fn(), + } + }, propsData: { loaderPosition: "right", selectingInitiatesLoad: true, diff --git a/src/ux-components/list-button-horizontal/list-button-horizontal.vue b/src/ux-components/list-button-horizontal/list-button-horizontal.vue index 974a965b8..eef4be443 100644 --- a/src/ux-components/list-button-horizontal/list-button-horizontal.vue +++ b/src/ux-components/list-button-horizontal/list-button-horizontal.vue @@ -54,6 +54,7 @@