-
Notifications
You must be signed in to change notification settings - Fork 549
posthog migration: part 4 #7366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe changes introduce standardized guidelines and implementation for analytics event reporting in the dashboard application. Documentation is added to specify naming conventions, event rationale, and ownership. A new centralized analytics module with multiple reporting functions is created. Existing components replace previous generic tracking calls with these new specific reporting functions, centralizing and standardizing analytics event handling. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ContractDeployForm
participant reportContractDeployed
participant PostHog
User->>ContractDeployForm: Submit deployment form
ContractDeployForm->>ContractDeployForm: Deploy contract logic
alt Deployment successful
ContractDeployForm->>reportContractDeployed: reportContractDeployed({address, chainId})
reportContractDeployed->>PostHog: posthog.capture("contract deployed", {address, chainId})
end
sequenceDiagram
participant User
participant PlanSelector
participant reportOnboardingPlanSelected
participant reportOnboardingPlanSelectionSkipped
participant PostHog
User->>PlanSelector: Select plan or skip
alt Plan selected
PlanSelector->>reportOnboardingPlanSelected: reportOnboardingPlanSelected({plan})
reportOnboardingPlanSelected->>PostHog: posthog.capture("onboarding plan selected", {plan})
else Plan skipped
PlanSelector->>reportOnboardingPlanSelectionSkipped: reportOnboardingPlanSelectionSkipped()
reportOnboardingPlanSelectionSkipped->>PostHog: posthog.capture("onboarding plan selection skipped")
end
sequenceDiagram
participant User
participant InviteTeamMembersUI
participant reportOnboardingMembersInvited
participant reportOnboardingMembersSkipped
participant reportOnboardingMembersUpsellButtonClicked
participant reportOnboardingMembersUpsellPlanSelected
participant PostHog
User->>InviteTeamMembersUI: Invite members / skip / upsell actions
alt Members invited
InviteTeamMembersUI->>reportOnboardingMembersInvited: reportOnboardingMembersInvited({count})
reportOnboardingMembersInvited->>PostHog: posthog.capture("onboarding members invited", {count})
else Members skipped
InviteTeamMembersUI->>reportOnboardingMembersSkipped: reportOnboardingMembersSkipped()
reportOnboardingMembersSkipped->>PostHog: posthog.capture("onboarding members skipped")
else Upsell button clicked
InviteTeamMembersUI->>reportOnboardingMembersUpsellButtonClicked: reportOnboardingMembersUpsellButtonClicked()
reportOnboardingMembersUpsellButtonClicked->>PostHog: posthog.capture("onboarding members upsell button clicked")
else Upsell plan selected
InviteTeamMembersUI->>reportOnboardingMembersUpsellPlanSelected: reportOnboardingMembersUpsellPlanSelected({plan})
reportOnboardingMembersUpsellPlanSelected->>PostHog: posthog.capture("onboarding members upsell plan selected", {plan})
end
sequenceDiagram
participant TeamInfoForm
participant InviteTeamMembers
participant reportOnboardingStarted
participant reportOnboardingCompleted
participant PostHog
TeamInfoForm->>reportOnboardingStarted: reportOnboardingStarted()
reportOnboardingStarted->>PostHog: posthog.capture("onboarding started")
InviteTeamMembers->>reportOnboardingCompleted: reportOnboardingCompleted()
reportOnboardingCompleted->>PostHog: posthog.capture("onboarding completed")
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
@coderabbitai review |
✅ Actions performedReview triggered.
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7366 +/- ##
=======================================
Coverage 52.35% 52.35%
=======================================
Files 939 939
Lines 63161 63161
Branches 4217 4217
=======================================
Hits 33070 33070
Misses 29984 29984
Partials 107 107
🚀 New features to boost your workflow:
|
size-limit report 📦
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (7)
apps/dashboard/src/components/contract-components/contract-deploy-form/custom-contract.tsx (1)
648-652
: Consider capturing failure & attempt events as wellYou now track only the successful deployment. If product analytics still care about attempt and error counts (removed in this refactor), add corresponding helpers such as
reportContractDeployAttempted
/reportContractDeployFailed
so funnel drop-off can be analysed.No action required if those metrics are intentionally dropped.
apps/dashboard/src/@/analytics/README.md (2)
14-20
: Fix Markdown table formatting (MD058)Add blank lines around the table for proper rendering and to silence
markdownlint
.-## 2. Naming conventions -| Concept | Convention | Example | +## 2. Naming conventions + +| Concept | Convention | Example | -|---------|------------|---------| +|---------|------------|---------| -| **Reporting function** | `report<Subject><Verb>` (PascalCase) | `reportContractDeployed` | -| **File** | All event functions live in the shared `report.ts` file (for now) | — | +| **Reporting function** | `report<Subject><Verb>` (PascalCase) | `reportContractDeployed` | +| **File** | All event functions live in the shared `report.ts` file (for now) | — | +
44-48
: Minor punctuation nitComma before so connects two independent clauses.
-1. **Explain the "why".** The JSDoc block is mandatory so future contributors know the purpose. +1. **Explain the "why".** The JSDoc block is mandatory, so future contributors know the purpose.AGENTS.md (2)
107-141
: Duplicate guidance now exists in two places – consider DRYing the docsThe “Analytics Event Reporting” section here is copy-pasted almost verbatim into
.cursor/rules/dashboard.mdc
. Duplicating normative rules in multiple files invites drift and conflicting edits down the road.Recommend keeping a single source of truth (e.g. the rules file) and linking to it from other docs, or extracting the shared block into a Markdown include.
123-137
: Example violates the repo’s own TypeScript style rule (#29)Rule 3. 29 says: “Write idiomatic TypeScript: explicit function declarations and return types.”
The snippet omits an explicitvoid
return type.-export function reportContractDeployed(properties: { +export function reportContractDeployed(properties: { address: string; chainId: number; -}) { +}): void { posthog.capture("contract deployed", properties); }A tiny change, but it keeps the example aligned with the documented standard.
.cursor/rules/dashboard.mdc (2)
104-113
: Avoid maintaining identical rule text in multiple guideline filesThis block duplicates the “Analytics Event Reporting” rules already present in
AGENTS.md
. Two sources of truth become stale fast—prefer a single canonical location and reference it elsewhere.
122-127
: Add explicitvoid
return type in the exampleConsistent with the project’s TypeScript style guide, append
: void
:-export function reportContractDeployed(properties: { +export function reportContractDeployed(properties: { address: string; chainId: number; -}) { +}): void { posthog.capture("contract deployed", properties); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
.cursor/rules/dashboard.mdc
(1 hunks)AGENTS.md
(1 hunks)apps/dashboard/src/@/analytics/README.md
(1 hunks)apps/dashboard/src/@/analytics/report.ts
(1 hunks)apps/dashboard/src/components/contract-components/contract-deploy-form/custom-contract.tsx
(3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/dashboard/src/components/contract-components/contract-deploy-form/custom-contract.tsx (1)
apps/dashboard/src/@/analytics/report.ts (1)
reportContractDeployed
(12-20)
🪛 LanguageTool
apps/dashboard/src/@/analytics/README.md
[uncategorized] ~46-~46: Use a comma before ‘so’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...he "why".** The JSDoc block is mandatory so future contributors know the purpose. ...
(COMMA_COMPOUND_SENTENCE_2)
🪛 markdownlint-cli2 (0.17.2)
apps/dashboard/src/@/analytics/README.md
15-15: Tables should be surrounded by blank lines
null
(MD058, blanks-around-tables)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Graphite / mergeability_check
- GitHub Check: Size
🔇 Additional comments (1)
apps/dashboard/src/@/analytics/report.ts (1)
1-1
: ```shell
#!/bin/bash
echo "=== Usages of analytics/report.ts ==="
rg -n "analytics/report" .echo
echo "=== TSConfig paths ==="
if [ -f tsconfig.json ]; then
rg -n ""paths"" tsconfig.json -A 5
else
echo "tsconfig.json not found"
fiecho
echo "=== Next.config.js alias ==="
if [ -f next.config.js ]; then
rg -n "alias" next.config.js -A 5
else
echo "next.config.js not found"
fi</details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
912f4bb
to
8e3d9b9
Compare
50192f2
to
beca7ef
Compare
f005dd2
to
74ce5f7
Compare
b1e03cb
to
0a882e9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Missing Analytics Event for Plan Upgrades
The analytics event for successful plan upgrades is missing. The trackEvent
call for teamOnboarding/upgradePlan/success
was removed from the useStripeRedirectEvent
callback, which previously tracked when a user's billingPlan
became non-free after a Stripe redirect. This successful upgrade event was not replaced by the new analytics system, leading to a loss of critical conversion data for onboarding plan upgrades.
apps/dashboard/src/app/(app)/get-started/team/[team_slug]/select-plan/_components/plan-selector.tsx#L24-L36
Bug: Stripe Redirect Fails to Capture Plan Upgrade Event
The tracking event for successful plan upgrades is missing after a Stripe redirect during the team onboarding member invitation step. Previously, the teamOnboarding
upgradePlan
success
event, including the upgraded plan name, was reported when a team's billing plan became non-free after returning from Stripe checkout. This conversion event is no longer captured.
apps/dashboard/src/app/(app)/login/onboarding/team-onboarding/InviteTeamMembers.tsx#L53-L62
js/apps/dashboard/src/app/(app)/login/onboarding/team-onboarding/InviteTeamMembers.tsx
Lines 53 to 62 in 74ce5f7
await pollWithTimeout({ | |
shouldStop: async () => { | |
const team = await props.getTeam(); | |
const isNonFreePlan = | |
team.billingPlan !== "free" && team.billingPlan !== "starter"; | |
return isNonFreePlan; | |
}, | |
timeoutMs: 5000, | |
}); |
Was this report helpful? Give feedback by reacting with 👍 or 👎
Merge activity
|
# Analytics Event Reporting System This PR introduces a structured analytics event reporting system for the dashboard app using PostHog. It provides clear guidelines and standardized patterns for tracking user actions. ## Key Features - Added a centralized analytics reporting system in `src/@/analytics/report.ts` - Implemented standardized naming conventions for events (`<subject> <verb>`) and reporting functions (`report<Subject><Verb>`) - Created comprehensive documentation in `apps/dashboard/src/@/analytics/README.md` - Added mandatory JSDoc requirements to document the purpose and ownership of each event - Integrated the first event: `reportContractDeployed` to track contract deployments - Updated the contract deployment form to use the new analytics system ## Guidelines - Events should only be added when they answer concrete product/business questions - All events must include typed properties and proper documentation - Analytics code is client-side only (never import `posthog-js` in server components) - Developers should notify #core-services before renaming or removing events This standardized approach will make our analytics more maintainable, discoverable, and purposeful. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Documentation** - Added comprehensive guidelines and a README for analytics event reporting, including naming conventions, usage examples, and requirements for event tracking in the dashboard app. - **New Features** - Introduced new analytics events covering contract deployments and multiple stages of team onboarding, such as plan selection, member invitations, and onboarding completion. - **Refactor** - Centralized analytics reporting by replacing generic event tracking with dedicated reporting functions across contract deployment and team onboarding flows. - Removed redundant and granular event tracking calls, simplifying analytics integration and improving consistency. <!-- end of auto-generated comment: release notes by coderabbit.ai --> <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on enhancing analytics event reporting for onboarding and contract deployment processes across the application, ensuring better tracking of user interactions and feedback. ### Detailed summary - Added `.eslintignore` entries for markdown files. - Updated `InviteTeamMembers` and `InviteSection` to report success counts on invites. - Introduced new reporting functions in `report.ts` for onboarding and contract events. - Removed unused `trackEvent` calls, replacing them with specific reporting functions. - Enhanced documentation for analytics guidelines and event reporting in `README.md` files. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
0a882e9
to
d9eee50
Compare
74ce5f7
to
2aa9ce5
Compare
Analytics Event Reporting System
This PR introduces a structured analytics event reporting system for the dashboard app using PostHog. It provides clear guidelines and standardized patterns for tracking user actions.
Key Features
src/@/analytics/report.ts
<subject> <verb>
) and reporting functions (report<Subject><Verb>
)apps/dashboard/src/@/analytics/README.md
reportContractDeployed
to track contract deploymentsGuidelines
posthog-js
in server components)This standardized approach will make our analytics more maintainable, discoverable, and purposeful.
Summary by CodeRabbit
Documentation
New Features
Refactor
PR-Codex overview
This PR focuses on enhancing analytics event reporting for onboarding processes and contract deployments using
posthog
. It introduces new reporting functions, updates existing components to utilize these functions, and improves error handling.Detailed summary
src/@/analytics/report.ts
for onboarding and contract events.InviteTeamMembers
andTeamInfoForm
components to report onboarding events.useTrack
and replaced it with specific reporting functions.parseError
function to return strings for error messages.Feedback
component.InviteSection
to pass success count on invite completion.AGENTS.md
andREADME.md
.