Skip to content

Commit

Permalink
ci: add google analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
pyphilia committed Dec 20, 2021
1 parent 5a3da5c commit dd06b6a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"react": "^17.0.1",
"react-beautiful-dnd": "13.1.0",
"react-dom": "^17.0.1",
"react-ga4": "1.4.1",
"react-i18next": "11.11.4",
"react-image-crop": "9.0.4",
"react-query": "3.31.0",
Expand Down
4 changes: 4 additions & 0 deletions src/config/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const {
GRAASP_PERFORM_HOST: ENV_GRAASP_PERFORM_HOST,
AUTHENTICATION_HOST: ENV_AUTHENTICATION_HOST,
NODE_ENV: ENV_NODE_ENV,
GA_MEASUREMENT_ID: ENV_GA_MEASUREMENT_ID,
} = env;

export const APP_NAME = 'Graasp';
Expand Down Expand Up @@ -39,6 +40,9 @@ export const GRAASP_PERFORM_HOST =
process.env.REACT_APP_GRAASP_PERFORM_HOST ||
'http://localhost:3112';

export const GA_MEASUREMENT_ID =
ENV_GA_MEASUREMENT_ID || process.env.REACT_APP_GA_MEASUREMENT_ID;

export const DESCRIPTION_MAX_LENGTH = 30;

// todo: use local image
Expand Down
3 changes: 2 additions & 1 deletion src/env.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"SHOW_NOTIFICATIONS": false,
"AUTHENTICATION_HOST": false,
"NODE_ENV": false,
"GRAASP_PERFORM_HOST": false
"GRAASP_PERFORM_HOST": false,
"GA_MEASUREMENT_ID": false
}
7 changes: 7 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import React from 'react';
import ReactDOM from 'react-dom';
import ReactGA from 'react-ga4';
import './index.css';
import Root from './components/Root';
import * as serviceWorker from './serviceWorker';

import '@graasp/ui/dist/bundle.css';
import { GA_MEASUREMENT_ID } from './config/constants';

if (GA_MEASUREMENT_ID) {
ReactGA.initialize(GA_MEASUREMENT_ID);
ReactGA.send('pageview');
}

ReactDOM.render(
<React.StrictMode>
Expand Down
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10171,6 +10171,7 @@ __metadata:
react: ^17.0.1
react-beautiful-dnd: 13.1.0
react-dom: ^17.0.1
react-ga4: 1.4.1
react-i18next: 11.11.4
react-image-crop: 9.0.4
react-query: 3.31.0
Expand Down Expand Up @@ -16675,6 +16676,13 @@ __metadata:
languageName: node
linkType: hard

"react-ga4@npm:1.4.1":
version: 1.4.1
resolution: "react-ga4@npm:1.4.1"
checksum: 4c33ecb47dfc26c241a6af8e2b08b29b6c059f40e456e93d1c2b65c995edce18f32d9777295774ec992d968d7c5efdd105eb62398972d85ff2e2b6dad8646a26
languageName: node
linkType: hard

"react-i18next@npm:11.11.4":
version: 11.11.4
resolution: "react-i18next@npm:11.11.4"
Expand Down

0 comments on commit dd06b6a

Please sign in to comment.