Merge remote-tracking branch 'origin/develop' into feature/removed-unused-props
This commit is contained in:
commit
77932fa0d9
6 changed files with 49 additions and 56 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
const analyticsPageEvents = {
|
const analyticsPageEvents = {
|
||||||
ENTRY: "ENTRY",
|
ENTRY: "ENTRY",
|
||||||
|
EVENT: "EVENT"
|
||||||
};
|
};
|
||||||
|
|
||||||
export { analyticsPageEvents };
|
export { analyticsPageEvents };
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
"
|
"
|
||||||
:buttonLabel="name"
|
:buttonLabel="name"
|
||||||
altText=""
|
altText=""
|
||||||
|
isRequired
|
||||||
:buttonID="`${glassLocation}-${glassName}-${name}`"
|
:buttonID="`${glassLocation}-${glassName}-${name}`"
|
||||||
:groupName="`${glassLocation}-${glassName}`"
|
:groupName="`${glassLocation}-${glassName}`"
|
||||||
@isCheckedChanged="ResetTintAndPartSelections()"
|
@isCheckedChanged="ResetTintAndPartSelections()"
|
||||||
|
|
@ -50,7 +51,7 @@
|
||||||
:answers="value"
|
:answers="value"
|
||||||
textPosition="text-start"
|
textPosition="text-start"
|
||||||
:loaderEnabled="false"
|
:loaderEnabled="false"
|
||||||
:isRequired="true"
|
isRequired
|
||||||
:groupName="`${glassLocation}-${glassName}-${name}`"
|
:groupName="`${glassLocation}-${glassName}-${name}`"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -3,35 +3,31 @@ import baseMixin from "@/mixins/base-mixin";
|
||||||
import { settleAllPromises } from "@/helpers/layout-helper";
|
import { settleAllPromises } from "@/helpers/layout-helper";
|
||||||
import { getDeviceIdValue, getSessionIdValue, getSessionKeyValue } from "@/helpers/heritage-integration/cookie-helper";
|
import { getDeviceIdValue, getSessionIdValue, getSessionKeyValue } from "@/helpers/heritage-integration/cookie-helper";
|
||||||
import { queryStrings } from "@/constants/query-strings";
|
import { queryStrings } from "@/constants/query-strings";
|
||||||
|
import { analyticsPageEvents } from "@/constants/analytics-page-events";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
methods: {
|
methods: {
|
||||||
async logPageEvent(destinationFmgPageValue, pageEvent){
|
logEvent(destinationFmgPageValue, pageEvent, category, action, label, value){
|
||||||
const logActivityPromise = baseMixin.methods.dispatchNonBlockingStoreAction(storeActions.LOG_ACTIVITY,
|
var payload = {
|
||||||
{
|
userId: getDeviceIdValue(),
|
||||||
userId: getDeviceIdValue(),
|
sessionKey: getSessionKeyValue(),
|
||||||
sessionKey: getSessionKeyValue(),
|
pageName: destinationFmgPageValue,
|
||||||
pageName: destinationFmgPageValue,
|
sessionId: getSessionIdValue(),
|
||||||
sessionId: getSessionIdValue(),
|
shouldUseSessionId: true,
|
||||||
shouldUseSessionId: true,
|
};
|
||||||
pageEvent: {
|
|
||||||
action: '',
|
if (pageEvent) {
|
||||||
event: pageEvent,
|
payload.pageEvent = {action: '', event: pageEvent};
|
||||||
}
|
}
|
||||||
}, false);
|
|
||||||
|
if (category) {
|
||||||
// Settle promises and get results
|
payload.customEvent = {category: category, action: action, label: label, value: value};
|
||||||
const promiseResultMap = [
|
}
|
||||||
{
|
|
||||||
resultKey: "logActivity",
|
baseMixin.methods.dispatchNonBlockingStoreAction(storeActions.LOG_ACTIVITY, payload, false);
|
||||||
promise: logActivityPromise,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
let resultMap = await settleAllPromises(promiseResultMap);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
pushEventToGA(category, action, label, value, pageName) {
|
pushEventToGA(category, action, label, value, pageName, pushToLogApp) {
|
||||||
const eventToBePushed = {
|
const eventToBePushed = {
|
||||||
'event': 'ga_event',
|
'event': 'ga_event',
|
||||||
'category': category,
|
'category': category,
|
||||||
|
|
@ -40,7 +36,12 @@ export default {
|
||||||
'value': value,
|
'value': value,
|
||||||
'path': `/fmg/?${queryStrings.FMG_PAGE}=${pageName}`
|
'path': `/fmg/?${queryStrings.FMG_PAGE}=${pageName}`
|
||||||
}
|
}
|
||||||
|
|
||||||
pushToDataLayerIfDefined(eventToBePushed);
|
pushToDataLayerIfDefined(eventToBePushed);
|
||||||
|
|
||||||
|
if (pushToLogApp) {
|
||||||
|
this.logEvent(pageName, null, category, action, label, value);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
pushPageViewToGA(pageName) {
|
pushPageViewToGA(pageName) {
|
||||||
|
|
@ -49,7 +50,9 @@ export default {
|
||||||
'pagePath': `/fmg/?${queryStrings.FMG_PAGE}=${pageName}`,
|
'pagePath': `/fmg/?${queryStrings.FMG_PAGE}=${pageName}`,
|
||||||
'pageTitle': pageName
|
'pageTitle': pageName
|
||||||
};
|
};
|
||||||
|
|
||||||
pushToDataLayerIfDefined(pageViewEvent);
|
pushToDataLayerIfDefined(pageViewEvent);
|
||||||
|
this.logEvent(pageName, analyticsPageEvents.ENTRY);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import { setupMocksForJsFiles } from "@/helpers/unit-test-helper.js";
|
||||||
import { storeActions } from "@/constants/store-actions";
|
import { storeActions } from "@/constants/store-actions";
|
||||||
|
|
||||||
describe("analyticsMixin.js", () => {
|
describe("analyticsMixin.js", () => {
|
||||||
test("logPageEvent: calls dispatch with type and payload", () => {
|
test("logEvent: calls dispatch with type and payload", () => {
|
||||||
const type = "";
|
const type = "";
|
||||||
const payload = {};
|
const payload = {};
|
||||||
|
|
||||||
|
|
@ -14,7 +14,7 @@ describe("analyticsMixin.js", () => {
|
||||||
}
|
}
|
||||||
var mocks = setupMocksForJsFiles(mockData);
|
var mocks = setupMocksForJsFiles(mockData);
|
||||||
|
|
||||||
analyticsMixin.methods.logPageEvent(type, payload);
|
analyticsMixin.methods.logEvent(type, payload);
|
||||||
|
|
||||||
expect(mocks.baseMixin.methods.dispatchNonBlockingStoreAction).toBeCalled();
|
expect(mocks.baseMixin.methods.dispatchNonBlockingStoreAction).toBeCalled();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ import analyticsMixin from "@/mixins/analytics-mixin";
|
||||||
// Components
|
// Components
|
||||||
import ComponentTest from "@/layouts/component-test/component-test.vue";
|
import ComponentTest from "@/layouts/component-test/component-test.vue";
|
||||||
import FormTest from "@/layouts/form-test/form-test.vue";
|
import FormTest from "@/layouts/form-test/form-test.vue";
|
||||||
import { analyticsPageEvents } from "./router-constants/analytics-page-events";
|
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
{
|
{
|
||||||
|
|
@ -124,7 +123,6 @@ const router = createRouter({
|
||||||
|
|
||||||
router.afterEach((to, from) => {
|
router.afterEach((to, from) => {
|
||||||
analyticsMixin.methods.pushPageViewToGA(to.query[queryStrings.FMG_PAGE]);
|
analyticsMixin.methods.pushPageViewToGA(to.query[queryStrings.FMG_PAGE]);
|
||||||
analyticsMixin.methods.logPageEvent(to.query[queryStrings.FMG_PAGE], analyticsPageEvents.ENTRY);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
router.navigate = (scenario, currentRoute, optionalQuery = {}, optionalParams = {}, optionalPageData = {}) => {
|
router.navigate = (scenario, currentRoute, optionalQuery = {}, optionalParams = {}, optionalPageData = {}) => {
|
||||||
|
|
|
||||||
|
|
@ -422,37 +422,27 @@ export const actions = {
|
||||||
},
|
},
|
||||||
|
|
||||||
logActivity(context, { userId, sessionKey, pageName, sessionId, pageEvent, customEvent, shouldUseSessionId }) {
|
logActivity(context, { userId, sessionKey, pageName, sessionId, pageEvent, customEvent, shouldUseSessionId }) {
|
||||||
var customEventData = {};
|
var payload = {
|
||||||
customEvent?.forEach(function(event)
|
userId: userId,
|
||||||
{
|
sessionKey: sessionKey,
|
||||||
var category = event.category;
|
sessionId: sessionId,
|
||||||
var action = event.action;
|
pageName: pageName,
|
||||||
var label = event.label;
|
applicationName: 'SafeliteDotCom',
|
||||||
var value = event.value;
|
shouldUseSessionId: shouldUseSessionId
|
||||||
customEventData[category] = {
|
};
|
||||||
category: category,
|
|
||||||
action: action,
|
if (typeof pageEvent !== 'undefined') {
|
||||||
label: label,
|
payload.pageEvent = { action: pageEvent.action, event: pageEvent.event};
|
||||||
value: value
|
}
|
||||||
};
|
|
||||||
})
|
if (typeof customEvent !== 'undefined') {
|
||||||
|
payload.customEvents = [{category: customEvent.category, action: customEvent.action, label: customEvent.label, value: customEvent.value}];
|
||||||
|
}
|
||||||
|
|
||||||
return globalMethods.callHttpClient({
|
return globalMethods.callHttpClient({
|
||||||
method: endpoints.LogActivity.method,
|
method: endpoints.LogActivity.method,
|
||||||
endpoint: endpoints.LogActivity.url,
|
endpoint: endpoints.LogActivity.url,
|
||||||
payload: {
|
payload: payload
|
||||||
userId: userId,
|
|
||||||
sessionKey: sessionKey,
|
|
||||||
sessionId: sessionId,
|
|
||||||
pageName: pageName,
|
|
||||||
applicationName: 'SafeliteDotCom',
|
|
||||||
shouldUseSessionId: shouldUseSessionId,
|
|
||||||
pageEvent: {
|
|
||||||
action: pageEvent.action,
|
|
||||||
event: pageEvent.event,
|
|
||||||
},
|
|
||||||
customEvent: customEventData
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue