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.6.0 to 2.6.1

3

internal/types.ts

@@ -36,2 +36,4 @@ interface BasicPayload {

type FetchResult = Promise<{ ok: boolean }>;
export type {

@@ -45,2 +47,3 @@ EventData,

PreflightResult,
FetchResult,
};

21

internal/utils.ts
import type {
FetchResult,
PartialPayload,

@@ -148,4 +149,8 @@ PreflightResult,

async function collect(load: ServerPayload) {
fetch(endpoint.value, {
function earlyPromise(ok: boolean): FetchResult {
return Promise.resolve({ ok });
}
async function collect(load: ServerPayload): FetchResult {
return fetch(endpoint.value, {
method: 'POST',

@@ -158,13 +163,15 @@ headers: {

})
.then(async (res) => {
if (res && !res.ok)
return helloDebugger.value('err-collect', res);
.then(async (response) => {
if (!response.ok)
throw new Error('Network error', { cause: response });
cache.value = await res.text();
cache.value = await response.text();
return { ok: true };
})
.catch((err) => {
helloDebugger.value('err-collect', err);
return { ok: false };
});
}
export { isValidString, preflight, getPayload, collect, umConfig, helloDebugger };
export { isValidString, preflight, getPayload, collect, earlyPromise, umConfig, helloDebugger };
{
"name": "nuxt-umami",
"type": "module",
"version": "2.6.0",
"version": "2.6.1",
"description": "Integrate Umami Analytics into Nuxt",

@@ -44,9 +44,9 @@ "author": "ML <me.mlaure@gmail.com>",

"devDependencies": {
"@antfu/eslint-config": "~2.7.0",
"@types/node": "^20.11.24",
"bumpp": "^9.3.0",
"eslint": "^8.57.0",
"nuxt": "^3.10.3",
"typescript": "^5.3.3"
"@antfu/eslint-config": "~2.16.0",
"@types/node": "^20.12.7",
"bumpp": "^9.4.0",
"eslint": "^9.1.1",
"nuxt": "^3.11.2",
"typescript": "^5.4.5"
}
}

@@ -158,2 +158,12 @@ # Nuxt Umami

### Method Return
Both `umTrackEvent` and `umTrackView` return a Promise with an `ok` status that you can await or chain, `Promise<{ok: boolean}>`.
```ts
umTrackView().then(res => console.log(res.ok));
umTrackView().then(({ ok }) => console.log(ok));
```
### Vue Directive

@@ -160,0 +170,0 @@

@@ -1,3 +0,3 @@

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

@@ -11,11 +11,11 @@ /**

*/
function trackView(url?: string, referrer?: string): void {
function trackView(url?: string, referrer?: string): FetchResult {
const check = preflight.value;
if (check === 'ssr')
return;
return earlyPromise(false);
if (check !== true) {
helloDebugger.value(`err-${check}`);
return;
return earlyPromise(false);
}

@@ -26,3 +26,3 @@

void collect(
return collect(
{

@@ -47,11 +47,11 @@ type: version === 2 ? 'event' : 'pageview',

*/
function trackEvent(eventName: string, eventData?: EventData) {
function trackEvent(eventName: string, eventData?: EventData): FetchResult {
const check = preflight.value;
if (check === 'ssr')
return;
return earlyPromise(false);
if (check !== true) {
helloDebugger.value(`err-${check}`);
return;
return earlyPromise(false);
}

@@ -74,12 +74,6 @@

const eventObj = version === 2
? {
name,
data,
}
: {
event_name: name,
event_data: data,
};
? { name, data }
: { event_name: name, event_data: data };
void collect({
return collect({
type: 'event',

@@ -86,0 +80,0 @@ payload: {

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