This repository was archived by the owner on Apr 5, 2024. It is now read-only.
Commit f9c6134 1 parent 168a48c commit f9c6134 Copy full SHA for f9c6134
File tree 3 files changed +17
-9
lines changed
3 files changed +17
-9
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,11 @@ ENV GITHUB_SHA $GITHUB_SHA
26
26
WORKDIR /app
27
27
COPY --from=deps /app/node_modules ./node_modules
28
28
COPY . .
29
- RUN yarn build:export
29
+ RUN if [ -z "$PRODUCTION" ]; then \
30
+ echo "Overriding .env for staging" ; \
31
+ cp .env.staging .env.production; \
32
+ fi && \
33
+ yarn build:export
30
34
31
35
# Production image, copy all the files and run next
32
36
FROM ghcr.io/socialgouv/docker/nginx:6.70.1 AS runner
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ export type MatomoResult = {
4
4
nbVisits : number ;
5
5
} ;
6
6
7
- export const fetchMatomoData = async ( ) : Promise < Partial < MatomoResult > > => {
7
+ export const fetchMatomoData = async ( ) : Promise < MatomoResult > => {
8
8
const MATOMO_URL = [
9
9
`${ process . env . NEXT_PUBLIC_MATOMO_URL } /?module=API&method=VisitsSummary.getVisits&idSite=${ process . env . NEXT_PUBLIC_MATOMO_SITE_ID } &format=JSON&period=year&date=today` ,
10
10
`${ process . env . NEXT_PUBLIC_MATOMO_URL } /?module=API&method=Actions.get&idSite=${ process . env . NEXT_PUBLIC_MATOMO_SITE_ID } &format=JSON&period=year&date=today` ,
@@ -18,8 +18,8 @@ export const fetchMatomoData = async (): Promise<Partial<MatomoResult>> => {
18
18
) ;
19
19
const [ nbVisitData , infoData ] = await Promise . all ( promises ) ;
20
20
return {
21
- nbPageViews : infoData ?. nb_pageviews ,
22
- nbUniqPageViews : infoData ?. nb_uniq_pageviews ,
23
- nbVisits : nbVisitData ?. value ,
21
+ nbPageViews : infoData ?. nb_pageviews ?? 0 ,
22
+ nbUniqPageViews : infoData ?. nb_uniq_pageviews ?? 0 ,
23
+ nbVisits : nbVisitData ?. value ?? 0 ,
24
24
} ;
25
25
} ;
Original file line number Diff line number Diff line change @@ -5,7 +5,11 @@ import { NextSeo } from "next-seo";
5
5
import React , { useEffect } from "react" ;
6
6
7
7
const Index : NextPage = ( ) => {
8
- const [ matomoData , setMatomoData ] = React . useState < MatomoResult > ( ) ;
8
+ const [ matomoData , setMatomoData ] = React . useState < MatomoResult > ( {
9
+ nbPageViews : 0 ,
10
+ nbVisits : 0 ,
11
+ nbUniqPageViews : 0 ,
12
+ } ) ;
9
13
10
14
useEffect ( ( ) => {
11
15
( async ( ) => {
@@ -30,17 +34,17 @@ const Index: NextPage = () => {
30
34
< div className = "fr-grid-row fr-grid-row--gutters fr-grid-row--center fr-px-3w" >
31
35
< StatsTile
32
36
title = "Nombre de visites"
33
- stats = { matomoData ? .nbVisits ?? 0 }
37
+ stats = { matomoData . nbVisits }
34
38
description = "C'est le nombre de visites total du site sur les 12 derniers mois"
35
39
/>
36
40
< StatsTile
37
41
title = "Nombre de pages vues (total)"
38
- stats = { matomoData ? .nbPageViews ?? 0 }
42
+ stats = { matomoData . nbPageViews }
39
43
description = "C'est le nombre de pages vues au total sur le site sur les 12 derniers mois"
40
44
/>
41
45
< StatsTile
42
46
title = "Nombre de pages vues (uniques)"
43
- stats = { matomoData ? .nbUniqPageViews ?? 0 }
47
+ stats = { matomoData . nbUniqPageViews }
44
48
description = "C'est le nombre de pages vues uniques sur le site sur les 12 derniers mois"
45
49
/>
46
50
</ div >
You can’t perform that action at this time.
0 commit comments