diff --git a/src/cartridges/int_adyen_SFRA/cartridge/adyen/analytics/__tests__/analyticsHook.test.js b/src/cartridges/int_adyen_SFRA/cartridge/adyen/analytics/__tests__/analyticsHook.test.js index dd0d45430..7a5520b06 100644 --- a/src/cartridges/int_adyen_SFRA/cartridge/adyen/analytics/__tests__/analyticsHook.test.js +++ b/src/cartridges/int_adyen_SFRA/cartridge/adyen/analytics/__tests__/analyticsHook.test.js @@ -25,7 +25,7 @@ describe('analyticsHook', () => { }; onStartHandler(req); expect(createAnalyticsEvent).toHaveBeenCalled(); - expect(createAnalyticsEvent).toHaveBeenCalledWith('mocked_sessionID','Adyen-GetPaymentMethods', 'START', 'EXPECTED', 'info'); + expect(createAnalyticsEvent).toHaveBeenCalledWith('mocked_sessionID','Adyen-GetPaymentMethods', 'expectedStart', 'EXPECTED', 'info'); }) it('should not create Start event when adyen analytics is disabled in BM', () => { const req = { @@ -51,7 +51,7 @@ describe('analyticsHook', () => { }; onCompleteHandler(req, res); expect(createAnalyticsEvent).toHaveBeenCalled(); - expect(createAnalyticsEvent).toHaveBeenCalledWith('mocked_sessionID','Adyen-GetPaymentMethods', 'END', 'EXPECTED', 'info'); + expect(createAnalyticsEvent).toHaveBeenCalledWith('mocked_sessionID','Adyen-GetPaymentMethods', 'expectedEnd', 'EXPECTED', 'info'); }) it('should create End event with unexpected status when onCompleteHandler is called for error in route', () => { const req = { @@ -62,7 +62,7 @@ describe('analyticsHook', () => { }; onCompleteHandler(req, res); expect(createAnalyticsEvent).toHaveBeenCalled(); - expect(createAnalyticsEvent).toHaveBeenCalledWith('mocked_sessionID','Adyen-GetPaymentMethods', 'END', 'UNEXPECTED', 'info'); + expect(createAnalyticsEvent).toHaveBeenCalledWith('mocked_sessionID','Adyen-GetPaymentMethods', 'unexpectedEnd', 'UNEXPECTED', 'info'); }) it('should not create End event when adyen analytics is disabled in BM', () => { const req = { diff --git a/src/cartridges/int_adyen_SFRA/cartridge/adyen/analytics/analyticsHook.js b/src/cartridges/int_adyen_SFRA/cartridge/adyen/analytics/analyticsHook.js index c7cf0a032..41f976bca 100644 --- a/src/cartridges/int_adyen_SFRA/cartridge/adyen/analytics/analyticsHook.js +++ b/src/cartridges/int_adyen_SFRA/cartridge/adyen/analytics/analyticsHook.js @@ -60,7 +60,7 @@ function onStartHandler(req) { analyticsEvent.createAnalyticsEvent( session.sessionID, path.join('-'), - analyticsConstants.eventType.START, + analyticsConstants.eventType.EXPECTED_START, analyticsConstants.eventStatus.EXPECTED, analyticsConstants.eventCode.INFO, ); @@ -75,7 +75,7 @@ function onCompleteHandler(req, res) { analyticsEvent.createAnalyticsEvent( session.sessionID, path.join('-'), - analyticsConstants.eventType.END, + analyticsConstants.eventType.UNEXPECTED_END, analyticsConstants.eventStatus.UNEXPECTED, analyticsConstants.eventCode.INFO, ); @@ -83,7 +83,7 @@ function onCompleteHandler(req, res) { analyticsEvent.createAnalyticsEvent( session.sessionID, path.join('-'), - analyticsConstants.eventType.END, + analyticsConstants.eventType.EXPECTED_END, analyticsConstants.eventStatus.EXPECTED, analyticsConstants.eventCode.INFO, ); diff --git a/src/cartridges/int_adyen_SFRA/cartridge/adyen/analytics/analyticsService.js b/src/cartridges/int_adyen_SFRA/cartridge/adyen/analytics/analyticsService.js index 86677af28..170678d31 100644 --- a/src/cartridges/int_adyen_SFRA/cartridge/adyen/analytics/analyticsService.js +++ b/src/cartridges/int_adyen_SFRA/cartridge/adyen/analytics/analyticsService.js @@ -4,6 +4,7 @@ const AdyenHelper = require('*/cartridge/adyen/utils/adyenHelper'); const AdyenConfigs = require('*/cartridge/adyen/utils/adyenConfigs'); const constants = require('*/cartridge/adyen/config/constants'); const AdyenLogs = require('*/cartridge/adyen/logs/adyenCustomLogs'); +const analyticsConstants = require('*/cartridge/adyen/analytics/constants'); function execute(serviceType, requestObject, checkoutAttemptID = '') { const service = AdyenHelper.getService(serviceType); @@ -42,6 +43,7 @@ function createCheckoutAttemptId() { applicationInfo: AdyenHelper.getApplicationInfo(), channel: 'Web', platform: 'Web', + pluginType: analyticsConstants.pluginType, }; const response = execute(constants.SERVICE.ADYEN_ANALYTICS, requestObject); diff --git a/src/cartridges/int_adyen_SFRA/cartridge/adyen/analytics/constants.js b/src/cartridges/int_adyen_SFRA/cartridge/adyen/analytics/constants.js index 64142b308..e38b3eef4 100644 --- a/src/cartridges/int_adyen_SFRA/cartridge/adyen/analytics/constants.js +++ b/src/cartridges/int_adyen_SFRA/cartridge/adyen/analytics/constants.js @@ -1,8 +1,11 @@ module.exports = { analyticsEventObjectId: 'AdyenAnalyticsEvents', + pluginType: 'salesforceCommerceCloud', eventType: { - START: 'START', - END: 'END', + EXPECTED_START: 'expectedStart', + UNEXPECTED_START: 'unexpectedStart', + EXPECTED_END: 'expectedEnd', + UNEXPECTED_END: 'unexpectedEnd', }, eventStatus: { EXPECTED: 'EXPECTED', diff --git a/src/cartridges/int_adyen_SFRA/cartridge/adyen/analytics/job/analyticsJob.js b/src/cartridges/int_adyen_SFRA/cartridge/adyen/analytics/job/analyticsJob.js index 7918bd055..62db62776 100644 --- a/src/cartridges/int_adyen_SFRA/cartridge/adyen/analytics/job/analyticsJob.js +++ b/src/cartridges/int_adyen_SFRA/cartridge/adyen/analytics/job/analyticsJob.js @@ -8,6 +8,7 @@ function createRequestObjectForAllReferenceIds(groupedObjects) { const requestObject = { channel: 'Web', platform: 'Web', + pluginType: constants.pluginType, }; // Iterate over all referenceIds and group events into one requestObject @@ -17,20 +18,20 @@ function createRequestObjectForAllReferenceIds(groupedObjects) { events.forEach((event) => { const eventObject = { timestamp: new Date(event.creationDate).getTime().toString(), - type: 'focus', // this has to be changed once API accepts our event types + type: event.eventType, target: event.eventStatus, id: event.eventId, component: event.eventSource, }; const eventCode = event.eventCode.toLowerCase(); - const eventTypes = [ + const eventCodeList = [ constants.eventCode.INFO, constants.eventCode.ERROR, constants.eventCode.LOG, ]; - if (eventTypes.includes(eventCode)) { + if (eventCodeList.includes(eventCode)) { if (!requestObject[eventCode]) { requestObject[eventCode] = []; }