Skip to content

Commit 5138e83

Browse files
committed
IS-1940: Add logging of tab change event
1 parent 7c2bd04 commit 5138e83

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

src/components/NavigationBar.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
minOversiktRoutePathRoutePath,
88
} from '@/routers/AppRouter';
99

10-
const tekster = {
10+
const texts = {
1111
enhetensOversikt: 'Enhetens oversikt',
1212
minOversikt: 'Min oversikt',
1313
};
@@ -54,6 +54,7 @@ const NavigationBarContent = styled.div`
5454
padding-top: 1em;
5555
padding-bottom: 1em;
5656
display: flex;
57+
5758
> :not(:last-child) {
5859
margin-right: 1em;
5960
}
@@ -72,13 +73,13 @@ export const NavigationBar = (): ReactElement => {
7273
className={({ isActive }) => (isActive ? 'active' : '')}
7374
to={minOversiktRoutePathRoutePath}
7475
>
75-
{tekster.minOversikt}
76+
{texts.minOversikt}
7677
</LinkStyled>
7778
<LinkStyled
7879
className={({ isActive }) => (isActive ? 'active' : '')}
7980
to={enhetOversiktRoutePath}
8081
>
81-
{tekster.enhetensOversikt}
82+
{texts.enhetensOversikt}
8283
</LinkStyled>
8384
<MoteoversiktLinkContent>
8485
<MoteoversiktLink />

src/containers/OversiktContainer.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { NavigationBar } from '@/components/NavigationBar';
99
import { useTabType } from '@/context/tab/TabTypeContext';
1010
import { NotificationBar } from '@/components/error/NotificationBar';
1111
import ErrorBoundary from '@/components/error/ErrorBoundary';
12+
import * as Amplitude from '@/utils/amplitude';
13+
import { EventType } from '@/utils/amplitude';
1214

1315
const Container = styled.div`
1416
display: flex;
@@ -21,10 +23,29 @@ interface Props {
2123
tabType: OverviewTabType;
2224
}
2325

26+
function logPageView(tab: OverviewTabType) {
27+
Amplitude.logEvent({
28+
type: EventType.PageView,
29+
data: { url: window.location.href, sidetittel: toReadableString(tab) },
30+
});
31+
}
32+
33+
function toReadableString(overviewTabType: OverviewTabType): string {
34+
switch (overviewTabType) {
35+
case OverviewTabType.ENHET_OVERVIEW:
36+
return 'Enhetens oversikt';
37+
case OverviewTabType.MY_OVERVIEW:
38+
return 'Min oversikt';
39+
}
40+
}
41+
2442
const OversiktContainer = ({ tabType }: Props): ReactElement => {
2543
const personregisterQuery = usePersonregisterQuery();
2644
const personoversiktQuery = usePersonoversiktQuery();
2745
const { setTabType } = useTabType();
46+
useEffect(() => {
47+
logPageView(tabType);
48+
}, [tabType]);
2849

2950
useEffect(() => {
3051
setTabType(tabType);

0 commit comments

Comments
 (0)