Skip to content

feat: enhance API token handling and playground UI notifications#360

Merged
bernirosas merged 4 commits intomainfrom
feat/allow-no-api-key-on-set-up
Apr 6, 2026
Merged

feat: enhance API token handling and playground UI notifications#360
bernirosas merged 4 commits intomainfrom
feat/allow-no-api-key-on-set-up

Conversation

@bernirosas
Copy link
Copy Markdown
Contributor

@bernirosas bernirosas commented Mar 30, 2026

  • Updated the global TS interface to make the token property optional.
  • Improved the demo HTML to include a notice for when no API token is set, informing users that events will be queued.
  • Modified the configuration form to allow for an empty token field, with a hint indicating that events will queue until a token is provided.
  • Enhanced JavaScript logic to manage event statuses based on the presence of a token, updating UI elements accordingly.
  • Added tests to ensure proper behavior when the token is missing, including capturing events and observing dynamically added elements.
Screenshot 2026-04-06 at 12 04 28 PM

These changes improve user experience and ensure better handling of API token scenarios.

- Updated the global TS interface to make the token property optional.
- Improved the demo HTML to include a notice for when no API token is set, informing users that events will be queued.
- Modified the configuration form to allow for an empty token field, with a hint indicating that events will queue until a token is provided.
- Enhanced JavaScript logic to manage event statuses based on the presence of a token, updating UI elements accordingly.
- Added tests to ensure proper behavior when the token is missing, including capturing events and observing dynamically added elements.

These changes improve user experience and ensure better handling of API token scenarios.
@bernirosas bernirosas changed the title feat: enhance API token handling and UI notifications feat: enhance API token handling and palyground UI notifications Apr 1, 2026
@bernirosas bernirosas changed the title feat: enhance API token handling and palyground UI notifications feat: enhance API token handling and playground UI notifications Apr 1, 2026
- Added a console log to notify when the API token is not set, indicating that events will be queued until the token is available. This enhances user awareness regarding token handling in the application.
@bernirosas bernirosas requested a review from anonvt April 6, 2026 16:15
Comment thread src/detector.ts
Comment thread src/detector.ts
- Updated the README to specify that if a token is not provided during library initialization, the `window.TS.token` must be set for the event queue to flush. This enhances user understanding of the token requirement for event processing.
anonvt
anonvt previously approved these changes Apr 6, 2026
Copy link
Copy Markdown
Collaborator

@anonvt anonvt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — the core design (queue pause + token watcher + drain) is sound, and the test coverage is solid. Nice UX improvement for the playground.

Left one nit on the watchForToken function.

Comment thread src/detector.ts
- Updated the README to clarify that if a token is not provided during library initialization, events will be queued until the token is set via property assignment.
- Added a warning against replacing the entire `window.TS` object after the library has loaded, as this would prevent the queued events from being sent.
- Enhanced comments in `detector.ts` to reinforce the importance of direct property assignment for setting the token.
@bernirosas bernirosas merged commit 12d18ab into main Apr 6, 2026
4 checks passed
@bernirosas bernirosas deleted the feat/allow-no-api-key-on-set-up branch April 6, 2026 19:25
@anonvt anonvt mentioned this pull request Apr 15, 2026
3 tasks
anonvt added a commit that referenced this pull request Apr 15, 2026
## Summary
- Bumps version to `2.8.0`
- Fixes jsdom localStorage test failures on Node.js 25+

## Changes since v2.7.0

### Features
- **Lazy token loading** — events queue when no API token is set and
drain automatically when `window.TS.token` is assigned later (#360)
- **Interactive playground** — new `/demo` page for testing the
analytics library (#359)

### Fixes
- Add `lang` attribute to HTML elements for a11y compliance (#355)
- Configure jsdom for Node 25+ localStorage compatibility
(`--no-experimental-webstorage`)

### Tests
- New queue tests for memory store fallback and error handling (#358)

### Housekeeping
- Dependency bumps: biome, react, express, msw, codecov-action,
checkout, deploy-pages, upload-pages-artifact, pnpm/action-setup
- Added CLAUDE.md (#354)

## Test plan
- [x] `pnpm run lint:ci` passes
- [x] `pnpm run types:check` passes
- [x] `pnpm run test` — 47/47 tests pass (17 test files)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants