Skip to content

fix: add deeplinking to posthog code git setup#1733

Merged
k11kirky merged 3 commits intomainfrom
04-20-fix_add_deeplinking_to_posthog_code_git_setup
Apr 20, 2026
Merged

fix: add deeplinking to posthog code git setup#1733
k11kirky merged 3 commits intomainfrom
04-20-fix_add_deeplinking_to_posthog_code_git_setup

Conversation

@k11kirky
Copy link
Copy Markdown
Contributor

@k11kirky k11kirky commented Apr 20, 2026

TLDR

The GitHub integration flow previously relied entirely on polling to detect when a user completed the GitHub App install in their browser. This meant the app had no reliable way to know when the flow succeeded or failed, and the UI couldn't react immediately or surface meaningful error states.

Changes

  • Added a deep link handler in GitHubIntegrationService that listens for integration callbacks from PostHog Cloud after the GitHub App install completes. The service emits typed events (Callback, FlowTimedOut) and queues callbacks that arrive before the renderer has subscribed.
  • Added a 5-minute flow timeout in the service that fires FlowTimedOut if no deep link callback is received.
  • Exposed three new tRPC endpoints: onCallback and onFlowTimedOut subscriptions, and a consumePendingCallback query to drain any callback that arrived before the renderer mounted.
  • Added a useGitHubIntegrationCallback hook that subscribes to both events and drains any pending callback on mount, calling onSuccess, onError, or onTimedOut accordingly.
  • Polling is now only used in dev mode (where the deep link protocol is not registered) and as a safety fallback timeout in production.
  • The onboarding GitIntegrationStep now shows a timeout banner with a retry prompt, displays the connected GitHub account name when available, and surfaces a callout when GitHub is already connected on a different project.
  • GitHubIntegrationSection in settings follows the same pattern, replacing polling-based detection with the new callback hook.
  • The next redirect URL after GitHub authorization now points to /account/social-connected with query params instead of the project root, enabling the deep link callback to carry status, installation ID, and error details back to the app.

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@k11kirky k11kirky marked this pull request as ready for review April 20, 2026 13:53
…king_to_posthog_code_git_setup

# Conflicts:
#	apps/code/src/main/services/github-integration/service.ts
#	packages/agent/src/adapters/codex/codex-agent.test.ts
Copy link
Copy Markdown
Contributor

@jonathanlab jonathanlab left a comment

Choose a reason for hiding this comment

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

LGTM

this.deepLinkService.registerHandler("integration", (_path, params) =>
this.handleCallback(params),
);
log.info("Registered integration deep link handler");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: trying to keep log noise down, in general let's only log the failure cases

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good call — removed the noisy success logs throughout this file and kept only failure/warn logs.

Comment on lines 79 to 83
} catch (error) {
this.clearFlowTimeout();
return {
success: false,
error: error instanceof Error ? error.message : "Unknown error",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: could use another log here just to know what went wrong in prod?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added a log.error in the catch block including the projectId and error message.

Only log failure cases and add error log in catch block of startFlow
for prod debuggability.

Generated-By: PostHog Code
Task-Id: 18a9315c-bc74-4528-8ab8-73e4fedcdeca
@k11kirky k11kirky merged commit cd0679a into main Apr 20, 2026
16 checks passed
@k11kirky k11kirky deleted the 04-20-fix_add_deeplinking_to_posthog_code_git_setup branch April 20, 2026 15:41
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