Socket
Socket
Sign inDemoInstall

nuxt-umami

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nuxt-umami - npm Package Compare versions

Comparing version 1.2.1 to 2.0.0-beta.1

app.config.ts

59

package.json
{
"name": "nuxt-umami",
"type": "module",
"version": "1.2.1",
"private": false,
"description": "Embed the Umami analytics library into Nuxt",
"version": "2.0.0-beta.1",
"main": "./nuxt.config.ts",
"description": "Integrate Umami Analytics into Nuxt",
"author": "ML <me.mlaure@gmail.com>",
"license": "unlicense",
"repository": "https://github.com/ijkml/nuxt-umami",
"license": "MIT",
"repository": "https://github.com/ijkml/nuxt-umami/tree/next",
"keywords": [
"nuxt",
"umami",
"umami analytics",
"analytics",
"tracking",
"nuxt module"
"nuxt-umami",
"nuxt layer",
"nuxt module",
"nuxt plugin"
],
"exports": {
".": {
"require": "./dist/module.cjs",
"import": "./dist/module.mjs"
}
},
"main": "./dist/module.cjs",
"types": "./dist/types.d.ts",
"files": [
"dist"
"utils/",
"middleware/",
"internal/",
"app.config.ts",
"app.vue",
"nuxt.config.ts"
],
"scripts": {
"prepack": "nuxt-module-build",
"dev": "nuxi dev playground",
"dev:build": "nuxi build playground",
"dev:prepare": "nuxt-module-build --stub && nuxi prepare playground",
"dev": "nuxi prepare & nuxi dev .playground",
"build": "nuxi build .playground",
"generate": "nuxi generate .playground",
"preview": "nuxi preview .playground",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"release": "npm run prepack && bumpp --commit --push --tag && npm publish --access public"
"release": "bumpp --commit --push --tag && npm publish --access public --tag next",
"release:beta": "bumpp --commit --push --no-tag && npm publish --access public --tag next"
},
"dependencies": {
"@nuxt/kit": "^3.0.0-rc.13"
},
"devDependencies": {
"@antfu/eslint-config-ts": "^0.35.1",
"@nuxt/module-builder": "latest",
"@nuxt/schema": "^3.0.0-rc.13",
"@nuxt/types": "^2.15.8",
"@nuxtjs/eslint-config-typescript": "latest",
"@antfu/eslint-config": "^0.35.2",
"@types/node": "^18.14.0",
"bumpp": "^8.2.1",
"eslint": "latest",
"nuxt": "3.0.0-rc.13"
"eslint": "^8.34.0",
"eslint-plugin-vue": "^9.9.0",
"nuxt": "^3.2.2",
"typescript": "^4.9.5"
}
}

@@ -1,180 +0,129 @@

![cover image](/preview/cover.png)
# Nuxt Umami <sup>@next<sup>
# Nuxt Umami Module
[![npm](https://img.shields.io/npm/v/nuxt-umami.svg?style=flat-square)](https://www.npmjs.com/package/nuxt-umami)
[![npm](https://img.shields.io/npm/v/nuxt-umami/next?style=flat-square)](https://www.npmjs.com/package/nuxt-umami/v/next)
[![Downloads](https://img.shields.io/npm/dt/nuxt-umami.svg?style=flat-square)](https://www.npmjs.com/package/nuxt-umami)
[![License](https://img.shields.io/npm/l/nuxt-umami.svg?style=flat-square)](/LICENSE)
[![License](https://img.shields.io/npm/l/nuxt-umami/?style=flat-square)](/LICENSE)
This is a fully featured nuxt module that makes implementing [**Umami Analytics**](https://umami.is/) into your Nuxt project a breeze.
Deeply integrate [**Umami Analytics**](https://umami.is/) into your Nuxt websites / applications.
> **Heads up:**
> This version uses features (Nuxt Layers) that are only available in **Nuxt 3**.
> Check out [Nuxt Umami v1](https://github.com/ijkml/nuxt-umami) for Nuxt 2 compat.
## Features
- 📖 Open Source
- ✨ SSR support
- 💯 Feature complete
- ✅ TypeScript & JSDocs
- ✅ Supports `<script setup>` syntax
- ✨ SSR Support, of course
- ➖ No extra script: no extra tag, no script loading, instant availability
- 😜 Escapes ad & script blockers (catch me if you can)
- 💯 Feature complete + extensive config
- ✅ Better Typescript, JSDocs, auto completion
- ✅ Error handling + debugging
- ✅ Nuxt utils + auto import
## Setup
## Installation
### Step 1: Installation and add to Nuxt
With `pnpm`
```bash
pnpm add -D nuxt-umami
```
Install using your favorite package manager...
Or, with `npm`
```bash
npm install -D nuxt-umami
pnpm add nuxt-umami@next #pnpm
```
Or, with `yarn`
```bash
yarn add -D nuxt-umami
npm install nuxt-umami@next #npm
```
### Setup
Then add `nuxt-umami` to your `extends` array in `nuxt.config`:
Add the module to `nuxt.config`:
```ts
defineNuxtConfig({
extends: ['nuxt-umami']
});
```
```typescript
// nuxt.config.ts (Nuxt 3)
export default defineNuxtConfig({
modules: ['nuxt-umami'],
umami: {
enable: true, // enable the module? true by default
autoTrack: true,
doNotTrack: false,
cache: false,
domains: 'mywebsite.com,mywebsite2.com',
websiteId: 'your-website-id',
scriptUrl: 'https://path.to.umami.js',
}
})
Or, you can totally skip the installation process and do
// or inline config
export default defineNuxtConfig({
modules: [['nuxt-umami', {
// nuxt-umami options
}]]
})
```ts
defineNuxtConfig({
extends: ['github:ijkml/nuxt-umami#next']
});
```
```javascript
// nuxt.config.js (Nuxt 2)
export default {
modules: [
['nuxt-umami'],
],
umami: {
autoTrack: true,
doNotTrack: false,
cache: false,
domains: 'mywebsite.com,mywebsite2.com',
websiteId: 'your-website-id',
scriptUrl: 'https://path.to.umami.js',
}
}
> **Warning**:
> This might cause unwanted errors due to changes as the branch is still WIP.
// or inline config
export default {
modules: [
['nuxt-umami', {
// nuxt-umami options
}]
]
}
```
### Step 2: Configure Umami
Only `websiteId` and `scriptUrl` are mandatory. [See the Umami docs](https://umami.is/docs/tracker-configuration) for more explanation of these options.
You can provide configuration options using the `app.config.ts` file or `appConfig` property of the Nuxt config.
> **New**:
> Set the `enable` option to `false` to disable the module (temporarily).
#### `app.config.ts` file
(recommended for readability and ease of update)
### Environment Variables
If you want, you can set up and use environment variables in `.env` files. But that is not really necessary as the module config does not require any "sensitive" data. Every part of the configuration can be viewed in the script in `<head>` after the page is loaded.
```ts
export default defineAppConfig({
umami: {
// ...umami config here
},
});
```
<br>
#### `appConfig` property
## Usage
> **Note**:
> You can use `$umami` anywhere you have access to `NuxtApp` or the `useNuxtApp` composable (middleware, asyncData, etc).
```ts
defineNuxtConfig({
extends: ['nuxt-umami@next'],
appConfig: {
umami: {
// ...umami config here
},
},
});
```
> **Warning**:
> $umami is only available `onMounted`.
### Step 3:
### In `<script setup>`
Use it?
```vue
<script setup>
const { $umami } = useNuxtApp();
## Configuration
onMounted(() => {
// Sends an event with an event type of custom.
$umami("Signup button click");
});
</script>
```
| option | type | description | required | default |
|---|---|---|---|---|
| host | string | Your Umami endpoint. This is where your script is hosted. Eg: `https://ijkml.xyz/`. | true | '' |
| id | string | Unique website-id provided by Umami. | true | '' |
| domains | string | Limit tracker to specific domains by providing a comma-separated list (without 'http'). Leave blank for all domains. | false | '' |
| ignoreDnt | boolean | Option to ignore browsers' Do Not Track setting. | false | true |
| autoTrack | boolean | Option to automatically track page views. | false | true |
| ignoreLocalhost | boolean | Option to prevent tracking on localhost. | false | false |
### In middleware, asyncData, etc
## Usage
```javascript
const { data } = await useAsyncData("mountains", (nuxtApp) => {
const { $umami } = nuxtApp();
// do something, return something
});
```
Two functions are auto-imported, `umTrackView()` and `umTrackEvent()`. Use them however and wherever you like.
## Available Functions
### Available Methods
> For a list of all available functions, see [Umami Tracker Functions](https://umami.is/docs/tracker-functions)
- `umTrackView(url, referrer)`
- `url`: the path being tracked, eg `/about`, `/contact?by=phone#office`. *Most times*, this can be correctly inferred. Equivalent of `router.fullPath`.
- `referrer`: the page referrer. *Most times*, this can be correctly inferred. Equivalent of `document.referrer`.
## Credits
- `umTrackEvent(eventName, eventData)`
- `eventName`: a string type text
- `eventData`: could be string, number, array or object
- [VueUse](https://github.com/vueuse/vueuse) - for `useScriptTag` composable.
- [Joe Pritchard](https://github.com/joe-pritchard/nuxt-umami-module) - author of nuxt-umami-module (compatible only with Nuxt 2).
## Author
Reference: [Umami Tracker Functions](https://umami.is/docs/tracker-functions).
Hi, I'm [ML](https://github.com/ijkml/). I'm dedicated to contributing to open source and sharing my insights on [Twitter](https://twitter.com/ijk_ml). If you encounter any issues with my module, don't hesitate to open an issue. I'm always available to help and resolve any bugs.
Using the module in your app? Consider giving it a star 🌟. It'd mean the world to me.
## Issues, Bugs, Ideas?
## Contributions
Open an issue, fire a PR. Contributions are welcome! If you encounter any issues, don't hesitate to open an issue. I'm always available to help and resolve any bugs.
## Contributors
<a href="https://github.com/ijkml/nuxt-umami/graphs/contributors">
<img src="https://contrib.rocks/image?repo=ijkml/nuxt-umami" />
<img alt="Nuxt Umami contributors" src="https://contrib.rocks/image?repo=ijkml/nuxt-umami" />
</a>
<!-- Banner Image For Reference: https://banner.browserku.com/ -->
<!-- <div
class="relative bg-gradient-to-r from-[#255461] to-[#00DC82] h-full font-open-sans bg-cover bg-center p-2"
>
<div class="z-2 relative bg-white bg-opacity-90 rounded-md shadow-lg h-full p-7 flex flex-col justify-between overflow-hidden">
<img class="absolute z-1 top-[-80px] right-[-20px] w-[500px] opacity-8" :src="bg"/>
<div>
<h1 class="text-5xl font-bold line-clamp-3 pb-1">{{ title }}</h1>
<p class="text-gray-700 italic">{{ description }}</p>
</div>
<div class="mt-3 flex items-center justify-between">
<div class="flex items-center space-x-2 text-lg">
<img class="w-10 h-10 rounded-full" crossorigin="anonymous" :src="avatar" />
<span class="font-semibold">{{ author }}</span>
</div>
<div>
<img :src="logo" alt="logo" class="h-12" />
</div>
</div>
</div>
</div> -->
<!-- Format Data -->
<!-- {
"title": "nuxt-umami",
"description": "Umami Analytics built for Nuxt 2/3.",
"author": "Moses Laurence",
"avatar": "https://avatars.githubusercontent.com/u/52390439?v=4",
"bg": "https://nuxtjs.org/design-kit/black-logo.svg",
"logo": "https://nuxtjs.org/design-kit/black-text.svg"
} -->
[MIT](./LICENSE) License © 2023 [ML](https://github.com/ijkml/)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc