Skip to content

Commit b80ef17

Browse files
authored
Legger til manglende navn på seksjon til analytics på forsider (#2219)
* Legger til navn på seksjon til analytics for snarveier, innlogget seksjon og "mer"-lenker
1 parent e37118f commit b80ef17

File tree

6 files changed

+26
-11
lines changed

6 files changed

+26
-11
lines changed

packages/nextjs/src/components/_common/areaCard/AreaCard.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import { LinkPanel } from '@navikt/ds-react';
33
import { EditorHelp } from 'components/_editor-only/editor-help/EditorHelp';
44
import { classNames } from 'utils/classnames';
5+
import { useLayoutConfig } from 'components/layouts/useLayoutConfig';
56
import { LenkeBase } from 'components/_common/lenke/lenkeBase/LenkeBase';
67
import { AreaCardGraphics } from './graphics/AreaCardGraphics';
78

@@ -17,6 +18,9 @@ type Props = {
1718
} & Omit<React.ComponentProps<typeof LinkPanel>, 'as'>;
1819

1920
export const AreaCard = ({ path, title, area, linkGroup, className, ...rest }: Props) => {
21+
const { layoutConfig } = useLayoutConfig();
22+
const analyticsLinkGroup= linkGroup ?? layoutConfig.title;
23+
2024
if (!area) {
2125
return <EditorHelp text={'Velg en grafikk for kortet'} />;
2226
}
@@ -28,7 +32,7 @@ export const AreaCard = ({ path, title, area, linkGroup, className, ...rest }: P
2832
href={path}
2933
analyticsLabel={title}
3034
analyticsComponent={'Områdekort'}
31-
analyticsLinkGroup={linkGroup}
35+
analyticsLinkGroup={analyticsLinkGroup}
3236
className={classNames(style.linkPanel, graphicsStyle.expandOnHover, className)}
3337
as={LenkeBase}
3438
>

packages/nextjs/src/components/_common/moreLink/MoreLink.tsx

+14-4
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,25 @@ import { LenkeStandalone } from 'components/_common/lenke/lenkeStandalone/LenkeS
55

66
import styles from './MoreLink.module.scss';
77

8-
export const MoreLink = ({ link }: { link?: LinkSelectable }) => {
9-
if (!link) {
8+
type Props = {
9+
link: LinkSelectable;
10+
analyticsGroup?: string;
11+
};
12+
13+
export const MoreLink = ( props: Props) => {
14+
if (!props.link) {
1015
return null;
1116
}
1217

13-
const { text, url } = getSelectableLinkProps(link);
18+
const { text, url } = getSelectableLinkProps(props.link);
1419

1520
return (
16-
<LenkeStandalone href={url} className={styles.moreLink} withChevron={false}>
21+
<LenkeStandalone
22+
href={url}
23+
linkGroup={props.analyticsGroup}
24+
className={styles.moreLink}
25+
withChevron={false}
26+
>
1727
<ArrowRightIcon aria-hidden={true} className={styles.arrow} />
1828
{text}
1929
</LenkeStandalone>

packages/nextjs/src/components/layouts/frontpage-loggedin-section/FrontpageLoggedinSectionLayout.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export const FrontpageLoggedinSectionLayout = ({ layoutProps, pageProps }: Props
4343
}
4444

4545
const { header, mypage } = config;
46+
const title = yourServicesText('yourServices');
4647

4748
return (
4849
<AuthDependantRender renderOn={'loggedIn'}>
@@ -53,11 +54,11 @@ export const FrontpageLoggedinSectionLayout = ({ layoutProps, pageProps }: Props
5354
data-hj-suppress
5455
>
5556
<HeaderWithName headerText={header} />
56-
<Header level={'2'} size={'small'} className={style.services}>
57-
{yourServicesText('yourServices')}
57+
<Header level="3" size="small" className={style.services}>
58+
{title}
5859
</Header>
5960
<Region pageProps={pageProps} regionProps={regions.cards} className={style.cards} />
60-
<MoreLink link={mypage?.link} />
61+
<MoreLink analyticsGroup={title} link={mypage?.link} />
6162
</LayoutContainer>
6263
</AuthDependantRender>
6364
);

packages/nextjs/src/components/parts/frontpage-current-topics/FrontpageCurrentTopicsPart.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export const FrontpageCurrentTopicsPart = ({
8282
);
8383
})}
8484
</ul>
85-
{link && <MoreLink link={link} />}
85+
{link && <MoreLink analyticsGroup={title} link={link} />}
8686
</div>
8787
);
8888
};

packages/nextjs/src/components/parts/frontpage-person-shortcuts/FrontpagePersonShortcutsPart.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const FrontpagePersonShortcutsPart = ({
6161
href={href}
6262
className={style.linkPanel}
6363
analyticsComponent="Lenkepanel navno enkel"
64-
analyticsLinkGroup={title}
64+
analyticsLinkGroup={sectionTitle}
6565
>
6666
<div className={style.icon}>
6767
{

packages/nextjs/src/components/parts/frontpage-shortcuts/FrontpageShortcutsPart.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export const FrontpageShortcutsPart = ({
7979
<li key={title}>
8080
<LinkPanelNavnoSimple
8181
href={href}
82-
analyticsLinkGroup={title}
82+
analyticsLinkGroup={sectionTitle}
8383
icon={<IllustrationStatic illustration={illustration} />}
8484
className={classNames(
8585
style.item,

0 commit comments

Comments
 (0)