Skip to content
Snippets Groups Projects
Commit fcb98e01 authored by Brian Canini's avatar Brian Canini
Browse files

Updating drupal/google_analytics (2.2.0 => 2.4.0)

parent eec39a04
No related branches found
No related tags found
No related merge requests found
Showing
with 171 additions and 134 deletions
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "b6620065182be6bb85da3f6c9b1102e7",
"content-hash": "5d437286ae2e43f67225efd0efc295c9",
"packages": [
{
"name": "alchemy/zippy",
......@@ -5056,20 +5056,20 @@
},
{
"name": "drupal/google_analytics",
"version": "2.2.0",
"version": "2.4.0",
"source": {
"type": "git",
"url": "https://git.drupalcode.org/project/google_analytics.git",
"reference": "8.x-2.2"
"reference": "8.x-2.4"
},
"dist": {
"type": "zip",
"url": "https://ftp.drupal.org/files/projects/google_analytics-8.x-2.2.zip",
"reference": "8.x-2.2",
"shasum": "15cd0642ad99f3776a46b702e5012713405a0733"
"url": "https://ftp.drupal.org/files/projects/google_analytics-8.x-2.4.zip",
"reference": "8.x-2.4",
"shasum": "f2e78ec140024ddcd19e027704ba73c33731f656"
},
"require": {
"drupal/core": "~8.0"
"drupal/core": "~8.5"
},
"require-dev": {
"drupal/php": "*",
......@@ -5081,8 +5081,8 @@
"dev-2.x": "2.x-dev"
},
"drupal": {
"version": "8.x-2.2",
"datestamp": "1506372845",
"version": "8.x-2.4",
"datestamp": "1548968580",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
......@@ -5106,7 +5106,7 @@
"description": "Allows your site to be tracked by Google Analytics by adding a Javascript tracking code to every page.",
"homepage": "https://www.drupal.org/project/google_analytics",
"support": {
"source": "http://git.drupal.org/project/google_analytics.git",
"source": "https://git.drupal.org/project/google_analytics.git",
"issues": "https://www.drupal.org/project/issues/google_analytics"
}
},
......
......@@ -5209,21 +5209,21 @@
},
{
"name": "drupal/google_analytics",
"version": "2.2.0",
"version_normalized": "2.2.0.0",
"version": "2.4.0",
"version_normalized": "2.4.0.0",
"source": {
"type": "git",
"url": "https://git.drupalcode.org/project/google_analytics.git",
"reference": "8.x-2.2"
"reference": "8.x-2.4"
},
"dist": {
"type": "zip",
"url": "https://ftp.drupal.org/files/projects/google_analytics-8.x-2.2.zip",
"reference": "8.x-2.2",
"shasum": "15cd0642ad99f3776a46b702e5012713405a0733"
"url": "https://ftp.drupal.org/files/projects/google_analytics-8.x-2.4.zip",
"reference": "8.x-2.4",
"shasum": "f2e78ec140024ddcd19e027704ba73c33731f656"
},
"require": {
"drupal/core": "~8.0"
"drupal/core": "~8.5"
},
"require-dev": {
"drupal/php": "*",
......@@ -5235,8 +5235,8 @@
"dev-2.x": "2.x-dev"
},
"drupal": {
"version": "8.x-2.2",
"datestamp": "1506372845",
"version": "8.x-2.4",
"datestamp": "1548968580",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
......@@ -5261,7 +5261,7 @@
"description": "Allows your site to be tracked by Google Analytics by adding a Javascript tracking code to every page.",
"homepage": "https://www.drupal.org/project/google_analytics",
"support": {
"source": "http://git.drupal.org/project/google_analytics.git",
"source": "https://git.drupal.org/project/google_analytics.git",
"issues": "https://www.drupal.org/project/issues/google_analytics"
}
},
......
Module: Google Analytics
Author: Alexander Hass <http://drupal.org/user/85918>
Author: Alexander Hass <https://drupal.org/user/85918>
Description
......@@ -45,15 +45,15 @@ user with 'Administer Google Analytics' permission.
Like the blocks visibility settings in Drupal core, there is a choice for
"Add if the following PHP code returns TRUE." Sample PHP snippets that can be
used in this textarea can be found on the handbook page "Overview-approach to
block visibility" at http://drupal.org/node/64135.
block visibility" at https://drupal.org/node/64135.
Custom dimensions and metrics
=============================
One example for custom dimensions tracking is the "User roles" tracking.
1. In the Google Analytics (http://www.google.com/analytics/) Management
Interface you need to setup Dimension #1 with name e.g. "User roles". This
step is required. Do not miss it, please.
1. In the Google Analytics (https://marketingplatform.google.com/about/analytics/)
Management Interface you need to setup Dimension #1 with name
e.g. "User roles". This step is required. Do not miss it, please.
2. Enter the below configuration data into the Drupal custom dimensions settings
form under admin/config/system/googleanalytics. You can also choose another
......@@ -69,7 +69,7 @@ Advanced Settings
=================
You can include additional JavaScript snippets in the custom javascript
code textarea. These can be found on the official Google Analytics pages
and a few examples at http://drupal.org/node/248699. Support is not
and a few examples at https://drupal.org/node/248699. Support is not
provided for any customisations you include.
To speed up page loading you may also cache the Google Analytics "analytics.js"
......@@ -89,7 +89,7 @@ Body:
<li><a href="mailto:foo@example.com">Mailto</a></li>
<li><a href="/files/test.txt">Download file</a></li>
<li><a class="colorbox" href="#">Open colorbox</a></li>
<li><a href="http://example.com/">External link</a></li>
<li><a href="https://example.com/">External link</a></li>
<li><a href="/go/test">Go link</a></li>
</ul>
......
......@@ -15,8 +15,10 @@
],
"support": {
"issues": "https://www.drupal.org/project/issues/google_analytics",
"source": "http://git.drupal.org/project/google_analytics.git"
"source": "https://git.drupal.org/project/google_analytics.git"
},
"license": "GPL-2.0+",
"require": {}
"require": {
"drupal/core": "~8.5"
}
}
......@@ -4,12 +4,14 @@ description: 'Allows your site to be tracked by Google Analytics by adding a Jav
package: Statistics
# core: 8.x
configure: google_analytics.admin_settings_form
dependencies:
- drupal:system (>= 8.5)
test_dependencies:
- php:php
- token:token
# Information added by Drupal.org packaging script on 2017-09-25
version: '8.x-2.2'
# Information added by Drupal.org packaging script on 2019-01-31
version: '8.x-2.4'
core: '8.x'
project: 'google_analytics'
datestamp: 1506372866
datestamp: 1548968592
......@@ -6,6 +6,21 @@
*/
use Drupal\Core\Url;
use Drupal\user\Entity\Role;
/**
* Implements hook_install().
*/
function google_analytics_install() {
// Make the default install more user and GDPR friendly.
$role = Role::load('authenticated');
$role->grantPermission('opt-in or out of google analytics tracking');
$success = $role->save();
if ($success) {
$messenger = \Drupal::messenger();
$messenger->addMessage(t('Module %module granted %permission permission to authenticated users.', ['%module' => 'Google Analytics', '%permission' => t('Opt-in or out of tracking')]), 'status');
}
}
/**
* Implements hook_uninstall().
......
......@@ -7,7 +7,7 @@
* Adds the required Javascript to all your Drupal pages to allow tracking by
* the Google Analytics statistics package.
*
* @author: Alexander Hass <http://drupal.org/user/85918>
* @author: Alexander Hass <https://drupal.org/user/85918>
*/
use Drupal\Component\Serialization\Json;
......@@ -22,11 +22,6 @@
use GuzzleHttp\Exception\RequestException;
use Drupal\google_analytics\Component\Render\GoogleAnalyticsJavaScriptSnippet;
/**
* Define the default file extension list that should be tracked as download.
*/
define('GOOGLE_ANALYTICS_TRACKFILES_EXTENSIONS', '7z|aac|arc|arj|asf|asx|avi|bin|csv|doc(x|m)?|dot(x|m)?|exe|flv|gif|gz|gzip|hqx|jar|jpe?g|js|mp(2|3|4|e?g)|mov(ie)?|msi|msp|pdf|phps|png|ppt(x|m)?|pot(x|m)?|pps(x|m)?|ppam|sld(x|m)?|thmx|qtm?|ra(m|r)?|sea|sit|tar|tgz|torrent|txt|wav|wma|wmv|wpd|xls(x|m|b)?|xlt(x|m)|xlam|xml|z|zip');
/**
* Advertise the supported google analytics api details.
*/
......@@ -52,7 +47,7 @@ function google_analytics_help($route_name, RouteMatchInterface $route_match) {
return $output;
case 'google_analytics.admin_settings_form':
return t('<a href=":ga_url">Google Analytics</a> is a free (registration required) website traffic and marketing effectiveness service.', [':ga_url' => 'http://www.google.com/analytics/']);
return t('<a href=":ga_url">Google Analytics</a> is a free (registration required) website traffic and marketing effectiveness service.', [':ga_url' => 'https://marketingplatform.google.com/about/analytics/']);
}
}
......@@ -142,12 +137,12 @@ function google_analytics_page_attachments(array &$page) {
'error' => t('Error message'),
];
foreach (drupal_get_messages(NULL, FALSE) as $type => $messages) {
foreach (\Drupal::messenger()->all(NULL, FALSE) as $type => $messages) {
// Track only the selected message types.
if (in_array($type, $message_types)) {
foreach ($messages as $message) {
// @todo: Track as exceptions?
$message_events .= 'ga("send", "event", ' . Json::encode(t('Messages')) . ', ' . Json::encode($status_heading[$type]) . ', ' . Json::encode(strip_tags($message)) . ');';
$message_events .= 'ga("send", "event", ' . Json::encode(t('Messages')) . ', ' . Json::encode($status_heading[$type]) . ', ' . Json::encode(strip_tags((string) $message)) . ');';
}
}
}
......@@ -176,7 +171,7 @@ function google_analytics_page_attachments(array &$page) {
// Track access denied (403) and file not found (404) pages.
if ($status == '403') {
// See http://www.google.com/support/analytics/bin/answer.py?answer=86927
// See https://www.google.com/support/analytics/bin/answer.py?answer=86927
$url_custom = '"' . $base_path . '403.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer';
}
elseif ($status == '404') {
......@@ -443,11 +438,12 @@ function google_analytics_user_profile_form_submit($form, FormStateInterface $fo
*/
function google_analytics_cron() {
$config = \Drupal::config('google_analytics.settings');
$request_time = \Drupal::time()->getRequestTime();
// Regenerate the tracking code file every day.
if (REQUEST_TIME - \Drupal::state()->get('google_analytics.last_cache') >= 86400 && $config->get('cache')) {
if ($request_time - \Drupal::state()->get('google_analytics.last_cache') >= 86400 && $config->get('cache')) {
_google_analytics_cache('https://www.google-analytics.com/analytics.js', TRUE);
\Drupal::state()->set('google_analytics.last_cache', REQUEST_TIME);
\Drupal::state()->set('google_analytics.last_cache', $request_time);
}
}
......@@ -495,9 +491,9 @@ function _google_analytics_cache($location, $synchronize = FALSE) {
if (!file_exists($file_destination) || $synchronize) {
// Download the latest tracking code.
try {
$data = \Drupal::httpClient()
$data = (string) \Drupal::httpClient()
->get($location)
->getBody(TRUE);
->getBody();
if (file_exists($file_destination)) {
// Synchronize tracking code and and replace local file if outdated.
......
......@@ -3,7 +3,7 @@
* Google Analytics admin behaviors.
*/
(function ($, window) {
(function ($) {
'use strict';
......@@ -141,4 +141,4 @@
}
};
})(jQuery, window);
})(jQuery);
......@@ -179,8 +179,8 @@
* Extract the relative internal URL from an absolute internal URL.
*
* Examples:
* - http://mydomain.com/node/1 -> /node/1
* - http://example.com/foo/bar -> http://example.com/foo/bar
* - https://mydomain.com/node/1 -> /node/1
* - https://example.com/foo/bar -> https://example.com/foo/bar
*
* @param {string} url
* The web url to check.
......
......@@ -161,8 +161,8 @@
* Extract the relative internal URL from an absolute internal URL.
*
* Examples:
* - http://mydomain.com/node/1 -> /node/1
* - http://example.com/foo/bar -> http://example.com/foo/bar
* - https://mydomain.com/node/1 -> /node/1
* - https://example.com/foo/bar -> https://example.com/foo/bar
*
* @param {string} url
* The web url to check.
......
......@@ -2,6 +2,7 @@ id: d6_google_analytics_settings
label: Google Analytics 6 configuration
migration_tags:
- Drupal 6
- Configuration
source:
plugin: variable
variables:
......@@ -32,6 +33,7 @@ source:
- googleanalytics_translation_set
- googleanalytics_visibility
- googleanalytics_visibility_roles
source_module: googleanalytics
process:
account: googleanalytics_account
cache: googleanalytics_cache
......
......@@ -12,11 +12,9 @@ process:
key: 'constants/key'
module: 'constants/module'
settings:
# Based on skip_row_if_not_set
plugin: google_analytics_skip_row_if_not_set
key: custom
module: googleanalytics
source: data
plugin: skip_row_if_not_set
index: 'custom'
source: data/google_analytics
destination:
plugin: user_data
migration_dependencies:
......
......@@ -2,6 +2,7 @@ id: d7_google_analytics_settings
label: Google Analytics 7 configuration
migration_tags:
- Drupal 7
- Configuration
source:
plugin: variable
variables:
......@@ -34,6 +35,7 @@ source:
- googleanalytics_translation_set
- googleanalytics_visibility_pages
- googleanalytics_visibility_roles
source_module: googleanalytics
process:
account: googleanalytics_account
premium: googleanalytics_premium
......
......@@ -12,11 +12,9 @@ process:
key: 'constants/key'
module: 'constants/module'
settings:
# Based on skip_row_if_not_set
plugin: google_analytics_skip_row_if_not_set
key: custom
module: googleanalytics
source: data
plugin: skip_row_if_not_set
index: 'custom'
source: data/google_analytics
destination:
plugin: user_data
migration_dependencies:
......
<?php
namespace Drupal\google_analytics;
/**
* Provides an interface.
*/
interface GoogleAnalitycsInterface {
/**
* Define the default file extension list that should be tracked as download.
*/
const GOOGLE_ANALYTICS_TRACKFILES_EXTENSIONS = '7z|aac|arc|arj|asf|asx|avi|bin|csv|doc(x|m)?|dot(x|m)?|exe|flv|gif|gz|gzip|hqx|jar|jpe?g|js|mp(2|3|4|e?g)|mov(ie)?|msi|msp|pdf|phps|png|ppt(x|m)?|pot(x|m)?|pps(x|m)?|ppam|sld(x|m)?|thmx|qtm?|ra(m|r)?|sea|sit|tar|tgz|torrent|txt|wav|wma|wmv|wpd|xls(x|m|b)?|xlt(x|m)|xlam|xml|z|zip';
}
<?php
namespace Drupal\google_analytics\Plugin\migrate\process;
use Drupal\migrate\ProcessPluginBase;
use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Row;
use Drupal\migrate\MigrateSkipRowException;
/**
* If the source evaluates to empty, we skip the current row.
*
* @MigrateProcessPlugin(
* id = "google_analytics_skip_row_if_not_set",
* handle_multiples = TRUE
* )
*/
class GoogleAnalyticsSkipRowIfNotSet extends ProcessPluginBase {
/**
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
if (!isset($value[$this->configuration['module']][$this->configuration['key']])) {
throw new MigrateSkipRowException();
}
return $value[$this->configuration['module']][$this->configuration['key']];
}
}
......@@ -29,6 +29,8 @@ class GoogleAnalyticsVisibilityPages extends ProcessPluginBase implements Contai
protected $moduleHandler;
/**
* The migration process plugin.
*
* The migration process plugin, configured for lookups in the d6_user_role
* and d7_user_role migrations.
*
......
......@@ -28,6 +28,8 @@ class GoogleAnalyticsVisibilityRoles extends ProcessPluginBase implements Contai
protected $moduleHandler;
/**
* The migration process plugin.
*
* The migration process plugin, configured for lookups in the d6_user_role
* and d7_user_role migrations.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment