diff --git a/src/components/analytics-monsido/index.tsx b/src/components/analytics-monsido/index.tsx deleted file mode 100644 index 4612235a0..000000000 --- a/src/components/analytics-monsido/index.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import { FC, useEffect } from 'react'; -import { getConfig } from '../../config'; - -const AnalyticsMonsido: FC = () => { - const { hostname } = location; - const isFellesDatakatalog = [ - 'data.norge.no', - 'fellesdatakatalog.digdir.no' - ].includes(hostname); - const isTransportPortal = getConfig().isNapProfile; - - useEffect(() => { - const scriptInline = document.createElement('script'); - const script = document.createElement('script'); - - scriptInline.type = 'text/javascript'; - scriptInline.innerHTML = ` - window._monsido = window._monsido || { - token: ${ - isTransportPortal - ? '"H7pMv_I-KwnWIR1nkiCXuw"' - : '"xAbTzhYnF9PHMK5X7XE-8g"' - }, - statistics: { - enabled: true, - cookieLessTracking: false, - documentTracking: { - enabled: false, - documentCls: "monsido_download", - documentIgnoreCls: "monsido_ignore_download", - documentExt: ["pdf","doc","ppt","docx","pptx"], - }, - }, - heatmap: { enabled: true } - }; - `; - - script.src = 'https://app-script.monsido.com/v2/monsido-script.js'; - script.async = true; - - if (isFellesDatakatalog || isTransportPortal) { - document.body.appendChild(scriptInline); - document.body.appendChild(script); - } - - return () => { - if (isFellesDatakatalog || isTransportPortal) { - document.body.removeChild(scriptInline); - document.body.removeChild(script); - } - }; - }, []); - - return null; -}; - -export default AnalyticsMonsido; diff --git a/src/components/analytics-monsido/utils/errors.ts b/src/components/analytics-monsido/utils/errors.ts deleted file mode 100644 index 67b01d9b1..000000000 --- a/src/components/analytics-monsido/utils/errors.ts +++ /dev/null @@ -1,5 +0,0 @@ -export const MonsidoError = { - UnknownAction: 'Monsido: unknown action', - MonsidoFunctionsNotDefined: 'Monsido: monsido_functions is not defined', - EnvironmentVariableNotDefined: 'Monsido: environment variable is not defined' -}; diff --git a/src/components/analytics-monsido/utils/events.ts b/src/components/analytics-monsido/utils/events.ts deleted file mode 100644 index 5d88b38a1..000000000 --- a/src/components/analytics-monsido/utils/events.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* eslint-disable eslint-comments/disable-enable-pair */ -/* eslint-disable no-console */ - -import { MonsidoError } from './errors'; -import { getEnvironment } from './helpers'; - -export const MonsidoTrackEventParams = { - Action: { - Click: { - Button: { - AccessRequest: `${getEnvironment()}Access request button` - } - } - }, - Category: { - ClickTracking: `${getEnvironment()}ClickTracking` - }, - Event: { - ButtonClicked: `${getEnvironment()}ButtonClickEvent` - }, - IncreaseCountBy: 1 -}; - -export const monsidoTrackButtonClickEvent = (action: string) => { - if (window.monsido_functions === undefined) { - console.error(MonsidoError.MonsidoFunctionsNotDefined); - return null; - } - if ( - !Object.values(MonsidoTrackEventParams.Action.Click.Button).includes(action) - ) { - console.error(MonsidoError.UnknownAction); - return null; - } - return window.monsido_functions.trackEvent( - MonsidoTrackEventParams.Category.ClickTracking, - action, - MonsidoTrackEventParams.Event.ButtonClicked, - MonsidoTrackEventParams.IncreaseCountBy - ); -}; diff --git a/src/components/analytics-monsido/utils/helpers.ts b/src/components/analytics-monsido/utils/helpers.ts deleted file mode 100644 index 6bbc0d3ce..000000000 --- a/src/components/analytics-monsido/utils/helpers.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* eslint-disable eslint-comments/disable-enable-pair */ -/* eslint-disable no-console */ - -export const getEnvironment = () => { - const { hostname } = location; - let environment = ''; - if (hostname.includes('staging')) { - environment = 'STAG-'; - } else if (hostname.includes('demo')) { - environment = 'DEMO-'; - } else if (hostname.includes('localhost')) { - environment = 'LOCAL-'; - } else { - environment = 'PROD-'; - } - return environment; -}; diff --git a/src/components/analytics-monsido/utils/index.ts b/src/components/analytics-monsido/utils/index.ts deleted file mode 100644 index 7981d6b64..000000000 --- a/src/components/analytics-monsido/utils/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './events'; diff --git a/src/components/analytics-siteimprove/index.tsx b/src/components/analytics-siteimprove/index.tsx new file mode 100644 index 000000000..325bea431 --- /dev/null +++ b/src/components/analytics-siteimprove/index.tsx @@ -0,0 +1,18 @@ +import { FC, useEffect } from 'react'; + +const AnalyticsSiteImprove: FC = () => { + useEffect(() => { + const script = document.createElement('script'); + script.src = 'https://siteimproveanalytics.com/js/siteanalyze_6255470.js'; + script.async = true; + + document.body.appendChild(script); + return () => { + document.body.removeChild(script); + }; + }, []); + + return null; +}; + +export default AnalyticsSiteImprove; diff --git a/src/components/details-page/components/details-page/index.tsx b/src/components/details-page/components/details-page/index.tsx index 27d552cea..2bde6acb8 100755 --- a/src/components/details-page/components/details-page/index.tsx +++ b/src/components/details-page/components/details-page/index.tsx @@ -51,10 +51,6 @@ import withCommunity, { } from '../../../with-community'; import Aside from '../aside'; import { accessRequestWhiteList } from '../../../../white-list'; -import { - MonsidoTrackEventParams, - monsidoTrackButtonClickEvent -} from '../../../analytics-monsido/utils/events'; interface ExternalProps { entity: Entity; @@ -326,15 +322,7 @@ const DetailsPage: FC> = ({ target='_blank' rel='noreferrer' > - + )} diff --git a/src/entrypoints/main/bootstrap.tsx b/src/entrypoints/main/bootstrap.tsx index df165bc18..68194a8b7 100644 --- a/src/entrypoints/main/bootstrap.tsx +++ b/src/entrypoints/main/bootstrap.tsx @@ -16,7 +16,7 @@ import { getConfig } from '../../config'; import { themeFDK, themeNAP } from '../../app/theme'; import GlobalStyles from '../../app/styles'; -import AnalyticsMonsido from '../../components/analytics-monsido'; +import AnalyticsSiteImprove from '../../components/analytics-siteimprove'; import { store } from '../../redux/store'; const client = new ApolloClient({ @@ -31,7 +31,7 @@ render( - + diff --git a/src/entrypoints/publishing/app/index.tsx b/src/entrypoints/publishing/app/index.tsx index 2d7428c9a..52fa6a714 100755 --- a/src/entrypoints/publishing/app/index.tsx +++ b/src/entrypoints/publishing/app/index.tsx @@ -10,12 +10,12 @@ import store from '../redux/store'; import GlobalStyles from '../styles'; import Router from '../router'; -import AnalyticsMonsido from '../../../components/analytics-monsido'; +import AnalyticsSiteImprove from '../../../components/analytics-siteimprove'; const App: FC = () => ( - + diff --git a/src/types/global.d.ts b/src/types/global.d.ts index aa358a997..a9bb7490d 100644 --- a/src/types/global.d.ts +++ b/src/types/global.d.ts @@ -1,12 +1 @@ -export declare global { - interface Window { - monsido_functions: { - trackEvent: ( - category: string, - action: string, - event: string, - increaseBy: number - ) => string; - }; - } -} +export declare global {}