UNPKG

@piwikpro/nuxt-piwik-pro

Version:

Dedicated Piwik PRO library that helps with implementing Piwik PRO Tag Manager and the Piwik PRO tracking client in Nuxt.js applications.

16 lines (15 loc) 705 B
const handlePiwikPRO = async (nuxtApp, handler) => { if (import.meta.client) { const { $piwikPRO } = nuxtApp; // This check is needed in case of using `usePiwikPro` without injecting the module itself into Nuxt application in nuxt.config.ts if ($piwikPRO) { return await handler($piwikPRO); } console.error("Piwik PRO is not injected to Nuxt App. Pass '@piwikpro/nuxt-piwik-pro' package as a Nuxt module in 'nuxt.config' file."); } else { console.warn("Piwik PRO is client only library and cannot be use in server side."); } return undefined; }; export const usePiwikPro = (handler) => handlePiwikPRO(useNuxtApp(), handler);