:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import { useEffect } from 'react'
import { SceneExport } from 'scenes/sceneTypes'
import { DesktopBridgePage } from './DesktopBridgePage'
import { DESKTOP_SCHEME } from './desktopScheme'
export interface CodeLoopLinkProps {
loopId: string
}
export const scene: SceneExport<CodeLoopLinkProps> = {
component: CodeLoopLink,
paramsToProps: ({ params: { loopId } }) => ({
loopId: loopId ?? '',
}),
}
export function loopDeepLink(loopId: string): string {
return `${DESKTOP_SCHEME}://loop/${encodeURIComponent(loopId)}`
}
/**
* Public, unauthenticated bridge for desktop-app "loop" links (`/code/loop/<loopId>`). On mount it
* deep-links into the desktop app via the `posthog-code(-dev)://` custom scheme; for visitors
* without the app it shows an explanation, a manual "open" button (in case the browser blocks
* the auto-redirect), and a download link. Loops only exist in the desktop app, so nothing is
* rendered here beyond this interstitial.
*/
export function CodeLoopLink({ loopId }: CodeLoopLinkProps): JSX.Element {
// Null when the loop id is missing (a partial URL or params not yet resolved), since firing
// with an empty id would send a malformed `<scheme>://loop/`.
const deepLink = loopId ? loopDeepLink(loopId) : null
useEffect(() => {
if (deepLink) {
window.location.href = deepLink
}
}, [deepLink])
return <DesktopBridgePage subject="This loop" deepLink={deepLink} />
}
export default CodeLoopLink