Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nuxt-umami

Package Overview
Dependencies
Maintainers
1
Versions
70
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 2.1.0 to 2.1.2

1

internal/debug.ts

@@ -22,2 +22,3 @@ import type { PreflightResult } from './types';

const helloDebugger = process.env.NODE_ENV === 'production'
// eslint-disable-next-line unused-imports/no-unused-vars
? (id: ErrorId, raw?: any) => {}

@@ -24,0 +25,0 @@ : (id: ErrorId, raw?: any) => {

38

internal/utils.ts

@@ -36,2 +36,3 @@ import type {

autoTrack = true,
customEndpoint: customEP = undefined,
version = 1,

@@ -41,2 +42,8 @@ } = {},

const customEndpoint = !isValidString(customEP)
? undefined
: customEP.startsWith('/')
? customEP
: `/${customEP}`;
return {

@@ -49,2 +56,3 @@ host: umamiHost || host,

autoTrack,
customEndpoint,
version,

@@ -54,5 +62,13 @@ };

function preflight(): PreflightResult {
const { ignoreDnt, domains, id, host, ignoreLocal } = umConfig.value;
const domainList = computed(() => {
const domains = umConfig.value.domains;
return (Array.isArray(domains) && domains.length)
? domains
: isValidString(domains)
? domains.split(',').map(d => d.trim())
: undefined;
});
const preflight = computed((): PreflightResult => {
if (typeof window === 'undefined') {

@@ -62,2 +78,4 @@ return 'ssr';

const { ignoreDnt, id, host, ignoreLocal } = umConfig.value;
if (!isValidString(id)) {

@@ -80,9 +98,5 @@ return 'id';

const domainList = (Array.isArray(domains) && domains.length)
? domains
: isValidString(domains)
? domains.split(',').map(d => d.trim())
: undefined;
const domains = domainList.value;
if (domainList && !domainList.includes(hostname)) {
if (domains && !domains.includes(hostname)) {
return 'domain';

@@ -102,3 +116,3 @@ }

return true;
}
});

@@ -130,6 +144,6 @@ function getPayload(): GetPayloadReturn {

async function collect(load: ServerPayload) {
const { host, version } = umConfig.value;
const { host, customEndpoint, version } = umConfig.value;
const root = new URL(host);
const branch = version === 2 ? 'api/send' : 'api/collect';
const endpoint = `${root.protocol}//${root.host}/${branch}`;
const branch = customEndpoint || (version === 2 ? '/api/send' : '/api/collect');
const endpoint = `${root.protocol}//${root.host}${branch}`;

@@ -136,0 +150,0 @@ fetch(endpoint, {

@@ -11,2 +11,3 @@ export default defineNuxtConfig({

version: 1,
customEndpoint: undefined,
},

@@ -75,2 +76,6 @@ },

version?: 1 | 2
/**
* Self-hosted Umami lets you set a COLLECT_API_ENDPOINT, which is `/api/collect` by default. See Umami [Docs](https://umami.is/docs/environment-variables).
*/
customEndpoint?: `/${string}`
}

@@ -88,4 +93,5 @@ }

version?: 1 | 2
customEndpoint?: `/${string}`
}
}
}
{
"name": "nuxt-umami",
"type": "module",
"version": "2.1.0",
"version": "2.1.2",
"description": "Integrate Umami Analytics into Nuxt",

@@ -39,10 +39,10 @@ "author": "ML <me.mlaure@gmail.com>",

"devDependencies": {
"@antfu/eslint-config": "^0.37.0",
"@types/node": "^18.15.5",
"bumpp": "^9.0.0",
"eslint": "^8.36.0",
"eslint-plugin-vue": "^9.9.0",
"nuxt": "^3.3.1",
"typescript": "^5.0.2"
"@antfu/eslint-config": "^0.38.4",
"@types/node": "^18.15.11",
"bumpp": "^9.1.0",
"eslint": "^8.37.0",
"eslint-plugin-vue": "^9.10.0",
"nuxt": "^3.3.3",
"typescript": "^5.0.3"
}
}

@@ -90,2 +90,14 @@ # Nuxt Umami <sup>@next<sup>

#### Environment Variables
> **Note**:
> Available in `^2.1.0` and takes precedence over `appConfig`.
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.
```sh
NUXT_PUBLIC_UMAMI_HOST="https://domain.tld"
NUXT_PUBLIC_UMAMI_ID="abc123-456def-ghi789"
```
### Step 3:

@@ -105,16 +117,5 @@

| ignoreLocalhost | `boolean` | Option to prevent tracking on localhost. | no | `false` |
| version | `1 \| 2` | Umami version (Cloud) | no | `1` |
| customEndpoint | `string` | Set a custom `COLLECT_API_ENDPOINT`. See [Docs](https://umami.is/docs/environment-variables). | no | `undefined`
| version | `1 \| 2` | Umami version (Cloud) | no | `1` |
### Environment Variables
> **Note**:
> Available in `^2.1.0` and takes precedence over `appConfig`.
You can provide the `host` and `id` config as environment variables. Simply add `NUXT_PUBLIC_UMAMI_HOST` and `NUXT_PUBLIC_UMAMI_ID` to your `.env` file, and that's it.
```sh
NUXT_PUBLIC_UMAMI_HOST="https://domain.tld"
NUXT_PUBLIC_UMAMI_ID="abc123-456def-ghi789"
```
## Usage

@@ -121,0 +122,0 @@

@@ -13,3 +13,3 @@ import { collect, getPayload, preflight, umConfig } from '../internal/utils';

function trackView(url?: string, referrer?: string): void {
const check = preflight();
const check = preflight.value;

@@ -48,3 +48,3 @@ if (check === 'ssr') {

function trackEvent(eventName: string, eventData?: EventData) {
const check = preflight();
const check = preflight.value;

@@ -51,0 +51,0 @@ if (check === 'ssr') {

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