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 2.0.3 to 2.0.4-beta.1

20

internal/debug.ts

@@ -21,14 +21,12 @@ import type { PreflightResult } from './types';

function screamer(id: ErrorId, raw?: any) {
const { level, text } = warnings[id];
// eslint-disable-next-line no-console
console[level](`[UMAMI]: ${text}`, '\n');
// eslint-disable-next-line no-console
raw && (console[level](raw));
}
const helloDebugger = process.env.NODE_ENV === 'production'
? (id: ErrorId, raw?: any) => {}
: (id: ErrorId, raw?: any) => {
const { level, text } = warnings[id];
// eslint-disable-next-line no-console
console[level](`[UMAMI]: ${text}`, '\n');
// eslint-disable-next-line no-console
raw && (console[level](raw));
};
function silencio(id: ErrorId, raw?: any) {}
const helloDebugger = process.env.NODE_ENV === 'production' ? silencio : screamer;
export { helloDebugger };

@@ -26,10 +26,2 @@ interface BasicPayload {

interface PreflightArgs {
ignoreDnt?: boolean
domains?: string
id?: string
host?: string
ignoreLocal?: boolean
}
interface ServerPayload {

@@ -53,5 +45,4 @@ type: PayloadType

ServerPayload,
PreflightArgs,
PreflightResult,
GetPayloadReturn,
};
import type {
GetPayloadReturn,
PartialPayload,
PreflightArgs,
PreflightResult,

@@ -28,5 +27,31 @@ ServerPayload,

function preflight(
{ ignoreDnt, domains, id, host, ignoreLocal }: PreflightArgs,
): PreflightResult {
const umConfig = computed(() => {
const { public: { umamiHost, umamiId } } = useRuntimeConfig();
const {
umami: {
host = '',
id = '',
domains = '',
ignoreDnt = true,
ignoreLocalhost: ignoreLocal = false,
autoTrack = true,
version = 1,
},
} = useAppConfig();
return {
host: umamiHost || host,
id: umamiId || id,
domains,
ignoreDnt,
ignoreLocal,
autoTrack,
version,
};
});
function preflight(): PreflightResult {
const { ignoreDnt, domains, id, host, ignoreLocal } = umConfig.value;
if (typeof window === 'undefined') {

@@ -99,3 +124,3 @@ return 'ssr';

async function collect(load: ServerPayload) {
const { umami: { host, version } } = useAppConfig();
const { host, version } = umConfig.value;
const root = new URL(host);

@@ -122,2 +147,2 @@ const branch = version === 2 ? 'api/send' : 'api/collect';

export { preflight, getPayload, assert, collect };
export { preflight, getPayload, assert, collect, umConfig };

@@ -0,5 +1,6 @@

import { umConfig } from '../internal/utils';
import { umTrackView } from '../utils/umami';
export default defineNuxtRouteMiddleware((to) => {
const { umami: { autoTrack } = {} } = useAppConfig();
const { autoTrack } = umConfig.value;

@@ -6,0 +7,0 @@ if (autoTrack) {

@@ -13,2 +13,8 @@ export default defineNuxtConfig({

},
runtimeConfig: {
public: {
umamiHost: '',
umamiId: '',
},
},
});

@@ -15,0 +21,0 @@

{
"name": "nuxt-umami",
"type": "module",
"version": "2.0.3",
"version": "2.0.4-beta.1",
"description": "Integrate Umami Analytics into Nuxt",

@@ -6,0 +6,0 @@ "author": "ML <me.mlaure@gmail.com>",

@@ -26,2 +26,6 @@ # Nuxt Umami <sup>@next<sup>

### 🚀 Try it online
<a href="https://stackblitz.com/edit/nuxt-umami-next"><img src="https://developer.stackblitz.com/img/open_in_stackblitz.svg" alt="Open in StackBlitz"></a>
### Step 1: Install and add to Nuxt

@@ -28,0 +32,0 @@

@@ -1,2 +0,2 @@

import { assert, collect, getPayload, preflight } from '../internal/utils';
import { collect, getPayload, preflight, umConfig } from '../internal/utils';
import type { EventData, EventPayload, ViewPayload } from '../internal/types';

@@ -13,12 +13,4 @@ import { helloDebugger } from '../internal/debug';

function trackView(url?: string, referrer?: string): void {
const {
umami: {
id, host, domains,
ignoreDnt = false,
ignoreLocalhost: ignoreLocal = false,
} = {},
} = useAppConfig();
const check = preflight();
const check = preflight({ domains, ignoreDnt, id, host, ignoreLocal });
if (check === 'ssr') {

@@ -33,4 +25,3 @@ return;

assert(typeof id === 'string');
const { id } = umConfig.value;
const { pageReferrer, pageUrl, payload } = getPayload();

@@ -58,12 +49,4 @@

function trackEvent(eventName: string, eventData?: EventData) {
const {
umami: {
id, host, domains,
ignoreDnt = false,
ignoreLocalhost: ignoreLocal = false,
} = {},
} = useAppConfig();
const check = preflight();
const check = preflight({ domains, ignoreDnt, host, id, ignoreLocal });
if (check === 'ssr') {

@@ -78,4 +61,3 @@ return;

assert(typeof id === 'string');
const { id } = umConfig.value;
const { payload } = getPayload();

@@ -82,0 +64,0 @@ const name = eventName || '#unknown-event';

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