: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 { Meta, StoryObj } from '@storybook/react'
import { useActions } from 'kea'
import { useEffect } from 'react'
import { App } from 'scenes/App'
import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
import { mswDecorator, useStorybookMocks } from '~/mocks/browser'
import preflightJson from '../mocks/fixtures/_preflight.json'
const meta: Meta = {
title: 'Scenes-App/Error Project Unavailable',
decorators: [
mswDecorator({
get: {
'/_preflight': {
...preflightJson,
cloud: true,
region: 'EU',
realm: 'cloud',
can_create_org: true,
available_social_auth_providers: { github: true, gitlab: true, 'google-oauth2': true, saml: false },
},
'/api/environments/@current/': () => [
403,
{
code: 'project_unavailable',
type: 'authentication_error',
detail: 'You do not have access to this project',
},
],
},
}),
],
parameters: {
layout: 'fullscreen',
viewMode: 'story',
mockDate: '2023-02-01',
pageUrl: urls.projectRoot(),
testOptions: {
waitForLoadersToDisappear: true,
},
},
}
export default meta
type Story = StoryObj<{}>
export const AccessRevoked: Story = {
render: () => {
const { loadCurrentTeamSuccess } = useActions(teamLogic)
useStorybookMocks({
get: {
'/api/users/@me/': () => [
200,
{
email: '[email protected]',
first_name: 'Test PostHog',
organization: {
name: 'Test org',
teams: [],
projects: [],
},
team: {
id: 1,
name: 'Test team',
},
},
],
'api/organizations/@current/': () => [
200,
{
membership_level: 15,
name: 'Test org',
teams: [],
projects: [],
},
],
},
})
useEffect(() => {
loadCurrentTeamSuccess(null)
}, [loadCurrentTeamSuccess])
return <App />
},
}
export const NoSelectableProjects: Story = {
render: () => {
const { loadCurrentTeamSuccess } = useActions(teamLogic)
useStorybookMocks({
get: {
'/api/users/@me/': () => [
200,
{
email: '[email protected]',
first_name: 'Test PostHog',
organization: {
name: 'Test org',
teams: [],
projects: [],
},
team: null,
},
],
'api/organizations/@current/': () => [
200,
{
membership_level: 1,
name: 'Test org',
teams: [],
projects: [],
},
],
},
})
useEffect(() => {
loadCurrentTeamSuccess(null)
}, [loadCurrentTeamSuccess])
return <App />
},
}