Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
ecde7e20
Commit
ecde7e20
authored
Feb 28, 2023
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use env
parent
721895f5
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
52 additions
and
28 deletions
+52
-28
.env.example
.env.example
+2
-1
.env.template
.env.template
+1
-0
README.md
README.md
+1
-0
config.ts
configs/app/config.ts
+3
-0
getCspPolicy.ts
lib/csp/getCspPolicy.ts
+1
-0
_app.tsx
pages/_app.tsx
+16
-27
GoogleAnalytics.tsx
ui/shared/GoogleAnalytics.tsx
+28
-0
No files found.
.env.example
View file @
ecde7e20
NEXT_PUBLIC_SENTRY_DSN=xxx
NEXT_PUBLIC_SENTRY_DSN=xxx
SENTRY_CSP_REPORT_URI=xxx
SENTRY_CSP_REPORT_URI=xxx
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=xxx
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=xxx
NEXT_PUBLIC_RE_CAPTCHA_APP_SITE_KEY=xxx
NEXT_PUBLIC_RE_CAPTCHA_APP_SITE_KEY=xxx
\ No newline at end of file
NEXT_PUBLIC_GOOGLE_ANALYTICS_PROPERTY_ID=UA-XXXXXX-X
\ No newline at end of file
.env.template
View file @
ecde7e20
...
@@ -56,6 +56,7 @@ NEXT_PUBLIC_SENTRY_DSN=__PLACEHOLDER_FOR_NEXT_PUBLIC_SENTRY_DSN__
...
@@ -56,6 +56,7 @@ NEXT_PUBLIC_SENTRY_DSN=__PLACEHOLDER_FOR_NEXT_PUBLIC_SENTRY_DSN__
NEXT_PUBLIC_AUTH0_CLIENT_ID=__PLACEHOLDER_FOR_NEXT_PUBLIC_AUTH0_CLIENT_ID__
NEXT_PUBLIC_AUTH0_CLIENT_ID=__PLACEHOLDER_FOR_NEXT_PUBLIC_AUTH0_CLIENT_ID__
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=__PLACEHOLDER_FOR_NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID__
NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID=__PLACEHOLDER_FOR_NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID__
NEXT_PUBLIC_RE_CAPTCHA_APP_SITE_KEY=__PLACEHOLDER_FOR_NEXT_PUBLIC_RE_CAPTCHA_APP_SITE_KEY__
NEXT_PUBLIC_RE_CAPTCHA_APP_SITE_KEY=__PLACEHOLDER_FOR_NEXT_PUBLIC_RE_CAPTCHA_APP_SITE_KEY__
NEXT_PUBLIC_GOOGLE_ANALYTICS_PROPERTY_ID=__PLACEHOLDER_FOR_NEXT_PUBLIC_GOOGLE_ANALYTICS_PROPERTY_ID__
# l2 config
# l2 config
NEXT_PUBLIC_IS_L2_NETWORK=__PLACEHOLDER_FOR_NEXT_PUBLIC_IS_L2_NETWORKL__
NEXT_PUBLIC_IS_L2_NETWORK=__PLACEHOLDER_FOR_NEXT_PUBLIC_IS_L2_NETWORKL__
...
...
README.md
View file @
ecde7e20
...
@@ -130,6 +130,7 @@ The app instance could be customized by passing following variables to NodeJS en
...
@@ -130,6 +130,7 @@ The app instance could be customized by passing following variables to NodeJS en
| NEXT_PUBLIC_AUTH0_CLIENT_ID |
`string`
| Client id for
[
Auth0
](
https://auth0.com/
)
provider |
`<secret>`
|
| NEXT_PUBLIC_AUTH0_CLIENT_ID |
`string`
| Client id for
[
Auth0
](
https://auth0.com/
)
provider |
`<secret>`
|
| NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID |
`string`
| Project id for
[
WalletConnect
](
https://docs.walletconnect.com/2.0/web3modal/react/installation#obtain-project-id
)
integration |
`<secret>`
|
| NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID |
`string`
| Project id for
[
WalletConnect
](
https://docs.walletconnect.com/2.0/web3modal/react/installation#obtain-project-id
)
integration |
`<secret>`
|
| NEXT_PUBLIC_RE_CAPTCHA_APP_SITE_KEY |
`string`
| Site key for
[
reCAPTCHA
](
https://developers.google.com/recaptcha
)
service |
`<secret>`
|
| NEXT_PUBLIC_RE_CAPTCHA_APP_SITE_KEY |
`string`
| Site key for
[
reCAPTCHA
](
https://developers.google.com/recaptcha
)
service |
`<secret>`
|
| NEXT_PUBLIC_GOOGLE_ANALYTICS_PROPERTY_ID |
`string`
| Property ID for
[
Google Analytics
](
https://analytics.google.com/
)
service |
`UA-XXXXXX-X`
|
### L2 configuration
### L2 configuration
| Variable | Type | Description | Default value
| Variable | Type | Description | Default value
...
...
configs/app/config.ts
View file @
ecde7e20
...
@@ -133,6 +133,9 @@ const config = Object.freeze({
...
@@ -133,6 +133,9 @@ const config = Object.freeze({
reCaptcha
:
{
reCaptcha
:
{
siteKey
:
getEnvValue
(
process
.
env
.
NEXT_PUBLIC_RE_CAPTCHA_APP_SITE_KEY
)
||
''
,
siteKey
:
getEnvValue
(
process
.
env
.
NEXT_PUBLIC_RE_CAPTCHA_APP_SITE_KEY
)
||
''
,
},
},
googleAnalytics
:
{
propertyId
:
getEnvValue
(
process
.
env
.
NEXT_PUBLIC_GOOGLE_ANALYTICS_PROPERTY_ID
),
},
});
});
export
default
config
;
export
default
config
;
lib/csp/getCspPolicy.ts
View file @
ecde7e20
...
@@ -93,6 +93,7 @@ function makePolicyMap() {
...
@@ -93,6 +93,7 @@ function makePolicyMap() {
// google analytics
// google analytics
'
https://www.googletagmanager.com
'
,
'
https://www.googletagmanager.com
'
,
'
https://www.google-analytics.com
'
,
'
https://www.google-analytics.com
'
,
'
https://stats.g.doubleclick.net
'
,
],
],
'
script-src
'
:
[
'
script-src
'
:
[
...
...
pages/_app.tsx
View file @
ecde7e20
...
@@ -2,7 +2,6 @@ import * as Sentry from '@sentry/react';
...
@@ -2,7 +2,6 @@ import * as Sentry from '@sentry/react';
import
{
QueryClient
,
QueryClientProvider
}
from
'
@tanstack/react-query
'
;
import
{
QueryClient
,
QueryClientProvider
}
from
'
@tanstack/react-query
'
;
import
{
ReactQueryDevtools
}
from
'
@tanstack/react-query-devtools
'
;
import
{
ReactQueryDevtools
}
from
'
@tanstack/react-query-devtools
'
;
import
type
{
AppProps
}
from
'
next/app
'
;
import
type
{
AppProps
}
from
'
next/app
'
;
import
Script
from
'
next/script
'
;
import
React
,
{
useState
}
from
'
react
'
;
import
React
,
{
useState
}
from
'
react
'
;
import
appConfig
from
'
configs/app/config
'
;
import
appConfig
from
'
configs/app/config
'
;
...
@@ -16,6 +15,7 @@ import { SocketProvider } from 'lib/socket/context';
...
@@ -16,6 +15,7 @@ import { SocketProvider } from 'lib/socket/context';
import
theme
from
'
theme
'
;
import
theme
from
'
theme
'
;
import
AppError
from
'
ui/shared/AppError/AppError
'
;
import
AppError
from
'
ui/shared/AppError/AppError
'
;
import
ErrorBoundary
from
'
ui/shared/ErrorBoundary
'
;
import
ErrorBoundary
from
'
ui/shared/ErrorBoundary
'
;
import
GoogleAnalytics
from
'
ui/shared/GoogleAnalytics
'
;
function
MyApp
({
Component
,
pageProps
}:
AppProps
)
{
function
MyApp
({
Component
,
pageProps
}:
AppProps
)
{
useConfigSentry
();
useConfigSentry
();
...
@@ -59,32 +59,21 @@ function MyApp({ Component, pageProps }: AppProps) {
...
@@ -59,32 +59,21 @@ function MyApp({ Component, pageProps }: AppProps) {
},
[]);
},
[]);
return
(
return
(
<>
<
Chakra
theme=
{
theme
}
cookies=
{
pageProps
.
cookies
}
>
<
Chakra
theme=
{
theme
}
cookies=
{
pageProps
.
cookies
}
>
<
ErrorBoundary
renderErrorScreen=
{
renderErrorScreen
}
onError=
{
handleError
}
>
<
ErrorBoundary
renderErrorScreen=
{
renderErrorScreen
}
onError=
{
handleError
}
>
<
AppContextProvider
pageProps=
{
pageProps
}
>
<
AppContextProvider
pageProps=
{
pageProps
}
>
<
QueryClientProvider
client=
{
queryClient
}
>
<
QueryClientProvider
client=
{
queryClient
}
>
<
ScrollDirectionProvider
>
<
ScrollDirectionProvider
>
<
SocketProvider
url=
{
`${ appConfig.api.socket }${ appConfig.api.basePath }/socket/v2`
}
>
<
SocketProvider
url=
{
`${ appConfig.api.socket }${ appConfig.api.basePath }/socket/v2`
}
>
<
Component
{
...
pageProps
}
/>
<
Component
{
...
pageProps
}
/>
</
SocketProvider
>
</
SocketProvider
>
</
ScrollDirectionProvider
>
</
ScrollDirectionProvider
>
<
ReactQueryDevtools
/>
<
ReactQueryDevtools
/>
<
GoogleAnalytics
/>
</
QueryClientProvider
>
</
QueryClientProvider
>
</
AppContextProvider
>
</
AppContextProvider
>
</
ErrorBoundary
>
</
ErrorBoundary
>
</
Chakra
>
</
Chakra
>
{
/* <!-- Google tag (gtag.js) --> */
}
<
Script
src=
"https://www.googletagmanager.com/gtag/js?id=UA-125140709-1"
/>
<
Script
id=
"google-analytics"
>
{
`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-125140709-1');
`
}
</
Script
>
</>
);
);
}
}
...
...
ui/shared/GoogleAnalytics.tsx
0 → 100644
View file @
ecde7e20
import
Script
from
'
next/script
'
;
import
React
from
'
react
'
;
import
appConfig
from
'
configs/app/config
'
;
const
GoogleAnalytics
=
()
=>
{
if
(
!
appConfig
.
googleAnalytics
.
propertyId
)
{
return
null
;
}
const
id
=
appConfig
.
googleAnalytics
.
propertyId
;
return
(
<>
<
Script
src=
{
`https://www.googletagmanager.com/gtag/js?id=${ id }`
}
/>
<
Script
id=
"google-analytics"
>
{
`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${ id }');
`
}
</
Script
>
</>
);
};
export
default
React
.
memo
(
GoogleAnalytics
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment