Automattic/newspack-popups

JSON encoded interaction data breaks webhooks

Closed this issue · 4 comments

This json encoded item is breaking the data event payload:

$data['interaction_data']['donation_suggested_values'] = \wp_json_encode( $suggested_summary );

When the prompt_interaction is triggered for a prompt with the donation block, this is the result:

{"request_id":3889,"timestamp":1689023418,"action":"prompt_interaction","data":{"prompt_id":3336,"prompt_title":"Inline Donation (secondary)","prompt_frequency":"always","prompt_placement":"inline","prompt_blocks":["donation"],"interaction_data":{"donation_suggested_values":"{"l":"default","o":[20],"m":[15],"y":[180]}","donation_order_id":3880,"donation_amount":20,"donation_currency":"CAD","donation_recurrence":"once","donation_platform":"wc"},"action":"form_submission_success","action_type":"donation","referer":"/nascetur-turpis-torquent-duis-nulla-enim-luctus/"},"client_id":"flbtctma99"}

hmmm and how this ever worked? I'm gonna look into this

I suppose it works with GA4, that's why we didn't catch it

1200550061930446-as-1205039914378954

Turns out that the json is corrupted when we update_option with it. WordPress strips all the slashes.

I submitted a PR to workaround that

Automattic/newspack-plugin#2579