diff --git a/.github/workflows/deploy_to_prod.yaml b/.github/workflows/deploy_to_prod.yaml index 835c9fbae..8a1613ae6 100644 --- a/.github/workflows/deploy_to_prod.yaml +++ b/.github/workflows/deploy_to_prod.yaml @@ -13,7 +13,7 @@ jobs: deploy_to_prod: name: 'Deploy to PROD' runs-on: 'ubuntu-latest' - environment: 'PROD_mimir' + environment: 'production' steps: - id: build_app uses: enonic/release-tools/build-and-publish@master diff --git a/.github/workflows/former_build_deploy_to_prod.yaml b/.github/workflows/former_build_deploy_to_prod.yaml index 6177c0fd1..1a2eadb49 100644 --- a/.github/workflows/former_build_deploy_to_prod.yaml +++ b/.github/workflows/former_build_deploy_to_prod.yaml @@ -12,7 +12,7 @@ jobs: deploy-artifact: name: 'Deploy artifact' runs-on: ubuntu-latest - environment: 'PROD_mimir' + environment: 'production' steps: - name: Download workflow artifact uses: dawidd6/action-download-artifact@v3.1.4 diff --git a/package-lock.json b/package-lock.json index 0f9e70262..4f60d2345 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,6 @@ "date-fns": "~3.6.0", "highcharts-react-official": "~3.2.1", "react-bootstrap": "~2.10.2", - "react-ga": "~3.3.1", "react-select": "~5.8.0", "redux": "~5.0.1", "redux-logger": "~3.0.6", @@ -17216,15 +17215,6 @@ "react": ">=16.8.6" } }, - "node_modules/react-ga": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/react-ga/-/react-ga-3.3.1.tgz", - "integrity": "sha512-4Vc0W5EvXAXUN/wWyxvsAKDLLgtJ3oLmhYYssx+YzphJpejtOst6cbIHCIyF50Fdxuf5DDKqRYny24yJ2y7GFQ==", - "peerDependencies": { - "prop-types": "^15.6.0", - "react": "^15.6.2 || ^16.0 || ^17 || ^18" - } - }, "node_modules/react-helmet-async": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/react-helmet-async/-/react-helmet-async-2.0.5.tgz", @@ -33505,12 +33495,6 @@ "prop-types": "^15.7.2" } }, - "react-ga": { - "version": "3.3.1", - "resolved": "https://registry.npmjs.org/react-ga/-/react-ga-3.3.1.tgz", - "integrity": "sha512-4Vc0W5EvXAXUN/wWyxvsAKDLLgtJ3oLmhYYssx+YzphJpejtOst6cbIHCIyF50Fdxuf5DDKqRYny24yJ2y7GFQ==", - "requires": {} - }, "react-helmet-async": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/react-helmet-async/-/react-helmet-async-2.0.5.tgz", diff --git a/package.json b/package.json index 931247fd0..636ec9a7f 100644 --- a/package.json +++ b/package.json @@ -164,7 +164,6 @@ "date-fns": "~3.6.0", "highcharts-react-official": "~3.2.1", "react-bootstrap": "~2.10.2", - "react-ga": "~3.3.1", "react-select": "~5.8.0", "redux": "~5.0.1", "redux-logger": "~3.0.6", diff --git a/src/main/resources/assets/js/app/highchart.es6 b/src/main/resources/assets/js/app/highchart.es6 index 0afc561fa..7c16179e4 100644 --- a/src/main/resources/assets/js/app/highchart.es6 +++ b/src/main/resources/assets/js/app/highchart.es6 @@ -139,40 +139,19 @@ export function init() { }) } - const category = 'Highcharts' - const action = 'Lastet ned highcharts' - config.exporting.menuItemDefinitions = { printChart: { onclick: function () { - const label = `${config.title.text} - Skriv ut graf` - gtag('event', action, { - event_category: category, - event_label: label, - }) - this.print() }, }, downloadPNG: { onclick: function () { - const label = `${config.title.text} - Last ned som PNG` - gtag('event', action, { - event_category: category, - event_label: label, - }) - this.exportChartLocal() //png is default }, }, downloadJPEG: { onclick: function () { - const label = `${config.title.text} - Last ned som JPEG` - gtag('event', action, { - event_category: category, - event_label: label, - }) - this.exportChartLocal({ type: 'image/jpeg', }) @@ -180,12 +159,6 @@ export function init() { }, downloadPDF: { onclick: function () { - const label = `${config.title.text} - Last ned som PDF` - gtag('event', action, { - event_category: category, - event_label: label, - }) - this.exportChartLocal({ type: 'application/pdf', }) @@ -193,12 +166,6 @@ export function init() { }, downloadSVG: { onclick: function () { - const label = `${config.title.text} - Last ned som SVG` - gtag('event', action, { - event_category: category, - event_label: label, - }) - this.exportChartLocal({ type: 'image/svg+xml', }) @@ -206,11 +173,6 @@ export function init() { }, downloadXLS: { onclick: function () { - const label = `${config.title.text} - Last ned som XLS` - gtag('event', action, { - event_category: category, - event_label: label, - }) const rows = this.getDataRows(true) const xlsxRows = rows.slice(1).map(function (row) { return row.map(function (column) { @@ -230,12 +192,6 @@ export function init() { }, downloadCSV: { onclick: function () { - const label = `${config.title.text} - Last ned som CSV` - gtag('event', action, { - event_category: category, - event_label: label, - }) - this.downloadCSV() }, }, diff --git a/src/main/resources/assets/styles/_keyFigures.scss b/src/main/resources/assets/styles/_keyFigures.scss index 34f0ccc41..0f0c4ea6e 100644 --- a/src/main/resources/assets/styles/_keyFigures.scss +++ b/src/main/resources/assets/styles/_keyFigures.scss @@ -15,4 +15,10 @@ margin-right: auto; } } +} + +.macro-keyfigure{ + .green-box { + margin-bottom: 15px; + } } \ No newline at end of file diff --git a/src/main/resources/lib/types/partTypes/attachmentTablesFigures.ts b/src/main/resources/lib/types/partTypes/attachmentTablesFigures.ts index fa733b964..6eed4364c 100644 --- a/src/main/resources/lib/types/partTypes/attachmentTablesFigures.ts +++ b/src/main/resources/lib/types/partTypes/attachmentTablesFigures.ts @@ -6,7 +6,6 @@ export type AttachmentTablesFiguresProps = { showAll: string showLess: string appName: string - GA_TRACKING_ID: string | null title: string } diff --git a/src/main/resources/lib/types/partTypes/keyFigure.ts b/src/main/resources/lib/types/partTypes/keyFigure.ts index 8ff12b828..63d9b039f 100644 --- a/src/main/resources/lib/types/partTypes/keyFigure.ts +++ b/src/main/resources/lib/types/partTypes/keyFigure.ts @@ -13,6 +13,7 @@ export interface KeyFigureProps { pageTypeKeyFigure: boolean hiddenTitle: string isInStatisticsPage: boolean + isMacro: boolean } export interface KeyFigureData { diff --git a/src/main/resources/lib/types/partTypes/links.ts b/src/main/resources/lib/types/partTypes/links.ts index 38ac61d85..832a8f7bc 100644 --- a/src/main/resources/lib/types/partTypes/links.ts +++ b/src/main/resources/lib/types/partTypes/links.ts @@ -5,7 +5,6 @@ export interface LinksProps { linkType?: 'regular' | 'profiled' | 'header' text?: string description?: string - GA_TRACKING_ID?: string isPDFAttachment?: boolean attachmentTitle?: string } diff --git a/src/main/resources/lib/types/partTypes/nameSearch.ts b/src/main/resources/lib/types/partTypes/nameSearch.ts index 58dc8e2f5..0a7c01227 100644 --- a/src/main/resources/lib/types/partTypes/nameSearch.ts +++ b/src/main/resources/lib/types/partTypes/nameSearch.ts @@ -52,5 +52,4 @@ export interface NameSearchProps { close: string } language: string - GA_TRACKING_ID: string | null } diff --git a/src/main/resources/lib/types/partTypes/searchResult.ts b/src/main/resources/lib/types/partTypes/searchResult.ts index 2dbee9810..bf6223480 100644 --- a/src/main/resources/lib/types/partTypes/searchResult.ts +++ b/src/main/resources/lib/types/partTypes/searchResult.ts @@ -51,7 +51,6 @@ export interface SearchResultProps { contentTypePhrases: Array contentTypes: Array subjects: Array - GA_TRACKING_ID: string | null contentTypeUrlParam: string | undefined subjectUrlParam: string | undefined searchResultSRText: string diff --git a/src/main/resources/lib/types/partTypes/table.ts b/src/main/resources/lib/types/partTypes/table.ts index a31ec6405..55df9be7f 100644 --- a/src/main/resources/lib/types/partTypes/table.ts +++ b/src/main/resources/lib/types/partTypes/table.ts @@ -23,7 +23,6 @@ export interface TableProps { sourceTableLabel: string statBankWebUrl: string hiddenTitle: string | undefined - GA_TRACKING_ID: string | null } export interface TableStandardSymbolLink { diff --git a/src/main/resources/main.es6 b/src/main/resources/main.es6 index f8be120ce..42420dcab 100644 --- a/src/main/resources/main.es6 +++ b/src/main/resources/main.es6 @@ -103,6 +103,10 @@ try { feature: 'structured-data', enabled: false, }, + { + feature: 'pageMap', + enabled: false, + }, ], }, ]) diff --git a/src/main/resources/react4xp/ReactGA.tsx b/src/main/resources/react4xp/ReactGA.tsx deleted file mode 100644 index 439c45299..000000000 --- a/src/main/resources/react4xp/ReactGA.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import ReactGA from 'react-ga' - -export const addGtagForEvent = (GA_TRACKING_ID, action, category, label) => { - ReactGA.initialize(GA_TRACKING_ID, { - titleCase: false, - }) - ReactGA.event({ - action, - category, - label, - }) - ReactGA.set({ - anonymizeIp: true, - }) -} diff --git a/src/main/resources/react4xp/_entries/AttachmentTablesFigures.tsx b/src/main/resources/react4xp/_entries/AttachmentTablesFigures.tsx index 59086f99f..b59efa3bd 100644 --- a/src/main/resources/react4xp/_entries/AttachmentTablesFigures.tsx +++ b/src/main/resources/react4xp/_entries/AttachmentTablesFigures.tsx @@ -9,7 +9,6 @@ import { } from '../../lib/types/partTypes/attachmentTablesFigures' import Table from '../table/Table' -import { addGtagForEvent } from '/react4xp/ReactGA' function AttachmentTableFigures(props: AttachmentTablesFiguresProps) { const [isHidden, setIsHidden] = useState(true) @@ -29,19 +28,6 @@ function AttachmentTableFigures(props: AttachmentTablesFiguresProps) { } } - function toggleAccordion(isOpen: boolean, index: number) { - const { contentType, subHeader, open } = accordions[index] - - if (isOpen && contentType === `${props.appName}:table` && props.GA_TRACKING_ID) { - addGtagForEvent( - props.GA_TRACKING_ID, - 'Utvidet vedleggstabell', - 'Statistikkside vedleggstabeller', - `${subHeader} ${open}` - ) - } - } - function getButtonBreakpoint() { if (accordions.length > 5) { return '' @@ -127,7 +113,6 @@ function AttachmentTableFigures(props: AttachmentTablesFiguresProps) { header={accordion.open} subHeader={accordion.subHeader} openByDefault={anchor && accordion.id && accordion.id === anchor} - onToggle={(isOpen: boolean) => toggleAccordion(isOpen, index)} > {renderAccordionBody(accordion)} diff --git a/src/main/resources/react4xp/_entries/KeyFigure.tsx b/src/main/resources/react4xp/_entries/KeyFigure.tsx index 01a18318a..567a39370 100644 --- a/src/main/resources/react4xp/_entries/KeyFigure.tsx +++ b/src/main/resources/react4xp/_entries/KeyFigure.tsx @@ -87,6 +87,7 @@ class KeyFigures extends React.Component { isRight = !columns || (columns && !isRight) || keyFigure.size === 'large' return ( + {this.props.isMacro && !keyFigure.greenBox ? this.addDivider(isRight) : null} { /> {this.addKeyFigureSource(keyFigure)} - {i < keyFigures.length - 1 ? ( - - ) : null} + {i < keyFigures.length - 1 ? this.addDivider(isRight) : null} + {this.props.isMacro && !keyFigure.greenBox ? this.addDivider(isRight) : null} ) }) } + addDivider(isRight: boolean) { + return + } + addKeyFigureSource(keyFigure: KeyFigureData) { if ((!this.props.source || !this.props.source.url) && keyFigure.source && keyFigure.source.url) { const sourceLabel = this.props.sourceLabel diff --git a/src/main/resources/react4xp/table/Table.tsx b/src/main/resources/react4xp/table/Table.tsx index 380975c82..744d672b1 100644 --- a/src/main/resources/react4xp/table/Table.tsx +++ b/src/main/resources/react4xp/table/Table.tsx @@ -4,7 +4,6 @@ import { default as isEmpty } from 'ramda/es/isEmpty' import { NumericFormat } from 'react-number-format' import { Alert } from 'react-bootstrap' import { ChevronLeft, ChevronRight } from 'react-feather' -import { addGtagForEvent } from '/react4xp/ReactGA' import { type TableProps } from '../../lib/types/partTypes/table' import { PreliminaryData, type TableCellUniform } from '../../lib/types/xmlParser' @@ -156,10 +155,6 @@ function Table(props: TableProps) { } function downloadTableAsCSV() { - if (props.GA_TRACKING_ID) { - addGtagForEvent(props.GA_TRACKING_ID, 'Lastet ned csv tabell', 'Statistikkside tabeller', 'Last ned csv tabell') - } - if (window && window.downloadTableFile) { window.downloadTableFile(tableRef.current, { type: 'csv', @@ -172,15 +167,6 @@ function Table(props: TableProps) { } function downloadTableAsExcel() { - if (props.GA_TRACKING_ID) { - addGtagForEvent( - props.GA_TRACKING_ID, - 'Lastet ned excell tabell', - 'Statistikkside tabeller', - 'Last ned excell tabell' - ) - } - if (window && window.downloadTableFile) { window.downloadTableFile(tableRef.current, { type: 'xlsx', diff --git a/src/main/resources/site/error/error.html b/src/main/resources/site/error/error.html index 7a25912f1..72f7b5f78 100644 --- a/src/main/resources/site/error/error.html +++ b/src/main/resources/site/error/error.html @@ -1,24 +1,21 @@ - - - - - Side ikke funnet / Page not found - - - - - - -
-
-
- - + + + Side ikke funnet / Page not found + + + + + + + +
+
+
+ + + \ No newline at end of file diff --git a/src/main/resources/site/error/error.ts b/src/main/resources/site/error/error.ts index 4bc6d96b8..c940d7aab 100644 --- a/src/main/resources/site/error/error.ts +++ b/src/main/resources/site/error/error.ts @@ -77,7 +77,6 @@ function getMainErrorBody(status: number, contentHtml: string, language: Languag language, pageTitle: status === 404 ? 'Side ikke funnet / Page not found' : 'Siden feilet / Page error', bodyClasses: '', - GA_TRACKING_ID: app.config && app.config.GA_TRACKING_ID ? app.config.GA_TRACKING_ID : null, contentHtml, } const mainErrorBody = render(mainErrorView, mainErrorModel) diff --git a/src/main/resources/site/macros/keyFigure/keyFigure.ts b/src/main/resources/site/macros/keyFigure/keyFigure.ts new file mode 100644 index 000000000..400e151d8 --- /dev/null +++ b/src/main/resources/site/macros/keyFigure/keyFigure.ts @@ -0,0 +1,18 @@ +import { renderError } from '/lib/ssb/error/error' +import { type KeyFigure as KeyFigureConfig } from '/site/macros/keyFigure' +import { macroPreview } from '/site/parts/keyFigure/keyFigure' + +export function macro(context: XP.MacroContext): XP.Response { + try { + const config = context.params + const keyFigure = macroPreview(context.request, config.keyFigure) + + if (keyFigure.status && keyFigure.status !== 200) throw new Error(`keyFigure with id ${config.keyFigure} missing`) + + keyFigure.body = `
${keyFigure.body}
` + + return keyFigure + } catch (e) { + return renderError(context.request, 'Error in macro', e) + } +} diff --git a/src/main/resources/site/macros/keyFigure/keyFigure.xml b/src/main/resources/site/macros/keyFigure/keyFigure.xml new file mode 100644 index 000000000..1bbb0ff62 --- /dev/null +++ b/src/main/resources/site/macros/keyFigure/keyFigure.xml @@ -0,0 +1,14 @@ + + Nøkkeltall + +
+ + + + + ${site} + keyFigure + + + +
diff --git a/src/main/resources/site/macros/links/links.ts b/src/main/resources/site/macros/links/links.ts index f123b2595..0c0be33a8 100644 --- a/src/main/resources/site/macros/links/links.ts +++ b/src/main/resources/site/macros/links/links.ts @@ -6,7 +6,6 @@ import { prepareText } from '/site/parts/links/links' import { type TableLink } from '/site/mixins/tableLink' import { type HeaderLink } from '/site/mixins/headerLink' import { type ProfiledLink } from '/site/mixins/profiledLink' -import { GA_TRACKING_ID } from '/site/pages/default/default' import { type Links as LinksConfig } from '.' export function macro(context: XP.MacroContext) { @@ -62,7 +61,6 @@ export function macro(context: XP.MacroContext) { children: content ? prepareText(content, linkText) : linkText, href: contentUrl, linkType: 'header', - GA_TRACKING_ID: GA_TRACKING_ID, isPDFAttachment, attachmentTitle, } diff --git a/src/main/resources/site/pages/default/default.html b/src/main/resources/site/pages/default/default.html index 2c0cdc1c1..76ca49f4c 100644 --- a/src/main/resources/site/pages/default/default.html +++ b/src/main/resources/site/pages/default/default.html @@ -18,18 +18,6 @@ - - - - - - - @@ -63,6 +51,12 @@ +
+ + [(${pageMap})] +
+ +
- \ No newline at end of file + diff --git a/src/main/resources/site/pages/default/default.ts b/src/main/resources/site/pages/default/default.ts index 2fbdf5d4a..6449d35f2 100644 --- a/src/main/resources/site/pages/default/default.ts +++ b/src/main/resources/site/pages/default/default.ts @@ -66,7 +66,6 @@ const previewOverride: object = { contentList: 'relatedFactPage', } -export const GA_TRACKING_ID: string | null = app.config?.GA_TRACKING_ID || null export const GTM_TRACKING_ID: string | null = app.config?.GTM_TRACKING_ID || null export const GTM_AUTH: string | null = app.config?.GTM_AUTH || null @@ -221,6 +220,8 @@ export function get(req: XP.Request): XP.Response { metaInfo.addMetaInfoSearch && isEnabled('structured-data', false, 'ssb') ? prepareStructuredData(metaInfo, page) : undefined + const pageMap: string | undefined = + metaInfo.addMetaInfoSearch && isEnabled('pageMap', false, 'ssb') ? preparePageMap(metaInfo, page) : undefined const statbankFane: boolean = req.params.xpframe === 'statbank' const statBankContent: StatbankFrameData = parseStatbankFrameContent(statbankFane, req, page) @@ -252,13 +253,13 @@ export function get(req: XP.Request): XP.Response { language, statbankWeb: statbankFane, ...statBankContent, - GA_TRACKING_ID, GTM_TRACKING_ID, GTM_AUTH, headerBody: header?.body, footerBody: footer?.body, ...metaInfo, jsonLd, + pageMap, breadcrumbsReactId: breadcrumbId, hideHeader, hideBreadcrumb, @@ -371,6 +372,40 @@ function prepareStructuredData(metaInfo: MetaInfoData, page: DefaultPage): Artic } } +function preparePageMap(metainfo: MetaInfoData, page: DefaultPage): string { + const keywords = metainfo.metaInfoSearchKeywords + ? `` + : '' + const author = page.data.authorItemSet + ? `` + : '' + const category = metainfo.metaInfoMainSubject + ? `` + : '' + const contentType = metainfo.metaInfoSearchContentType + ? `` + : '' + const description = metainfo.metaInfoDescription + ? metainfo.metaInfoDescription + : page.x['com-enonic-app-metafields']?.['meta-data']?.seoDescription || '' + return `` +} + function parseMetaInfoData( municipality: MunicipalityWithCounty | undefined, pageType: string, @@ -682,10 +717,10 @@ interface DefaultModel { ieUrl: string language: Language statbankWeb: boolean - GA_TRACKING_ID: string | null GTM_TRACKING_ID: string | null GTM_AUTH: string | null jsonLd: Article | undefined + pageMap: string | undefined headerBody: string | undefined footerBody: string | undefined breadcrumbsReactId: string | undefined diff --git a/src/main/resources/site/parts/attachmentTablesFigures/attachmentTablesFigures.ts b/src/main/resources/site/parts/attachmentTablesFigures/attachmentTablesFigures.ts index 5f3331bc5..e5d6a94de 100644 --- a/src/main/resources/site/parts/attachmentTablesFigures/attachmentTablesFigures.ts +++ b/src/main/resources/site/parts/attachmentTablesFigures/attachmentTablesFigures.ts @@ -16,7 +16,6 @@ import { type AttachmentTablesFiguresData, type AttachmentTablesFiguresProps, } from '/lib/types/partTypes/attachmentTablesFigures' -import { GA_TRACKING_ID } from '/site/pages/default/default' import { type Statistics } from '/site/content-types' import { getProps } from '/site/parts/table/table' import { preview as highchartPreview } from '/site/parts/highchart/highchart' @@ -72,7 +71,6 @@ function getTablesAndFiguresComponent(page: Content, req: XP.Request showAll: phrases.showAll, showLess: phrases.showLess, appName: app.name, - GA_TRACKING_ID: GA_TRACKING_ID, title, } diff --git a/src/main/resources/site/parts/highchart/Highchart.jsx b/src/main/resources/site/parts/highchart/Highchart.jsx index 23d3a327f..d0f112e23 100644 --- a/src/main/resources/site/parts/highchart/Highchart.jsx +++ b/src/main/resources/site/parts/highchart/Highchart.jsx @@ -4,7 +4,6 @@ import HighchartsReact from 'highcharts-react-official' import PropTypes from 'prop-types' import { Row, Col, Container } from 'react-bootstrap' import { Title, Button, Tabs, Divider, Link } from '@statisticsnorway/ssb-component-library' -import { addGtagForEvent } from '/react4xp/ReactGA' import accessibilityLang from './../../../assets/js/highchart-lang.json' @@ -145,33 +144,18 @@ function Highchart(props) { printChart: { text: props.phrases['highcharts.printChart'], onclick: function () { - const label = `${highchart.config.title.text} - Skriv ut graf` - if (props.GA_TRACKING_ID) { - addGtagForEvent(props.GA_TRACKING_ID, action, category, label) - } - this.print() }, }, downloadPNG: { text: props.phrases['highcharts.downloadPNG'], onclick: function () { - const label = `${highchart.config.title.text} - Last ned som PNG` - if (props.GA_TRACKING_ID) { - addGtagForEvent(props.GA_TRACKING_ID, action, category, label) - } - this.exportChartLocal() // png is default }, }, downloadJPEG: { text: props.phrases['highcharts.downloadJPEG'], onclick: function () { - const label = `${highchart.config.title.text} - Last ned som JPEG` - if (props.GA_TRACKING_ID) { - addGtagForEvent(props.GA_TRACKING_ID, action, category, label) - } - this.exportChartLocal({ type: 'image/jpeg', }) @@ -180,11 +164,6 @@ function Highchart(props) { downloadPDF: { text: props.phrases['highcharts.downloadPDF'], onclick: function () { - const label = `${highchart.config.title.text} - Last ned som PDF` - if (props.GA_TRACKING_ID) { - addGtagForEvent(props.GA_TRACKING_ID, action, category, label) - } - this.exportChartLocal({ type: 'application/pdf', }) @@ -193,11 +172,6 @@ function Highchart(props) { downloadSVG: { text: props.phrases['highcharts.downloadSVG'], onclick: function () { - const label = `${highchart.config.title.text} - Last ned som SVG` - if (props.GA_TRACKING_ID) { - addGtagForEvent(props.GA_TRACKING_ID, action, category, label) - } - this.exportChartLocal({ type: 'image/svg+xml', }) @@ -205,25 +179,13 @@ function Highchart(props) { }, downloadXLS: { text: props.phrases['highcharts.downloadXLS'], - onclick: function () { - const label = `${highchart.config.title.text} - Last ned som XLS` - if (props.GA_TRACKING_ID) { - addGtagForEvent(props.GA_TRACKING_ID, action, category, label) - } - - // TODO: Re-implement zipcelx fix (are there other alternatives for react?) this.downloadXLS() }, }, downloadCSV: { text: props.phrases['highcharts.downloadCSV'], onclick: function () { - const label = `${highchart.config.title.text} - Last ned som CSV` - if (props.GA_TRACKING_ID) { - addGtagForEvent(props.GA_TRACKING_ID, action, category, label) - } - this.downloadCSV() }, }, @@ -268,7 +230,6 @@ Highchart.propTypes = { phrases: PropTypes.object, appName: PropTypes.string, pageType: PropTypes.string, - GA_TRACKING_ID: PropTypes.string, } export default (props) => diff --git a/src/main/resources/site/parts/highchart/highchart.ts b/src/main/resources/site/parts/highchart/highchart.ts index 542562d1f..933e3dcf4 100644 --- a/src/main/resources/site/parts/highchart/highchart.ts +++ b/src/main/resources/site/parts/highchart/highchart.ts @@ -24,7 +24,6 @@ import { isEnabled } from '/lib/featureToggle' import { getPhrases } from '/lib/ssb/utils/language' import { getTbprocessorKey } from '/lib/ssb/dataset/tbprocessor/tbprocessor' import { type HighchartsExtendedProps, type HighchartsReactProps } from '/lib/types/partTypes/highchartsReact' -import { GA_TRACKING_ID } from '/site/pages/default/default' import { type DataSource } from '/site/mixins/dataSource' import { type CombinedGraph, type Highchart } from '/site/content-types' @@ -98,7 +97,6 @@ function renderPart(req: XP.Request, highchartIds: Array): XP.Response { phrases: getPhrases(page), appName: app.name, pageType: page.type, - GA_TRACKING_ID: GA_TRACKING_ID, } if (isEnabled('highchart-react', true, 'ssb')) { diff --git a/src/main/resources/site/parts/keyFigure/keyFigure.ts b/src/main/resources/site/parts/keyFigure/keyFigure.ts index 2c32deebf..f16046022 100644 --- a/src/main/resources/site/parts/keyFigure/keyFigure.ts +++ b/src/main/resources/site/parts/keyFigure/keyFigure.ts @@ -20,7 +20,16 @@ export function get(req: XP.Request): XP.Response { const keyFigureIds: Array | [] = config.figure ? util.data.forceArray(config.figure) : [] const municipality: MunicipalityWithCounty | undefined = getMunicipality(req as RequestWithCode) - return renderPart(req, municipality, keyFigureIds) + return renderPart(req, municipality, keyFigureIds, false) + } catch (e) { + return renderError(req, 'Error in part', e) + } +} + +export function macroPreview(req: XP.Request, id: string): XP.Response { + try { + const municipality = getSiteConfigAndMunicipality() + return renderPart(req, municipality, [id], true) } catch (e) { return renderError(req, 'Error in part', e) } @@ -28,23 +37,29 @@ export function get(req: XP.Request): XP.Response { export function preview(req: XP.Request, id: string): XP.Response { try { - const siteConfig = getSiteConfig() - if (!siteConfig) throw Error('No site config found') - - const defaultMunicipality: XP.SiteConfig['defaultMunicipality'] = siteConfig.defaultMunicipality - const municipality: MunicipalityWithCounty | undefined = getMunicipality({ - code: defaultMunicipality, - } as RequestWithCode) - return renderPart(req, municipality, [id]) + const municipality = getSiteConfigAndMunicipality() + return renderPart(req, municipality, [id], false) } catch (e) { return renderError(req, 'Error in part', e) } } +function getSiteConfigAndMunicipality() { + const siteConfig = getSiteConfig() + if (!siteConfig) throw Error('No site config found') + + const defaultMunicipality: XP.SiteConfig['defaultMunicipality'] = siteConfig.defaultMunicipality + const municipality: MunicipalityWithCounty | undefined = getMunicipality({ + code: defaultMunicipality, + } as RequestWithCode) + return municipality +} + function renderPart( req: XP.Request, municipality: MunicipalityWithCounty | undefined, - keyFigureIds: Array + keyFigureIds: Array, + isMacro: boolean ): XP.Response { const page = getContent() if (!page) throw Error('No page found') @@ -75,7 +90,7 @@ function renderPart( }) as Array } - return renderKeyFigure(page, keyFigures, keyFiguresDraft, showPreviewDraft, req, config) + return renderKeyFigure(page, keyFigures, keyFiguresDraft, showPreviewDraft, req, isMacro, config) } function renderKeyFigure( @@ -84,6 +99,7 @@ function renderKeyFigure( parsedKeyFiguresDraft: Array | null, showPreviewDraft: boolean, req: XP.Request, + isMacro: boolean, config?: KeyFigurePartConfig ): XP.Response { const draftExist = !!parsedKeyFiguresDraft @@ -117,6 +133,7 @@ function renderKeyFigure( pageTypeKeyFigure: page.type === `${app.name}:keyFigure`, hiddenTitle: hiddenTitle.toString().replace(/[\[\]']+/g, ''), isInStatisticsPage: page.type === `${app.name}:statistics`, + isMacro, } return render('KeyFigure', props, req, { diff --git a/src/main/resources/site/parts/links/links.ts b/src/main/resources/site/parts/links/links.ts index 89364180f..208078d55 100644 --- a/src/main/resources/site/parts/links/links.ts +++ b/src/main/resources/site/parts/links/links.ts @@ -3,7 +3,6 @@ import { getComponent, attachmentUrl, pageUrl } from '/lib/xp/portal' import { render } from '/lib/enonic/react4xp' import { renderError } from '/lib/ssb/error/error' import { type LinksProps } from '/lib/types/partTypes/links' -import { GA_TRACKING_ID } from '/site/pages/default/default' import { type Links as LinksPartConfig } from '.' export function get(req: XP.Request): XP.Response { @@ -77,7 +76,6 @@ function renderPart(req: XP.Request, config: LinksPartConfig) { children: content ? prepareText(content, linkText) : linkText, href: contentUrl, linkType: 'header', - GA_TRACKING_ID: GA_TRACKING_ID, isPDFAttachment, attachmentTitle, } diff --git a/src/main/resources/site/parts/links/links.tsx b/src/main/resources/site/parts/links/links.tsx index ee09652ad..1d93d6930 100644 --- a/src/main/resources/site/parts/links/links.tsx +++ b/src/main/resources/site/parts/links/links.tsx @@ -1,29 +1,15 @@ import React from 'react' import { Link, TableLink } from '@statisticsnorway/ssb-component-library' import { ArrowRight } from 'react-feather' -import { addGtagForEvent } from '/react4xp/ReactGA' import { LinksProps } from '../../../lib/types/partTypes/links' const Links = (props: LinksProps) => { - const { children, href, withIcon, linkType, text, description, GA_TRACKING_ID, isPDFAttachment, attachmentTitle } = - props - - const handleClick = () => { - if (linkType === 'header') { - if (GA_TRACKING_ID && isPDFAttachment) addGtagForEvent(GA_TRACKING_ID, 'Åpne PDF', 'Nedlasting', attachmentTitle) - } - } + const { children, href, withIcon, linkType, text, description } = props const renderLinks = () => { const renderIcon = typeof withIcon === 'boolean' ? withIcon : withIcon === 'true' // Macro config returns string. This is a workaround. return ( - } - linkType={linkType} - onClick={handleClick} - standAlone - > + } linkType={linkType} standAlone> {children} ) diff --git a/src/main/resources/site/parts/nameSearch/nameSearch.jsx b/src/main/resources/site/parts/nameSearch/nameSearch.jsx index a0166c509..520e3b544 100644 --- a/src/main/resources/site/parts/nameSearch/nameSearch.jsx +++ b/src/main/resources/site/parts/nameSearch/nameSearch.jsx @@ -11,7 +11,6 @@ import highchartsExportingOffline from 'highcharts/modules/offline-exporting' import highchartsExportData from 'highcharts/modules/export-data' import highchartsAccessibility from 'highcharts/modules/accessibility' import { useMediaQuery } from 'react-responsive' -import { addGtagForEvent } from '/react4xp/ReactGA' import { sanitize } from '../../../lib/ssb/utils/htmlUtils' import accessibilityLang from './../../../assets/js/highchart-lang.json' @@ -208,10 +207,6 @@ function NameSearch(props) { setErrorMessage(undefined) // Clear network error message, if any setSearchedTerm(name.value) - if (props.GA_TRACKING_ID) { - addGtagForEvent(props.GA_TRACKING_ID, 'Navn det søkes på', 'Navnekalkulator', name.value) - } - axios .get(props.urlToService, { params: { @@ -539,7 +534,6 @@ NameSearch.propTypes = { }), language: PropTypes.string, graphData: PropTypes.bool, - GA_TRACKING_ID: PropTypes.string, } export default (props) => diff --git a/src/main/resources/site/parts/nameSearch/nameSearch.ts b/src/main/resources/site/parts/nameSearch/nameSearch.ts index 9da266ce4..68f2fc951 100644 --- a/src/main/resources/site/parts/nameSearch/nameSearch.ts +++ b/src/main/resources/site/parts/nameSearch/nameSearch.ts @@ -3,7 +3,6 @@ import { localize } from '/lib/xp/i18n' import { renderError } from '/lib/ssb/error/error' import { render } from '/lib/enonic/react4xp' import { type NameSearchProps } from '/lib/types/partTypes/nameSearch' -import { GA_TRACKING_ID } from '/site/pages/default/default' import { type NameSearch as NameSearchPartConfig } from '.' export const get = (req: XP.Request): XP.Response => { @@ -35,7 +34,6 @@ function renderPart(req: XP.Request) { frontPage: component.config.frontPage, phrases: partsPhrases(currentContent?.language || 'nb'), language: currentContent?.language || 'nb', - GA_TRACKING_ID: GA_TRACKING_ID, } return render('site/parts/nameSearch/nameSearch', props, req) diff --git a/src/main/resources/site/parts/searchResult/searchResult.ts b/src/main/resources/site/parts/searchResult/searchResult.ts index e3fc5057f..3958d68d4 100644 --- a/src/main/resources/site/parts/searchResult/searchResult.ts +++ b/src/main/resources/site/parts/searchResult/searchResult.ts @@ -374,7 +374,6 @@ export function renderPart(req: XP.Request) { contentTypePhrases: contentTypePhrases, contentTypes: solrResult.contentTypes, subjects: solrResult.subjects, - GA_TRACKING_ID: app.config && app.config.GA_TRACKING_ID ? app.config.GA_TRACKING_ID : null, contentTypeUrlParam: req.params.innholdstype, subjectUrlParam: req.params.emne, searchResultSRText: localize({ diff --git a/src/main/resources/site/parts/searchResult/searchResultView.tsx b/src/main/resources/site/parts/searchResult/searchResultView.tsx index e45883e4a..76cb789ca 100644 --- a/src/main/resources/site/parts/searchResult/searchResultView.tsx +++ b/src/main/resources/site/parts/searchResult/searchResultView.tsx @@ -15,7 +15,6 @@ import { ChevronDown, User, X } from 'react-feather' import axios from 'axios' import { NumericFormat } from 'react-number-format' import { Col, Row } from 'react-bootstrap' -import { addGtagForEvent } from '../../../react4xp/ReactGA' import { sanitize } from '../../../lib/ssb/utils/htmlUtils' import { type SearchResultProps } from '../../../lib/types/partTypes/searchResult' import { type DropdownItem } from '../../../lib/types/partTypes/publicationArchive' @@ -90,13 +89,6 @@ function SearchResult(props: SearchResultProps) { if (filterChanged || sortChanged) { fetchFilteredSearchResult() } - // GA events for best bet and zero hits results - if (props.bestBetHit) { - addGtagForEvent(props.GA_TRACKING_ID, 'Best Bet', 'Søk', searchTerm) - } - if (!props.bestBetHit && !hits.length) { - addGtagForEvent(props.GA_TRACKING_ID, 'Null treff', 'Søk', searchTerm) - } }, [filter, sortList]) // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -141,15 +133,11 @@ function SearchResult(props: SearchResultProps) { if (sortChanged) { setNumberChanged((prev) => prev + 1) - if (props.GA_TRACKING_ID && numberChanged < 2) { - const sortLabel = value === 'best' ? props.sortBestHitPhrase : props.sortDatePhrase - addGtagForEvent(props.GA_TRACKING_ID, 'Sorter', 'Søk', sortLabel) - } } } + function onShowMoreSearchResults(focusElement: boolean) { fetchSearchResult(focusElement) - addGtagForEvent(props.GA_TRACKING_ID, 'Klikk', 'Søk', 'Vis flere') } function removeFilter() { @@ -161,7 +149,6 @@ function SearchResult(props: SearchResultProps) { setSelectedContentType(allContentTypeItem) setSelectedMainSubject(allSubjectsItem) setFilterChanged(true) // we want the useEffect to trigger fetching of results, and new filters - addGtagForEvent(props.GA_TRACKING_ID, 'Klikk', 'Søk', 'Fjern alle filtervalg') } function renderListItem(hit: PreparedSearchResult, i?: number) { @@ -174,9 +161,6 @@ function SearchResult(props: SearchResultProps) { className='ssb-link header' // deepcode ignore DOMXSS: url comes from pageUrl which escapes + Reacts own escaping href={hit.url} - onClick={() => { - addGtagForEvent(props.GA_TRACKING_ID, 'Klikk på lenke', 'Søk', `${searchTerm} - Lenke nummer: ${i + 1}`) - }} > onShowMoreSearchResults(false)} - onKeyDown={(e) => { + onKeyDown={(e: React.KeyboardEvent) => { if (e.key === 'Enter' || e.key === ' ') { onShowMoreSearchResults(true) } @@ -341,6 +325,7 @@ function SearchResult(props: SearchResultProps) {
) } + return null } function renderNoHitMessage() { @@ -418,7 +403,6 @@ function SearchResult(props: SearchResultProps) { function renderNameResult() { const mainNameResult = props.nameSearchData if (mainNameResult && mainNameResult.count && !filterChanged && numberChanged === 0) { - addGtagForEvent(props.GA_TRACKING_ID, 'Navnesøket', 'Søk', searchTerm) return ( // TODO: Legge til en bedre url til navnestatistikken { onChange('mainSubject', value) - addGtagForEvent(props.GA_TRACKING_ID, 'Valgt emne', 'Søk', value.title) if (!openAccordion) { setOpenAccordion(true) } @@ -523,7 +506,6 @@ function SearchResult(props: SearchResultProps) { key={`contentType-${reset}`} onSelect={(value: DropdownItem) => { onChange('contentType', value) - addGtagForEvent(props.GA_TRACKING_ID, 'Valgt innholdstype', 'Søk', value.title) if (!openAccordion) { setOpenAccordion(true) } diff --git a/src/main/resources/site/parts/table/table.ts b/src/main/resources/site/parts/table/table.ts index 629babdee..f9403dbbe 100644 --- a/src/main/resources/site/parts/table/table.ts +++ b/src/main/resources/site/parts/table/table.ts @@ -22,7 +22,6 @@ import { type TableStandardSymbolLink, type TableSourceList, } from '/lib/types/partTypes/table' -import { GA_TRACKING_ID } from '/site/pages/default/default' import { type Statistics, type Table } from '/site/content-types' const view = resolve('./table.html') @@ -130,7 +129,6 @@ export function getProps(req: XP.Request, tableId?: string): TableProps { sourceTableLabel, statBankWebUrl, hiddenTitle: table.caption ? table.caption.content : undefined, - GA_TRACKING_ID: GA_TRACKING_ID, } } function renderPart(req: XP.Request, tableId?: string): XP.Response { diff --git a/src/main/resources/site/parts/upcomingReleases/upcomingReleases.tsx b/src/main/resources/site/parts/upcomingReleases/upcomingReleases.tsx index e2202fce8..5239e5e21 100644 --- a/src/main/resources/site/parts/upcomingReleases/upcomingReleases.tsx +++ b/src/main/resources/site/parts/upcomingReleases/upcomingReleases.tsx @@ -2,6 +2,7 @@ import React, { useState } from 'react' import { Button, Link } from '@statisticsnorway/ssb-component-library' import axios from 'axios' import { ChevronDown } from 'react-feather' +import { parseISO } from 'date-fns/parseISO' import { sanitize } from '../../../lib/ssb/utils/htmlUtils' import { type UpcomingReleasesProps } from '../../../lib/types/partTypes/upcomingReleases' import { type PreparedUpcomingRelease, type YearReleases } from '../../../lib/types/variants' @@ -227,7 +228,7 @@ function UpcomingReleases(props: UpcomingReleasesProps) { } function renderDay(dayWithReleases, language, isFirst, statisticsPageUrlText) { - const date = new Date(dayWithReleases.date) + const date = parseISO(dayWithReleases.date) const releaseDate = { day: date.getDate(), monthName: getShortMonthName(date.getMonth(), language),