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