diff --git a/tracker/src/plausible.js b/tracker/src/plausible.js index 000198d26c65..6a9b6f3e0a7e 100644 --- a/tracker/src/plausible.js +++ b/tracker/src/plausible.js @@ -34,7 +34,6 @@ elements.forEach(element => { const attributeValue = element.getAttribute(attribute); const eventValue = `${attribute}-${attributeValue}`; - trigger('phx-event', { props: { event: attribute, diff --git a/tracker/test/fixtures/live-view-moon-components-2.html b/tracker/test/fixtures/live-view-moon-components-2.html new file mode 100644 index 000000000000..6242cc069eec --- /dev/null +++ b/tracker/test/fixtures/live-view-moon-components-2.html @@ -0,0 +1,20 @@ + + + + + + + Plausible Playwright LiveView tests + + + + + + LiveView-related tests +
+ + + +
+ + diff --git a/tracker/test/fixtures/live-view-moon-components-3.html b/tracker/test/fixtures/live-view-moon-components-3.html new file mode 100644 index 000000000000..fb94467700f0 --- /dev/null +++ b/tracker/test/fixtures/live-view-moon-components-3.html @@ -0,0 +1,20 @@ + + + + + + + Plausible Playwright LiveView tests + + + + + + LiveView-related tests +
+ + + +
+ + diff --git a/tracker/test/fixtures/live-view-moon-components-4.html b/tracker/test/fixtures/live-view-moon-components-4.html new file mode 100644 index 000000000000..f6c3dc43e847 --- /dev/null +++ b/tracker/test/fixtures/live-view-moon-components-4.html @@ -0,0 +1,20 @@ + + + + + + + Plausible Playwright LiveView tests + + + + + + LiveView-related tests +
+ + + +
+ + diff --git a/tracker/test/fixtures/live-view-moon-components.html b/tracker/test/fixtures/live-view-moon-components.html new file mode 100644 index 000000000000..98e673f575fd --- /dev/null +++ b/tracker/test/fixtures/live-view-moon-components.html @@ -0,0 +1,20 @@ + + + + + + + Plausible Playwright LiveView tests + + + + + + LiveView-related tests +
+ + + +
+ + diff --git a/tracker/test/fixtures/live-view.html b/tracker/test/fixtures/live-view.html index 6e6aaabb5b7b..5614ce37bffd 100644 --- a/tracker/test/fixtures/live-view.html +++ b/tracker/test/fixtures/live-view.html @@ -12,7 +12,7 @@ LiveView-related tests
- +
diff --git a/tracker/test/live-view.spec.js b/tracker/test/live-view.spec.js index b1882472618c..fae1e9728067 100644 --- a/tracker/test/live-view.spec.js +++ b/tracker/test/live-view.spec.js @@ -47,5 +47,68 @@ test.describe('script.live-view.js tracking', () => { expect(request.postDataJSON().u).toEqual("/navigate") expectCustomEvent(request, 'pageview', {}) }); + +}); + +test.describe('script.live-view.js moon ds tracking', () => { + let plausibleRequestMock; + + test.beforeEach(async ({ page }) => { + plausibleRequestMock = mockRequest(page, '/api/event') + await page.goto('/live-view-moon-components.html'); + }); + + test('Sends data-moon-react-assets-id', async ({ page }) => { + await page.evaluate(() => window.dispatchEvent(new CustomEvent("data-moon-react-assets-id", { value: "main-form" }))) + const request = await plausibleRequestMock; + expectCustomEvent(request, 'phx-event', { event: 'data-moon-react-assets-id', value: 'main-form' }) + }); + +}); + +test.describe('script.live-view.js moon icons ds tracking', () => { + let plausibleRequestMock; + + test.beforeEach(async ({ page }) => { + plausibleRequestMock = mockRequest(page, '/api/event') + await page.goto('/live-view-moon-components-4.html'); + }); + + test('Sends data-moon-icons-react-id', async ({ page }) => { + await page.evaluate(() => window.dispatchEvent(new CustomEvent("data-moon-icons-react-id", { value: "main-form-react" }))) + const request = await plausibleRequestMock; + expectCustomEvent(request, 'phx-event', { event: 'data-moon-icons-react-id', value: 'main-form-react' }) + }); + +}); + +test.describe('script.live-view.js moon ds elixir tracking', () => { + let plausibleRequestMock; + + test.beforeEach(async ({ page }) => { + plausibleRequestMock = mockRequest(page, '/api/event') + await page.goto('/live-view-moon-components-2.html'); + }); + test('Sends data-moon-elixir-assets-id', async ({ page }) => { + await page.evaluate(() => window.dispatchEvent(new CustomEvent("data-moon-elixir-assets-id", { value: "main-form-elixir" }))) + const request = await plausibleRequestMock; + expectCustomEvent(request, 'phx-event', { event: 'data-moon-elixir-assets-id', value: 'main-form-elixir' }) + }); }); + +test.describe('script.live-view.js moon ds icons tracking', () => { + let plausibleRequestMock; + + test.beforeEach(async ({ page }) => { + plausibleRequestMock = mockRequest(page, '/api/event') + await page.goto('/live-view-moon-components-3.html'); + }); + + test('Sends data-moon-icons-id', async ({ page }) => { + await page.evaluate(() => window.dispatchEvent(new CustomEvent("data-moon-icons-id", { value: "main-form-icon" }))) + const request = await plausibleRequestMock; + expectCustomEvent(request, 'phx-event', { event: 'data-moon-icons-id', value: 'main-form-icon' }) + }); + +}); \ No newline at end of file