Skip to content

posthog tracking for subscription created event#6

Merged
saikumarbt merged 1 commit into
mainfrom
posthog-tracking-for-subscription-created-event
Jul 7, 2026
Merged

posthog tracking for subscription created event#6
saikumarbt merged 1 commit into
mainfrom
posthog-tracking-for-subscription-created-event

Conversation

@saikumarbt

Copy link
Copy Markdown
Owner

No description provided.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

Summary by CodeRabbit

  • New Features

    • Added a subscription creation flow with a modal form for name, price, payment method, frequency, and category.
    • The home tab now lets you add subscriptions directly and view live subscription data.
    • The subscriptions tab is now fully interactive, with search, expandable cards, and empty-state messaging.
  • Bug Fixes

    • Improved app sign-in and sign-out tracking for more reliable analytics.
    • Added smarter icon handling so subscription cards display better for wallet-based entries.

Walkthrough

This PR adds a SubscriptionsContext for managing subscriptions state, a new CreateSubscriptionModal for creating subscriptions, updates the home and subscriptions tabs to use this context with search/filtering, extends icon resolution with brand keyword matching, adds a wallet-icon fallback style to SubscriptionCard, and refines PostHog analytics capture for sign-up, sign-in/sign-out transitions, and subscription creation.

Changes

Subscriptions feature and analytics

Layer / File(s) Summary
Subscriptions context and provider
context/SubscriptionsContext.tsx, app/_layout.tsx
Adds SubscriptionsContext with state seeded from HOME_SUBSCRIPTIONS, addSubscription, memoized value, useSubscriptions hook, and wraps RootLayoutContent with SubscriptionsProvider.
Icon resolution and card rendering
constants/icons.ts, components/SubscriptionCard.tsx
Adds netflix icon, IconKey type, and resolveSubscriptionIcon keyword matcher with wallet fallback; SubscriptionCard renders a tinted tile when the fallback wallet icon is used.
CreateSubscriptionModal component
components/CreateSubscriptionModal.tsx, type.d.ts
New modal for creating subscriptions with form state, validation, category/frequency selectors, PostHog subscription_created capture, and CreateSubscriptionModalProps type.
Home and subscriptions tab wiring
app/(tabs)/index.tsx, app/(tabs)/subscriptions.tsx
Home tab uses context subscriptions and wires the create modal; Subscriptions tab becomes a searchable list with filtering and card expansion via SubscriptionsContext.
PostHog auth analytics
app/(auth)/sign-up.tsx, app/_layout.tsx
Captures user_signed_up on sign-up completion and refines user_signed_in/user_signed_out capture using a wasSignedIn ref to avoid firing on initial unknown state.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CreateSubscriptionModal
  participant PostHog
  participant SubscriptionsContext
  participant IndexTab

  User->>CreateSubscriptionModal: open modal, fill form, submit
  CreateSubscriptionModal->>CreateSubscriptionModal: validate name and price
  CreateSubscriptionModal->>PostHog: capture("subscription_created")
  CreateSubscriptionModal->>SubscriptionsContext: onCreate(subscription)
  SubscriptionsContext->>SubscriptionsContext: addSubscription prepends new item
  SubscriptionsContext-->>IndexTab: updated subscriptions list
  IndexTab-->>User: renders updated FlatList
Loading

Possibly related PRs

Poem

A rabbit hops with modal glee,
New subscriptions, plain to see 🐰
Icons matched by name so keen,
PostHog watching every scene.
Hop, capture, add, and cheer—
Another feature landed here! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive No substantive description was provided, so there is not enough detail to evaluate the change summary. Add a brief PR description that explains the main behavior changes and why they were made.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change around PostHog tracking for subscription creation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch posthog-tracking-for-subscription-created-event

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/(auth)/sign-up.tsx (1)

46-56: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Move user_signed_up after finalize() succeeds. posthog.capture("user_signed_up") runs before signUp.finalize(), so a failed or aborted finalize can still emit a success event. PostHog merges anonymous events on identify(), so attribution here isn’t the issue.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/`(auth)/sign-up.tsx around lines 46 - 56, Move the PostHog success event
so it only fires after signUp.finalize() completes successfully. In sign-up.tsx,
update the signUp.status === "complete" flow to await finalize first, then call
posthog.capture("user_signed_up") only on success; keep the existing navigation
logic inside the finalize navigate callback and avoid emitting the event before
finalize can fail or abort.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@context/SubscriptionsContext.tsx`:
- Around line 20-42: `SubscriptionsProvider` currently keeps `subscriptions`
only in `useState`, so added items disappear after reload. Update the provider
to persist and hydrate the list (for example by loading/saving through
AsyncStorage) inside `SubscriptionsProvider`, `useMemo`, and `addSubscription`,
so the initial state is restored on mount and every update is written back. If
persistence is intentionally out of scope, make sure that is explicitly handled
elsewhere in the stack; otherwise wire it in here.

---

Outside diff comments:
In `@app/`(auth)/sign-up.tsx:
- Around line 46-56: Move the PostHog success event so it only fires after
signUp.finalize() completes successfully. In sign-up.tsx, update the
signUp.status === "complete" flow to await finalize first, then call
posthog.capture("user_signed_up") only on success; keep the existing navigation
logic inside the finalize navigate callback and avoid emitting the event before
finalize can fail or abort.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 91b41152-9350-4f4d-97fb-5bfff750f71a

📥 Commits

Reviewing files that changed from the base of the PR and between a3a6659 and 636b093.

📒 Files selected for processing (9)
  • app/(auth)/sign-up.tsx
  • app/(tabs)/index.tsx
  • app/(tabs)/subscriptions.tsx
  • app/_layout.tsx
  • components/CreateSubscriptionModal.tsx
  • components/SubscriptionCard.tsx
  • constants/icons.ts
  • context/SubscriptionsContext.tsx
  • type.d.ts

Comment on lines +20 to +42
export const SubscriptionsProvider = ({
children,
}: {
children: ReactNode;
}) => {
const [subscriptions, setSubscriptions] =
useState<Subscription[]>(HOME_SUBSCRIPTIONS);

const addSubscription = useCallback((subscription: Subscription) => {
setSubscriptions((current) => [subscription, ...current]);
}, []);

const value = useMemo(
() => ({ subscriptions, addSubscription }),
[subscriptions, addSubscription],
);

return (
<SubscriptionsContext.Provider value={value}>
{children}
</SubscriptionsContext.Provider>
);
};

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Subscriptions are lost on reload — no persistence.

SubscriptionsProvider only holds state in memory via useState. Since this PR is what actually enables users to create subscriptions (previously all data was static demo content), any subscription a user adds disappears on app restart/reload. For a subscription-tracker app this materially undermines the value of the new feature.

Consider persisting subscriptions (e.g., AsyncStorage) with hydration on mount, or confirm this is explicitly deferred to a later PR in the stack.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@context/SubscriptionsContext.tsx` around lines 20 - 42,
`SubscriptionsProvider` currently keeps `subscriptions` only in `useState`, so
added items disappear after reload. Update the provider to persist and hydrate
the list (for example by loading/saving through AsyncStorage) inside
`SubscriptionsProvider`, `useMemo`, and `addSubscription`, so the initial state
is restored on mount and every update is written back. If persistence is
intentionally out of scope, make sure that is explicitly handled elsewhere in
the stack; otherwise wire it in here.

@saikumarbt
saikumarbt merged commit 9559d95 into main Jul 7, 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