Skip to content

UHF-11535: Read matomo site id from drupalSettings#1223

Merged
jeremysteerio merged 3 commits intomainfrom
UHF-11535
Mar 20, 2025
Merged

UHF-11535: Read matomo site id from drupalSettings#1223
jeremysteerio merged 3 commits intomainfrom
UHF-11535

Conversation

@jeremysteerio
Copy link
Contributor

@jeremysteerio jeremysteerio commented Mar 18, 2025

UHF-11535

What was done

  • Add logic to use JS client for matomo if matomo_site_id is present in drupalSettings

How to install

  • Make sure your instance is up and running on latest dev branch.
    • git pull origin dev
    • make fresh
  • Update the HDBT theme
    • composer require drupal/hdbt:dev-UHF-11535
  • Run make drush-cr

How to test

⚠️ First test and setup this branch: City-of-Helsinki/drupal-helfi-platform-config#924 ⚠️

☝️ These instructions only work if you've set up helfi_matomo module and have matomo_site_id present in drupalSettings

  • Run nvm use; npm i in hdbt directory

  • Do these changes to matomo.js:

    • Comment out line 16
    • Line 72-73: add window.loadMatomoAnalytics = loadMatomoAnalytics; as the last line of the self-calling function (so we can call this manually
    • Run make drush-cr
    • Open the site as anonymous user
    • Inspect the <head> in the HTML document
    • Run loadMatomoAnalytics() in the browser console. This should not produce any errors
    • Take a look at the <head> element again. The first element shold be a <script> tag with src="//webanalytics.digiaiiris.com/js/piwik.min.js"
  • Check that this feature works

  • Check that code follows our standards

Continuous documentation

  • This feature has been documented/the documentation has been updated
  • This change doesn't require updates to the documentation

Translations

  • Translations have been added to .po -files and included in this PR

Other PRs

@github-actions
Copy link

✅ Tests passed! You can check the output here: https://city-of-helsinki.github.io/drupal-hdbt-visual-regression/pull/1223/html_report/

@github-actions
Copy link

⚠️ Visual regression found! Please check if this change is wanted or accidental. You can check the output here: https://city-of-helsinki.github.io/drupal-hdbt-visual-regression/pull/1223/html_report/

Copy link
Contributor

@teroelonen teroelonen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be good 🦖

@jeremysteerio jeremysteerio merged commit 34e3b83 into main Mar 20, 2025
2 checks passed
@jeremysteerio jeremysteerio deleted the UHF-11535 branch March 20, 2025 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants