From eee01013dcbadf8384e830c5f2028c8fcaf1e7e2 Mon Sep 17 00:00:00 2001 From: ML Date: Fri, 19 Jul 2024 21:16:53 +0100 Subject: [PATCH] chore: create docs folder --- docs/README.md | 220 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 220 insertions(+) create mode 100644 docs/README.md diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..6e848a9 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,220 @@ +# Nuxt Umami + +[![npm](https://img.shields.io/npm/v/nuxt-umami?style=flat-square)](https://www.npmjs.com/package/nuxt-umami/) +[![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?style=flat-square)](/LICENSE) +[![Sponsor](https://img.shields.io/badge/Sponsor-21262d?style=flat-square&logo=github&logoColor=db61a2)](https://github.com/sponsors/ijkml) + +Integrate [**Umami Analytics**](https://umami.is/) into your Nuxt websites/applications. + +## Features + +- 📖 Open source +- ✨ SSR support, of course +- ➖ No extra script, no loading delay +- 😜 Escapes ad & script blockers +- 💯 Simple, feature complete, extensive config +- ✅ Typescript, JSDocs, auto completion +- ✅ Auto imported, available (almsot) everywhere +- ✅ Easy debuggin' (one `console.log` at a time) + +## Setup + +### 🚀 Try it online + +Open in StackBlitz + +### Step 1: Install and add to Nuxt + +Install using your favorite package manager... + +```bash +pnpm add nuxt-umami #pnpm +``` + +```bash +npm install nuxt-umami #npm +``` + +Then add `nuxt-umami` to your `extends` array in `nuxt.config`: + +```ts +defineNuxtConfig({ + extends: ['nuxt-umami'] +}); +``` + +Or, you can totally skip the installation process and do + +```ts +defineNuxtConfig({ + extends: ['github:ijkml/nuxt-umami'] +}); +``` + +### Step 2: Configure Umami + +You can provide configuration options using the `app.config.ts` file or `appConfig` property of the Nuxt config. + +#### `app.config.ts` file + +(recommended for readability and ease of update) + +```ts +export default defineAppConfig({ + umami: { + // ...umami config here + }, +}); +``` + +#### `appConfig` property + +```ts +defineNuxtConfig({ + extends: ['nuxt-umami'], + appConfig: { + umami: { + // ...umami config here + }, + }, +}); +``` + +#### Environment Variables + +You can provide the `host` and `id` config (only) as environment variables. Simply add `NUXT_PUBLIC_UMAMI_HOST` and `NUXT_PUBLIC_UMAMI_ID` to your `.env` file, and that's it. Please note that provided env variables override `appConfig`. + +```sh +NUXT_PUBLIC_UMAMI_HOST="https://domain.tld" +NUXT_PUBLIC_UMAMI_ID="abc123-456def-ghi789" +``` + +### Step 3: + +
+Use it +

+ +```vue + + + +``` + +

+
+ +## Configuration + +| option | type | description | required | default | +| --------------- | ------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | -------- | ----------- | +| host | `string` | Your Umami endpoint. This is where your script is hosted. Eg: `https://ijkml.xyz/`. | yes | `''` | +| id | `string` | Unique website-id provided by Umami. | yes | `''` | +| domains | `string \| Array` | Limit tracker to specific domains by providing an array or comma-separated list (without 'http'). Leave blank for all domains. | no | `undefined` | +| autoTrack | `boolean` | Option to automatically track page views. | no | `true` | +| ignoreLocalhost | `boolean` | Option to prevent tracking on localhost. | no | `false` | +| customEndpoint | `string` | Set a custom `COLLECT_API_ENDPOINT`. See [Docs](https://umami.is/docs/environment-variables). | no | `undefined` | +| version | `1 \| 2` | Umami version | no | `1` | +| useDirective | `boolean` | Option to enable the `v-umami` directive. See below. | no | `false` | +| debug | `boolean` | Option to enable error logs (in production), useful for testing in prod :) | no | `false` | + +## Usage + +Two functions are auto-imported, `umTrackView()` and `umTrackEvent()`. Use them freely. Please note that in `