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/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/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/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/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/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 b2f5b8d65..76ca49f4c 100644 --- a/src/main/resources/site/pages/default/default.html +++ b/src/main/resources/site/pages/default/default.html @@ -18,18 +18,6 @@ - - - - - - - diff --git a/src/main/resources/site/pages/default/default.ts b/src/main/resources/site/pages/default/default.ts index 062356dba..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 @@ -254,7 +253,6 @@ export function get(req: XP.Request): XP.Response { language, statbankWeb: statbankFane, ...statBankContent, - GA_TRACKING_ID, GTM_TRACKING_ID, GTM_AUTH, headerBody: header?.body, @@ -719,7 +717,6 @@ 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 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/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 {