Skip to content

Conversation

@jcortes
Copy link
Collaborator

@jcortes jcortes commented Dec 1, 2025

WHY

Resolves #19330

Summary by CodeRabbit

  • New Features

    • Added project insight management capabilities: create, retrieve, update, and list project insights.
    • Enhanced insight selection with a new property definition for insight identification.
  • Chores

    • Updated package version to 0.3.0.
    • Bumped versions of existing PostHog actions for improvements and compatibility.

✏️ Tip: You can customize this high-level summary in your review settings.

@jcortes jcortes self-assigned this Dec 1, 2025
@vercel
Copy link

vercel bot commented Dec 1, 2025

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

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
pipedream-docs Ignored Ignored Dec 1, 2025 10:15pm
pipedream-docs-redirect-do-not-edit Ignored Ignored Dec 1, 2025 10:15pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 1, 2025

Walkthrough

The 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

Cohort / File(s) Summary
Version bumps in existing actions
components/posthog/actions/capture-event/capture-event.mjs, components/posthog/actions/create-query/create-query.mjs, components/posthog/actions/get-cohorts/get-cohorts.mjs, components/posthog/actions/get-persons/get-persons.mjs, components/posthog/actions/get-surveys/get-surveys.mjs, components/posthog/sources/new-action-performed/new-action-performed.mjs
Action version increments: capture-event (0.0.5→0.0.6), create-query (0.0.4→0.0.5), get-cohorts (0.0.4→0.0.5), get-persons (0.0.4→0.0.5), get-surveys (0.0.4→0.0.5), new-action-performed (0.0.3→0.0.4). No logic changes.
New insight-related actions
components/posthog/actions/list-project-insights/list-project-insights.mjs, components/posthog/actions/get-project-insight/get-project-insight.mjs, components/posthog/actions/create-project-insight/create-project-insight.mjs, components/posthog/actions/update-project-insight/update-project-insight.mjs
New action modules for PostHog Insights API; list retrieves insights with optional filtering, get fetches a single insight with refresh option, create adds a new insight with metadata/query, update modifies an existing insight with field remapping.
JSON parsing utility
components/posthog/common/utils.mjs
Introduces parseJson(input, maxDepth = 100) function with recursive traversal, cycle detection via WeakSet, and depth guarding for safe parsing of nested JSON-like structures.
Core app and package updates
components/posthog/posthog.app.mjs, components/posthog/package.json
Adds insightId propDefinition with dynamic lookup, four new public methods (listInsights, getInsight, createInsight, updateInsight) for insight CRUD operations via REST endpoints. Package version bumped 0.2.1→0.3.0.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • parseJson utility: Verify cycle prevention logic, recursion depth handling, and JSON detection heuristics for edge cases.
  • New action implementations: Confirm correct parameter mapping (e.g., derived_name, query/tags JSON parsing) and consistent error handling across all four insight actions.
  • posthog.app.mjs method signatures: Validate REST endpoint paths and parameter passing for the four new insight methods.
  • Consistency: Ensure new actions follow existing action patterns and properly utilize the new utility.

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive The description identifies the related issue (#19330) but provides minimal additional context. While the template requires a 'WHY' section, the author has minimally satisfied this with issue reference. Expand the description to explain the business value or technical rationale for implementing these Insights API endpoints beyond the issue reference alone.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title '[ACTION] PostHog - Insights API' clearly and specifically describes the main change: implementing PostHog Insights API actions, which aligns with the changeset's introduction of four new Insights API action modules.
Linked Issues check ✅ Passed All four required Insights API operations are implemented: list-project-insights [#19330], get-project-insight [#19330], create-project-insight [#19330], and update-project-insight [#19330], meeting the linked issue's coding requirements.
Out of Scope Changes check ✅ Passed The changeset includes version bumps and a utility module (parseJson), which are in-scope supporting changes for the new Insights API functionality. No unrelated changes are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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 posthog-new-components

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
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: 3

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aca5999 and 755dfb5.

📒 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 derivedName to derived_name for the API
  • Uses utils.parseJson for query and tags consistent with the update action
  • Provides a meaningful summary with conditional insight name display
  • Returns the created insight object

69-74: Consider removing the deleted prop for create operation.

Having a deleted property 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 iterateResults for pagination with maxResults limit
  • 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 insightId propDefinition correctly:

  • Uses pagination with limit and offset
  • Provides meaningful labels with fallback chain (name || derived_name || "Insight ${value}")
  • Follows the same pattern as projectId and other prop definitions

164-197: LGTM! Insight API methods are well-structured.

All four insight methods follow the established patterns in the codebase:

  • listInsights and getInsight default to GET
  • createInsight uses POST
  • updateInsight uses PATCH

The methods correctly spread ...opts to allow passing additional parameters like params and data.

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: true for PATCH semantics
  • Provides clear summary output

Copy link
Collaborator

@lcaresia lcaresia left a 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.

Comment on lines +44 to +51
options: [
"force_cache",
"blocking",
"async",
"lazy_async",
"force_blocking",
"force_async",
],
Copy link
Collaborator

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.

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.

[ACTION] PostHog - Insights API

3 participants