Skip to content

refactor(host): route #746's host resolution through HostResolution#749

Merged
rafaeelaudibert merged 1 commit into
feat/base-url-overridefrom
posthog-code/host-resolution-class
Jun 30, 2026
Merged

refactor(host): route #746's host resolution through HostResolution#749
rafaeelaudibert merged 1 commit into
feat/base-url-overridefrom
posthog-code/host-resolution-class

Conversation

@gewenyu99

@gewenyu99 gewenyu99 commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

Introduces HostResolution and points #746's own host-resolution code at it — minimal, meant to merge into #746 and release with it.

Where #746 resolves a PostHog origin via the loose getHost/getCloudUrl/getLlmGatewayUrl/detectRegion(region, baseUrl) helpers, it now goes through HostResolution instead:

  • auth-time region+host resolution (setup-utils)
  • the LLM gateway (agent-interface, mcp-prompt-streaming)
  • the region→app-url derivations (linear, audit, events-audit, posthog-integration, AiOptIn)

Credentials.host stays a string here. Flipping it to the object and migrating every other consumer is the stacked PR (#755), so this stays minimal and doesn't grow #746.

Stacked on #746 (feat/base-url-override).

@github-actions

Copy link
Copy Markdown

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci basic-integration
  • /wizard-ci error-tracking-upload-source-maps
  • /wizard-ci mcp-analytics
  • /wizard-ci misc
  • /wizard-ci revenue

Test an individual app:

  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
Show more apps
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci error-tracking-upload-source-maps/android
  • /wizard-ci error-tracking-upload-source-maps/cicd-docker-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-github-actions-docker-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-github-actions-nested-docker-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-github-actions-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-github-actions-single-stage-docker-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-gitlab-node-raw
  • /wizard-ci error-tracking-upload-source-maps/cicd-monorepo-pnpm-node-react
  • /wizard-ci error-tracking-upload-source-maps/cicd-monorepo-raw-node-react
  • /wizard-ci error-tracking-upload-source-maps/cicd-ssh-vps-node-raw
  • /wizard-ci error-tracking-upload-source-maps/flutter
  • /wizard-ci error-tracking-upload-source-maps/ios
  • /wizard-ci error-tracking-upload-source-maps/next
  • /wizard-ci error-tracking-upload-source-maps/next-no-posthog
  • /wizard-ci error-tracking-upload-source-maps/node-raw
  • /wizard-ci error-tracking-upload-source-maps/node-rollup
  • /wizard-ci error-tracking-upload-source-maps/node-rollup-typescript-plugin
  • /wizard-ci error-tracking-upload-source-maps/node-webpack
  • /wizard-ci error-tracking-upload-source-maps/nuxt-3-6
  • /wizard-ci error-tracking-upload-source-maps/nuxt-4-3
  • /wizard-ci error-tracking-upload-source-maps/react-native
  • /wizard-ci error-tracking-upload-source-maps/react-vite
  • /wizard-ci error-tracking-upload-source-maps/rust
  • /wizard-ci mcp-analytics/custom-dispatcher
  • /wizard-ci mcp-analytics/typescript-sdk
  • /wizard-ci misc/quack-quack
  • /wizard-ci revenue/stripe

Results will be posted here when complete.

gewenyu99 added a commit that referenced this pull request Jun 28, 2026
With HostResolution carrying the resolved region+host family on the
credentials, the standalone `cloudRegion` option is fully dead:

- `WizardRunOptions.cloudRegion` is never read anywhere.
- `addMCPServerToClientsStep`'s `cloudRegion` param was already ignored
  (`_cloudRegion`) and its only caller never passes it.

Remove both (and the now-unused `CloudRegion` import in the MCP step).
Pure dead-code removal — no behavior change.

Stacked on #749.

Generated-By: PostHog Code
Task-Id: fb61e413-9459-4e61-9396-ac008c6bec94
@gewenyu99 gewenyu99 force-pushed the posthog-code/host-resolution-class branch from 03864d4 to a8be871 Compare June 28, 2026 22:26
@gewenyu99 gewenyu99 changed the title refactor(host): one immutable HostResolution object (stacked on #746) refactor(host): introduce immutable HostResolution class Jun 28, 2026
@gewenyu99 gewenyu99 force-pushed the posthog-code/host-resolution-class branch from a8be871 to 25691f6 Compare June 28, 2026 22:52
@gewenyu99 gewenyu99 changed the title refactor(host): introduce immutable HostResolution class refactor(host): route #746's host resolution through HostResolution Jun 28, 2026
@gewenyu99 gewenyu99 marked this pull request as ready for review June 28, 2026 22:56
Introduce HostResolution — a frozen, resolve-once snapshot of every PostHog
origin (api/app/asset/gateway/mcp), a façade over the @utils/urls resolvers
that carries the --base-url override through every field.

Point #746's own host resolution at it: the auth-time region+host resolution
(setup-utils), the LLM gateway (agent-interface, mcp-prompt-streaming), and the
region->app-url derivations (linear, audit, events-audit, posthog-integration,
AiOptIn) now go through HostResolution instead of getHost/getCloudUrl/
getLlmGatewayUrl/detectRegion.

Credentials.host stays a string here, so the single-field sites construct a
throwaway HostResolution to read one origin — each marked TODO: clean up in
#755, where the Credentials.host flip lets them read off the resolved object.

Meant to merge into #746.
@gewenyu99 gewenyu99 force-pushed the posthog-code/host-resolution-class branch from 25691f6 to e5eb333 Compare June 28, 2026 23:15
gewenyu99 added a commit that referenced this pull request Jun 28, 2026
The rest of the migration, on top of the class PR. Flip Credentials.host from a
string to a HostResolution (resolved once at auth) and route every remaining
consumer through it (host.apiHost / host.appHost / host.gatewayUrl /
host.mcpUrl), replacing the loose (region, baseUrl) threading everywhere outside
#746's surface: self-driving, source-maps, task-stream, orchestrator, agentic,
prompts, Doctor/Slack screens, the WizardUI interfaces, plus test/playground
ripple. Also resolves the #749 TODOs — the throwaway single-field constructions
become reads off the resolved credentials.host.

Pre-auth OAuth/provisioning URL resolution stays loose (no region yet).
Comment on lines +65 to +66
/** The resolved cloud region. `'us'` when a base URL is pinned. */
readonly region: CloudRegion;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if this should simply be null when a base URL is pinned? We don't even use this for a lot. Or maybe unknown.

*/
readonly mcpUrl: string;

private constructor(fields: {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice

@rafaeelaudibert rafaeelaudibert merged commit 1f6a999 into feat/base-url-override Jun 30, 2026
12 checks passed
@rafaeelaudibert rafaeelaudibert deleted the posthog-code/host-resolution-class branch June 30, 2026 00:31
rafaeelaudibert pushed a commit that referenced this pull request Jun 30, 2026
…749)

Introduces `HostResolution` and points **#746's own host-resolution code** at it — minimal, meant to **merge into #746** and release with it.

Where #746 resolves a PostHog origin via the loose `getHost`/`getCloudUrl`/`getLlmGatewayUrl`/`detectRegion(region, baseUrl)` helpers, it now goes through `HostResolution` instead:
- auth-time region+host resolution (`setup-utils`)
- the LLM gateway (`agent-interface`, `mcp-prompt-streaming`)
- the region→app-url derivations (`linear`, `audit`, `events-audit`, `posthog-integration`, `AiOptIn`)

`Credentials.host` stays a `string` here. Flipping it to the object and migrating every *other* consumer is the stacked PR (#755), so this stays minimal and doesn't grow #746.

Stacked on #746 (`feat/base-url-override`).
gewenyu99 added a commit that referenced this pull request Jun 30, 2026
The rest of the migration, on top of the class PR. Flip Credentials.host from a
string to a HostResolution (resolved once at auth) and route every remaining
consumer through it (host.apiHost / host.appHost / host.gatewayUrl /
host.mcpUrl), replacing the loose (region, baseUrl) threading everywhere outside
prompts, Doctor/Slack screens, the WizardUI interfaces, plus test/playground
ripple. Also resolves the #749 TODOs — the throwaway single-field constructions
become reads off the resolved credentials.host.

Pre-auth OAuth/provisioning URL resolution stays loose (no region yet).
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.

2 participants