Skip to content

Commit

Permalink
Enabling only for vercel production deployments
Browse files Browse the repository at this point in the history
Using NEXT_PUBLIC_VERCEL_ENV as described in:

https://vercel.com/docs/concepts/projects/environment-variables
  • Loading branch information
4lejandrito committed Jul 13, 2022
1 parent ce2001c commit 9aa9272
Show file tree
Hide file tree
Showing 11 changed files with 3,170 additions and 134 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ jobs:
- run: npm install
- run: npm run build
- run: npm test
- run: npm run test:vercel
if: ${{ github.event_name == 'push' }}
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
6 changes: 5 additions & 1 deletion index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ export default function PlausibleProvider(props: {
HTMLScriptElement
>
}) {
const { enabled = process.env.NODE_ENV === 'production' } = props
const {
enabled = process.env.NODE_ENV === 'production' &&
(!process.env.NEXT_PUBLIC_VERCEL_ENV ||
process.env.NEXT_PUBLIC_VERCEL_ENV === 'production'),
} = props
const domain = getDomain(props)
const proxyOptions: NextPlausiblePublicProxyOptions | undefined =
getConfig()?.publicRuntimeConfig?.nextPlausiblePublicProxyOptions
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
],
"scripts": {
"test": "cd test && npm i && npm test",
"test:vercel": "cd test && npm i && npm run test:vercel",
"start": "rollup -c -w",
"build": "rollup -c",
"prepublishOnly": "NODE_ENV=production npm run build",
Expand Down
Loading

0 comments on commit 9aa9272

Please sign in to comment.