Skip to content

Fixed(#22) setUserId not Working for js-sdk

Ankit Panchal requested to merge ankit-panchal/userid-not-passing into main

Currently, the default value for hasCookieConsent is set to false. When it is false, the Snowplow tracker is initialized with the following options:

anonymousTracking: { withServerAnonymisation: true },
stateStorageStrategy: 'none',
eventMethod: 'post'

However, this implementation seems to be incorrect. According to the Snowplow documentation, when using anonymousTracking, no user data can be sent, which is why the userID is not being passed.

A better approach would be to use the following configuration instead:

 cookieDomain: null,
 cookieLifetime: 0,
 respectDoNotTrack: true,  

By setting cookieLifetime to 0, we ensure that no cookies are stored, and with cookieDomain set to null, no cookie domains will be set. Additionally, including the respectDoNotTrack option according to the documentation would be a good practice.

This configuration ensures that no cookies are stored when users have not given their consent, and it also respects their browser's Do Not Track settings.

Merge request reports