snowplow / snowplow/snowplow-javascript-tracker

Renew sessionId if expired

Open
#1,420 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Is your feature request related to a problem? Please describe.
We have two use cases that are based on a Snowplow session:

  • Track an A/B Test experiment event - only once per session
  • Tracking event sampling - sampling is calculated once per session

To implement the two use cases, we have two local storage values, where we track whether we already reported an experiment and whether a specific event action is sampled or not. OnSessionUpdateCallback, we delete the two values, and they are re-evaluated on the next event.

The Problem is that a snowplow session is only updated on tracking events. As our logic comes first, the session is not renewed yet (if expired) and the state is as it was. This has the following impact for our use cases:

  • A/B Test: No event is sent because the state still says the experiment was already reported. Even if the Snowplow session has expired and would renew now.
  • Sampling: The event will be tracked if the session had sampling on. If the session has expired, it renews immediately, and the event is sent for the new session. At the same time, our state is reset, and the next tracking event reevaluates the sampling and could disable it for the session, so we will end up with only one event for the session.

Describe the solution you'd like
An exposed function, similar to newSession(), renews the session only if it has expired. Our code could invoke this function before making a session-dependent decision or action.

Alternative: Sampling for specific events (and actions) is possible within Snowplow. This would only solve the sampling use case.

Please let us know what you think and if there is already such a logic we can use. We would also be open to a call to talk more about our use cases.

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 reviewing the existing newSession() logic and the session update behavior in this tracker. Determine how expiration is detected and define an exposed operation that renews only expired sessions, then verify that session-dependent decisions can call it before tracking; resolve the alternative sampling approach with maintainers.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
analytics
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.