From 78391173441d3d4c22ecd21c5c78afc7f25a2a57 Mon Sep 17 00:00:00 2001 From: Even Thomassen Date: Wed, 27 Jun 2018 23:50:47 +0200 Subject: [PATCH 1/2] cid is optional if uid is used, see [1]. [1] https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#cid Signed-off-by: Even Thomassen --- aioga/__init__.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/aioga/__init__.py b/aioga/__init__.py index 2613cde..3f2581f 100644 --- a/aioga/__init__.py +++ b/aioga/__init__.py @@ -35,13 +35,14 @@ def __init__( self.futs = set() - def _prepare_params(self, request_type, cid, **kwargs): + def _prepare_params(self, request_type, cid=None, **kwargs): params = { 'v': self.version, 'tid': self.tracking_id, - 'cid': cid, 't': request_type, } + if cid is not None: + params['cid'] = cid params.update(**kwargs) @@ -79,28 +80,28 @@ def _request(self, *args, **kwargs): return fut - def pageview(self, cid, **kwargs): + def pageview(self, cid=None, **kwargs): return self._request('pageview', cid, **kwargs) - def screenview(self, cid, **kwargs): + def screenview(self, cid=None, **kwargs): return self._request('screenview', cid, **kwargs) - def event(self, cid, **kwargs): + def event(self, cid=None, **kwargs): return self._request('event', cid, **kwargs) - def transaction(self, cid, **kwargs): + def transaction(self, cid=None, **kwargs): return self._request('transaction', cid, **kwargs) - def item(self, cid, **kwargs): + def item(self, cid=None, **kwargs): return self._request('item', cid, **kwargs) - def social(self, cid, **kwargs): + def social(self, cid=None, **kwargs): return self._request('social', cid, **kwargs) - def exception(self, cid, **kwargs): + def exception(self, cid=None, **kwargs): return self._request('exception', cid, **kwargs) - def timing(self, cid, **kwargs): + def timing(self, cid=None, **kwargs): return self._request('timing', cid, **kwargs) async def close(self): From f0a71d686faef33b9c109c135ea4121c3e6382fd Mon Sep 17 00:00:00 2001 From: Even Thomassen Date: Wed, 27 Jun 2018 23:59:58 +0200 Subject: [PATCH 2/2] Updated README to explain that cid can be optional when uid is used. Signed-off-by: Even Thomassen --- README.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index be67dd1..72ea9ec 100644 --- a/README.rst +++ b/README.rst @@ -66,7 +66,8 @@ Available methods Available parameters -------------------- -All methods require cid (Client ID). The value of this field +All methods accept cid (Client ID). This field is mandatory, +unless uid (User ID) is provided. The value of the cid field should be a random UUID (version 4) as described in ``_