: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 { getAccessControlDisabledReason } from 'lib/utils/accessControlUtils'
import { AccessControlLevel, AccessControlResourceType } from '~/types'
/**
* Every Replay Vision write that creates, configures, or triggers processing of scanner/observation/
* label data requires BOTH replay_scanner editor access (the resource RBAC is actually
* configured against — see RESOURCE_INHERITANCE_MAP) AND session_recording viewer access (since the
* write exposes or processes recording-derived content). The backend enforces both unconditionally for
* these actions (see `_scanner_for_url`/`initial()`'s `_CONFIG_ACTIONS` across scanners.py and
* observations.py) — this must match exactly, or a
* disabled-looking control can silently permit a request the backend blocks, and vice versa.
*/
export function getReplayVisionEditDisabledReason(scannerUserAccessLevel?: AccessControlLevel | null): string | null {
return (
getAccessControlDisabledReason(
AccessControlResourceType.ReplayScanner,
AccessControlLevel.Editor,
scannerUserAccessLevel ?? undefined
) ?? getAccessControlDisabledReason(AccessControlResourceType.SessionRecording, AccessControlLevel.Viewer)
)
}
/**
* Reading recording-derived content (e.g. drilling from a scanner chart into the sessions behind a data
* point) requires session_recording viewer access, independent of scanner access. A scanner-only viewer
* denied recordings must not be able to enumerate them, so gate any recording-surfacing affordance on this.
*/
export function getReplayVisionRecordingViewDisabledReason(): string | null {
return getAccessControlDisabledReason(AccessControlResourceType.SessionRecording, AccessControlLevel.Viewer) ?? null
}
/**
* Deleting a scanner is the one write that skips the session_recording check —
* destroy doesn't expose or process recording content (see `_CONFIG_ACTIONS`, which omits "destroy",
* in ReplayScannerViewSet). Kept as its own export so delete call sites are
* explicit about needing the narrower bar, rather than reusing the general helper and getting it
* right by accident.
*/
export function getReplayVisionDeleteDisabledReason(scannerUserAccessLevel?: AccessControlLevel | null): string | null {
return getAccessControlDisabledReason(
AccessControlResourceType.ReplayScanner,
AccessControlLevel.Editor,
scannerUserAccessLevel ?? undefined
)
}
/** Creating a scout needs the scanner edit bar, because the scout reads this scanner's observations
* on a schedule and spends credits, plus skill editor access, because the scout's instructions are a
* skill. */
export function getScoutCreateDisabledReason(scannerUserAccessLevel?: AccessControlLevel | null): string | null {
return (
getReplayVisionEditDisabledReason(scannerUserAccessLevel) ??
getAccessControlDisabledReason(AccessControlResourceType.LlmSkill, AccessControlLevel.Editor)
)
}