: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 type { Meta, StoryObj } from '@storybook/react'
import { mswDecorator } from '~/mocks/browser'
import { examples } from '~/queries/examples'
import { Query, QueryProps } from '~/queries/Query/Query'
import { Node } from '~/queries/schema/schema-general'
import webVitals from './__mocks__/WebVitals.json'
import webVitalsTrends from './__mocks__/WebVitalsTrends.json'
type Story = StoryObj<QueryProps<Node>>
const meta: Meta<QueryProps<Node>> = {
title: 'Queries/WebVitals',
component: Query,
parameters: {
layout: 'fullscreen',
viewMode: 'story',
testOptions: {
waitForLoadersToDisappear: true,
waitForSelector: '[data-attr=trend-line-graph] > canvas',
},
},
decorators: [
mswDecorator({
post: {
'/api/environments/:team_id/query/:kind/': async ({ request }) => {
const body = (await request.json()) as any
if (body.query.kind === 'WebVitalsQuery') {
return [200, webVitals]
} else if (body.query.kind === 'TrendsQuery') {
return [200, webVitalsTrends]
}
},
},
}),
],
// NOTE: See InsightCard.scss to see why we need this wrapper
render: (args) => {
return (
<div className="WebAnalyticsDashboard">
<div className="InsightVizDisplay">
<Query {...args} />
</div>
</div>
)
},
}
export default meta
export const WebVitals: Story = {
args: { query: examples['WebVitals'] },
}