Skip to content

rkmahale17/rulcode.com / .claude/skills/integration-react-native

integration-react-native

Unverified

Install and configure PostHog analytics SDK in React Native applications, including event tracking, feature flags, user identification, and error tracking. Use when the user needs to add PostHog analytics, session recording, or feature flags to a React Native app.

PostHog Integration for React Native

Set up PostHog analytics in a React Native application: install the SDK, configure the provider, implement event tracking, identify users, and add error tracking.

Workflow

Follow these steps in order:

  1. basic-integration-1.0-begin.md - PostHog Setup - Begin Start here
  2. basic-integration-1.1-edit.md - PostHog Setup - Edit
  3. basic-integration-1.2-revise.md - PostHog Setup - Revise
  4. basic-integration-1.3-conclude.md - PostHog Setup - Conclusion

Reference files

  • references/EXAMPLE.md - React Native example project code
  • references/react-native.md - React Native SDK docs
  • references/identify-users.md - User identification docs

Framework guidelines

  • Install posthog-react-native and its required peer dependency react-native-svg
  • Use react-native-config to load POSTHOG_PROJECT_TOKEN and POSTHOG_HOST from .env (embedded at build time, not runtime)
  • Place PostHogProvider INSIDE NavigationContainer for React Navigation v7 compatibility

Minimal provider setup:

import PostHog, { PostHogProvider } from 'posthog-react-native';
import Config from 'react-native-config';

const posthogClient = new PostHog(Config.POSTHOG_PROJECT_TOKEN, {
  host: Config.POSTHOG_HOST,
});

// Inside your App component, wrap content within NavigationContainer:
<NavigationContainer>
  <PostHogProvider client={posthogClient}>
    {/* app content */}
  </PostHogProvider>
</NavigationContainer>

Identifying users

Identify users during login and signup events. Pass the client-side session and distinct ID using X-POSTHOG-DISTINCT-ID and X-POSTHOG-SESSION-ID headers to maintain frontend/backend correlation. Refer to references/identify-users.md and references/EXAMPLE.md for the correct pattern.

Error tracking

Add PostHog error tracking around critical user flows and API boundaries. Capture errors with posthog.capture('$exception', { $exception_message: error.message }).

Verification

After completing the integration:

  1. Run the app and trigger a test event
  2. Confirm the event appears in the PostHog project dashboard within 60 seconds
  3. Verify user identification by checking the "Persons" tab for the identified user
deprecation-and-migrationaddyosmani/agent-skillsManages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code.Stars: 118kUpdated Claude CodeCodexVerifiedInstall
performance-optimizationaddyosmani/agent-skillsOptimizes application performance across frontend, backend, queries, and databases. Use when performance requirements exist, when you suspect performance regressions, when Core Web Vitals or load times need improvement, when N+1 query patterns need fixing, or when profiling reveals bottlenecks.Stars: 118kUpdated Claude CodeCodexVerifiedInstall
Agent Cost Reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 117kUpdated Claude CodeCodexVerifiedInstall
Agent Cost Reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 117kUpdated Claude CodeCodexVerifiedInstall