diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 67476725..8f9c2ab4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,10 +4,10 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 with: - python-version: '3.6' + python-version: '3.9' - name: Install requirements run: pip install flake8 pycodestyle - name: Check syntax diff --git a/ckanext/googleanalytics/cli.py b/ckanext/googleanalytics/cli.py index 073490fc..e4b5e62a 100644 --- a/ckanext/googleanalytics/cli.py +++ b/ckanext/googleanalytics/cli.py @@ -7,6 +7,7 @@ import logging import click import ckan.model as model +import ckan.plugins.toolkit as tk from . import dbutil, config diff --git a/ckanext/googleanalytics/config.py b/ckanext/googleanalytics/config.py index b73b4d75..149e3dd1 100644 --- a/ckanext/googleanalytics/config.py +++ b/ckanext/googleanalytics/config.py @@ -49,7 +49,6 @@ def tracking_mode(): if id_.startswith("GTM-"): return "gtm" - return "ga" diff --git a/ckanext/googleanalytics/ga_auth.py b/ckanext/googleanalytics/ga_auth.py index 4c706758..cd3bf23d 100644 --- a/ckanext/googleanalytics/ga_auth.py +++ b/ckanext/googleanalytics/ga_auth.py @@ -1,7 +1,7 @@ from apiclient.discovery import build from oauth2client.service_account import ServiceAccountCredentials -from ckanext.googleanalytics import utils, config +from ckanext.googleanalytics import config def init_service(credentials_file): diff --git a/ckanext/googleanalytics/helpers.py b/ckanext/googleanalytics/helpers.py index 52be647d..ddd75717 100644 --- a/ckanext/googleanalytics/helpers.py +++ b/ckanext/googleanalytics/helpers.py @@ -45,5 +45,6 @@ def googleanalytics_header(): def googleanalytics_tracking_mode(): return config.tracking_mode() + def googleanalytics_id(): return config.tracking_id() diff --git a/ckanext/googleanalytics/logic/action.py b/ckanext/googleanalytics/logic/action.py index 83560660..fd648607 100644 --- a/ckanext/googleanalytics/logic/action.py +++ b/ckanext/googleanalytics/logic/action.py @@ -4,7 +4,7 @@ from ckan.logic import validate from . import schema -from .. import utils, config +from .. import config from ..model import PackageStats, ResourceStats from ..ga_auth import init_service, get_profile_id diff --git a/ckanext/googleanalytics/tests/test_view.py b/ckanext/googleanalytics/tests/test_view.py index 80ef9e90..48787fb9 100644 --- a/ckanext/googleanalytics/tests/test_view.py +++ b/ckanext/googleanalytics/tests/test_view.py @@ -3,6 +3,7 @@ import ckan.plugins.toolkit as tk from ckanext.googleanalytics import config + def _render_header(mode, tracking_id): return tk.render_snippet("googleanalytics/snippets/_{}.html".format(mode), { "googleanalytics_id": tracking_id, diff --git a/ckanext/googleanalytics/utils.py b/ckanext/googleanalytics/utils.py index c2416331..bd97b177 100644 --- a/ckanext/googleanalytics/utils.py +++ b/ckanext/googleanalytics/utils.py @@ -68,7 +68,7 @@ def _mp_event(event): data=json.dumps({ "client_id": config.measurement_protocol_client_id(), "non_personalized_ads": False, - "events":[event] + "events": [event] }, cls=SafeJSONEncoder) )