Skip to content

Conversation

Amit91848
Copy link
Contributor

TODO before merge/release

  • Verify posthog keys are correct in prod .env
    • NEXT_PUBLIC_POSTHOG_KEY NEXT_PUBLIC_POSTHOG_HOST

What does this PR do?

Upgrades the posthog package and adds tracking for cal.ai banner.

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

@Amit91848 Amit91848 requested a review from a team as a code owner October 10, 2025 06:07
@graphite-app graphite-app bot requested a review from a team October 10, 2025 06:07
@keithwillcode keithwillcode added the core area: core, team members only label Oct 10, 2025
Copy link
Contributor

coderabbitai bot commented Oct 10, 2025

Walkthrough

This change updates PostHog dependencies (posthog-js to ^1.274.1 and posthog-node to ^5.9.5), removes the PostHog initialization option persistence: "memory", and adds analytics event capture across several UI components. BuyNumberDialog now captures calai_phone_number_purchased on successful purchase and calai_buy_number_button_clicked with agentId, workflowId, and teamId on click. PhoneNumberTab captures a Buy button click event when not readOnly. CalAiBanner captures events on banner dismissal and on “Try Now.” No exported/public API changes were made.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly states the two main changes—upgrading the PostHog package and adding Cal.ai banner tracking—using concise language and common commit prefix conventions making it easy to understand at a glance.
Description Check ✅ Passed The description succinctly outlines the purpose of the PR by noting the PostHog upgrade and banner tracking addition, and includes relevant pre-merge tasks and checkboxes, making it clearly related to the changes in the pull request.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/track_events_for_posthog

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.

@dosubot dosubot bot added ai area: AI, cal.ai ⬆️ dependencies Pull requests that update a dependency file labels Oct 10, 2025
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST || "https://us.i.posthog.com",
autocapture: false,
person_profiles: "never",
persistence: "memory",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Incase of memory, it tracks as a different person every time you refresh the page/open in new tab. Not good for analysing funnels / tracking movements.
now it stores it as localStorage + cookie.
For more info: https://posthog.com/docs/libraries/js/persistence

Copy link
Contributor

@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: 1

🧹 Nitpick comments (2)
packages/features/ee/workflows/components/agent-configuration/components/dialogs/BuyNumberDialog.tsx (1)

31-31: Consider capturing context with the purchase event.

The purchase success event currently doesn't include context properties like agentId, workflowId, and teamId, which could be valuable for analytics and understanding the purchase flow. These properties are available in the component and are captured in the button click event (line 122).

Apply this diff to add context to the purchase event:

-        posthog.capture("calai_phone_number_purchased");
+        posthog.capture("calai_phone_number_purchased", { agentId, workflowId, teamId });
packages/features/ee/workflows/components/agent-configuration/components/tabs/PhoneNumberTab.tsx (1)

279-283: Consider capturing context with the modal opened event.

For consistency with the calai_buy_number_button_clicked event in BuyNumberDialog.tsx (line 122) and to provide better analytics insights, consider capturing agentId, workflowId, and teamId with this event as well. These properties are available in the component scope.

Apply this diff to add context:

-                posthog.capture("calai_buy_number_modal_opened");
+                posthog.capture("calai_buy_number_modal_opened", { agentId, workflowId, teamId });
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 3bcce02 and 63ffebb.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (5)
  • apps/web/package.json (1 hunks)
  • packages/features/ee/event-tracking/lib/posthog/provider.tsx (0 hunks)
  • packages/features/ee/workflows/components/agent-configuration/components/dialogs/BuyNumberDialog.tsx (3 hunks)
  • packages/features/ee/workflows/components/agent-configuration/components/tabs/PhoneNumberTab.tsx (2 hunks)
  • packages/features/shell/CalAiBanner.tsx (2 hunks)
💤 Files with no reviewable changes (1)
  • packages/features/ee/event-tracking/lib/posthog/provider.tsx
🧰 Additional context used
📓 Path-based instructions (3)
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Always use t() for text localization in frontend code; direct text embedding should trigger a warning

Files:

  • packages/features/shell/CalAiBanner.tsx
  • packages/features/ee/workflows/components/agent-configuration/components/dialogs/BuyNumberDialog.tsx
  • packages/features/ee/workflows/components/agent-configuration/components/tabs/PhoneNumberTab.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

Files:

  • packages/features/shell/CalAiBanner.tsx
  • packages/features/ee/workflows/components/agent-configuration/components/dialogs/BuyNumberDialog.tsx
  • packages/features/ee/workflows/components/agent-configuration/components/tabs/PhoneNumberTab.tsx
**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.

Files:

  • packages/features/shell/CalAiBanner.tsx
  • packages/features/ee/workflows/components/agent-configuration/components/dialogs/BuyNumberDialog.tsx
  • packages/features/ee/workflows/components/agent-configuration/components/tabs/PhoneNumberTab.tsx
🧬 Code graph analysis (1)
packages/features/shell/CalAiBanner.tsx (1)
packages/lib/webstorage.ts (1)
  • localStorage (6-36)
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Install dependencies / Yarn install & cache
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (4)
packages/features/shell/CalAiBanner.tsx (1)

4-4: LGTM! Analytics tracking added for banner interactions.

The PostHog event tracking is correctly implemented for the banner dismissal and "Try Now" actions. The event names follow a consistent naming convention with the calai_ prefix.

Also applies to: 20-20, 26-26

packages/features/ee/workflows/components/agent-configuration/components/dialogs/BuyNumberDialog.tsx (2)

1-2: LGTM! PostHog import added.


122-122: LGTM! Button click event properly captures context.

The event correctly includes agentId, workflowId, and teamId for analytics tracking, and it's appropriately guarded by the conditional check on lines 119-121.

packages/features/ee/workflows/components/agent-configuration/components/tabs/PhoneNumberTab.tsx (1)

1-1: LGTM! PostHog import added.

Copy link
Contributor

E2E results are ready!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai area: AI, cal.ai core area: core, team members only ⬆️ dependencies Pull requests that update a dependency file ready-for-e2e size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants