Skip to main content

Device Id determination

Mobile

In case of mobile as every device has it's own id we are receiving device_id from the client, in the request body

[ { header: { decice_id: 1234-5678-90123, ... }, events: {...}, attributes: {...} }]

Web

In case of web we are not able to get some identifier related to device, so we are generating some unique id the part of which is timestamp.

Before the first request to the backend SDK generates device_id and sends it to the backend, after which from backend side we are putting that device_id to the response cookie and sending back to the client.

Here is more demonstrative diagram to understand how it is working now.

device_id_determination_web.png

Here is the code, which is generating device id based on ip and user agent

const now = this.date.getTime();
const dateStamp = Math.floor(now / 259200000);
const data = `${dateStamp}-${ip}-${uaString}`;
return createHash('sha256').update(data, 'utf8').digest('hex');

We are using chunks[0].config.deviceId with none value for anonymous tracking, it is currently using in imgur receiver.

In the current solution the device id stored in cookies will be used for all projects where we are using our sdk

https://picsartstage2.com/
https://picsart.com/
https://imgur.com/upload
https://tools.picsart.com/
https://app.onlineadmaker.com/

Note: Chrome is planning to disable third-party cookies with gradual rollout starting from 1% in Q1 2024. Other browsers also will follow the lead so we need to think about an alternative solution to third-party cookies.