Commit 78f15415 authored by Stefan Borchert's avatar Stefan Borchert Committed by Florent Torregrosa
Browse files

Issue #2978703 by stBorchert, ricovandevin, Grimreaper, somersoft, zcht,...

Issue #2978703 by stBorchert, ricovandevin, Grimreaper, somersoft, zcht, tsteur, pefferen: Support Matomo Tag Manager. Fix PHPCS, Composer normalize, some PHPMD, PHPCS Fixer.
parent 20cae770
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -86,7 +86,7 @@ at https://matomo.org/docs/javascript-tracking/#toc-custom-variables.

You can include additional JavaScript snippets in the custom javascript
code textarea. These can be found on various blog posts, or on the
official Matomo pages. Support is not provided for any customisations
official Matomo pages. Support is not provided for any customizations
you include.

To speed up page loading you may also cache the Matomo "matomo.js"
+6 −6
Original line number Diff line number Diff line
{
    "name": "drupal/matomo",
    "type": "drupal-module",
    "description": "Adds Matomo javascript tracking code to all your site's pages.",
    "license": "GPL-2.0-or-later",
    "conflict": {
        "drupal/csp": "<1.12"
    },
    "type": "drupal-module",
    "require-dev": {
        "drupal/csp": "~1.12",
        "drupal/php": "~1.1",
        "drupal/token": "~1.9",
        "drupal/csp": "~1.12"
        "drupal/token": "~1.9"
    },
    "conflict": {
        "drupal/csp": "<1.12"
    }
}
+3 −0
Original line number Diff line number Diff line
@@ -112,6 +112,9 @@ matomo.settings:
    translation_set:
      type: boolean
      label: 'Track translation sets as one unit'
    disable_tracking:
      type: boolean
      label: 'Disable tracking'
    cache:
      type: boolean
      label: 'Locally cache tracking code file'
+10 −0
Original line number Diff line number Diff line
@@ -89,3 +89,13 @@ function matomo_update_8101() {
  $config->set('privacy.disablecookies', FALSE);
  $config->save(TRUE);
}

/**
 * Add new disable tracking setting to Matomo default configuration.
 */
function matomo_update_8102() {
  $config_factory = \Drupal::configFactory();
  $config = $config_factory->getEditable('matomo.settings');
  $config->set('disable_tracking', FALSE);
  $config->save(TRUE);
}
+7 −2
Original line number Diff line number Diff line
@@ -47,7 +47,12 @@ function matomo_page_attachments(array &$page) {
  $request = \Drupal::request();

  // Add module cache tags.
  $page['#cache']['tags'] = Cache::mergeTags(isset($page['#cache']['tags']) ? $page['#cache']['tags'] : [], $config->getCacheTags());
  $page['#cache']['tags'] = Cache::mergeTags($page['#cache']['tags'] ?? [], $config->getCacheTags());

  if ($config->get('disable_tracking')) {
    // Tracking is disabled in favor of other methods (e.g. Tag Manager).
    return;
  }

  // Get page http status code for visibility filtering.
  $status = NULL;
@@ -436,7 +441,7 @@ function matomo_form_user_form_alter(&$form, FormStateInterface $form_state) {
      '#type' => 'checkbox',
      '#title' => t('Enable user tracking'),
      '#description' => $description,
      '#default_value' => isset($account_data_matomo['user_account_users']) ? $account_data_matomo['user_account_users'] : ($visibility_users == 1),
      '#default_value' => $account_data_matomo['user_account_users'] ?? ($visibility_users == 1),
      '#disabled' => $disabled,
    ];

Loading