[IMP] website: add X-Disable-Tracking header to improve tracking

In this commit we add a request header X-Disable-Tracking that enables the
client to ask the server not to track a request.

This is useful for example when the client prefetches pages to be able to work
offline. In that case, the prefetched pages must not be considered as viewed
by the user. In such scenario and without such header, it is not possible to
get an accurate page tracking.

Task-2476513

Part-of: odoo/odoo#86031
This commit is contained in:
Pierre-Yves Dufays
2022-04-29 08:09:58 +02:00
parent 0a98036387
commit aef2d27053
+1 -1
View File
@@ -133,7 +133,7 @@ class Http(models.AbstractModel):
@classmethod
def _register_website_track(cls, response):
if getattr(response, 'status_code', 0) != 200:
if getattr(response, 'status_code', 0) != 200 or request.httprequest.headers.get('X-Disable-Tracking') == '1':
return False
template = False