From b6b3f91936fe415a51289ec94d882fd21af23c51 Mon Sep 17 00:00:00 2001 From: Sergey Motornyuk Date: Wed, 14 Jun 2023 15:50:55 +0300 Subject: [PATCH] chore: update version --- ckanext/googleanalytics/config.py | 13 +++++++++++ .../googleanalytics/config_declaration.yaml | 22 +++++++++++++++++++ ckanext/googleanalytics/views.py | 2 -- setup.cfg | 2 +- 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/ckanext/googleanalytics/config.py b/ckanext/googleanalytics/config.py index adf17f4..3711479 100644 --- a/ckanext/googleanalytics/config.py +++ b/ckanext/googleanalytics/config.py @@ -15,6 +15,7 @@ log = logging.getLogger(__name__) def tracking_id(): + # type: () -> str return tk.config["googleanalytics.id"] @@ -31,6 +32,7 @@ def download_handler(): def tracking_mode(): + # type: () -> Literal["ga", "gtag"] type_ = tk.config.get("googleanalytics.tracking_mode") if type_: return type_ @@ -47,10 +49,21 @@ def tracking_mode(): def measurement_id(): + # type: () -> str + """Set the MeasurementID for tracking API actions. By default, + `googleanalytics.id` is used. + + Use this option during migration from Universal Analytics, to track API + requests using Measurement Protocol, while tracking browser event using + Universal Analytics. + + Requires `googleanalytics.measurement_protocol.client_id`. + """ return tk.config.get("googleanalytics.measurement_protocol.id") or tracking_id() def measurement_protocol_client_id(): + # type: () -> str | None return tk.config.get("googleanalytics.measurement_protocol.client_id") diff --git a/ckanext/googleanalytics/config_declaration.yaml b/ckanext/googleanalytics/config_declaration.yaml index 76effb0..87920d3 100644 --- a/ckanext/googleanalytics/config_declaration.yaml +++ b/ckanext/googleanalytics/config_declaration.yaml @@ -5,9 +5,31 @@ groups: - key: googleanalytics.id required: true placeholder: UA-000000000-1 + validators: not_empty + description: | + Google tag ID(`G-*`) for Google Analytics 4 properties or the + Tracking ID(`UA-*`) for Universal Analytics properties. - key: googleanalytics.download_handler default: ckan.views.resource:download + description: | + Import path of the CKAN view that handles resource downloads. It can + be used in combination with plugins that replace download + view(`ckanext-cloudstorage`, `ckanext-s3filestore`). + + - key: googleanalytics.tracking_mode + experimental: true + example: gtag + description: | + Defines the type of code snippet embedded into the page. Can be set + to either `ga`(enables `googleanalytics.js`) or `gtag`(enables + `gtag.js`). The plugin will check `googleanalytics.id` and set + appropriate value depending on the prefix: `G-` enables `gtag`, while + `UA-` enables `ga` mode. + + Use this option only if you know better which snippet you need. In + future, after dropping UniversalAnalytics, this option will be + removed. - key: googleanalytics.account diff --git a/ckanext/googleanalytics/views.py b/ckanext/googleanalytics/views.py index 3952407..7f066f8 100644 --- a/ckanext/googleanalytics/views.py +++ b/ckanext/googleanalytics/views.py @@ -15,8 +15,6 @@ from ckan.plugins import PluginImplementations from ckanext.googleanalytics import utils, config, interfaces -CONFIG_HANDLER_PATH = "googleanalytics.download_handler" - log = logging.getLogger(__name__) ga = Blueprint("google_analytics", "google_analytics") diff --git a/setup.cfg b/setup.cfg index ebdb8e4..4847d97 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = ckanext-googleanalytics -version = 2.2.2 +version = 2.2.3 description = Add GA tracking and reporting to CKAN instance long_description = file: README.md long_description_content_type = text/markdown