Skip to content

Commit

Permalink
Automatically pass deplyoment protection secret if available (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiaslins authored Feb 5, 2024
1 parent c07d4b2 commit c55544d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vercel/analytics",
"version": "1.1.2",
"version": "1.1.3",
"description": "Gain real-time traffic insights with Vercel Web Analytics",
"keywords": [
"analytics",
Expand Down
8 changes: 7 additions & 1 deletion packages/web/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ export async function track(
properties?: Record<string, AllowedPropertyValues>,
context?: Context
): Promise<void> {
const ENDPOINT = process.env.VERCEL_URL || process.env.VERCEL_ANALYTICS_URL;
const ENDPOINT =
process.env.VERCEL_WEB_ANALYTICS_ENDPOINT || process.env.VERCEL_URL;
const DISABLE_LOGS = Boolean(process.env.VERCEL_WEB_ANALYTICS_DISABLE_LOGS);
const BYPASS_SECRET = process.env.VERCEL_AUTOMATION_BYPASS_SECRET;

if (typeof window !== 'undefined') {
if (!isProduction()) {
throw new Error(
Expand Down Expand Up @@ -125,6 +128,9 @@ export async function track(
: {
'x-va-server': '2',
}),
...(BYPASS_SECRET
? { 'x-vercel-protection-bypass': BYPASS_SECRET }
: {}),
},
body: JSON.stringify(body),
method: 'POST',
Expand Down

0 comments on commit c55544d

Please sign in to comment.