diff --git a/src/helpers/heritage-integration/cookie-helper.spec.js b/src/helpers/heritage-integration/cookie-helper.spec.js index b4498f61b..03fca51b5 100644 --- a/src/helpers/heritage-integration/cookie-helper.spec.js +++ b/src/helpers/heritage-integration/cookie-helper.spec.js @@ -1,4 +1,4 @@ -import {getFunnelCookie, getDeviceIdValue, getSessionKeyValue} from "@/helpers/heritage-integration/cookie-helper.js"; +import {getFunnelCookie, getDeviceIdValue, getSessionKeyValue, getSessionIdValue} from "@/helpers/heritage-integration/cookie-helper.js"; import { removeAllTestCookies, setupCookies } from "@/helpers/unit-test-helper"; describe("cookies", () => { @@ -126,5 +126,19 @@ describe("cookies", () => { }); }); + + describe("getSessionIdValue", () => { + test("getSessionIdValue, should return GUID", () => { + // Arrange + setupCookies({}); + + // Act + const result = getSessionIdValue(); + + //Assert + expect(result).toBe('cba0c3d1-3c1b-4305-bb56-31aa50f58e27'); + + }); + }); }) \ No newline at end of file diff --git a/src/helpers/unit-test-helper.js b/src/helpers/unit-test-helper.js index 20fad7ba2..753465886 100644 --- a/src/helpers/unit-test-helper.js +++ b/src/helpers/unit-test-helper.js @@ -62,6 +62,7 @@ export const cookies = { "anotherCookie": "{}", "someOtherCookie": "{}", "dxdev": "did=21b9b94a-ec23-42c1-aaac-e2ae4e4dbffe", + "sid": "cba0c3d1-3c1b-4305-bb56-31aa50f58e27", "skey": "12345" }; diff --git a/src/router/index.js b/src/router/index.js index 57a1cc3e2..985d90e11 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -21,6 +21,7 @@ import ComponentTest from "@/layouts/component-test/component-test.vue"; import FormTest from "@/layouts/form-test/form-test.vue"; import { getDeviceIdValue, getSessionIdValue, getSessionKeyValue } from "@/helpers/heritage-integration/cookie-helper"; import { settleAllPromises } from "@/helpers/layout-helper"; +import { analyticsPageEvents } from "./router-constants/analytics-page-events"; const routes = [ { @@ -78,7 +79,7 @@ const routes = [ await GoToFunnelStartOn404(next); } - logPageEvent(to.query.fmgPage); + // logPageEvent(to.query.fmgPage, analyticsPageEvents.ENTRY); return next({ name: to.query.fmgPage, query: to.query, params: to.params }); } @@ -100,7 +101,7 @@ const routes = [ await GoToFunnelStartOn404(next); } - logPageEvent(to.query.fmgPage); + // logPageEvent(to.query.fmgPage, analyticsPageEvents.ENTRY); // Assign current query string parameters, as well as our fmgPage one. next({ @@ -127,6 +128,7 @@ const router = createRouter({ router.afterEach((to, from) => { baseMixin.methods.pushPageViewToGA(to.query[queryStrings.FMG_PAGE]); + logPageEvent(to.query[queryStrings.FMG_PAGE], analyticsPageEvents.ENTRY); }); router.navigate = (scenario, currentRoute, optionalQuery = {}, optionalParams = {}, optionalPageData = {}) => { @@ -273,7 +275,7 @@ function resetDependentState(component) { return component.default.methods.resetDependentState(); } -async function logPageEvent(destinationFmgPageValue){ +async function logPageEvent(destinationFmgPageValue, pageEvent){ const logActivityPromise = baseMixin.methods.dispatchNonBlockingStoreAction(storeActions.LOG_ACTIVITY, { userId: getDeviceIdValue(), @@ -283,7 +285,7 @@ async function logPageEvent(destinationFmgPageValue){ shouldUseSessionId: true, pageEvent: { action: '', - event: 'ENTRY', + event: pageEvent, } }, false); diff --git a/src/router/router-constants/analytics-page-events.js b/src/router/router-constants/analytics-page-events.js new file mode 100644 index 000000000..ab4753b3d --- /dev/null +++ b/src/router/router-constants/analytics-page-events.js @@ -0,0 +1,5 @@ +const analyticsPageEvents = { + ENTRY: "ENTRY", +}; + +export { analyticsPageEvents }; diff --git a/src/store/index.js b/src/store/index.js index 04c966518..85b3e7a70 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -433,7 +433,7 @@ export const actions = { sessionKey: sessionKey, sessionId: sessionId, pageName: pageName, - applicationName: 'SafeliteContent', + applicationName: 'SafeliteDotCom', shouldUseSessionId: shouldUseSessionId, pageEvent: { action: pageEvent.action, diff --git a/src/store/store.spec.js b/src/store/store.spec.js index 7618cc25a..e5903ad64 100644 --- a/src/store/store.spec.js +++ b/src/store/store.spec.js @@ -617,6 +617,32 @@ describe("Actions", () => { expect(commit).toBeCalledWith(storeMutations.UPDATE_REFERRAL_CORRELATION_ID, "xxx-xxx-xxx"); }); + it("logActivity action, should return nothing", async () => { + + // Arrange + const context = state; + var pageEvent = { + action: "", + event: "ENTRY", + } + + var customEvent = [{ + category: "tstCat", + action: "click", + label: "damage", + value: "psych" + }]; + + // Act + globalMethods.callHttpClient.mockImplementation(() => { + return Promise.resolve({ }); + }); + + // Assert + const response = await actions.logActivity(context, { userId: "userId", sessionKey: "sessionKey", pageName: "pageName", sessionId: "sessionId", pageEvent: pageEvent, customEvent: customEvent, shouldUseSessionId: true }); + expect(response).toEqual({}); + }); + }); describe("Getters", () => {