From 2440d47294ae4354c7e7c6361dc717f4fa98a145 Mon Sep 17 00:00:00 2001 From: Krzysztof Durek Date: Wed, 17 Apr 2024 00:07:07 +0200 Subject: [PATCH] fix: umami tracking (#603) * fix: umami tracking * fix: umami tracking test --- README.md | 4 ++-- docs/analytics.md | 2 +- src/analytics/__test__/umami.test.js | 4 +++- src/analytics/umami.js | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 01a203a..5c82487 100644 --- a/README.md +++ b/README.md @@ -164,12 +164,12 @@ Generated tracking code should look like: ``` -Use `data-website-id` as environment variable `UMAMI_WEBSITE_ID`. Take the inital root host of `src` as `UMAMI_APP_URL`, and the name of the script (i.e. `umami.js` or `script.js`) as `UMAMI_SCRIPT_NAME`. +Use `data-website-id` as environment variable `UMAMI_WEBSITE_ID`. Take the initial root host of `src` as `UMAMI_APP_URL`, and the name of the script (i.e. `umami.js` or `script.js`) as `UMAMI_SCRIPT_NAME`. Sample event for YouTube button. ```javascript - window.umami('youtube-button'); + window.umami.track('youtube-button'); ``` #### Matomo diff --git a/docs/analytics.md b/docs/analytics.md index 30ff59f..30713db 100644 --- a/docs/analytics.md +++ b/docs/analytics.md @@ -27,7 +27,7 @@ Use `data-website-id` as environment variable `UMAMI_WEBSITE_ID`. Take the inita Sample event for YouTube button. ```javascript - window.umami('youtube-button'); + window.umami.track('youtube-button'); ``` ### Matomo diff --git a/src/analytics/__test__/umami.test.js b/src/analytics/__test__/umami.test.js index d766304..967f477 100644 --- a/src/analytics/__test__/umami.test.js +++ b/src/analytics/__test__/umami.test.js @@ -6,7 +6,9 @@ describe('umami.js', () => { const originalWindow = { ...window }; windowSpy.mockImplementation(() => ({ ...originalWindow, - umami: mockedUmami, + umami: { + track: mockedUmami, + }, })); it('should call umami with event', () => { trackUmamiEvent('youtube-button'); diff --git a/src/analytics/umami.js b/src/analytics/umami.js index f092ff9..fd90cc7 100644 --- a/src/analytics/umami.js +++ b/src/analytics/umami.js @@ -1,3 +1,3 @@ export function trackUmamiEvent(event) { - window.umami(event); + window.umami.track(event); }