From 7fc011f158f4f8a23cfcb69310060f040d604165 Mon Sep 17 00:00:00 2001 From: Nathan Schott Date: Fri, 22 Mar 2024 09:52:10 -0400 Subject: [PATCH] refactor: pass modal zoid polyfill duration as string --- src/components/modal/v2/lib/zoid-polyfill.js | 4 ++-- .../modal/v2/lib/zoid-polyfill.test.js | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/components/modal/v2/lib/zoid-polyfill.js b/src/components/modal/v2/lib/zoid-polyfill.js index 86c8eee171..14721a0c35 100644 --- a/src/components/modal/v2/lib/zoid-polyfill.js +++ b/src/components/modal/v2/lib/zoid-polyfill.js @@ -156,8 +156,8 @@ const setupWebview = props => { debug_id: trackingDetails.debug_id }, event_type: 'modal_rendered', - request_duration: timing && timing.responseEnd - timing.requestStart, - render_duration: timing && performance.now() - timing.responseEnd + request_duration: timing && Math.round(timing.responseEnd - timing.requestStart).toString(), + render_duration: timing && Math.round(performance.now() - timing.responseEnd).toString() }); }, diff --git a/tests/unit/spec/src/components/modal/v2/lib/zoid-polyfill.test.js b/tests/unit/spec/src/components/modal/v2/lib/zoid-polyfill.test.js index b96bf7106d..d9e3badc9e 100644 --- a/tests/unit/spec/src/components/modal/v2/lib/zoid-polyfill.test.js +++ b/tests/unit/spec/src/components/modal/v2/lib/zoid-polyfill.test.js @@ -126,7 +126,7 @@ describe('zoidPollyfill', () => { ); }); test('onCalculate returning a log message', () => { - window.xprops.onCalculate({ value: 500 }); + window.xprops.onCalculate({ value: '500' }); expect(logger.track).toHaveBeenCalledTimes(1); expect(logger.track).toHaveBeenCalledWith( @@ -134,7 +134,7 @@ describe('zoidPollyfill', () => { event_type: 'click', link: 'Calculator', src: 'Calculator', - amount: 500 + amount: '500' }) ); }); @@ -233,8 +233,8 @@ describe('zoidPollyfill', () => { "offer_country_code": "US", }, "event_type": "modal_rendered", - "render_duration": 50, - "request_duration": 100, + "render_duration": "50", + "request_duration": "100", }, ], "name": "onReady", @@ -260,7 +260,7 @@ describe('zoidPollyfill', () => { `); postMessage.mockClear(); - window.xprops.onCalculate({ value: 500 }); + window.xprops.onCalculate({ value: '500' }); expect(postMessage).toHaveBeenCalledTimes(1); expect(postMessage.mock.calls[0][0]).toEqual(expect.any(String)); @@ -268,7 +268,7 @@ describe('zoidPollyfill', () => { Object { "args": Array [ Object { - "calculator_input": 500, + "calculator_input": "500", "event_type": "modal_clicked", "page_view_link_name": "Calculator", "page_view_link_source": "Calculator", @@ -390,8 +390,8 @@ describe('zoidPollyfill', () => { "offer_country_code": "US", }, "event_type": "modal_rendered", - "render_duration": 50, - "request_duration": 100, + "render_duration": "50", + "request_duration": "100", }, ], "name": "onReady",