Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

getSessionId() returns session ids the tracker has already expired

オープン 初心者向け
#694 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
88/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
playwright, typescript

調査の方向性

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

  1. Load a page with the tracker and @databuddy/sdk.
  2. 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
  1. The tracker treats this session as expired and rotates it on the next init, but getSessionId() keeps returning the old id. Same result if did_session_timestamp is 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/sdk at current staging
  • 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

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。