snowplow / snowplow/snowplow-javascript-tracker

Invalid client_session entity with multiple trackers

Open
#1,374 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type:defect
Dominant language
TypeScript
Stars
590
Forks
232
Avg merge
2h 22m
Merged PRs (30d)
3

Description

Describe the bug
When using two trackers(A and B) on the same page and tracker A have configured:

anonymousTracking: {
    withSessionTracking: true,
}

tracker B attaches an invalid client_session entity (iglu:com.snowplowanalytics.snowplow/client_session/jsonschema/1-0-2) to all events. The entity is invalid due to the userId is empty string.
Tracker A sets a valid client_session entity with userId : "00000000-0000-0000-0000-000000000000"

To Reproduce

  • Initialize two trackers from v4 package on a simple webpage:
import { newTracker, trackPageView } from '@snowplow/browser-tracker';

const tracker_a = newTracker('tracker_a', 'https://a.example.com', {
  appId: 'my-app',
  contexts: {
    session: true,
  },
  anonymousTracking: {
    withSessionTracking: true,
  },
});

const tracker_b = newTracker('tracker_b', 'https://b.example.com', {
    appId: 'my-app',
    contexts: {
      session: true,
    },
  });

  trackPageView();
  • Load the webpage in a browser

Expected behavior
Two page views send with the client_session entity attached. Both of them should be valid.

Actual behaviour
Two page views send with the client_session entity attached. tracker_b's client_session entity is invalid because userId is empty string.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Windows 11
  • Browser: Edge
  • Version 130.0.2849.68

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
If setting the cookieName to different values on the two trackers this bug seems to go away.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two-tracker example from the issue with shared cookie settings, then inspect how each tracker creates and attaches its client_session entity. Verify the fix by confirming both page-view events contain valid entities, including a non-empty userId for tracker B.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
analytics, frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.