
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
@nuxtjs/plausible
Advanced tools
This module provides a minimal Plausible tracker integration with Nuxt.
.env
file support# pnpm
pnpm add -D @nuxtjs/plausible
# npm
npm i -D @nuxtjs/plausible
Add @nuxtjs/plausible
to your Nuxt config:
// `nuxt.config.ts`
export default defineNuxtConfig({
modules: ['@nuxtjs/plausible'],
})
Done! Plausible will now run in your application's client.
ℹ️ By default,
@nuxtjs/plausible
will usewindow.location.hostname
for the Plausibledomain
configuration key, which will suit most users.
All supported module options can be set by either the module options key plausible
, or the public runtime config key with the same name.
export default defineNuxtConfig({
modules: ['@nuxtjs/plausible'],
// Configure using the module options
plausible: {
domain: 'example.com',
},
// **Or** the public runtime config instead
runtimeConfig: {
public: {
plausible: {
domain: 'example.com',
},
},
},
})
Alternatively, leveraging automatically replaced public runtime config values by matching .env
variables at runtime, set your desired option in your project's .env
file:
# Sets the `plausible` public runtime config value for the key `domain`
NUXT_PUBLIC_PLAUSIBLE_DOMAIN=example.com
Option | Type | Description | Default |
---|---|---|---|
hashMode | boolean | Whether page views shall be tracked when the URL hash changes. Enable this if your Nuxt app has the hashMode router option enabled. | false |
trackLocalhost | boolean | Whether events shall be tracked when running the site locally. | false |
domain | string | The domain to bind tracking event to. | window.location.hostname |
apiHost | string | The API host where the events will be sent to. | https://plausible.io |
autoPageviews | boolean | Track the current page and all further pages automatically. Disable this if you want to manually manage pageview tracking. | true |
autoOutboundTracking | boolean | Track all outbound link clicks automatically. If enabled, a MutationObserver automagically detects link nodes throughout the application and binds click events to them. | false |
As with other composables in the Nuxt 3 ecosystem, the following ones are available without the need of importing them.
ℹ️ Since the Plausible instance is available in the client only, calling the tracking composables will have no effect. They will exit gracefully on the server.
useTrackEvent
Track a custom event. Track your defined goals by passing the goal's name as the argument eventName
.
Type Declarations
function useTrackEvent(
eventName: string,
options?: EventOptions,
eventData?: PlausibleOptions,
): void
Example
// Tracks the `signup` goal
useTrackEvent('signup')
// Tracks the `Download` goal passing a `method` property.
useTrackEvent('Download', { props: { method: 'HTTP' } })
useTrackPageview
Manually track a page view.
Pass optional event data to be sent with the eventData
argument. Defaults to the current page's data merged with the default options provided during the Plausible initialization.
Type Declarations
function useTrackPageview(
eventData?: PlausibleOptions,
options?: EventOptions,
): void
corepack enable
pnpm install
pnpm run dev:prepare
pnpm run dev
MIT License © 2022 Johann Schopplich
FAQs
Natively integrates Plausible Analytics into Nuxt
We found that @nuxtjs/plausible demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.