Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid client_session entity with stateStorageStrategy: 'none' #1298

Open
jethron opened this issue Mar 20, 2024 · 0 comments
Open

Invalid client_session entity with stateStorageStrategy: 'none' #1298

jethron opened this issue Mar 20, 2024 · 0 comments
Labels
type:defect Bugs or weaknesses. The issue has to contain steps to reproduce.

Comments

@jethron
Copy link
Contributor

jethron commented Mar 20, 2024

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 both userId and sessionId values 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

@jethron jethron added the type:defect Bugs or weaknesses. The issue has to contain steps to reproduce. label Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:defect Bugs or weaknesses. The issue has to contain steps to reproduce.
Projects
None yet
Development

No branches or pull requests

1 participant