🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@vercel/analytics

Package Overview
Dependencies
Maintainers
8
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vercel/analytics - npm Package Compare versions

Comparing version

to
0.1.7

5

dist/index.d.ts

@@ -7,3 +7,2 @@ interface PageViewEvent {

declare type Mode = 'auto' | 'development' | 'production';
declare type AllowedPropertyValues = string | number | boolean | null;
declare type BeforeSend = (event: Event) => Event | null;

@@ -20,3 +19,2 @@ interface AnalyticsProps {

vai?: boolean;
vam?: Mode;
}

@@ -26,4 +24,3 @@ }

declare const inject: (props?: AnalyticsProps) => void;
declare const track: (name: string, properties?: Record<string, AllowedPropertyValues>) => void;
export { inject, track };
export { inject };

74

dist/index.js

@@ -14,46 +14,13 @@ // src/queue.ts

}
function detectEnvironment() {
function isDevelopment() {
if (typeof process === "undefined")
return "production";
if (process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test")
return "development";
return "production";
return false;
return process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
}
function setMode(mode = "auto") {
function getMode(mode = "auto") {
if (mode === "auto") {
window.vam = detectEnvironment();
return isDevelopment() ? "development" : "production";
}
window.vam = mode;
return mode;
}
function getMode() {
return window.vam || "production";
}
function isProduction() {
return getMode() === "production";
}
function isDevelopment() {
return getMode() === "development";
}
var removeKey = (key, { [key]: _, ...rest }) => rest;
function parseProperties(properties, options) {
let props = properties;
const errorProperties = [];
for (const [key, value] of Object.entries(properties)) {
if (typeof value === "object" && value !== null) {
if (options.strip) {
props = removeKey(key, props);
} else {
errorProperties.push(key);
}
}
}
if (errorProperties.length > 0 && !options.strip) {
throw Error(
`The following properties are not valid: ${errorProperties.join(
", "
)}. Only strings, numbers, booleans, and null are allowed.`
);
}
return props;
}

@@ -67,3 +34,3 @@ // src/generic.ts

return;
setMode(props.mode);
const mode = getMode(props.mode);
initQueue();

@@ -73,3 +40,3 @@ if (props.beforeSend) {

}
const src = isDevelopment() ? "https://cdn.vercel-insights.com/v1/script.debug.js" : "/_vercel/insights/script.js";
const src = mode === "development" ? "https://cdn.vercel-insights.com/v1/script.debug.js" : "/_vercel/insights/script.js";
if (document.head.querySelector(`script[src*="${src}"]`))

@@ -80,3 +47,3 @@ return;

script.defer = true;
if (isDevelopment() && props.debug === false) {
if (mode === "development" && props.debug === false) {
script.setAttribute("data-debug", "false");

@@ -86,26 +53,5 @@ }

};
var track = (name, properties) => {
var _a, _b;
if (!properties) {
(_a = window.va) == null ? void 0 : _a.call(window, "track", { name });
return;
}
try {
const props = parseProperties(properties, {
strip: isProduction()
});
(_b = window.va) == null ? void 0 : _b.call(window, "track", {
name,
data: props
});
} catch (err) {
if (err instanceof Error && isDevelopment()) {
console.error(err);
}
}
};
export {
inject,
track
inject
};
//# sourceMappingURL=index.js.map

@@ -7,3 +7,2 @@ interface PageViewEvent {

declare type Mode = 'auto' | 'development' | 'production';
declare type AllowedPropertyValues = string | number | boolean | null;
declare type BeforeSend = (event: Event) => Event | null;

@@ -20,10 +19,7 @@ interface AnalyticsProps {

vai?: boolean;
vam?: Mode;
}
}
declare const track: (name: string, properties?: Record<string, AllowedPropertyValues>) => void;
declare function Analytics({ beforeSend, debug, mode, }: AnalyticsProps): null;
export { Analytics, AnalyticsProps, track };
export { Analytics, AnalyticsProps };

@@ -17,46 +17,13 @@ // src/react.tsx

}
function detectEnvironment() {
function isDevelopment() {
if (typeof process === "undefined")
return "production";
if (process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test")
return "development";
return "production";
return false;
return process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
}
function setMode(mode = "auto") {
function getMode(mode = "auto") {
if (mode === "auto") {
window.vam = detectEnvironment();
return isDevelopment() ? "development" : "production";
}
window.vam = mode;
return mode;
}
function getMode() {
return window.vam || "production";
}
function isProduction() {
return getMode() === "production";
}
function isDevelopment() {
return getMode() === "development";
}
var removeKey = (key, { [key]: _, ...rest }) => rest;
function parseProperties(properties, options) {
let props = properties;
const errorProperties = [];
for (const [key, value] of Object.entries(properties)) {
if (typeof value === "object" && value !== null) {
if (options.strip) {
props = removeKey(key, props);
} else {
errorProperties.push(key);
}
}
}
if (errorProperties.length > 0 && !options.strip) {
throw Error(
`The following properties are not valid: ${errorProperties.join(
", "
)}. Only strings, numbers, booleans, and null are allowed.`
);
}
return props;
}

@@ -70,3 +37,3 @@ // src/generic.ts

return;
setMode(props.mode);
const mode = getMode(props.mode);
initQueue();

@@ -76,3 +43,3 @@ if (props.beforeSend) {

}
const src = isDevelopment() ? "https://cdn.vercel-insights.com/v1/script.debug.js" : "/_vercel/insights/script.js";
const src = mode === "development" ? "https://cdn.vercel-insights.com/v1/script.debug.js" : "/_vercel/insights/script.js";
if (document.head.querySelector(`script[src*="${src}"]`))

@@ -83,3 +50,3 @@ return;

script.defer = true;
if (isDevelopment() && props.debug === false) {
if (mode === "development" && props.debug === false) {
script.setAttribute("data-debug", "false");

@@ -89,22 +56,2 @@ }

};
var track = (name, properties) => {
var _a, _b;
if (!properties) {
(_a = window.va) == null ? void 0 : _a.call(window, "track", { name });
return;
}
try {
const props = parseProperties(properties, {
strip: isProduction()
});
(_b = window.va) == null ? void 0 : _b.call(window, "track", {
name,
data: props
});
} catch (err) {
if (err instanceof Error && isDevelopment()) {
console.error(err);
}
}
};

@@ -123,5 +70,4 @@ // src/react.tsx

export {
Analytics,
track
Analytics
};
//# sourceMappingURL=index.js.map
{
"name": "@vercel/analytics",
"version": "0.1.7-beta.1",
"version": "0.1.7",
"keywords": [

@@ -5,0 +5,0 @@ "analytics",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet