Submodule JS is always altered - even if service is disabled

Created on 15 January 2024, about 1 year ago
Updated 16 January 2024, about 1 year ago

Problem/Motivation

Enable Matomo regardless of user consent and display in functional group

Steps to reproduce

- Enable Matomo module
- Enable Cookies module
- Disable consent required at Matomo service, move to functional group
- JS Code is altered

Proposed resolution

Add check if service is enabled & consent is required to the submodule hook_page_attachments calls.

🐛 Bug report
Status

Closed: won't fix

Version

1.2

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @dalberthab
  • Status changed to Closed: won't fix about 1 year ago
  • 🇩🇪Germany Anybody Porta Westfalica

    @dalberthab do I get you right, that you're suggesting a change to the server-side code?
    If yes - that won't work due to caching. All logic needs to be client-side.

    I made the same request some years ago, until I understood, why it wouldn't be correct. Still you can check and react to consent in JS. That's the only correct way.

  • 🇩🇪Germany Anybody Porta Westfalica

    If you're reporting a bug in the JS code, please feel free to reopen and post a MR for a fix.

  • @Anybody I tried some hot code to test my suggested change (new to drupal)

    function cookies_matomo_page_attachments(&$page) {
      $doKo = CookiesKnockOutService::getInstance()->doKnockOut();
      if ($doKo && isset($page["#attached"]["html_head"])) {

    to

    function cookies_matomo_page_attachments(&$page) {
      $doKo = CookiesKnockOutService::getInstance()->doKnockOut();
      $service = \Drupal::entityTypeManager()->getStorage('cookies_service')->load('matomo');
      if ($doKo && $service->status() && $service->getConsentRequired() && isset($page["#attached"]["html_head"])) {

    and the script type is not altered.

Production build 0.71.5 2024