diff --git a/modules/browsiRtdProvider.js b/modules/browsiRtdProvider.js index 0996fc9905b..31b2d709f35 100644 --- a/modules/browsiRtdProvider.js +++ b/modules/browsiRtdProvider.js @@ -59,10 +59,12 @@ export function addBrowsiTag(data) { export function sendPageviewEvent(eventType) { if (eventType === 'PAGEVIEW') { - events.emit(CONSTANTS.EVENTS.BILLABLE_EVENT, { - vendor: 'browsi', - type: 'pageview', - billingId: generateUUID() + window.addEventListener('browsi_pageview', () => { + events.emit(CONSTANTS.EVENTS.BILLABLE_EVENT, { + vendor: 'browsi', + type: 'pageview', + billingId: generateUUID() + }) }) } } diff --git a/test/spec/modules/browsiRtdProvider_spec.js b/test/spec/modules/browsiRtdProvider_spec.js index 19483047827..75120aa7505 100644 --- a/test/spec/modules/browsiRtdProvider_spec.js +++ b/test/spec/modules/browsiRtdProvider_spec.js @@ -252,7 +252,8 @@ describe('browsi Real time data sub module', function () { }) it('should send event if type is correct', function () { sendPageviewEvent('PAGEVIEW') - + const pageViewEvent = new CustomEvent('browsi_pageview', {}); + window.dispatchEvent(pageViewEvent); const expectedCall = { vendor: 'browsi', type: 'pageview',