New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow to set identity_func by ANALYTICAL_IDENTITY_FUNC settings #189
Conversation
Codecov Report
@@ Coverage Diff @@
## main #189 +/- ##
=======================================
Coverage 94.49% 94.49%
=======================================
Files 31 31
Lines 1344 1345 +1
=======================================
+ Hits 1270 1271 +1
Misses 74 74
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you extend the tests to match your changes, please? And also mention ANALYTICAL_IDENTIFY_FUNC
in the docs.
Thank you for your understanding.
@PetrDlouhy Are you still interested to take this PR ahead? |
@bittner I will look at it. |
@bittner I added simple test, some docs and also renamed the setting from ANALITICAL_IDENTIFY_FUNC to ANALYTICAL_IDENTITY_FUNC. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC, the problem you're trying to solve relates to hard requirements of some of Analytical's analytics providers. Shouldn't this be solved in the respective modules instead of requiring our users to code an identity function?
docs/settings.rst
Outdated
|
||
.. data:: ANALYTICAL_IDENTITY_FUNC | ||
|
||
Default: Identity function dependend on provider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default: Identity function dependend on provider | |
Default: Identity function dependent on provider |
docs/settings.rst
Outdated
default settings of diferent providers. | ||
|
||
E.g. Google has in it's conditions for enabling UserID requirement, that prohibits | ||
sending personal data (such as e-mail address) to analytics. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sending personal data (such as e-mail address) to analytics. | |
sending personal data (such as an e-mail address) to analytics. |
@bittner I have fixed the typos. I think, that possibility to manually override the identity function allows flexibility in corner cases. E.g. I want to use my UUID field to keep consistency of my data even if the default behavior of I don't know other providers, but the It is also truth, that one identity function might not fit for all providers, if more of them are used. So maybe we might better use settings like: ANALYTICAL_IDENTITY_FUNC_OVERRIDES = {
'google_analytics_gtag': lambda user: user.uuid,
} and ANALYTICAL_IDENTITY_FUNC_DEFAULT = lambda user: user.uuid which would override only the default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that making the identity func dependent on the provider would make sense. I would keep it simple, though.
ANALYTICAL_IDENTITY_FUNC = {
'google_analytics_gtag': lambda user: user.uuid,
}
or maybe even
ANALYTICAL_AUTO_IDENTIFY = {
'google_analytics_gtag': lambda user: user.uuid,
'matomo': True,
}
Though I just noticed something else: The feature you attempt to contribute already exists (get_identity
, lines 75+). Instead of a (lamda) function, though, you simply add an analytical_identity
value (or the service specific value) to the template context.
Isn't that good enough?
In such case add uuid field to the user and set ```ANALYTICAL_IDENTITY_FUNC``` to | ||
```lambda user: user.uuid``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In such case add uuid field to the user and set ```ANALYTICAL_IDENTITY_FUNC``` to | |
```lambda user: user.uuid``` | |
In such a case add the ``uuid`` field to the user and set ``ANALYTICAL_IDENTITY_FUNC`` to | |
``lambda user: user.uuid`` or a proper function that takes ``user`` as an argument, e.g. | |
.. code-block:: python | |
def uuid_identity(user): | |
return user.uuid | |
ANALYTICAL_IDENTITY_FUNC = uuid_identity |
E.g. Google has in its conditions for enabling UserID the requirement, that prohibits | ||
sending personal data (such as an e-mail address) to analytics. | ||
If e-mail address is used as username, using GTag would break the requirements. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E.g. Google has in its conditions for enabling UserID the requirement, that prohibits | |
sending personal data (such as an e-mail address) to analytics. | |
If e-mail address is used as username, using GTag would break the requirements. | |
For example, Google Analytics requires not sending personal data (such as an e-mail address) for | |
enabling UserID. If an e-mail address is used as username using GTag would break that requirement. |
I have to admit, I don't understand "for enabling UserID".
Also, do you have any references for your claim of the GA requirement? Is it a hard requirement or is it "just" in their terms of use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant transition from google_analytics
to google_analytics_gtag
with user identity which I underwent in my project.
The requirements are their terms of use, which they write very suggestively: https://developers.google.com/analytics/solutions/crm-integration#user_id
And also I think I had to agree to that when switching on the User ID feature in Google Analytics.
You are right. The Also some providers (like |
Great! It would be awesome if you could provide the missing pieces to the documentation. A working code sample would be fantastic.
That was already reported (#188, #197). Can you spot how to fix this problem? P.S.: Too sad for the nice test you added just recently! 😢 |
Google has in it's conditions for enabling UserID requirement, that prohibits sending personal data (such as e-mail address) to analytics.
I am using e-mail address as username, so using GTag would break the requirements for me.
This enables me to set user UUID for the UserID parameter.