Skip to content

Commit

Permalink
refactor: update native modal event keys and values
Browse files Browse the repository at this point in the history
  • Loading branch information
Seavenly committed Oct 26, 2023
1 parent 36e9b3b commit 3de2482
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
32 changes: 16 additions & 16 deletions src/components/modal/v2/lib/zoid-polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,51 +139,51 @@ const setupWebview = props => {
__shared__: {
// Analytic Details
fdata: trackingDetails.fdata,
experimentation_experience_ids: trackingDetails.experimentation_experience_ids,
experimentation_treatment_ids: trackingDetails.experimentation_treatment_ids,
experimentation_experience: trackingDetails.experimentation_experience_ids,
experimentation_treatment: trackingDetails.experimentation_treatment_ids,
credit_product_identifiers: trackingDetails.credit_product_identifiers,
offer_country_code: trackingDetails.offer_country_code,
merchant_country_code: trackingDetails.merchant_country_code,
views: trackingDetails.views,
qualified_products: trackingDetails.qualified_products,
debug_id: trackingDetails.debug_id
},
event_type: 'modal_render',
event_type: 'modal_rendered',
request_duration: timing && timing.responseEnd - timing.requestStart,
render_duration: timing && timing.loadEventEnd - timing.responseEnd
});
},

onClick: ({ linkName, src = linkName }) => {
sendCallbackMessage('onClick', {
event_type: 'modal_click',
link_name: linkName,
link_src: src
event_type: 'modal_clicked',
page_view_link_name: linkName,
page_view_link_source: src
});
},

onCalculate: ({ value }) => {
sendCallbackMessage('onCalculate', {
event_type: 'modal_click',
link_name: 'Calculator',
link_src: 'Calculator',
data: value
event_type: 'modal_clicked',
page_view_link_name: 'Calculator',
page_view_link_source: 'Calculator',
calculator_input: value
});
},

onShow: () => {
sendCallbackMessage('onShow', {
event_type: 'modal_open',
link_name: 'Show',
link_src: 'Show'
event_type: 'modal_viewed',
page_view_link_name: 'Show',
page_view_link_source: 'Show'
});
},

onClose: ({ linkName, src = linkName }) => {
sendCallbackMessage('onClose', {
event_type: 'modal_close',
link_name: linkName,
link_src: src
event_type: 'modal_closed',
page_view_link_name: linkName,
page_view_link_source: src
});
},
// Overridable defaults
Expand Down
30 changes: 15 additions & 15 deletions tests/unit/spec/src/components/modal/v2/lib/zoid-polyfill.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ describe('zoidPollyfill', () => {
"fdata": "123abc",
"offer_country_code": "US",
},
"event_type": "modal_render",
"event_type": "modal_rendered",
"render_duration": 50,
"request_duration": 100,
},
Expand All @@ -228,9 +228,9 @@ describe('zoidPollyfill', () => {
Object {
"args": Array [
Object {
"event_type": "modal_click",
"link_name": "test link",
"link_src": "test src",
"event_type": "modal_clicked",
"page_view_link_name": "test link",
"page_view_link_source": "test src",
},
],
"name": "onClick",
Expand All @@ -246,10 +246,10 @@ describe('zoidPollyfill', () => {
Object {
"args": Array [
Object {
"data": 500,
"event_type": "modal_click",
"link_name": "Calculator",
"link_src": "Calculator",
"calculator_input": 500,
"event_type": "modal_clicked",
"page_view_link_name": "Calculator",
"page_view_link_source": "Calculator",
},
],
"name": "onCalculate",
Expand All @@ -265,9 +265,9 @@ describe('zoidPollyfill', () => {
Object {
"args": Array [
Object {
"event_type": "modal_open",
"link_name": "Show",
"link_src": "Show",
"event_type": "modal_viewed",
"page_view_link_name": "Show",
"page_view_link_source": "Show",
},
],
"name": "onShow",
Expand All @@ -283,9 +283,9 @@ describe('zoidPollyfill', () => {
Object {
"args": Array [
Object {
"event_type": "modal_close",
"link_name": "Close Button",
"link_src": "Close Button",
"event_type": "modal_closed",
"page_view_link_name": "Close Button",
"page_view_link_source": "Close Button",
},
],
"name": "onClose",
Expand Down Expand Up @@ -367,7 +367,7 @@ describe('zoidPollyfill', () => {
"fdata": "123abc",
"offer_country_code": "US",
},
"event_type": "modal_render",
"event_type": "modal_rendered",
"render_duration": 50,
"request_duration": 100,
},
Expand Down

0 comments on commit 3de2482

Please sign in to comment.