Skip to content

docs: track events from handlers, not render logic - #20

Merged
ivnbogdan merged 2 commits into
mainfrom
docs/track-events-in-handlers
Nov 5, 2026
Merged

ivnbogdan merged 2 commits into
mainfrom
docs/track-events-in-handlers

Conversation

@ivnbogdan

Copy link
Copy Markdown
Contributor

Why

Community feedback found React docs that call trackEvent from render logic. React re-renders then get counted as user activity. We're making every SDK's examples track user actions from event handlers, never from a component body or useEffect. See aptabase/aptabase-js#17 and aptabase/aptabase-com#16.

What

  • llms.txt: the useAptabase example called trackEvent("screen_viewed") directly in the component body. It now calls it from an onPress handler, with a note explaining why.
  • README.md
    • The counter now sends the updated count. Before, it sent the stale count from before setCount.
    • Added a short note on where to call trackEvent.
    • The "track an event at startup" tip now says where: right after Aptabase.init, outside any component.
  • examples/HelloWorldExpoRouter
    • init(...) was called in the RootLayout body on every render. It now runs once at module load.
    • Removed trackEvent from the font-error useEffect. The error is still thrown to the Expo Router error boundary.
    • Added a Send test event button on Tab One that calls trackEvent from its handler.

🤖 Generated with Claude Code

ivnbogdan and others added 2 commits November 5, 2026 08:45
- llms.txt: replace the useAptabase snippet that called trackEvent in the
  component body with an onPress handler, and add guidance against
  render/effect tracking.
- README: send the updated count (not the stale one) and note where to
  call trackEvent.
- HelloWorldExpoRouter: call init once at module load instead of on every
  render, drop trackEvent from useEffect, and add a 'Send test event'
  button.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ivnbogdan
ivnbogdan merged commit ed5ccdb into main Nov 5, 2026
1 check passed
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.

1 participant