Skip to content

Commit

Permalink
fix: Use custom param to track new story map previous path
Browse files Browse the repository at this point in the history
  • Loading branch information
josebui committed Sep 22, 2023
1 parent f45e19f commit 521deef
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/storyMap/components/StoryMapNew.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react';
import _ from 'lodash/fp';
import { useTranslation } from 'react-i18next';
import { useDispatch, useSelector } from 'react-redux';
import { useNavigate } from 'react-router-dom';
import { useNavigate, useSearchParams } from 'react-router-dom';
import { Paper, useMediaQuery } from '@mui/material';

import { useDocumentTitle } from 'common/document';
Expand Down Expand Up @@ -94,17 +94,20 @@ const StoryMapNew = () => {
const { t } = useTranslation();
const navigate = useNavigate();
const { trackEvent } = useAnalytics();
const [searchParams] = useSearchParams();
const [saved, setSaved] = useState();

useDocumentTitle(t('storyMap.new_document_title'));

useEffect(() => {
const source = searchParams.get('source') || 'direct';
trackEvent('storymap.start', {
props: {
[ILM_OUTPUT_PROP]: LANDSCAPE_NARRATIVES,
source,
},
});
}, [trackEvent]);
}, [trackEvent, searchParams]);

useEffect(() => {
if (!saved) {
Expand Down
2 changes: 1 addition & 1 deletion src/storyMap/components/StoryMapsCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ const StoryMapsCard = ({ title, storyMaps, showCreate = true }) => {
() =>
showCreate && {
label: t('storyMap.home_create'),
to: 'tools/story-maps/new?utm_source=home_page',
to: 'tools/story-maps/new?source=home_page',
},
[t, showCreate]
);
Expand Down
2 changes: 1 addition & 1 deletion src/storyMap/components/StoryMapsHomeCardDefault.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const StoryMapsHomeCardDefault = () => {
titleId="story-maps-default-title"
action={{
label: t('storyMap.home_create'),
to: 'tools/story-maps/new?utm_source=home_page',
to: 'tools/story-maps/new?source=home_page',
}}
image={{
src: storyMapImage,
Expand Down
2 changes: 1 addition & 1 deletion src/storyMap/components/StoryMapsToolHome.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const StoryMapsToolsHome = () => {
<Button
variant="contained"
component={Link}
to="/tools/story-maps/new?utm_source=story_maps_tools_page"
to="/tools/story-maps/new?source=story_maps_page"
sx={{ mt: 2, mb: 3 }}
>
{t('storyMap.tool_home_create_button')}
Expand Down

0 comments on commit 521deef

Please sign in to comment.