ATI enhancement: Set or update atuserid cookie
Is your feature request related to a problem? Please describe. We currently see double counting of users in ATI if they visit a Simorgh page then later visit an Orbit-using page. This is because the way Orbit sets and stores the user ID is different from the default ATI approach which Simorgh uses.
Describe the solution you'd like Make the following changes:
When a user arrives on a Simorgh page, before sending anything to ATI, check for the existance of an atuserid cookie on our domain.
If the cookie does not exist:
- Generate a UUID, e.g.
00000000-1111-aaaa-bbbb-1234567890ab - Generate a date 13 months in the future, e.g.
2020-11-24T08:28:00.888Z - Create a JSON object in the following format:
{"name":"atuserid","val":"00000000-1111-aaaa-bbbb-1234567890ab","options":{"end":"2020-11-24T08:28:00.888Z","path":"/"}}using the two values created - Stringify and URL Encode the JSON object, e.g.
%7B%22name%22%3A%22atuserid%22%2C%22val%22%3A%2200000000-1111-aaaa-bbbb-1234567890ab%22%2C%22options%22%3A%7B%22end%22%3A%222020-11-24T08%3A28%3A00.888Z%22%2C%22path%22%3A%22%2F%22%7D%7D - Write the string as the value of a cookie named
atuseridand save for the current domain (e.g..bbc.co.ukor.bbc.com) with an expiry date matching the date generated in Step 2, and path/ - You can now allow the ATI code to construct it's hit, which will include the UUID from the cookie as the
idclientparameter (this work done already)
If the cookie does exist
- Generate a date 13 months in the future, e.g.
2020-11-24T08:28:00.888Z - Update the date in the value of the cookie to match the new date
- Update the expiry date of the cookie to match the new date
Describe alternatives you've considered N/A
Testing notes [Tester to complete]
Dev insight: Will Cypress tests be required or are unit tests sufficient? Will there be any potential regression? etc
- [ ] This feature is expected to need manual testing.
Additional context Add any other context or screenshots about the feature request here.
One AC I have is that the format of the cookie value should satisfy the following Regex. This is something ATI have supplied:
{\"name\":\"atuserid\",\"val\":\"([0-9a-zA-Z\\-]+)\".*