Work in progress

This commit is contained in:
Julien Nahum
2023-12-09 15:47:03 +01:00
parent f970557b76
commit 1f853e8178
315 changed files with 34058 additions and 25 deletions

26
client/plugins/amplitude.js vendored Normal file
View File

@@ -0,0 +1,26 @@
const {logEvent} = useAmplitude()
// Hook function used by event listener
function hookLogEvent (binding) {
const modifiers = Object.keys(binding.modifiers)
if (modifiers.length !== 1) {
throw new Error('Amplitude directive takes only one modifier which is the event name.')
}
const eventName = modifiers[0]
logEvent(eventName, binding.value)
}
export default defineNuxtPlugin(nuxtApp => {
// Doing something with nuxtApp
const registeredListeners = {}
nuxtApp.vueApp.directive('track', {
beforeMount (el, binding, vnode) {
registeredListeners[el] = () => {
hookLogEvent(binding)
}
el.addEventListener('click', registeredListeners[el])
}
})
})