#22 / no interface needed, function _post_analytics modified

This commit is contained in:
Gleb 2017-03-27 15:43:39 +03:00
parent 4ace99329f
commit e49e8bbac7
2 changed files with 15 additions and 3 deletions

View File

@ -21,6 +21,11 @@ Features
* Adds Google Analytics Event Tracking to some API calls so that usage of the
API can be reported on via Google Analytics.
* Add Google Analytics Event Tracking function that can be used in any exstension
to create your custom events tracking.
``ckanext.googleanalytics.plugin._post_analytics``
* Adds Google Analytics Event Tracking to group links on the home page,
user profile links, editing and saving user profiles, etc.

View File

@ -24,7 +24,8 @@ log = logging.getLogger('ckanext.googleanalytics')
def _post_analytics(
user, request_obj_type, request_function, request_id):
user, event_type, request_obj_type, request_function, request_id):
if config.get('googleanalytics.id'):
data_dict = {
"v": 1,
@ -35,7 +36,7 @@ def _post_analytics(
"dh": c.environ['HTTP_HOST'],
"dp": c.environ['PATH_INFO'],
"dr": c.environ.get('HTTP_REFERER', ''),
"ec": "CKAN Resource Download Request",
"ec": event_type,
"ea": request_obj_type + request_function,
"el": request_id,
}
@ -45,7 +46,13 @@ def _post_analytics(
def post_analytics_decorator(func):
def func_wrapper(cls, id, resource_id, filename):
_post_analytics(c.user, "Resource", "Download", resource_id)
_post_analytics(
c.user,
"CKAN Resource Download Request",
"Resource",
"Download",
resource_id
)
return func(cls, id, resource_id, filename)