: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 } from '@storybook/react'
import {
featureFlagsActivityResponseJson,
insightsActivityResponseJson,
personActivityResponseJson,
teamActivityResponseJson,
} from 'lib/components/ActivityLog/__mocks__/activityLogMocks'
import { ActivityLog, ActivityLogProps } from 'lib/components/ActivityLog/ActivityLog'
import { mswDecorator, useStorybookMocks } from '~/mocks/browser'
import organizationCurrent from '~/mocks/fixtures/api/organizations/@current/@current.json'
import { ActivityScope } from '~/types'
const meta: Meta<ActivityLogProps> = {
title: 'Components/ActivityLog',
component: ActivityLog,
decorators: [
(Story) => (
<div className="w-[calc(100vw-2rem)]">
<Story />
</div>
),
mswDecorator({
get: {
// TODO: setting available featues should be a decorator to make this easy
'/api/users/@me': () => [
200,
{
email: '[email protected]',
first_name: 'Test Hedgehog',
organization: {
...organizationCurrent,
available_product_features: [
{
key: 'audit_logs',
name: 'Audit logs',
},
],
},
},
],
'/api/projects/:team/feature_flags/6/activity': () => [200, { results: [] }],
'/api/projects/:team/feature_flags/7/activity': () => [
200,
{ results: featureFlagsActivityResponseJson },
],
'/api/environments/:team_id/insights/activity': () => [200, { results: insightsActivityResponseJson }],
'/api/person/:id/activity': () => [200, { results: personActivityResponseJson }],
'/api/projects/:id/activity': () => [200, { results: teamActivityResponseJson }],
},
}),
],
parameters: {
mockDate: '2024-05-01 12:00:00',
},
}
export default meta
export function FeatureFlagActivity(): JSX.Element {
return <ActivityLog scope={ActivityScope.FEATURE_FLAG} id={7} />
}
export function DataManagementActivity(): JSX.Element {
return <ActivityLog scope={ActivityScope.DATA_MANAGEMENT} />
}
export function InsightActivity(): JSX.Element {
return <ActivityLog scope={ActivityScope.INSIGHT} />
}
export function PersonsActivity(): JSX.Element {
return <ActivityLog scope={ActivityScope.PERSON} id={12} />
}
export function TeamActivity(): JSX.Element {
return <ActivityLog scope={ActivityScope.TEAM} id={12} />
}
export function WithCaption(): JSX.Element {
return (
<ActivityLog
scope={ActivityScope.FEATURE_FLAG}
id={7}
caption={
<>
This is a list that <strong>needs</strong> some extra description or context. Which can have a very,
very long caption. A <i>very</i> long caption that wraps over more than one line, not a very
Hemingway choice, but important information has to be included. And it will be, in this prop.
</>
}
/>
)
}
export function WithNoData(): JSX.Element {
return <ActivityLog scope={ActivityScope.FEATURE_FLAG} id={6} />
}
export function WithoutAuditLogsFeaure(): JSX.Element {
useStorybookMocks({
get: {
'/api/users/@me': () => [
200,
{
email: '[email protected]',
first_name: 'Test Hedgehog',
organization: {
...organizationCurrent,
available_product_features: [],
},
},
],
},
})
return <ActivityLog scope={ActivityScope.FEATURE_FLAG} id={7} />
}