From 1fc38dccf9b59e4de0f94ad2f2f02afa098fe7e7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 20 Sep 2025 19:45:21 +0000 Subject: [PATCH 1/4] Initial plan From f82dd9a21fb1b724e44fd0e35b860eeefe997656 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 20 Sep 2025 19:55:48 +0000 Subject: [PATCH 2/4] Fix Microsoft Clarity consent API property names and add verification testing Co-authored-by: BenjaminMichaelis <22186029+BenjaminMichaelis@users.noreply.github.com> --- EssentialCSharp.Web/wwwroot/consent-test.html | 275 ++++++++++++++++++ .../wwwroot/js/consent-manager.js | 50 +++- 2 files changed, 323 insertions(+), 2 deletions(-) create mode 100644 EssentialCSharp.Web/wwwroot/consent-test.html diff --git a/EssentialCSharp.Web/wwwroot/consent-test.html b/EssentialCSharp.Web/wwwroot/consent-test.html new file mode 100644 index 00000000..14991537 --- /dev/null +++ b/EssentialCSharp.Web/wwwroot/consent-test.html @@ -0,0 +1,275 @@ + + + + + + Essential C# - Consent Verification Test + + + + + + + + + + + + + + +
+

๐Ÿ›ก๏ธ Essential C# - Microsoft Clarity Consent Verification

+ +
+ Purpose: This page tests the Microsoft Clarity consent implementation to ensure compliance with GDPR and similar regulations. +
Testing: The verification function from Microsoft's documentation is implemented below. +
+ +
+

๐Ÿงช Test Actions

+ + + + + + +
+ +
+

๐Ÿ“Š Real-time Status

+
+

Consent Manager Status: Loading...

+

Clarity Status: Loading...

+

Region Requires Consent: Loading...

+
+
+ +
+

๐Ÿ“ Console Output

+
Initializing consent verification test...
+
+ +
+

๐Ÿ“š Expected Results

+
+ โœ… When consent is DENIED: +
โ€ข analytics_storage: "DENIED" +
โ€ข ad_storage: "DENIED" +
โ€ข Clarity should not set cookies +
+ +
+ โœ… When consent is GRANTED: +
โ€ข analytics_storage: "GRANTED" +
โ€ข ad_storage: "GRANTED" +
โ€ข Clarity can set cookies and track normally +
+
+
+ + + + \ No newline at end of file diff --git a/EssentialCSharp.Web/wwwroot/js/consent-manager.js b/EssentialCSharp.Web/wwwroot/js/consent-manager.js index ceb16233..22d51b08 100644 --- a/EssentialCSharp.Web/wwwroot/js/consent-manager.js +++ b/EssentialCSharp.Web/wwwroot/js/consent-manager.js @@ -312,8 +312,8 @@ class ConsentManager { if (window.clarity) { try { clarity('consentv2', { - ad_Storage: this.consentState.ad_storage, - analytics_Storage: this.consentState.analytics_storage + ad_storage: this.consentState.ad_storage, + analytics_storage: this.consentState.analytics_storage }); } catch (error) { console.warn('Failed to update Clarity consent:', error); @@ -507,4 +507,50 @@ window.openConsentPreferences = function() { if (window.consentManager) { window.consentManager.openConsentPreferences(); } +}; + +// Global function for verifying consent implementation (testing/debugging) +window.verifyClarityConsent = function() { + console.log('=== Microsoft Clarity Consent Verification ==='); + + if (typeof clarity === 'undefined') { + console.log('โŒ Clarity not loaded yet. Please wait and try again.'); + return; + } + + try { + clarity('metadata', (d, upgrade, consent) => { + console.log('โœ… Clarity metadata callback executed'); + console.log('๐Ÿ“Š Consent Status:', consent); + + if (consent) { + const analyticsStatus = consent.analytics_storage || 'UNKNOWN'; + const adStatus = consent.ad_storage || 'UNKNOWN'; + + console.log(`๐Ÿ” Analytics Storage: ${analyticsStatus}`); + console.log(`๐Ÿ” Ad Storage: ${adStatus}`); + + if (analyticsStatus === 'DENIED' && adStatus === 'DENIED') { + console.log('โœ… Consent properly denied - Clarity should not set cookies'); + } else if (analyticsStatus === 'GRANTED' || adStatus === 'GRANTED') { + console.log('โœ… Consent granted - Clarity can set cookies based on granted permissions'); + } else { + console.log('โš ๏ธ Unexpected consent status detected'); + } + } else { + console.log('โŒ No consent object returned'); + } + + // Also show current consent manager state for comparison + if (window.consentManager) { + console.log('๐Ÿ“‹ Current Consent Manager State:'); + console.log(' - Analytics Consent:', window.consentManager.hasAnalyticsConsent()); + console.log(' - Advertising Consent:', window.consentManager.hasAdvertisingConsent()); + console.log(' - Requires Consent:', window.consentManager.requiresConsent); + console.log(' - Full State:', window.consentManager.consentState); + } + }, false, true, true); + } catch (error) { + console.log('โŒ Error running verification:', error); + } }; \ No newline at end of file From 5a466ded3bc1bf4f9c1a3cb95764086e32d4f4b2 Mon Sep 17 00:00:00 2001 From: Benjamin Michaelis Date: Sat, 20 Sep 2025 21:11:30 -0700 Subject: [PATCH 3/4] Delete EssentialCSharp.Web/wwwroot/consent-test.html --- EssentialCSharp.Web/wwwroot/consent-test.html | 275 ------------------ 1 file changed, 275 deletions(-) delete mode 100644 EssentialCSharp.Web/wwwroot/consent-test.html diff --git a/EssentialCSharp.Web/wwwroot/consent-test.html b/EssentialCSharp.Web/wwwroot/consent-test.html deleted file mode 100644 index 14991537..00000000 --- a/EssentialCSharp.Web/wwwroot/consent-test.html +++ /dev/null @@ -1,275 +0,0 @@ - - - - - - Essential C# - Consent Verification Test - - - - - - - - - - - - - - -
-

๐Ÿ›ก๏ธ Essential C# - Microsoft Clarity Consent Verification

- -
- Purpose: This page tests the Microsoft Clarity consent implementation to ensure compliance with GDPR and similar regulations. -
Testing: The verification function from Microsoft's documentation is implemented below. -
- -
-

๐Ÿงช Test Actions

- - - - - - -
- -
-

๐Ÿ“Š Real-time Status

-
-

Consent Manager Status: Loading...

-

Clarity Status: Loading...

-

Region Requires Consent: Loading...

-
-
- -
-

๐Ÿ“ Console Output

-
Initializing consent verification test...
-
- -
-

๐Ÿ“š Expected Results

-
- โœ… When consent is DENIED: -
โ€ข analytics_storage: "DENIED" -
โ€ข ad_storage: "DENIED" -
โ€ข Clarity should not set cookies -
- -
- โœ… When consent is GRANTED: -
โ€ข analytics_storage: "GRANTED" -
โ€ข ad_storage: "GRANTED" -
โ€ข Clarity can set cookies and track normally -
-
-
- - - - \ No newline at end of file From dbe1456b5f9c241b014645cce49f741c18bbd7b6 Mon Sep 17 00:00:00 2001 From: Benjamin Michaelis Date: Sat, 20 Sep 2025 21:12:13 -0700 Subject: [PATCH 4/4] Update EssentialCSharp.Web/wwwroot/js/consent-manager.js --- .../wwwroot/js/consent-manager.js | 46 ------------------- 1 file changed, 46 deletions(-) diff --git a/EssentialCSharp.Web/wwwroot/js/consent-manager.js b/EssentialCSharp.Web/wwwroot/js/consent-manager.js index 22d51b08..ae107df4 100644 --- a/EssentialCSharp.Web/wwwroot/js/consent-manager.js +++ b/EssentialCSharp.Web/wwwroot/js/consent-manager.js @@ -507,50 +507,4 @@ window.openConsentPreferences = function() { if (window.consentManager) { window.consentManager.openConsentPreferences(); } -}; - -// Global function for verifying consent implementation (testing/debugging) -window.verifyClarityConsent = function() { - console.log('=== Microsoft Clarity Consent Verification ==='); - - if (typeof clarity === 'undefined') { - console.log('โŒ Clarity not loaded yet. Please wait and try again.'); - return; - } - - try { - clarity('metadata', (d, upgrade, consent) => { - console.log('โœ… Clarity metadata callback executed'); - console.log('๐Ÿ“Š Consent Status:', consent); - - if (consent) { - const analyticsStatus = consent.analytics_storage || 'UNKNOWN'; - const adStatus = consent.ad_storage || 'UNKNOWN'; - - console.log(`๐Ÿ” Analytics Storage: ${analyticsStatus}`); - console.log(`๐Ÿ” Ad Storage: ${adStatus}`); - - if (analyticsStatus === 'DENIED' && adStatus === 'DENIED') { - console.log('โœ… Consent properly denied - Clarity should not set cookies'); - } else if (analyticsStatus === 'GRANTED' || adStatus === 'GRANTED') { - console.log('โœ… Consent granted - Clarity can set cookies based on granted permissions'); - } else { - console.log('โš ๏ธ Unexpected consent status detected'); - } - } else { - console.log('โŒ No consent object returned'); - } - - // Also show current consent manager state for comparison - if (window.consentManager) { - console.log('๐Ÿ“‹ Current Consent Manager State:'); - console.log(' - Analytics Consent:', window.consentManager.hasAnalyticsConsent()); - console.log(' - Advertising Consent:', window.consentManager.hasAdvertisingConsent()); - console.log(' - Requires Consent:', window.consentManager.requiresConsent); - console.log(' - Full State:', window.consentManager.consentState); - } - }, false, true, true); - } catch (error) { - console.log('โŒ Error running verification:', error); - } }; \ No newline at end of file