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.3 to 2.1.4

51

internal/utils.ts

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

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

@@ -42,8 +42,10 @@ } = {},

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

@@ -71,2 +73,10 @@ host: umamiHost || host,

const endpoint = computed(() => {
const { host, customEndpoint, version } = umConfig.value;
const root = new URL(host);
const branch = customEndpoint || (version === 2 ? '/api/send' : '/api/collect');
return `${root.protocol}//${root.host}${branch}`;
});
const preflight = computed((): PreflightResult => {

@@ -83,3 +93,3 @@ if (typeof window === 'undefined') {

if (isInvalidHost(host)) {
if (isInvalidHost(host) || isInvalidHost(endpoint.value)) {
return 'host';

@@ -116,17 +126,17 @@ }

function getPayload(): GetPayloadReturn {
const getPayload = computed((): GetPayloadReturn => {
const {
location: { hostname, pathname, search, hash },
location: { hostname },
screen: { width, height },
navigator,
document: { referrer: pageReferrer },
navigator: { language },
document: { referrer },
} = window;
const pageUrl = pathname + search + hash;
const { fullPath } = useRoute();
const payload: PartialPayload = {
screen: `${width}x${height}`,
language: navigator.language,
language,
hostname,
url: pageUrl,
url: fullPath,
};

@@ -136,14 +146,9 @@

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

@@ -150,0 +155,0 @@ headers: {

@@ -6,8 +6,8 @@ export default defineNuxtConfig({

host: '',
domains: undefined,
version: 1,
domains: '',
autoTrack: true,
ignoreDnt: true,
customEndpoint: '/',
ignoreLocalhost: false,
version: 1,
customEndpoint: undefined,
},

@@ -14,0 +14,0 @@ },

{
"name": "nuxt-umami",
"type": "module",
"version": "2.1.3",
"version": "2.1.4",
"description": "Integrate Umami Analytics into Nuxt",

@@ -42,7 +42,7 @@ "author": "ML <me.mlaure@gmail.com>",

"bumpp": "^9.1.0",
"eslint": "^8.37.0",
"eslint": "^8.38.0",
"eslint-plugin-vue": "^9.10.0",
"nuxt": "^3.3.3",
"typescript": "^5.0.3"
"nuxt": "^3.4.0",
"typescript": "^5.0.4"
}
}

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

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

@@ -60,3 +60,4 @@ void collect(

const { id } = umConfig.value;
const { payload } = getPayload();
const { payload } = getPayload.value;
const name = eventName || '#unknown-event';

@@ -63,0 +64,0 @@

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