getSessionId() returns session ids the tracker has already expired
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 88/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- playwright, typescript
- 領域
- analytics, frontend, testing-qa
調査の方向性
packages/sdk/src/core/tracker.ts の getSessionId() から始め、packages/tracker/src/core/tracker.ts の getOrCreateSessionId() とストレージ処理を比較します。did_session_timestamp の欠落値と期限切れの値に対する SDK のテストカバレッジを拡張しつつ、新しいセッションの動作と URL パラメータの優先順位を維持します。SDK の Playwright スイートを実行し、getSessionId()、getTrackingIds()、getTrackingParams() が期限切れのセッションを公開しなくなったことを確認します。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
The SDK helper getSessionId() (packages/sdk/src/core/tracker.ts) reads did_session from sessionStorage and returns it as-is, without checking the did_session_timestamp that the tracker writes alongside it.
The tracker itself rotates sessions after 30 minutes of inactivity — getOrCreateSessionId() compares did_session_timestamp against that window, discards the stale pair, and generates a new id. But the SDK helper ignores the timestamp, so between expiry and the tracker's next visit it returns a session id that is no longer the current one.
getTrackingIds() and getTrackingParams() inherit the problem since they delegate to getSessionId().
To Reproduce
- Load a page with the tracker and
@databuddy/sdk. - After the tracker initializes, backdate the timestamp past the expiry window:
sessionStorage.setItem("did_session_timestamp", String(Date.now() - 31 * 60 * 1000));
getSessionId(); // returns the stale id
- The tracker treats this session as expired and rotates it on the next init, but
getSessionId()keeps returning the old id. Same result ifdid_session_timestampis missing entirely.
Expected behavior
getSessionId() should apply the same rule as the tracker: null when the timestamp is missing or older than 30 minutes. Fresh sessions still return the stored id, and URL params keep priority.
Screenshots
Not applicable. The failure is a logically stale return value.
Environment (please complete the following information):
- SDK:
@databuddy/sdkat currentstaging - Browser-agnostic; reproduced through the SDK's Playwright suite
Additional context
The expiry logic lives in the tracker: packages/tracker/src/core/tracker.ts — getOrCreateSessionId() uses sessionAge < 30 * 60 * 1000. The SDK helper currently has no awareness of it.
Affected code: getSessionId() in packages/sdk/src/core/tracker.ts.
Existing tests cover empty storage, populated storage, and URL-parameter precedence, but not the expiry timestamp.
AI usage disclosure
This report was drafted with AI assistance (Claude via Qoder) for research and writing. I read the tracker and SDK sources, reproduced the mismatch in the SDK's test setup, and reviewed/edited the report before submitting.
- 主要言語
- TypeScript
- スター
- 1.2k
- フォーク
- 227
- 平均マージ
- 21時間 11分
- マージ済み PR(30日)
- 238
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
似ている issue
-
category::task code priority::normal
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
e0ipso/strikethroo#145 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 85/100
cocos/cocos-docs#3333 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
RevenueCat/react-native-purchases#2079 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
RevenueCat/purchases-hybrid-common#2039 ·
メンテナーはふだん 1 日以内に返信
-
agent-reported area/react bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信