Complete GA integration

This commit is contained in:
Paulo Gustavo Veiga 2022-02-15 20:39:52 -08:00
parent 301d141ce0
commit 33aac44ecf
6 changed files with 24 additions and 13 deletions

View File

@ -14,8 +14,9 @@ import AppI18n, { Locales } from './classes/app-i18n';
import MapsPage from './components/maps-page'; import MapsPage from './components/maps-page';
import CssBaseline from '@mui/material/CssBaseline'; import CssBaseline from '@mui/material/CssBaseline';
import { ThemeProvider, Theme, StyledEngineProvider } from '@mui/material/styles'; import { ThemeProvider, Theme, StyledEngineProvider } from '@mui/material/styles';
import GoogleAnalytics from 'react-ga'; import ReactGA from 'react-ga';
import EditorPage from './components/editor-page'; import EditorPage from './components/editor-page';
import AppConfig from './classes/app-config';
declare module '@mui/styles/defaultTheme' { declare module '@mui/styles/defaultTheme' {
@ -23,11 +24,8 @@ declare module '@mui/styles/defaultTheme' {
interface DefaultTheme extends Theme { } interface DefaultTheme extends Theme { }
} }
// Google Analytics Initialization. // Google Analytics Initialization.
GoogleAnalytics.initialize('UA-2347723-1'); ReactGA.initialize(AppConfig.getGoogleAnalyticsAccount());
GoogleAnalytics.pageview(window.location.pathname + window.location.search);
const queryClient = new QueryClient({ const queryClient = new QueryClient({
defaultOptions: { defaultOptions: {

View File

@ -1,10 +1,11 @@
import React from 'react'; import React, { useEffect } from 'react';
import ActionDispatcher from '../maps-page/action-dispatcher'; import ActionDispatcher from '../maps-page/action-dispatcher';
import { ActionType } from '../maps-page/action-chooser'; import { ActionType } from '../maps-page/action-chooser';
import Editor from '@wisemapping/editor'; import Editor from '@wisemapping/editor';
import AppI18n from '../../classes/app-i18n'; import AppI18n from '../../classes/app-i18n';
import { useSelector } from 'react-redux'; import { useSelector } from 'react-redux';
import { hotkeysEnabled } from '../../redux/editorSlice'; import { hotkeysEnabled } from '../../redux/editorSlice';
import ReactGA from 'react-ga';
export type EditorPropsType = { export type EditorPropsType = {
mapId: number; mapId: number;
@ -14,9 +15,12 @@ export type EditorPropsType = {
const EditorPage = ({ mapId, ...props }: EditorPropsType): React.ReactElement => { const EditorPage = ({ mapId, ...props }: EditorPropsType): React.ReactElement => {
const [activeDialog, setActiveDialog] = React.useState<ActionType | null>(null); const [activeDialog, setActiveDialog] = React.useState<ActionType | null>(null);
const hotkeys = useSelector(hotkeysEnabled); const hotkeys = useSelector(hotkeysEnabled);
// Load user locale ...
const userLocale = AppI18n.getUserLocale(); const userLocale = AppI18n.getUserLocale();
useEffect(() => {
ReactGA.pageview(window.location.pathname + window.location.search);
}, []);
return <> return <>
<Editor {...props} onAction={setActiveDialog} locale={userLocale.code} hotkeys={hotkeys} /> <Editor {...props} onAction={setActiveDialog} locale={userLocale.code} hotkeys={hotkeys} />
{ {

View File

@ -12,6 +12,7 @@ import { activeInstance } from '../../redux/clientSlice';
import Input from '../form/input'; import Input from '../form/input';
import GlobalError from '../form/global-error'; import GlobalError from '../form/global-error';
import SubmitButton from '../form/submit-button'; import SubmitButton from '../form/submit-button';
import ReactGA from 'react-ga';
import Typography from '@mui/material/Typography'; import Typography from '@mui/material/Typography';
@ -77,7 +78,8 @@ const ForgotPasswordPage = (): React.ReactElement => {
const intl = useIntl(); const intl = useIntl();
useEffect(() => { useEffect(() => {
document.title = intl.formatMessage({ id: 'forgot.page-title', defaultMessage: 'Forgot Password | WiseMapping' }); document.title = intl.formatMessage({ id: 'forgot.page-title', defaultMessage: 'Forgot Password | WiseMapping' });
}); ReactGA.pageview(window.location.pathname + window.location.search);
},[]);
return ( return (
<div> <div>

View File

@ -10,6 +10,7 @@ import FormContainer from '../layout/form-container';
import Typography from '@mui/material/Typography'; import Typography from '@mui/material/Typography';
import FormControl from '@mui/material/FormControl'; import FormControl from '@mui/material/FormControl';
import Link from '@mui/material/Link'; import Link from '@mui/material/Link';
import ReactGA from 'react-ga';
type ConfigStatusProps = { type ConfigStatusProps = {
enabled?: boolean; enabled?: boolean;
@ -68,7 +69,8 @@ const LoginPage = (): React.ReactElement => {
useEffect(() => { useEffect(() => {
document.title = intl.formatMessage({id:'login.page-title',defaultMessage:'Login | WiseMapping'}); document.title = intl.formatMessage({id:'login.page-title',defaultMessage:'Login | WiseMapping'});
}); ReactGA.pageview(window.location.pathname + window.location.search);
},[]);
return ( return (
<div> <div>

View File

@ -41,6 +41,8 @@ import ListItemSecondaryAction from '@mui/material/ListItemSecondaryAction';
import logoIcon from './logo-small.svg'; import logoIcon from './logo-small.svg';
import poweredByIcon from './pwrdby-white.svg'; import poweredByIcon from './pwrdby-white.svg';
import LabelDeleteConfirm from './maps-list/label-delete-confirm'; import LabelDeleteConfirm from './maps-list/label-delete-confirm';
import ReactGA from 'react-ga';
export type Filter = GenericFilter | LabelFilter; export type Filter = GenericFilter | LabelFilter;
@ -81,6 +83,7 @@ const MapsPage = (): ReactElement => {
id: 'maps.page-title', id: 'maps.page-title',
defaultMessage: 'My Maps | WiseMapping', defaultMessage: 'My Maps | WiseMapping',
}); });
ReactGA.pageview(window.location.pathname + window.location.search);
}, []); }, []);
const mutation = useMutation((id: number) => client.deleteLabel(id), { const mutation = useMutation((id: number) => client.deleteLabel(id), {

View File

@ -17,6 +17,7 @@ import SubmitButton from '../form/submit-button';
import Typography from '@mui/material/Typography'; import Typography from '@mui/material/Typography';
import FormControl from '@mui/material/FormControl'; import FormControl from '@mui/material/FormControl';
import AppConfig from '../../classes/app-config'; import AppConfig from '../../classes/app-config';
import ReactGA from 'react-ga';
export type Model = { export type Model = {
email: string; email: string;
@ -164,7 +165,8 @@ const RegistationPage = (): React.ReactElement => {
id: 'registration.page-title', id: 'registration.page-title',
defaultMessage: 'Registration | WiseMapping', defaultMessage: 'Registration | WiseMapping',
}); });
}); ReactGA.pageview(window.location.pathname + window.location.search);
},[]);
return ( return (
<div> <div>