: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 posthog from 'posthog-js'
import api from 'lib/api'
import { urls } from 'scenes/urls'
import type { ApplyOp } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/logic/setupPlanLogic'
/** Perform an op the browser owns, returning whether it handled it.
*
* In the view rather than `setupPlanLogic` to keep the scene's dependency graph —
* sourceManagementLogic and friends — out of everything that touches a suggestion.
*
* New tabs throughout: the user is midway through a checklist and navigating away
* loses their place in it.
*/
export function runNavigateOp(op: ApplyOp, entryPoint: string): boolean {
if (['open_oauth', 'open_source_wizard', 'open_settings'].includes(op.op)) {
posthog.capture('marketing analytics setup navigation opened', {
destination: op.op,
integration: op.kind,
entry_point: entryPoint,
})
}
switch (op.op) {
case 'open_oauth':
window.open(
api.integrations.authorizeUrl({
kind: op.kind as string,
next: window.location.pathname + window.location.search,
}),
'_blank',
'noopener'
)
return true
case 'open_source_wizard':
window.open(
urls.dataWarehouseSourceNew(
op.kind as string,
urls.marketingAnalyticsApp(),
'Marketing analytics',
undefined,
`marketing_analytics_setup_${entryPoint}`
),
'_blank',
'noopener'
)
return true
case 'open_settings':
window.open(urls.settings(op.anchor as any, 'marketing-settings'), '_blank', 'noopener')
return true
default:
return false
}
}