Skip to content

Commit

Permalink
feat: remove matomo
Browse files Browse the repository at this point in the history
  • Loading branch information
loicguillois committed Jan 21, 2025
1 parent 61ee6e8 commit 6910320
Show file tree
Hide file tree
Showing 17 changed files with 5 additions and 258 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/review-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,6 @@ jobs:
clever env set CC_PRE_BUILD_HOOK 'corepack enable && corepack yarn workspaces focus $WORKSPACE && corepack yarn workspaces foreach --from=$WORKSPACE -Rt run build' -a $APP_ALIAS
clever env set CC_WEBROOT "/frontend/build" -a $APP_ALIAS
clever env set REACT_APP_API_URL https://$PR_NAME-api.cleverapps.io -a $APP_ALIAS
clever env set REACT_APP_MATOMO_ENABLED "false" -a $APP_ALIAS
clever env set REACT_APP_MATOMO_SITE_ID "42" -a $APP_ALIAS
clever env set REACT_APP_MATOMO_URL_BASE "unused" -a $APP_ALIAS
clever env set WORKSPACE "@zerologementvacant/front" -a $APP_ALIAS
- name: Scale up for deployment
Expand Down
3 changes: 0 additions & 3 deletions frontend/.env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
REACT_APP_API_URL=http://localhost:3001
REACT_APP_MATOMO_ENABLED=false
REACT_APP_MATOMO_SITE_ID=1
REACT_APP_MATOMO_SRC_URL=http://url-matomo
REACT_APP_METABASE_STATS_DASHBOARD=UUID
REACT_APP_FEATURE_OCCUPANCY=ct1,ct2,ct3
1 change: 0 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
"@hookform/resolvers": "^3.9.1",
"@jonkoops/matomo-tracker-react": "^0.7.0",
"@lexical/html": "^0.20.0",
"@lexical/list": "^0.20.0",
"@lexical/react": "^0.20.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ import { SearchableSelect } from '../_dsfr';
import addressService, {
AddressSearchResult
} from '../../services/address.service';
import {
TrackEventActions,
TrackEventCategories
} from '../../models/TrackEvent';
import { useMatomo } from '@jonkoops/matomo-tracker-react';

interface Props {
onSelectAddress(addressSearchResult?: AddressSearchResult): void;
Expand All @@ -22,16 +17,9 @@ const AddressSearchableSelect = ({ onSelectAddress }: Props) => {
const [addressOptions, setAddressOptions] = useState<
{ value: string; label: string }[]
>([]);
const { trackEvent } = useMatomo();

const onChange = (value?: string) => {
if (value) {
const addressSearchResult = JSON.parse(value);
trackEvent({
category: TrackEventCategories.Home,
action: TrackEventActions.Home.SelectAddress,
name: addressSearchResult.label
});
onSelectAddress(addressSearchResult);
}
};
Expand Down
11 changes: 0 additions & 11 deletions frontend/src/components/Campaign/CampaignTitle.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Button from '@codegouvfr/react-dsfr/Button';
import { createModal } from '@codegouvfr/react-dsfr/Modal';
import { useMatomo } from '@jonkoops/matomo-tracker-react';
import classNames from 'classnames';
import { FormEvent, useState } from 'react';
import { InferType, object } from 'yup';
Expand All @@ -10,10 +9,6 @@ import { Campaign } from '../../models/Campaign';
import { useUpdateCampaignMutation } from '../../services/campaign.service';
import styles from './campaign.module.scss';
import { campaignTitleValidator, campaignDescriptionValidator, useForm } from '../../hooks/useForm';
import {
TrackEventActions,
TrackEventCategories
} from '../../models/TrackEvent';
import AppTextInput from '../_app/AppTextInput/AppTextInput';
import Typography from '@mui/material/Typography';

Expand All @@ -38,8 +33,6 @@ interface Props {
}

function CampaignTitle({ campaign, className, as, look }: Readonly<Props>) {
const { trackEvent } = useMatomo();

const [updateCampaign] = useUpdateCampaignMutation();

const [title, setTitle] = useState(campaign.title);
Expand All @@ -58,10 +51,6 @@ function CampaignTitle({ campaign, className, as, look }: Readonly<Props>) {
title,
description,
}).unwrap();
trackEvent({
category: TrackEventCategories.Campaigns,
action: TrackEventActions.Campaigns.Rename
});
modal.close();
});
}
Expand Down
10 changes: 0 additions & 10 deletions frontend/src/components/HousingDetails/HousingDetailsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { fr } from '@codegouvfr/react-dsfr';
import Button from '@codegouvfr/react-dsfr/Button';
import Paper from '@mui/material/Paper';
import Tabs from '@codegouvfr/react-dsfr/Tabs';
import { useMatomo } from '@jonkoops/matomo-tracker-react';
import Typography from '@mui/material/Typography';
import Grid from '@mui/material/Unstable_Grid2';
import classNames from 'classnames';
Expand All @@ -24,10 +23,6 @@ import HousingDetailsCardMobilisation from './HousingDetailsSubCardMobilisation'
import { Campaign } from '../../models/Campaign';
import { useUpdateHousingMutation } from '../../services/housing.service';
import AppLink from '../_app/AppLink/AppLink';
import {
TrackEventActions,
TrackEventCategories
} from '../../models/TrackEvent';
import { useUser } from '../../hooks/useUser';

interface Props {
Expand All @@ -44,7 +39,6 @@ function HousingDetailsCard({
housingCampaigns
}: Props) {
const { isVisitor } = useUser();
const { trackEvent } = useMatomo();
const [updateHousing] = useUpdateHousingMutation();

const [isHousingListEditionExpand, setIsHousingListEditionExpand] =
Expand All @@ -61,10 +55,6 @@ function HousingDetailsCard({
housing: Housing,
housingUpdate: HousingUpdate
) => {
trackEvent({
category: TrackEventCategories.Housing,
action: TrackEventActions.Housing.Update
});
await updateHousing({
housing,
housingUpdate
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,17 @@
import { SegmentedControl } from '@codegouvfr/react-dsfr/SegmentedControl';
import { useMatomo } from '@jonkoops/matomo-tracker-react';

import {
TrackEventActions,
TrackEventCategories,
} from '../../models/TrackEvent';
import { useAppDispatch } from '../../hooks/useStore';
import housingSlice from '../../store/reducers/housingReducer';

export function HousingDisplaySwitch() {
const dispatch = useAppDispatch();
const { trackEvent } = useMatomo();

const { changeView } = housingSlice.actions;

function toList() {
trackEvent({
category: TrackEventCategories.HousingList,
action: TrackEventActions.HousingList.ListView,
});
dispatch(changeView('list'));
}

function toMap() {
trackEvent({
category: TrackEventCategories.HousingList,
action: TrackEventActions.HousingList.MapView,
});
dispatch(changeView('map'));
}

Expand Down
18 changes: 1 addition & 17 deletions frontend/src/components/HousingList/HousingList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ import { HousingFilters } from '../../models/HousingFilters';
import classNames from 'classnames';
import { useCampaignList } from '../../hooks/useCampaignList';
import _ from 'lodash';
import {
TrackEventActions,
TrackEventCategories
} from '../../models/TrackEvent';
import { useMatomo } from '@jonkoops/matomo-tracker-react';

import SelectableListHeader from '../SelectableListHeader/SelectableListHeader';
import { findChild } from '../../utils/elementUtils';
Expand All @@ -45,7 +40,6 @@ import { isDefined } from '../../utils/compareUtils';
import Badge from '@codegouvfr/react-dsfr/Badge';
import Button from '@codegouvfr/react-dsfr/Button';
import AppCheckbox from '../_app/AppCheckbox/AppCheckbox';
import { useLocation } from 'react-router-dom';
import { campaignSort } from '../../models/Campaign';
import { useUser } from '../../hooks/useUser';

Expand All @@ -64,9 +58,8 @@ const HousingList = ({
}: HousingListProps) => {
const header = findChild(children, SelectableListHeader);

const location = useLocation();
const campaignList = useCampaignList();
const { trackEvent } = useMatomo();

const { isVisitor } = useUser();

const [updateHousing] = useUpdateHousingMutation();
Expand Down Expand Up @@ -281,15 +274,6 @@ const HousingList = ({
housing: Housing,
housingUpdate: HousingUpdate
) => {
trackEvent({
category: location.pathname.includes('parc-de-logements')
? TrackEventCategories.HousingList
: TrackEventCategories.Campaigns,
action: location.pathname.includes('parc-de-logements')
? TrackEventActions.HousingList.Update
: TrackEventActions.Campaigns.Update,
value: 1
});
await updateHousing({
housing,
housingUpdate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ import {
import { displayCount } from '../../../utils/stringUtils';
import { GeoPerimeter } from '../../../models/GeoPerimeter';
import GeoPerimeterEditionModal from '../GeoPerimeterEditionModal/GeoPerimeterEditionModal';
import {
TrackEventActions,
TrackEventCategories,
} from '../../../models/TrackEvent';
import { useMatomo } from '@jonkoops/matomo-tracker-react';
import GeoPerimeterUploadingModal from '../GeoPerimeterUploadingModal/GeoPerimeterUploadingModal';
import GeoPerimeterCard from '../../GeoPerimeterCard/GeoPerimeterCard';
import AppHelp from '../../_app/AppHelp/AppHelp';
Expand All @@ -39,7 +34,6 @@ interface Props {
}

const GeoPerimetersModal = ({ onClose }: Props) => {
const { trackEvent } = useMatomo();
const { data: geoPerimeters } = useListGeoPerimetersQuery();
const [isUploadingModalOpen, setIsUploadingModalOpen] =
useState<boolean>(false);
Expand All @@ -65,21 +59,13 @@ const GeoPerimetersModal = ({ onClose }: Props) => {
] = useDeleteGeoPerimetersMutation();

const onSubmitUploadingGeoPerimeter = (file: File) => {
trackEvent({
category: TrackEventCategories.GeoPerimeters,
action: TrackEventActions.GeoPerimeters.Upload,
});
uploadGeoPerimeterFile(file).finally(() => {
setIsUploadingModalOpen(false);
});
};

const onSubmitUpdatingGeoPerimeter = (kind: string, name?: string) => {
if (geoPerimetersToUpdate) {
trackEvent({
category: TrackEventCategories.GeoPerimeters,
action: TrackEventActions.GeoPerimeters.Rename,
});
updateGeoPerimeter({
geoPerimeterId: geoPerimetersToUpdate.id,
kind,
Expand All @@ -91,10 +77,6 @@ const GeoPerimetersModal = ({ onClose }: Props) => {
};

const onSubmitRemovingGeoPerimeter = async (geoPerimeters: GeoPerimeter[]): Promise<void> => {
trackEvent({
category: TrackEventCategories.GeoPerimeters,
action: TrackEventActions.GeoPerimeters.Delete,
});
await deleteGeoPerimeters(geoPerimeters.map((_) => _.id));
};

Expand Down
16 changes: 4 additions & 12 deletions frontend/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { startReactDsfr } from '@codegouvfr/react-dsfr/spa';
import { createInstance, MatomoProvider } from '@jonkoops/matomo-tracker-react';
import posthog from 'posthog-js';
import { StrictMode } from 'react';
import ReactDOM from 'react-dom/client';
Expand All @@ -24,11 +23,6 @@ declare module '@codegouvfr/react-dsfr/spa' {
}
}

const matomo = createInstance({
...config.matomo,
disabled: !config.matomo.enabled
});

if (config.posthog.enabled) {
posthog.init('phc_Thondx9VvGONN5SZK0OuDttJDIorIANsudwCL2gU3O7', {
api_host: 'https://eu.i.posthog.com',
Expand All @@ -43,12 +37,10 @@ root.render(
<StrictMode>
<ThemeProvider>
<MapProvider>
<MatomoProvider value={matomo}>
<StoreProvider store={store}>
<Notification />
<App />
</StoreProvider>
</MatomoProvider>
<StoreProvider store={store}>
<Notification />
<App />
</StoreProvider>
</MapProvider>
</ThemeProvider>
</StrictMode>
Expand Down
73 changes: 0 additions & 73 deletions frontend/src/models/TrackEvent.tsx

This file was deleted.

12 changes: 0 additions & 12 deletions frontend/src/utils/config.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
const config = {
apiEndpoint: process.env.REACT_APP_API_URL,
banEndpoint: 'https://api-adresse.data.gouv.fr',
matomo: {
enabled:
process.env.REACT_APP_MATOMO_ENABLED !== undefined
? process.env.REACT_APP_MATOMO_ENABLED === 'true'
: process.env.NODE_ENV === 'production',
urlBase: process.env.REACT_APP_MATOMO_URL_BASE ?? 'http://localhost',
siteId: process.env.REACT_APP_MATOMO_SITE_ID
? Number(process.env.REACT_APP_MATOMO_SITE_ID)
: 1,
srcUrl: process.env.REACT_APP_MATOMO_SRC_URL,
linkTracking: true
},
metabase: {
siteUrl: process.env.REACT_APP_METABASE_SITE_URL,
public: {
Expand Down
Loading

0 comments on commit 6910320

Please sign in to comment.