-
Notifications
You must be signed in to change notification settings - Fork 5.6k
[ACTION] PostHog - Insights API #19346
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
base: master
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
WalkthroughThe pull request adds support for PostHog Insights API operations: four new action modules for listing, getting, creating, and updating project insights, accompanied by a JSON parsing utility. Existing action versions are bumped, the core PostHog app integration is enhanced with new methods, and the package version is incremented to 0.3.0. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
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: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (13)
components/posthog/actions/capture-event/capture-event.mjs(1 hunks)components/posthog/actions/create-project-insight/create-project-insight.mjs(1 hunks)components/posthog/actions/create-query/create-query.mjs(1 hunks)components/posthog/actions/get-cohorts/get-cohorts.mjs(1 hunks)components/posthog/actions/get-persons/get-persons.mjs(1 hunks)components/posthog/actions/get-project-insight/get-project-insight.mjs(1 hunks)components/posthog/actions/get-surveys/get-surveys.mjs(1 hunks)components/posthog/actions/list-project-insights/list-project-insights.mjs(1 hunks)components/posthog/actions/update-project-insight/update-project-insight.mjs(1 hunks)components/posthog/common/utils.mjs(1 hunks)components/posthog/package.json(1 hunks)components/posthog/posthog.app.mjs(2 hunks)components/posthog/sources/new-action-performed/new-action-performed.mjs(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-20T01:01:02.970Z
Learnt from: js07
Repo: PipedreamHQ/pipedream PR: 18744
File: components/slack_v2/actions/send-large-message/send-large-message.mjs:49-64
Timestamp: 2025-10-20T01:01:02.970Z
Learning: In components/slack_v2/actions/send-large-message/send-large-message.mjs, the metadata_event_payload prop is typed as string, so the code only needs to handle string-to-JSON parsing and does not need to handle object inputs.
Applied to files:
components/posthog/actions/capture-event/capture-event.mjs
🧬 Code graph analysis (4)
components/posthog/actions/create-project-insight/create-project-insight.mjs (3)
components/posthog/actions/get-project-insight/get-project-insight.mjs (1)
insight(72-80)components/posthog/actions/update-project-insight/update-project-insight.mjs (1)
insight(99-112)components/posthog/sources/new-action-performed/new-action-performed.mjs (1)
query(61-61)
components/posthog/actions/get-project-insight/get-project-insight.mjs (2)
components/posthog/actions/create-project-insight/create-project-insight.mjs (1)
insight(89-101)components/posthog/actions/update-project-insight/update-project-insight.mjs (1)
insight(99-112)
components/posthog/actions/update-project-insight/update-project-insight.mjs (3)
components/posthog/actions/create-project-insight/create-project-insight.mjs (1)
insight(89-101)components/posthog/actions/get-project-insight/get-project-insight.mjs (1)
insight(72-80)components/posthog/sources/new-action-performed/new-action-performed.mjs (1)
query(61-61)
components/posthog/posthog.app.mjs (1)
components/posthog/sources/new-action-performed/new-action-performed.mjs (1)
limit(81-91)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: pnpm publish
- GitHub Check: Lint Code Base
- GitHub Check: Publish TypeScript components
- GitHub Check: Verify TypeScript components
🔇 Additional comments (15)
components/posthog/actions/create-query/create-query.mjs (1)
7-7: Version bump aligns with package update.The metadata version increment is appropriate and consistent with the broader PR changes.
components/posthog/package.json (1)
3-3: Minor version bump is appropriate.The 0.2.1 → 0.3.0 increment correctly reflects the addition of new Insights API features while maintaining backward compatibility.
components/posthog/sources/new-action-performed/new-action-performed.mjs (1)
8-8: Version bump is consistent with package-wide update.components/posthog/actions/get-persons/get-persons.mjs (1)
7-7: Version bump is consistent.components/posthog/actions/get-surveys/get-surveys.mjs (1)
7-7: Version bump is consistent.components/posthog/actions/get-cohorts/get-cohorts.mjs (1)
7-7: Version bump is consistent.components/posthog/actions/capture-event/capture-event.mjs (1)
7-7: Version bump is consistent.components/posthog/actions/get-project-insight/get-project-insight.mjs (2)
1-14: Action metadata is well-defined.The annotations correctly reflect a read-only, idempotent GET operation, and the documentation link follows the established pattern.
63-85: Implementation follows established patterns.The run method correctly:
- Destructures props for clarity
- Converts camelCase to snake_case for the API call (
from_dashboard)- Exports a user-friendly summary
- Returns the API response
components/posthog/actions/create-project-insight/create-project-insight.mjs (2)
76-107: Implementation looks correct and consistent.The action correctly:
- Destructures props and maps
derivedNametoderived_namefor the API- Uses
utils.parseJsonforqueryandtagsconsistent with the update action- Provides a meaningful summary with conditional insight name display
- Returns the created insight object
69-74: Consider removing thedeletedprop for create operation.Having a
deletedproperty when creating a new insight is semantically unusual—users wouldn't typically create an insight already marked as deleted. If this is intentional for API parity, consider documenting this use case in the description.⛔ Skipped due to learnings
Learnt from: nurul3101 Repo: PipedreamHQ/pipedream PR: 18092 File: components/prisma_management_api/README.md:24-31 Timestamp: 2025-08-19T09:02:18.222Z Learning: In Prisma Management API documentation, the "Create Database" section title is intentional and should not be changed to "Create Project", even though the action technically creates a complete project with database. This naming choice follows user-facing terminology preferences.Learnt from: jcortes Repo: PipedreamHQ/pipedream PR: 14467 File: components/gainsight_px/actions/create-account/create-account.mjs:4-6 Timestamp: 2024-10-30T15:24:39.294Z Learning: In `components/gainsight_px/actions/create-account/create-account.mjs`, the action name should be "Create Account" instead of "Create Memory".components/posthog/actions/list-project-insights/list-project-insights.mjs (1)
60-86: LGTM!The list action is well-implemented:
- Correctly uses
iterateResultsfor pagination withmaxResultslimit- Annotations accurately reflect read-only, idempotent behavior
- Summary message properly handles singular/plural forms
- Props are well-documented with appropriate defaults
components/posthog/posthog.app.mjs (2)
70-92: LGTM! Insight ID prop definition follows established patterns.The
insightIdpropDefinition correctly:
- Uses pagination with
limitandoffset- Provides meaningful labels with fallback chain (
name || derived_name || "Insight ${value}")- Follows the same pattern as
projectIdand other prop definitions
164-197: LGTM! Insight API methods are well-structured.All four insight methods follow the established patterns in the codebase:
listInsightsandgetInsightdefault to GETcreateInsightuses POSTupdateInsightuses PATCHThe methods correctly spread
...optsto allow passing additional parameters likeparamsanddata.components/posthog/actions/update-project-insight/update-project-insight.mjs (1)
85-116: Overall implementation is correct and consistent.The action:
- Correctly chains prop dependencies (organizationId → projectId → insightId)
- Uses consistent field mapping with
create-project-insight- Properly sets
idempotentHint: truefor PATCH semantics- Provides clear summary output
components/posthog/actions/update-project-insight/update-project-insight.mjs
Show resolved
Hide resolved
lcaresia
left a comment
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.
Hey, just need to move to a constants.mjs file, moving to QA.
| options: [ | ||
| "force_cache", | ||
| "blocking", | ||
| "async", | ||
| "lazy_async", | ||
| "force_blocking", | ||
| "force_async", | ||
| ], |
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.
Move this to a constants.mjs file.
WHY
Resolves #19330
Summary by CodeRabbit
New Features
Chores
✏️ Tip: You can customize this high-level summary in your review settings.