Commit 9480a206 authored by Jakob P's avatar Jakob P
Browse files

Issue #3287765 by japerry, daniel_j, Berdir, nkoporec: Automated Drupal 10 compatibility fixes

parent b703904d
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -14,9 +14,6 @@
    "source": "https://git.drupalcode.org/project/google_analytics"
  },
  "license": "GPL-2.0-or-later",
  "require": {
    "drupal/core": "^8.9|^9.0"
  },
  "require-dev": {
    "drupal/token": "^1.7"
  },
+1 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@ name: 'Google Analytics'
type: module
description: 'Allows your site to be tracked by Google Analytics by adding a Javascript tracking code to every page.'
package: Statistics
core_version_requirement: ^8.9 || ^9
core_version_requirement: ^9.3 || ^10
configure: google_analytics.admin_settings_form
dependencies:
  - drupal:path_alias
 No newline at end of file
+13 −21
Original line number Diff line number Diff line
@@ -10,21 +10,15 @@
 */

use Drupal\Component\Serialization\Json;
use Drupal\Component\Utility\Crypt;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
use Drupal\google_analytics\Event\BuildGaJavascriptEvent;
use Drupal\google_analytics\Event\GoogleAnalyticsConfigEvent;
use Drupal\google_analytics\Event\GoogleAnalyticsEventsEvent;
use Drupal\google_analytics\Event\PagePathEvent;
use Drupal\google_analytics\GaJavascriptObject;
use Drupal\google_analytics\Constants\GoogleAnalyticsEvents;
use Drupal\node\NodeInterface;
use GuzzleHttp\Exception\RequestException;
use Drupal\google_analytics\Component\Render\GoogleAnalyticsJavaScriptSnippet;
use Drupal\Core\File\FileSystemInterface;

/**
 * Advertise the supported google analytics api details.
@@ -126,7 +120,6 @@ function google_analytics_page_attachments(array &$page) {
      $link_settings['trackUrlFragments'] = $track_url_fragments;
    }

    if (!empty($link_settings)) {
    $page['#attached']['drupalSettings']['google_analytics'] = $link_settings;

    // Add debugging code.
@@ -140,7 +133,6 @@ function google_analytics_page_attachments(array &$page) {
    else {
      $page['#attached']['library'][] = 'google_analytics/google_analytics';
    }
    }

    if ($config->get('track.adsense')) {
      // Custom tracking. Prepend before all other JavaScript.
@@ -170,7 +162,7 @@ function google_analytics_page_attachments(array &$page) {

      // Get the event_dispatcher service and dispatch the event.
      $event_dispatcher = \Drupal::service('event_dispatcher');
      $event_dispatcher->dispatch(GoogleAnalyticsEvents::ADD_CONFIG, $ga_config);
      $event_dispatcher->dispatch($ga_config, GoogleAnalyticsEvents::ADD_CONFIG);

      // Json::encode() cannot convert custom URLs properly.
      $config_array = $ga_config->getConfig();
@@ -195,7 +187,7 @@ function google_analytics_page_attachments(array &$page) {

    // Get the event_dispatcher service and dispatch the event.
    $event_dispatcher = \Drupal::service('event_dispatcher');
    $event_dispatcher->dispatch(GoogleAnalyticsEvents::ADD_EVENT, $ga_events);
    $event_dispatcher->dispatch($ga_events, GoogleAnalyticsEvents::ADD_EVENT);

    if (!empty($ga_events->getEvents())) {
      foreach ($ga_events->getEvents() as $event) {
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ services:
    arguments: [ '@config.factory', '@private_key' ]
  google_analytics.javascript_cache:
    class: Drupal\google_analytics\JavascriptLocalCache
    arguments: [ '@http_client', '@file_system', '@config.factory', '@logger.factory', '@state' ]
    arguments: [ '@http_client', '@file_system', '@config.factory', '@logger.factory', '@state', '@file_url_generator' ]

  # Google Analytics Event Subscribers
  google_analytics.events.messages:
+2 −3
Original line number Diff line number Diff line
@@ -2,9 +2,8 @@

namespace Drupal\google_analytics\Event;

use Drupal\Component\EventDispatcher\Event;
use Drupal\google_analytics\GaAccount;
use Drupal\google_analytics\Helpers\GoogleAnalyticsAccounts;
use Symfony\Component\EventDispatcher\Event;
use Drupal\google_analytics\GaJavascriptObject;

/**
@@ -57,7 +56,7 @@ class GoogleAnalyticsConfigEvent extends Event {
  /**
   * Get the specific Google Analytics account associated with this config.
   *
   * @return \Drupal\google_analytics\Helpers\GoogleAnalyticsAccounts
   * @return \Drupal\google_analytics\GaAccount
   */
  public function getGaAccount() {
    return $this->gaAccount;
Loading