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 multiple trackers #1374

Open
dkbrkjni opened this issue Nov 8, 2024 · 1 comment
Open

Invalid client_session entity with multiple trackers #1374

dkbrkjni opened this issue Nov 8, 2024 · 1 comment
Labels
type:defect Bugs or weaknesses. The issue has to contain steps to reproduce.

Comments

@dkbrkjni
Copy link

dkbrkjni commented Nov 8, 2024

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.

@dkbrkjni dkbrkjni added the type:defect Bugs or weaknesses. The issue has to contain steps to reproduce. label Nov 8, 2024
@matus-tomlein
Copy link
Contributor

matus-tomlein commented Nov 11, 2024

Hi @dkbrkjni, thank you for reporting the issue! I can confirm that this is the case and is a bug in the tracker.

The reason for this is that both initialized trackers share the same cookie value for user and session information. Since one tracker has anonymous tracking enabled, it omits writing the user id in the cookie. The other tracker is not aware of the anonymous tracking setting, so thinks the empty user id is valid.

If you are running into this problem and are looking for a workaround, setting the cookieName property in the newTracker call will enable you to make each tracker use a different cookie and thus not conflict on the anonymous tracking config. But this will also mean that the trackers will track different user and session identifiers.

We will look into fixing the issue.

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

2 participants