-
Notifications
You must be signed in to change notification settings - Fork 2
Capture investigation referral data #162
Capture investigation referral data #162
Conversation
- add redirect view to capture investigation UUID - add middleware to track user behaviour
27de636
to
e28e4fb
Compare
Request and response objects are not JSON serializable, and a single DB write doesn't seem worth it to use Celery
bd875e2
to
12737d2
Compare
analytics/models.py
Outdated
method = models.TextField(null=True) | ||
title = models.TextField(null=True) | ||
visitor_uuid = models.TextField(null=True) | ||
user_profile_uuid = models.TextField(null=True) |
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.
Should we have null=True
for TextField
s? We usually only want blank=True
, so that we only have one way of representing a null value in the database.
analytics/middleware.py
Outdated
|
||
visitor_uuid = request.COOKIES.get('visitor_uuid', False) | ||
if not visitor_uuid: | ||
response.set_cookie('visitor_uuid', str(uuid.uuid4())) |
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.
Just noting that we can also use the request session to store this UUID, or just use the session ID, instead of dealing with cookies ourselves.
exclude = [p for p in settings.ANALYTICS_IGNORE_PATH | ||
if request.path.startswith(p)] | ||
return any(exclude) | ||
return False |
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.
This will also include page views for people who didn't go through the analytics endpoint. Just want to make sure that that is the desired functionality.
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.
Yep, this was intended
12737d2
to
afc7d0f
Compare
session ID is only recorded after this layer of middleware, hence the need for a new UUID
nurseconnect makes AJAX calls to menu on every page load for some reason request.is_ajax fails to pick this up in middleware
No description provided.