From d362d3e2959390d05b37c6259486d44166b2a4c7 Mon Sep 17 00:00:00 2001 From: "A. Malthe Henriksen" Date: Mon, 6 May 2024 13:42:06 +0000 Subject: [PATCH 1/4] Make app insights hostname dependent --- features.json | 1 + package-lock.json | 2 +- src/__viteBuildVariants__/ml-machine-simple/features.json | 1 + src/__viteBuildVariants__/ml-machine/features.json | 1 + src/__viteBuildVariants__/unbranded/features.json | 1 + src/appInsights.ts | 7 +++++++ src/script/FeatureToggles.ts | 1 + 7 files changed, 13 insertions(+), 1 deletion(-) diff --git a/features.json b/features.json index b770c3d48..fccfaa8c0 100644 --- a/features.json +++ b/features.json @@ -1,4 +1,5 @@ { + "hostname": "ml-machine.org", "title": "Learning tool", "knnModel": true } diff --git a/package-lock.json b/package-lock.json index 741ebc05d..c5fba26fe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9690,4 +9690,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/__viteBuildVariants__/ml-machine-simple/features.json b/src/__viteBuildVariants__/ml-machine-simple/features.json index e08c11f19..fbfce0df7 100644 --- a/src/__viteBuildVariants__/ml-machine-simple/features.json +++ b/src/__viteBuildVariants__/ml-machine-simple/features.json @@ -1,4 +1,5 @@ { + "hostname": "ml-machine.org", "title": "ML-Machine", "knnModel": false } diff --git a/src/__viteBuildVariants__/ml-machine/features.json b/src/__viteBuildVariants__/ml-machine/features.json index a45488f93..d2a162745 100644 --- a/src/__viteBuildVariants__/ml-machine/features.json +++ b/src/__viteBuildVariants__/ml-machine/features.json @@ -1,4 +1,5 @@ { + "hostname": "ml-machine.org", "title": "ML-Machine", "knnModel": true } diff --git a/src/__viteBuildVariants__/unbranded/features.json b/src/__viteBuildVariants__/unbranded/features.json index b770c3d48..fccfaa8c0 100644 --- a/src/__viteBuildVariants__/unbranded/features.json +++ b/src/__viteBuildVariants__/unbranded/features.json @@ -1,4 +1,5 @@ { + "hostname": "ml-machine.org", "title": "Learning tool", "knnModel": true } diff --git a/src/appInsights.ts b/src/appInsights.ts index cc421f112..f716e408e 100644 --- a/src/appInsights.ts +++ b/src/appInsights.ts @@ -6,8 +6,15 @@ import { ApplicationInsights } from '@microsoft/applicationinsights-web'; import CookieManager from './script/CookieManager'; +import { Feature, getFeature } from './script/FeatureToggles'; const load = () => { + if ( + location.hostname === 'localhost' || + location.hostname !== getFeature(Feature.HOSTNAME) + ) { + return; + } if (CookieManager.getComplianceChoices().analytics) { appInsights.loadAppInsights(); appInsights.trackPageView(); // Manually call trackPageView to establish the current user/session/pageview diff --git a/src/script/FeatureToggles.ts b/src/script/FeatureToggles.ts index bff7aa5f2..90525b60c 100644 --- a/src/script/FeatureToggles.ts +++ b/src/script/FeatureToggles.ts @@ -9,6 +9,7 @@ import Logger from './utils/Logger'; export enum Feature { KNN_MODEL = 'knnModel', + HOSTNAME = 'hostname', TITLE = 'title', } From cdc9754262caaa2c7f3101a0a063de6e2bb58f7c Mon Sep 17 00:00:00 2001 From: "A. Malthe Henriksen" Date: Mon, 6 May 2024 13:46:38 +0000 Subject: [PATCH 2/4] Hard-code value instead --- features.json | 1 - src/__viteBuildVariants__/ml-machine-simple/features.json | 1 - src/__viteBuildVariants__/ml-machine/features.json | 1 - src/__viteBuildVariants__/unbranded/features.json | 1 - src/appInsights.ts | 3 +-- 5 files changed, 1 insertion(+), 6 deletions(-) diff --git a/features.json b/features.json index fccfaa8c0..b770c3d48 100644 --- a/features.json +++ b/features.json @@ -1,5 +1,4 @@ { - "hostname": "ml-machine.org", "title": "Learning tool", "knnModel": true } diff --git a/src/__viteBuildVariants__/ml-machine-simple/features.json b/src/__viteBuildVariants__/ml-machine-simple/features.json index fbfce0df7..e08c11f19 100644 --- a/src/__viteBuildVariants__/ml-machine-simple/features.json +++ b/src/__viteBuildVariants__/ml-machine-simple/features.json @@ -1,5 +1,4 @@ { - "hostname": "ml-machine.org", "title": "ML-Machine", "knnModel": false } diff --git a/src/__viteBuildVariants__/ml-machine/features.json b/src/__viteBuildVariants__/ml-machine/features.json index d2a162745..a45488f93 100644 --- a/src/__viteBuildVariants__/ml-machine/features.json +++ b/src/__viteBuildVariants__/ml-machine/features.json @@ -1,5 +1,4 @@ { - "hostname": "ml-machine.org", "title": "ML-Machine", "knnModel": true } diff --git a/src/__viteBuildVariants__/unbranded/features.json b/src/__viteBuildVariants__/unbranded/features.json index fccfaa8c0..b770c3d48 100644 --- a/src/__viteBuildVariants__/unbranded/features.json +++ b/src/__viteBuildVariants__/unbranded/features.json @@ -1,5 +1,4 @@ { - "hostname": "ml-machine.org", "title": "Learning tool", "knnModel": true } diff --git a/src/appInsights.ts b/src/appInsights.ts index f716e408e..09e96ca8a 100644 --- a/src/appInsights.ts +++ b/src/appInsights.ts @@ -6,12 +6,11 @@ import { ApplicationInsights } from '@microsoft/applicationinsights-web'; import CookieManager from './script/CookieManager'; -import { Feature, getFeature } from './script/FeatureToggles'; const load = () => { if ( location.hostname === 'localhost' || - location.hostname !== getFeature(Feature.HOSTNAME) + location.hostname !== "ml-machine.org" ) { return; } From 178729bb78debad3264549bc80a23dde5b4eb04f Mon Sep 17 00:00:00 2001 From: "A. Malthe Henriksen" Date: Mon, 6 May 2024 13:47:26 +0000 Subject: [PATCH 3/4] Remove hostname feature --- src/script/FeatureToggles.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/script/FeatureToggles.ts b/src/script/FeatureToggles.ts index 90525b60c..bff7aa5f2 100644 --- a/src/script/FeatureToggles.ts +++ b/src/script/FeatureToggles.ts @@ -9,7 +9,6 @@ import Logger from './utils/Logger'; export enum Feature { KNN_MODEL = 'knnModel', - HOSTNAME = 'hostname', TITLE = 'title', } From 6e850e335372df7694aa140edfd62348b6296f79 Mon Sep 17 00:00:00 2001 From: "A. Malthe Henriksen" Date: Mon, 6 May 2024 13:48:21 +0000 Subject: [PATCH 4/4] Simplify if-statement --- src/appInsights.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/appInsights.ts b/src/appInsights.ts index 09e96ca8a..e626231b6 100644 --- a/src/appInsights.ts +++ b/src/appInsights.ts @@ -8,10 +8,7 @@ import { ApplicationInsights } from '@microsoft/applicationinsights-web'; import CookieManager from './script/CookieManager'; const load = () => { - if ( - location.hostname === 'localhost' || - location.hostname !== "ml-machine.org" - ) { + if (location.hostname !== "ml-machine.org") { return; } if (CookieManager.getComplianceChoices().analytics) {