This commit is contained in:
Sam Richards 2024-01-04 11:37:39 +01:00 committed by GitHub
commit f0476523f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 25 additions and 1 deletions

View File

@ -1 +1,25 @@
// noop
/**
* Create custom Matomo event.
*
* @see https://matomo.org/docs/event-tracking/
*/
export const trackCustomEvent = ({
eventCategory,
eventAction,
eventName,
eventValue
}) => {
if (process.env.NODE_ENV === 'production' || window.dev === true) {
if (!window._paq) return
const { _paq, dev } = window
_paq.push([`trackEvent`, eventCategory, eventAction, eventName, eventValue])
if (dev) {
console.debug(
`[Matomo] event tracked, category: ${eventCategory}, action: ${eventAction}, name: ${eventName}, value: ${eventValue}`
)
}
}
}