snowplow / snowplow/snowplow-javascript-tracker
Invalid `client_session` entity with `stateStorageStrategy: 'none'`
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 590
- Forks
- 232
- Avg merge
- 2h 22m
- Merged PRs (30d)
- 3
Description
Describe the bug
The client_session entity requires that the userId value be provided as a string matching a pattern (^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$|^[0-9a-f]{16}$) and the sessionId be provided as a UUID.
In the JS tracker, this value is usually populated with what would be the Domain User ID value and Session ID values, respectively.
To accommodate this, when creating the client_session entity, the tracker does a few compatibility checks for anonymousTracking to ensure it produces valid data.
Mostly the checks are:
- If anonymous tracking is enabled without
withSessionTracking, do not include the entity at all as bothuserIdandsessionIdvalues are unavailable - If anonymous tracking is enabled with
withSessionTracking, use the nil UUID in place of domain user ID to pass validation
However, if stateStorageStrategy is none (via initial configuration or toggling via enableAnonymousTracking) but anonymousTracking is not enabled (possible in the latter case by providing options: false), these checks will pass, but the tracker will populate userId and sessionId with an empty string as the respective identifiers are not available. The resulting event will fail schema validation.
To Reproduce
snowplow('newTracker', 'anon', 'http://localhost:9090', {stateStorageStrategy: 'none', contexts: {session: true}});
snowplow('trackPageView');
Expected behavior
Valid event produced by omitting client_session entity or falling back to nil UUID for user/session IDs.
Screenshots
Event fails validation on client_session entity:
{
"schemaKey" : "iglu:com.snowplowanalytics.snowplow/client_session/jsonschema/1-0-2",
"error" : {
"error" : "ValidationError",
"dataReports" : [
{
"message" : "$.sessionId: is an invalid uuid",
"path" : "$.sessionId",
"keyword" : "uuid",
"targets" : [
"",
"uuid"
]
},
{
"message" : "$.userId: does not match the regex pattern ^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$|^[0-9a-f]{16}$",
"path" : "$.userId",
"keyword" : "pattern",
"targets" : [
"^[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}$|^[0-9a-f]{16}$"
]
}
]
}
}
Additional context
See Zendesk #40198
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with newTracker configured with stateStorageStrategy: 'none' and contexts.session enabled, then call trackPageView and inspect the client_session entity. The work is done when this configuration produces a schema-valid event by omitting the entity or using valid nil UUID values for unavailable identifiers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- analytics, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100