Skip to content

Conversation

@luancazarine
Copy link
Collaborator

@luancazarine luancazarine commented Sep 30, 2025

Resolves #18501

Summary by CodeRabbit

  • Bug Fixes

    • Improved connectivity for event capture and query creation by correctly routing requests to public PostHog URLs when required, enhancing reliability on cloud/public instances.
  • Chores

    • Updated PostHog package to 0.2.1 and refreshed the platform SDK dependency.
    • Bumped versions of related actions (capture event, create query, get cohorts, get persons, get surveys) and the “new action performed” source for consistency.
    • No other behavioral changes.

- Bump version of @pipedream/posthog to 0.2.1 and update @pipedream/platform dependency to ^3.1.0.
- Increment action versions for capture-event, create-query, get-cohorts, get-persons, get-surveys, and new-action-performed to reflect recent changes.
- Modify _baseUrl method to support public URL generation based on authentication instance.
@vercel
Copy link

vercel bot commented Sep 30, 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 Sep 30, 2025 4:18pm
pipedream-docs-redirect-do-not-edit Ignored Ignored Sep 30, 2025 4:18pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 30, 2025

Walkthrough

This update introduces instance_url-aware request routing in PostHog app internals via a new publicUrl flag, updates two internal callers to use public URLs, bumps package and action/source versions, and updates a dependency in package.json.

Changes

Cohort / File(s) Summary
Core app: base URL and request flow
components/posthog/posthog.app.mjs
Added _baseUrl(publicUrl = false) to construct URLs based on instance_url; _makeRequest now accepts { publicUrl } and uses _baseUrl(publicUrl). Internal callers for createQuery and captureEvent route via public URL.
Action versions
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
Bumped exported version fields: capture-event 0.0.2→0.0.3; create-query 0.0.1→0.0.2; get-cohorts 0.0.1→0.0.2; get-persons 0.0.1→0.0.2; get-surveys 0.0.1→0.0.2. No logic changes.
Source version
components/posthog/sources/new-action-performed/new-action-performed.mjs
Bumped version 0.0.2→0.0.3. No logic changes.
Package metadata
components/posthog/package.json
Version 0.2.0→0.2.1; dependency update: @pipedream/platform ^3.0.3→^3.1.0.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor UserCode as Action/Source
    participant PH as PostHog App
    participant URL as _baseUrl(publicUrl)
    participant HTTP as PostHog API

    rect rgb(242, 248, 255)
    note right of UserCode: Example: createQuery / captureEvent
    UserCode->>PH: _makeRequest({ path, method, publicUrl: true, ... })
    PH->>URL: compute base URL with instance_url (publicUrl=true)
    URL-->>PH: https://<public-domain>/...
    PH->>HTTP: Request to public URL
    HTTP-->>PH: Response
    PH-->>UserCode: Result
    end

    rect rgb(248, 248, 248)
    note right of UserCode: Other calls (default)
    UserCode->>PH: _makeRequest({ path, method })
    PH->>URL: compute base URL (publicUrl=false)
    URL-->>PH: https://<instance-url>/...
    PH->>HTTP: Request to instance URL
    HTTP-->>PH: Response
    PH-->>UserCode: Result
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A whisk of URLs, hop-hop we go,
From burrowed instance to public show.
Versions nudged, dependencies fed,
Two calls now follow the carrot ahead.
I thump with joy—routes align true,
PostHog paths for every warren’s view. 🥕🐇

Pre-merge checks and finishing touches

❌ Failed checks (3 warnings)
Check name Status Explanation Resolution
Linked Issues Check ⚠️ Warning The changes only introduce a publicUrl flag in _baseUrl and apply it to two action callers (createQuery and captureEvent), but they do not update the remaining actions or any triggers to use posthog.$auth.instance_url, nor implement the default to us.posthog.com for auths missing that field. Please extend the implementation to ensure all PostHog triggers and actions read posthog.$auth.instance_url when present and default to us.posthog.com when it is absent, updating each affected module and trigger accordingly.
Out of Scope Changes Check ⚠️ Warning The pull request includes numerous version bumps for individual action modules and a package.json dependency upgrade that are unrelated to implementing instance_url support as described in the linked issue. Consider isolating the instance_url logic changes from the unrelated version and dependency updates by moving the version bumps and package.json modifications into a separate release or maintenance PR.
Description Check ⚠️ Warning The description does not follow the repository’s template because it lacks the required “## WHY” section and does not explain the motivation or context for the changes beyond referencing the issue. Please expand the description to include a “## WHY” section that outlines the motivation and background for the change, describing why using instance_url is necessary for EU and self-hosted customers.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly summarizes the primary change of making PostHog triggers and actions use the instance_url, directly reflecting the main fix described in the changeset without introducing unrelated topics.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 18501-bug-posthog-triggers-and-actions-should-use-instance_url

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
🧪 Early access (Sonnet 4.5): enabled

We are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience.

Note:

  • Public repositories are always opted into early access features.
  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.

Comment @coderabbitai help to get the list of available commands and usage tips.

@luancazarine luancazarine linked an issue Sep 30, 2025 that may be closed by this pull request
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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
components/posthog/posthog.app.mjs (1)

141-158: Remove publicUrl: true from createQuery. Query endpoints under /api/projects/:project_id/query are private REST endpoints that require authentication and the standard API domain, not the ingestion URL. Only POST-only ingestion endpoints (/i/v0/e, /batch, /flags) should set publicUrl: true. (posthog.com)

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 61d0151 and e9487e8.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (8)
  • components/posthog/actions/capture-event/capture-event.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-surveys/get-surveys.mjs (1 hunks)
  • components/posthog/package.json (2 hunks)
  • components/posthog/posthog.app.mjs (2 hunks)
  • components/posthog/sources/new-action-performed/new-action-performed.mjs (1 hunks)
⏰ 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: Publish TypeScript components
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Lint Code Base
🔇 Additional comments (11)
components/posthog/sources/new-action-performed/new-action-performed.mjs (2)

8-8: Version bump is appropriate.

The version bump from 0.0.2 to 0.0.3 correctly reflects the updated dependency behavior in the PostHog app layer.


83-91: Verified: createQuery uses instance_url for instance routing createQuery (and captureEvent) invoke _makeRequest with publicUrl: true, and _baseUrl constructs the URL from this.$auth.instance_url.

components/posthog/actions/capture-event/capture-event.mjs (2)

7-7: Version bump is appropriate.

The version bump from 0.0.2 to 0.0.3 correctly reflects the updated dependency behavior in the PostHog app layer.


54-64: Ensure captureEvent routes to the correct instance URL.

This action calls this.posthog.captureEvent() which, per PR objectives, must route to the correct PostHog instance (US, EU, or self-hosted). The AI summary indicates this method now uses publicUrl: true in the app layer, but the core implementation is not provided in this review set. The verification script in the previous file will check this.

components/posthog/actions/get-cohorts/get-cohorts.mjs (2)

7-7: Version bump is appropriate.

The version bump from 0.0.1 to 0.0.2 aligns with the package-wide updates for instance_url support.


34-41: Verify listCohorts uses the correct instance URL.

Unlike createQuery and captureEvent, listCohorts likely calls the private API and should use the instance URL without the publicUrl flag. Confirm that the base URL construction in posthog.app.mjs defaults to instance_url when publicUrl is not set.

components/posthog/actions/create-query/create-query.mjs (2)

7-7: Version bump is appropriate.

The version bump from 0.0.1 to 0.0.2 correctly reflects the package-wide instance_url routing updates.


39-49: Confirm createQuery uses instance_url routing.

This action calls this.posthog.createQuery(), which should now use publicUrl: true to route queries to the correct PostHog instance. The verification script in the first file will validate this implementation.

components/posthog/actions/get-persons/get-persons.mjs (2)

7-7: Version bump is appropriate.

The version bump from 0.0.1 to 0.0.2 aligns with the package-wide updates for instance_url support.


46-57: Verify listPersons uses the correct instance URL.

Like listCohorts, listPersons calls the private API and should use the instance URL without the publicUrl flag. Confirm that all private API methods in posthog.app.mjs correctly use instance_url for routing.

components/posthog/posthog.app.mjs (1)

79-94: LGTM: Clean implementation of publicUrl parameter propagation.

The destructuring pattern cleanly extracts publicUrl from opts and passes it through to _baseUrl(). This approach allows opt-in public URL usage per endpoint.

Copy link
Collaborator

@michelle0927 michelle0927 left a comment

Choose a reason for hiding this comment

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

LGTM!

@luancazarine luancazarine merged commit d439499 into master Oct 1, 2025
10 checks passed
@luancazarine luancazarine deleted the 18501-bug-posthog-triggers-and-actions-should-use-instance_url branch October 1, 2025 12:36
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.

[BUG] posthog triggers and actions should use instance_url

3 participants