udata-piwik


Nameudata-piwik JSON
Version 4.0.0 PyPI version JSON
download
home_pagehttps://github.com/opendatateam/udata-piwik
SummaryPiwik/Matomo support for uData
upload_time2023-11-20 16:14:23
maintainer
docs_urlNone
authorOpenDataTeam
requires_python>=3.7
licenseLGPL
keywords udata piwik
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # udata-piwik


[![Join the chat at https://gitter.im/opendatateam/udata][gitter-badge]][gitter-url]

This plugin provide integration between [udata][] and [Piwik/Matomo](https://matomo.org/)

## Compatibility

**udata-piwik** requires Python 2.7+ and [udata][].

## Installation

Install [udata][].

Remain in the same virtual environment (for Python) and use the same version of npm (for JS).

Install **udata-piwik**:

```shell
pip install udata-piwik
```

Modify your local configuration file of **udata** (typically, `udata.cfg`) as following:

```python
PLUGINS = ['piwik']
# Piwik/Matomo site IDs
# this site will track front (template) events
PIWIK_ID_FRONT = 1
# this site will track back (API) events
PIWIK_ID_API = 1
PIWIK_SCHEME = 'https'
PIWIK_URL = 'stats.data.gouv.fr'
PIWIK_AUTH = '<32-chars-auth-token-from-piwik>'
# `client.track` method `requests` timeout
PIWIK_TRACK_TIMEOUT = 60  # in seconds
# `client.analyze` method `requests` timeout
PIWIK_ANALYZE_TIMEOUT = 60 * 5  # in seconds
```

### Optional configuration

```python
# Content tracking options. Default: None
#   - 'all': track all impressions
#   - 'visible': track impressions of visible items only (default refresh: 750 ms)
PIWIK_CONTENT_TRACKING = 'visible'
```

## Testing on local env

```shell
$ docker-compose up
$ pip install -r requirements/test.pip
$ pytest
```

[circleci-url]: https://circleci.com/gh/opendatateam/udata-piwik
[circleci-badge]: https://circleci.com/gh/opendatateam/udata-piwik.svg?style=shield
[gitter-badge]: https://badges.gitter.im/Join%20Chat.svg
[gitter-url]: https://gitter.im/opendatateam/udata
[udata]: https://github.com/opendatateam/udata

# Changelog

## 4.0.0 (2023-11-20)

- [BREAKING] Remove metrics computation with Matomo as a source (cf below) [#273](https://github.com/opendatateam/udata-piwik/pull/273)
- Replace mongo legacy image in CI [#266](https://github.com/opendatateam/udata-piwik/pull/266)
- Upgrade test and develop deps [#284](https://github.com/opendatateam/udata-piwik/pull/284)

Up until this version, metrics were tentatively computed from Matomo for pretty much every object of a udata instance. We found this method to be pretty inaccurate, since Matomo limits the number of records stored to roughly the most visited 1000 for a given "namespace". There's a way around that by using the data from the Live module of Matomo but it's not enabled on our instance for privacy reasons. We also needed to count hits that Matomo could not know of: resources (files) downloads made directly on our server.

Thus, this module now only does three things:
- inject the Matomo tracking code in the templates
- process events for tracking the API usage in Matomo
- process events for tracking some Matomo goals

Metrics computation is now handled by [https://github.com/opendatateam/udata-metrics](udata-metrics) and does not use Matomo as a source.

:warning: Jobs to be unscheduled:
- `piwik-update-metrics`
- `piwik-current-metrics`
- `piwik-yesterday-metrics`

## 3.1.0 (2021-09-16)

- Change udata-gouvfr dependency to udata-front following renaming [#249](https://github.com/opendatateam/udata-piwik/pull/249)

## 3.0.0 (2021-07-07)

- Ensure compatibility with udata-front and removed goals mechanism [#245](https://github.com/opendatateam/udata-piwik/pull/245)

## 2.1.4 (2021-05-06)

- Pin influx docker image version to prevent usign Influx v2 [#239](https://github.com/opendatateam/udata-piwik/pull/239)

## 2.1.3 (2021-05-05)

- Fix noscript img protocol [#215](https://github.com/opendatateam/udata-piwik/pull/215)
- Add exception raise when analyze's API call fails [#230](https://github.com/opendatateam/udata-piwik/pull/230)

## 2.1.2 (2020-07-03)

- Add specific query for each model metrics [#203](https://github.com/opendatateam/udata-piwik/pull/203)

## 2.1.1 (2020-05-20)

- Remove object's id in error log message in order to have a cleaner message [#195](https://github.com/opendatateam/udata-piwik/pull/195)

## 2.1.0 (2020-05-12)

- Changed metrics system [#185](https://github.com/opendatateam/udata-piwik/pull/185):
  - Metrics are now stored into InfluxDB before being injected in udata's objects
  - Udata piwik accesses influxDB throught [udata-metrics](https://github.com/opendatateam/udata-metrics)
  - The periodic job `piwik-update-metrics` needs to be scheduled in addition to existing jobs, in order to retrieve the views metrics in udata's objects
  - The command `update-metrics` was added to trigger the metrics injection manually

## 2.0.2 (2020-04-24)

- [fix] Do not expect a json response from tracking api [#192](https://github.com/opendatateam/udata-piwik/pull/190)

## 2.0.1 (2020-04-07)

- Do not expect a json response from tracking api [#190](https://github.com/opendatateam/udata-piwik/pull/190)

## 2.0.0 (2020-03-11)

- Migrate to python3 🐍 [#68](https://github.com/opendatateam/udata-piwik/pull/68)
- Migrate footer snippet to the new `footer.snippets` hook [#157](https://github.com/opendatateam/udata-piwik/pull/157)

## 1.5.1 (2019-12-31)

- Fix JS syntax when subscribing to goals [#174](https://github.com/opendatateam/udata-piwik/pull/174)

## 1.5.0 (2019-12-30)

- Independant Matomo site ids for front and api tracking :warning: breaking change, you need to set `PIWIK_ID_FRONT` and `PIWIK_ID_API` in settings (they can be the same) [#173](https://github.com/opendatateam/udata-piwik/pull/173)

## 1.4.2 (2019-12-13)

- Improve detect_by_url error handling [#171](https://github.com/opendatateam/udata-piwik/pull/171)

## 1.4.1 (2019-05-15)

- Fix bulk handling of unicode URLs [#139](https://github.com/opendatateam/udata-piwik/pull/139)

## 1.4.0 (2019-03-27)

- Consolidate and expose default settings [#119](https://github.com/opendatateam/udata-piwik/pull/119)
- Process API calls in bulk [#120](https://github.com/opendatateam/udata-piwik/pull/120)

## 1.3.2 (2019-01-14)

- Add `PIWIK_SCHEME` config support [#104](https://github.com/opendatateam/udata-piwik/pull/104)

## 1.3.1 (2018-11-05)

- Ensure JS goals handling waits for `uData` object to be present [#91](https://github.com/opendatateam/udata-piwik/pull/91)

## 1.3.0 (2018-10-11)

- Advanced search tracking: display results count and categories (datasets, reuses, organizations) [#88](https://github.com/opendatateam/udata-piwik/pull/88)
- Lower jobs piriority to `low` [#90](https://github.com/opendatateam/udata-piwik/pull/90)
- Depends on `udata>=1.6.1`

## 1.2.0 (2018-06-06)

- Simpler and more reliable metrics computation [#54](https://github.com/opendatateam/udata-piwik/pull/54)

## 1.1.1 (2018-03-15)

- Handle multiple resources for same url [#49](https://github.com/opendatateam/udata-piwik/pull/49)

## 1.1.0 (2018-03-13)

- Refactor `counter.handle_downloads` - fix [#1421](https://github.com/opendatateam/udata/issues/1421)
- Switch to `flask-cli` and endpoint-based commands (requires `udata>=1.3`) [#33](https://github.com/opendatateam/udata-piwik/pull/33)
- Expose the new `udata.tasks` endpoint [#39](https://github.com/opendatateam/udata-piwik/pull/39)
- Expose the new `udata.views` endpoint [#41](https://github.com/opendatateam/udata-piwik/pull/41)
- Add content tracking options in configuration paramaters [#42](://github.com/opendatateam/udata-piwik/pull/42)

## 1.0.2 (2017-12-20)

- Fix version number
- Fix README on pypi

## 1.0.1 (2017-12-20)

- Fix packaging issue

## 1.0.0 (2017-12-19)

- Add (automated) tests against a Piwik instance [#20](https://github.com/opendatateam/udata-piwik/issues/20)
- Handle download count on latest url for (community) resources [#30](https://github.com/opendatateam/udata-piwik/pull/30)

## 0.9.3 (2017-12-11)

- Add a timeout to `analyze()` [#19](https://github.com/opendatateam/udata-piwik/pull/19)

## 0.9.2 (2017-12-11)

- Add a timeout to `track()` [#18](https://github.com/opendatateam/udata-piwik/pull/18)

## 0.9.1 (2017-01-10)

- Fix build and packaging

## 0.9.0 (2017-01-10)

- First published release


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/opendatateam/udata-piwik",
    "name": "udata-piwik",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "udata piwik",
    "author": "OpenDataTeam",
    "author_email": "contact@opendata.team",
    "download_url": "",
    "platform": null,
    "description": "# udata-piwik\n\n\n[![Join the chat at https://gitter.im/opendatateam/udata][gitter-badge]][gitter-url]\n\nThis plugin provide integration between [udata][] and [Piwik/Matomo](https://matomo.org/)\n\n## Compatibility\n\n**udata-piwik** requires Python 2.7+ and [udata][].\n\n## Installation\n\nInstall [udata][].\n\nRemain in the same virtual environment (for Python) and use the same version of npm (for JS).\n\nInstall **udata-piwik**:\n\n```shell\npip install udata-piwik\n```\n\nModify your local configuration file of **udata** (typically, `udata.cfg`) as following:\n\n```python\nPLUGINS = ['piwik']\n# Piwik/Matomo site IDs\n# this site will track front (template) events\nPIWIK_ID_FRONT = 1\n# this site will track back (API) events\nPIWIK_ID_API = 1\nPIWIK_SCHEME = 'https'\nPIWIK_URL = 'stats.data.gouv.fr'\nPIWIK_AUTH = '<32-chars-auth-token-from-piwik>'\n# `client.track` method `requests` timeout\nPIWIK_TRACK_TIMEOUT = 60  # in seconds\n# `client.analyze` method `requests` timeout\nPIWIK_ANALYZE_TIMEOUT = 60 * 5  # in seconds\n```\n\n### Optional configuration\n\n```python\n# Content tracking options. Default: None\n#   - 'all': track all impressions\n#   - 'visible': track impressions of visible items only (default refresh: 750 ms)\nPIWIK_CONTENT_TRACKING = 'visible'\n```\n\n## Testing on local env\n\n```shell\n$ docker-compose up\n$ pip install -r requirements/test.pip\n$ pytest\n```\n\n[circleci-url]: https://circleci.com/gh/opendatateam/udata-piwik\n[circleci-badge]: https://circleci.com/gh/opendatateam/udata-piwik.svg?style=shield\n[gitter-badge]: https://badges.gitter.im/Join%20Chat.svg\n[gitter-url]: https://gitter.im/opendatateam/udata\n[udata]: https://github.com/opendatateam/udata\n\n# Changelog\n\n## 4.0.0 (2023-11-20)\n\n- [BREAKING] Remove metrics computation with Matomo as a source (cf below) [#273](https://github.com/opendatateam/udata-piwik/pull/273)\n- Replace mongo legacy image in CI [#266](https://github.com/opendatateam/udata-piwik/pull/266)\n- Upgrade test and develop deps [#284](https://github.com/opendatateam/udata-piwik/pull/284)\n\nUp until this version, metrics were tentatively computed from Matomo for pretty much every object of a udata instance. We found this method to be pretty inaccurate, since Matomo limits the number of records stored to roughly the most visited 1000 for a given \"namespace\". There's a way around that by using the data from the Live module of Matomo but it's not enabled on our instance for privacy reasons. We also needed to count hits that Matomo could not know of: resources (files) downloads made directly on our server.\n\nThus, this module now only does three things:\n- inject the Matomo tracking code in the templates\n- process events for tracking the API usage in Matomo\n- process events for tracking some Matomo goals\n\nMetrics computation is now handled by [https://github.com/opendatateam/udata-metrics](udata-metrics) and does not use Matomo as a source.\n\n:warning: Jobs to be unscheduled:\n- `piwik-update-metrics`\n- `piwik-current-metrics`\n- `piwik-yesterday-metrics`\n\n## 3.1.0 (2021-09-16)\n\n- Change udata-gouvfr dependency to udata-front following renaming [#249](https://github.com/opendatateam/udata-piwik/pull/249)\n\n## 3.0.0 (2021-07-07)\n\n- Ensure compatibility with udata-front and removed goals mechanism [#245](https://github.com/opendatateam/udata-piwik/pull/245)\n\n## 2.1.4 (2021-05-06)\n\n- Pin influx docker image version to prevent usign Influx v2 [#239](https://github.com/opendatateam/udata-piwik/pull/239)\n\n## 2.1.3 (2021-05-05)\n\n- Fix noscript img protocol [#215](https://github.com/opendatateam/udata-piwik/pull/215)\n- Add exception raise when analyze's API call fails [#230](https://github.com/opendatateam/udata-piwik/pull/230)\n\n## 2.1.2 (2020-07-03)\n\n- Add specific query for each model metrics [#203](https://github.com/opendatateam/udata-piwik/pull/203)\n\n## 2.1.1 (2020-05-20)\n\n- Remove object's id in error log message in order to have a cleaner message [#195](https://github.com/opendatateam/udata-piwik/pull/195)\n\n## 2.1.0 (2020-05-12)\n\n- Changed metrics system [#185](https://github.com/opendatateam/udata-piwik/pull/185):\n  - Metrics are now stored into InfluxDB before being injected in udata's objects\n  - Udata piwik accesses influxDB throught [udata-metrics](https://github.com/opendatateam/udata-metrics)\n  - The periodic job `piwik-update-metrics` needs to be scheduled in addition to existing jobs, in order to retrieve the views metrics in udata's objects\n  - The command `update-metrics` was added to trigger the metrics injection manually\n\n## 2.0.2 (2020-04-24)\n\n- [fix] Do not expect a json response from tracking api [#192](https://github.com/opendatateam/udata-piwik/pull/190)\n\n## 2.0.1 (2020-04-07)\n\n- Do not expect a json response from tracking api [#190](https://github.com/opendatateam/udata-piwik/pull/190)\n\n## 2.0.0 (2020-03-11)\n\n- Migrate to python3 \ud83d\udc0d [#68](https://github.com/opendatateam/udata-piwik/pull/68)\n- Migrate footer snippet to the new `footer.snippets` hook [#157](https://github.com/opendatateam/udata-piwik/pull/157)\n\n## 1.5.1 (2019-12-31)\n\n- Fix JS syntax when subscribing to goals [#174](https://github.com/opendatateam/udata-piwik/pull/174)\n\n## 1.5.0 (2019-12-30)\n\n- Independant Matomo site ids for front and api tracking :warning: breaking change, you need to set `PIWIK_ID_FRONT` and `PIWIK_ID_API` in settings (they can be the same) [#173](https://github.com/opendatateam/udata-piwik/pull/173)\n\n## 1.4.2 (2019-12-13)\n\n- Improve detect_by_url error handling [#171](https://github.com/opendatateam/udata-piwik/pull/171)\n\n## 1.4.1 (2019-05-15)\n\n- Fix bulk handling of unicode URLs [#139](https://github.com/opendatateam/udata-piwik/pull/139)\n\n## 1.4.0 (2019-03-27)\n\n- Consolidate and expose default settings [#119](https://github.com/opendatateam/udata-piwik/pull/119)\n- Process API calls in bulk [#120](https://github.com/opendatateam/udata-piwik/pull/120)\n\n## 1.3.2 (2019-01-14)\n\n- Add `PIWIK_SCHEME` config support [#104](https://github.com/opendatateam/udata-piwik/pull/104)\n\n## 1.3.1 (2018-11-05)\n\n- Ensure JS goals handling waits for `uData` object to be present [#91](https://github.com/opendatateam/udata-piwik/pull/91)\n\n## 1.3.0 (2018-10-11)\n\n- Advanced search tracking: display results count and categories (datasets, reuses, organizations) [#88](https://github.com/opendatateam/udata-piwik/pull/88)\n- Lower jobs piriority to `low` [#90](https://github.com/opendatateam/udata-piwik/pull/90)\n- Depends on `udata>=1.6.1`\n\n## 1.2.0 (2018-06-06)\n\n- Simpler and more reliable metrics computation [#54](https://github.com/opendatateam/udata-piwik/pull/54)\n\n## 1.1.1 (2018-03-15)\n\n- Handle multiple resources for same url [#49](https://github.com/opendatateam/udata-piwik/pull/49)\n\n## 1.1.0 (2018-03-13)\n\n- Refactor `counter.handle_downloads` - fix [#1421](https://github.com/opendatateam/udata/issues/1421)\n- Switch to `flask-cli` and endpoint-based commands (requires `udata>=1.3`) [#33](https://github.com/opendatateam/udata-piwik/pull/33)\n- Expose the new `udata.tasks` endpoint [#39](https://github.com/opendatateam/udata-piwik/pull/39)\n- Expose the new `udata.views` endpoint [#41](https://github.com/opendatateam/udata-piwik/pull/41)\n- Add content tracking options in configuration paramaters [#42](://github.com/opendatateam/udata-piwik/pull/42)\n\n## 1.0.2 (2017-12-20)\n\n- Fix version number\n- Fix README on pypi\n\n## 1.0.1 (2017-12-20)\n\n- Fix packaging issue\n\n## 1.0.0 (2017-12-19)\n\n- Add (automated) tests against a Piwik instance [#20](https://github.com/opendatateam/udata-piwik/issues/20)\n- Handle download count on latest url for (community) resources [#30](https://github.com/opendatateam/udata-piwik/pull/30)\n\n## 0.9.3 (2017-12-11)\n\n- Add a timeout to `analyze()` [#19](https://github.com/opendatateam/udata-piwik/pull/19)\n\n## 0.9.2 (2017-12-11)\n\n- Add a timeout to `track()` [#18](https://github.com/opendatateam/udata-piwik/pull/18)\n\n## 0.9.1 (2017-01-10)\n\n- Fix build and packaging\n\n## 0.9.0 (2017-01-10)\n\n- First published release\n\n",
    "bugtrack_url": null,
    "license": "LGPL",
    "summary": "Piwik/Matomo support for uData",
    "version": "4.0.0",
    "project_urls": {
        "Homepage": "https://github.com/opendatateam/udata-piwik"
    },
    "split_keywords": [
        "udata",
        "piwik"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4800461fc4b0aa3f262599bec23ffcf55ccc696df28dcf9c1e8066e14a16cbe7",
                "md5": "413ce25fa7e417002dbe3c67fa460214",
                "sha256": "b34025ce3178066907133b92c3886d6eeab57b8db30a398a0022f2b558aeb649"
            },
            "downloads": -1,
            "filename": "udata_piwik-4.0.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "413ce25fa7e417002dbe3c67fa460214",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.7",
            "size": 9746,
            "upload_time": "2023-11-20T16:14:23",
            "upload_time_iso_8601": "2023-11-20T16:14:23.148912Z",
            "url": "https://files.pythonhosted.org/packages/48/00/461fc4b0aa3f262599bec23ffcf55ccc696df28dcf9c1e8066e14a16cbe7/udata_piwik-4.0.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-20 16:14:23",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "opendatateam",
    "github_project": "udata-piwik",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "circle": true,
    "lcname": "udata-piwik"
}
        
Elapsed time: 0.14792s