-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only create Matomo Tracker instance if confirm_tracking cookie has be… #36
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Only create Matomo Tracker instance if confirm_tracking cookie has been set. @fredvd |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,15 +8,16 @@ const Matomo = ({ matomoTracker }) => { | |
const confirmTracking = !!Number(cookies.confirm_tracking); | ||
let tracker; | ||
|
||
if (__CLIENT__) { | ||
tracker = new matomoTracker.default({ | ||
urlBase: config.settings.DSGVOBanner.tracker.urlBase, | ||
siteId: config.settings.DSGVOBanner.tracker.id, | ||
}); | ||
} | ||
|
||
useEffect(() => { | ||
if (confirmTracking) { | ||
if (confirmTracking && __CLIENT__ ) { | ||
tracker = new matomoTracker.default({ | ||
urlBase: config.settings.DSGVOBanner.tracker.urlBase, | ||
siteId: config.settings.DSGVOBanner.tracker.id, | ||
configurations: { // optional, default value: {} | ||
disableCookies: false, | ||
setSecureCookie: true, | ||
}, | ||
}); | ||
tracker.trackPageView(); | ||
} | ||
}, [tracker, confirmTracking]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The hook should not have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (This is also why the linter is complaining.) |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fredvd useEffect hooks only run on the client (see the implementation of the useClient hook! https://github.com/plone/volto/blob/0987c96dbc4597b8ab36009af4e4bfa125f123ec/packages/volto/src/hooks/client/useClient.js#L5) so this is redundant.