Skip to content

add posthog#105

Merged
niklas1simakov merged 2 commits intomainfrom
feat/posthogh
Apr 19, 2026
Merged

add posthog#105
niklas1simakov merged 2 commits intomainfrom
feat/posthogh

Conversation

@ValentinAhrend
Copy link
Copy Markdown
Contributor

@ValentinAhrend ValentinAhrend commented Apr 18, 2026

Summary by CodeRabbit

  • Chores

    • Added site-wide analytics tracking for key user interactions and configured request proxying for event ingestion; added analytics runtime dependency.
    • Updated repo ignore rules to exclude .claude.
  • Refactor

    • Replaced raw contact links with a reusable partner CTA component.
  • Documentation

    • Added an analytics integration setup report.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
start-munich Ready Ready Preview, Comment Apr 19, 2026 11:38am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 18, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dc553de6-a6b3-4375-9c33-1e7483bfb7f6

📥 Commits

Reviewing files that changed from the base of the PR and between 9f0bf12 and 51c3a4e.

📒 Files selected for processing (5)
  • app/events/EventsContent.tsx
  • app/for-partners/PartnerCTAButton.tsx
  • app/startups/StartupCard.tsx
  • instrumentation-client.ts
  • next.config.js
🚧 Files skipped from review as they are similar to previous changes (5)
  • app/startups/StartupCard.tsx
  • app/for-partners/PartnerCTAButton.tsx
  • app/events/EventsContent.tsx
  • next.config.js
  • instrumentation-client.ts

📝 Walkthrough

Walkthrough

Added PostHog analytics across the app: SDK initialization, dependency, proxy rewrites, and instrumentation of multiple UI click handlers; plus a new PartnerCTAButton component, an UpcomingEventTile callback, a documentation report, and a .claude gitignore entry.

Changes

Cohort / File(s) Summary
PostHog init & infra
instrumentation-client.ts, next.config.js, package.json
New PostHog init module, Next.js rewrites proxying /ingest/* to PostHog endpoints, and added posthog-js dependency.
Event & CTA tracking
app/events/EventsContent.tsx, app/join-start/2026/JoinStartClient.tsx, app/startup-details/[id]/StartupDetailsContent.tsx, app/startups/StartupCard.tsx, components/Navigation.tsx
Inserted posthog.capture(...) calls on various click handlers (event cards, application CTAs, startup website, startup cards, navigation links).
Partner CTA component
app/for-partners/PartnerCTAButton.tsx, app/for-partners/page.tsx
Added PartnerCTAButton client component that captures partner contact clicks and replaced raw anchor usages with it.
Event tile extension
components/UpcomingEventTile.tsx
Added optional onCtaClick?: () => void prop and invoke it on CTA clicks to allow parent-level analytics.
Docs & misc
posthog-setup-report.md, .gitignore
Added PostHog integration report and added .claude to .gitignore.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI as "Client Component"
    participant SDK as "instrumentation-client"
    participant Proxy as "Next.js /ingest"
    participant PostHog as "PostHog Server"

    User->>UI: click CTA
    UI->>SDK: posthog.capture(...)
    SDK->>Proxy: POST /ingest/...
    Proxy->>PostHog: forward request
    PostHog-->>Proxy: 200 OK
    Proxy-->>SDK: 200 OK
    SDK-->>UI: capture resolved
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • SimonBurmer

Poem

🐰
I hopped through clicks and tiny logs,
Tracked each bounce and cookie-gnawed bogs,
From CTA to startup site,
I counted clicks by dusk and night —
Hooray, the metrics shine like clogs! 🎉

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'add posthog' is vague and generic, using a non-descriptive term that doesn't convey meaningful information about what aspects of PostHog integration were added or the scope of the changes. Consider a more specific title that captures the primary scope, such as 'Integrate PostHog analytics across application' or 'Add PostHog event tracking for user interactions'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch feat/posthogh

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🧹 Nitpick comments (5)
.gitignore (1)

28-28: Unrelated change in PostHog PR.

The .claude gitignore entry appears unrelated to the stated PR objective of adding PostHog analytics. Consider moving this to a separate commit/PR to keep changes focused, or confirm if this was intentionally included.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.gitignore at line 28, The .gitignore entry ".claude" is unrelated to the
PostHog analytics work; remove the ".claude" line from the current .gitignore
change or move it into a separate commit/PR so the PostHog-focused PR only
contains analytics-related changes—locate the ".claude" entry in .gitignore and
either revert that line from this commit or create a follow-up commit/PR adding
it.
app/startups/StartupCard.tsx (1)

44-44: Consider capturing category as a consistent type.

category is string[] | undefined; PostHog will store it as an array which is fine, but if the field is sometimes undefined, you may want to default it (category ?? []) for cleaner analytics filtering. Minor.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/startups/StartupCard.tsx` at line 44, The PostHog event capture in
posthog.capture('startup_card_clicked', { startup_id: id, startup_name: name,
category: category }) may record category as undefined (type string[] |
undefined); update the payload in the StartupCard component so category is
always a consistent array (e.g., use category ?? []) when calling
posthog.capture to ensure analytics stores an empty array instead of undefined
for cleaner filtering.
components/Navigation.tsx (1)

209-209: Minor: event may race with client-side navigation.

For internal Link navigation (/apply), PostHog batches events and relies on sendBeacon/fetch-keepalive on page unload. With Next.js client-side routing there's no unload, so the event should flush normally — no action required, just be aware that if you ever see this event under-counted, you can force flush with posthog.capture('nav_apply_clicked', props, { send_instantly: true }).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@components/Navigation.tsx` at line 209, The current onClick handler calls
posthog.capture('nav_apply_clicked', { location: 'desktop' }) which can race
with client-side navigation; to force immediate delivery when you want to avoid
under-counting, update the onClick for the internal Link to call
posthog.capture('nav_apply_clicked', { location: 'desktop' }, { send_instantly:
true }) (i.e., modify the onClick where posthog.capture is invoked in
Navigation.tsx) so the event is flushed immediately during client-side routing.
posthog-setup-report.md (1)

1-32: Optional: relocate or omit the wizard report.

This appears to be an auto-generated "wizard" report rather than maintained project documentation. Consider either moving it under docs/ (e.g. docs/analytics/posthog-setup.md) so it's discoverable alongside other docs, or excluding it from the repo entirely if it's meant to be a one-time setup artifact. The embedded dashboard/insight URLs (line 21–26) will also go stale quickly as events and dashboards evolve — worth noting their "as of PR #105" nature or moving them to an internal wiki.

Also, the "agent skill folder" referenced at line 30 — if that was actually committed, please confirm it's intended to ship with the repo; otherwise add it to .gitignore.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@posthog-setup-report.md` around lines 1 - 32, This autogenerated wizard
report (posthog-setup-report.md) should be removed from the repo root or moved
into documentation (e.g., docs/analytics/posthog-setup.md) so it’s discoverable
as maintained docs; update its content to mark dashboard/insight URLs as
time-bound (e.g., "as of PR `#105`") or move those links to an internal wiki to
avoid staleness; verify whether the referenced "agent skill" folder was
intentionally committed—if it should not be shipped, remove it from version
control and add it to .gitignore, otherwise add a short README inside that
folder explaining its purpose.
app/events/EventsContent.tsx (1)

321-326: LGTM — capture before navigation is safe here because of target="_blank".

Since the link opens in a new tab, the current document stays alive and the posthog.capture request won't be torn down, so no send_instantly is needed. Including location: 'featured_spotlight' as event metadata is a nice touch — the recurring-card handlers below (lines 713–716) would benefit from an analogous location property for consistency in dashboards.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/events/EventsContent.tsx` around lines 321 - 326, The event capture for
the featured spotlight link includes location: 'featured_spotlight' but the
recurring-card handlers omit a location field; update the recurring-card
posthog.capture calls that send 'event_card_clicked' so they include a
consistent location property (e.g., location: 'recurring_card' or another
appropriate identifier) to match the featured link's metadata and keep dashboard
reporting consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/events/EventsContent.tsx`:
- Around line 712-718: Replace the quad-ternary onClick logic in EventsContent
(the inline onClick that checks event.id and calls posthog.capture +
window.open) with a lookup map from event IDs to target URLs, then compute a
single handler that if a URL exists calls posthog.capture({ event_id: event.id,
event_name: event.name }) and opens the URL with window.open(url, '_blank',
'noopener,noreferrer'); this removes duplication, centralizes the id→URL mapping
(include entries for 'legal-hack', 'rtsh', 'rtss', 'start-labs') and verify the
'start-labs' URL is correct before committing.

In `@app/for-partners/PartnerCTAButton.tsx`:
- Around line 11-20: The click handler in PartnerCTAButton uses
posthog.capture('partner_contact_clicked') which can lose events on same-tab
navigation; update the onClick in PartnerCTAButton to call posthog.capture with
send_instantly: true and include the link href as metadata (e.g.,
posthog.capture('partner_contact_clicked', { href }, { send_instantly: true }))
so the event is sent immediately and contains the href for consistency with
other events like startup_website_clicked.

In `@app/startups/StartupCard.tsx`:
- Around line 1-2: This file uses client-only features (useRouter, onClick
handlers, and posthog) but lacks the Next.js client component directive; add the
"use client" directive as the very first line of StartupCard.tsx to mark the
component as a client component so useRouter and posthog work correctly, then
save and verify StartupCard's exports and imports remain unchanged.

In `@instrumentation-client.ts`:
- Around line 3-5: Remove the stray console.log and add an explicit guard around
the PostHog initialization so you never pass undefined into posthog.init: check
process.env.NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN before calling posthog.init (use
an if/else or early return), only call posthog.init when the token exists, and
handle the missing-token branch (no-op or warn via console.warn/processLogger)
instead of using the non-null assertion; reference the posthog.init call and the
NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN environment variable when making the change.
- Around line 8-14: The config currently sets persistence: 'memory' while also
setting disable_persistence: true and leaving a commented cookieless_mode, which
breaks user continuity; either remove disable_persistence to honor persistence:
'memory' and ensure posthog.identify() is called on each page load, or instead
enable cookieless_mode: 'always' (uncomment and set it) to get GDPR-friendly
cookieless tracking; finally delete the commented //cookieless_mode line if you
choose the memory approach so the config isn’t ambiguous and keep defaults:
'2026-01-30' as-is.

In `@next.config.js`:
- Around line 3-15: Add an explicit rewrite entry inside the rewrites() return
array for the PostHog array endpoint before the catch-all "/ingest/:path*" rule:
add a rule with source "/ingest/array/:path*" and destination
"https://eu-assets.i.posthog.com/array/:path*" so caching and PostHog
recommendations are respected; keep skipTrailingSlashRedirect: true as-is and
consider adding ui_host to your PostHog SDK init separately if you use
surveys/feature flags/session replay.

---

Nitpick comments:
In @.gitignore:
- Line 28: The .gitignore entry ".claude" is unrelated to the PostHog analytics
work; remove the ".claude" line from the current .gitignore change or move it
into a separate commit/PR so the PostHog-focused PR only contains
analytics-related changes—locate the ".claude" entry in .gitignore and either
revert that line from this commit or create a follow-up commit/PR adding it.

In `@app/events/EventsContent.tsx`:
- Around line 321-326: The event capture for the featured spotlight link
includes location: 'featured_spotlight' but the recurring-card handlers omit a
location field; update the recurring-card posthog.capture calls that send
'event_card_clicked' so they include a consistent location property (e.g.,
location: 'recurring_card' or another appropriate identifier) to match the
featured link's metadata and keep dashboard reporting consistent.

In `@app/startups/StartupCard.tsx`:
- Line 44: The PostHog event capture in posthog.capture('startup_card_clicked',
{ startup_id: id, startup_name: name, category: category }) may record category
as undefined (type string[] | undefined); update the payload in the StartupCard
component so category is always a consistent array (e.g., use category ?? [])
when calling posthog.capture to ensure analytics stores an empty array instead
of undefined for cleaner filtering.

In `@components/Navigation.tsx`:
- Line 209: The current onClick handler calls
posthog.capture('nav_apply_clicked', { location: 'desktop' }) which can race
with client-side navigation; to force immediate delivery when you want to avoid
under-counting, update the onClick for the internal Link to call
posthog.capture('nav_apply_clicked', { location: 'desktop' }, { send_instantly:
true }) (i.e., modify the onClick where posthog.capture is invoked in
Navigation.tsx) so the event is flushed immediately during client-side routing.

In `@posthog-setup-report.md`:
- Around line 1-32: This autogenerated wizard report (posthog-setup-report.md)
should be removed from the repo root or moved into documentation (e.g.,
docs/analytics/posthog-setup.md) so it’s discoverable as maintained docs; update
its content to mark dashboard/insight URLs as time-bound (e.g., "as of PR `#105`")
or move those links to an internal wiki to avoid staleness; verify whether the
referenced "agent skill" folder was intentionally committed—if it should not be
shipped, remove it from version control and add it to .gitignore, otherwise add
a short README inside that folder explaining its purpose.
🪄 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: CHILL

Plan: Pro

Run ID: 8e050f73-26d2-4f75-8608-2a4da8d4acdd

📥 Commits

Reviewing files that changed from the base of the PR and between 3f8459b and 9f0bf12.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (14)
  • .gitignore
  • app/events/EventsContent.tsx
  • app/for-partners/PartnerCTAButton.tsx
  • app/for-partners/page.tsx
  • app/join-start/2026/JoinStartClient.tsx
  • app/startup-details/[id]/StartupDetailsContent.tsx
  • app/startups/StartupCard.tsx
  • components/Navigation.tsx
  • components/UpcomingEventTile.tsx
  • instrumentation-client.ts
  • next.config.js
  • package.json
  • posthog-setup-report.md
  • tsconfig.tsbuildinfo

Comment thread app/events/EventsContent.tsx
Comment thread app/for-partners/PartnerCTAButton.tsx
Comment thread app/startups/StartupCard.tsx
Comment thread instrumentation-client.ts Outdated
Comment thread instrumentation-client.ts Outdated
Comment thread next.config.js
@ValentinAhrend
Copy link
Copy Markdown
Contributor Author

I think this should be fine regarding the PR comments from codeRabbit. The changes were intentional.

@niklas1simakov niklas1simakov merged commit 09287c1 into main Apr 19, 2026
3 checks passed
@niklas1simakov niklas1simakov deleted the feat/posthogh branch April 19, 2026 14:23
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