From 9440fa3fb237be1c83ff3bce174e039139f9dba9 Mon Sep 17 00:00:00 2001 From: Greg Leonard <45019882+greg-el@users.noreply.github.com> Date: Fri, 24 Nov 2023 15:22:24 +0000 Subject: [PATCH] Use document-level listener --- .../src/api.ts | 22 ++++++---------- .../test/integration/buttonClick.test.ts | 25 +++++++++++++++++-- .../test/pages/button-click-tracking.html | 14 +++++++++++ 3 files changed, 45 insertions(+), 16 deletions(-) diff --git a/plugins/browser-plugin-button-click-tracking/src/api.ts b/plugins/browser-plugin-button-click-tracking/src/api.ts index b20954473..148ae6b0d 100644 --- a/plugins/browser-plugin-button-click-tracking/src/api.ts +++ b/plugins/browser-plugin-button-click-tracking/src/api.ts @@ -117,18 +117,12 @@ export function addListenersToButtonElements( context?: DynamicContext, document = window.document ) { - const addListener = (button: HTMLButtonElement | HTMLInputElement) => { - button.addEventListener('click', () => { - clickHandler(trackerId, button, context); - }); - }; - - // Add listeners to + + +