Skip to content
This repository was archived by the owner on Dec 26, 2023. It is now read-only.

Commit 0f1a8a5

Browse files
authored
Merge pull request #183 from Developer-DAO/add-plausible-analytics
2 parents 0eae254 + fed8615 commit 0f1a8a5

File tree

5 files changed

+39
-6
lines changed

5 files changed

+39
-6
lines changed

frontend/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,21 @@ nvm install; # to install the version in .nvmrc
8787
5. To test Walletconnect functionality, copy `.env.development` to `.env.local` and fill in your `INFURA_ID`.
8888
`INFURA_ID` can be easily obtained by register at <https://infura.io/>, then create a new Ethereum project for free.
8989

90+
### Deployment
91+
92+
This project uses Vercel to manage deployments. We use the Vercel GitHub integration to automatically deploy in two situations:
93+
94+
- When code is merged into `main`, a production deployment is triggered. Vercel will build the project and deploy it to `developerdao.com`.
95+
- When a pull request is created, a preview deployment is triggered. Vercel will build the project from the PR's code and deploy it to an auto-generated URL.
96+
97+
In both cases, Vercel runs `next build` to build the project. Since running `next build` automatically sets `NODE_ENV` to `production`, if you need to distinguish between an actual production deployment and a PR preview deployment (example: we only want to run code that connects to analytics in production and not for preview deploys), use the `NEXT_PUBLIC_VERCEL_ENV` (`process.env.NEXT_PUBLIC_VERCEL_ENV`) environment variable. This variable exists in Vercel and provides the following values:
98+
99+
| Vercel Environment | value |
100+
| --- | --- |
101+
| Production | `production` |
102+
| Preview | `preview` |
103+
| Development | `development` |
104+
90105
## Contributing
91106

92107
Thanks for showing interest in contributing to Developer DAO. Before submitting any changes please review our contributing gudielines in [CONTRIBUTING.md](./CONTRIBUTING.md).

frontend/next.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
const { withPlausibleProxy } = require('next-plausible');
12
const { i18n } = require('./next-i18next.config');
23

3-
module.exports = {
4+
module.exports = withPlausibleProxy()({
45
i18n,
5-
};
6+
});

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"jest": "^27.2.0",
2121
"next": "^11.1.2",
2222
"next-i18next": "^8.8.0",
23+
"next-plausible": "^3.1.4",
2324
"react": "^17.0.2",
2425
"react-confetti": "^6.0.1",
2526
"react-dom": "^17.0.2",

frontend/src/pages/_app.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { ReactNode } from 'react';
22
import Head from 'next/head';
33
import { appWithTranslation } from 'next-i18next';
44
import { ChakraProvider } from '@chakra-ui/react';
@@ -9,9 +9,18 @@ import { AppProps } from 'next/app';
99

1010
import { DEVELOPER_DAO_WEBSITE } from '../utils/DeveloperDaoConstants';
1111
import { theme } from '../theme';
12+
import PlausibleProvider from 'next-plausible';
1213

1314
const socialBanner = `${DEVELOPER_DAO_WEBSITE}/social-banner.png`;
1415

16+
const Plausible = ({ children }: { children: ReactNode }) => {
17+
return process.env.NEXT_PUBLIC_VERCEL_ENV === 'production' ? (
18+
<PlausibleProvider domain="developerdao.com">{children}</PlausibleProvider>
19+
) : (
20+
<>{children}</>
21+
);
22+
};
23+
1524
function SEO() {
1625
const { t } = useTranslation();
1726

@@ -134,9 +143,11 @@ user's mobile device or desktop. See https://developers.google.com/web/fundament
134143
const App = ({ Component, pageProps }: AppProps) => (
135144
<>
136145
<SEO />
137-
<ChakraProvider theme={theme}>
138-
<Component {...pageProps} />
139-
</ChakraProvider>
146+
<Plausible>
147+
<ChakraProvider theme={theme}>
148+
<Component {...pageProps} />
149+
</ChakraProvider>
150+
</Plausible>
140151
</>
141152
);
142153

frontend/yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7494,6 +7494,11 @@ next-i18next@^8.8.0:
74947494
i18next-fs-backend "^1.0.7"
74957495
react-i18next "^11.8.13"
74967496

7497+
next-plausible@^3.1.4:
7498+
version "3.1.4"
7499+
resolved "https://registry.yarnpkg.com/next-plausible/-/next-plausible-3.1.4.tgz#a386ff4e2327995cb4a1307e53e1b4af70817b52"
7500+
integrity sha512-NMLKJ0AKlKuvYU//RytyqSES5NtLRoH/ym3fCC02w2Ed1SrTgNRUrgpxyJrcguY/DYGPncQ3a0/nQ358vUTAwQ==
7501+
74977502
next-tick@~1.0.0:
74987503
version "1.0.0"
74997504
resolved "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz"

0 commit comments

Comments
 (0)