Skip to content

: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.

feat(actions): warn when an action's event stopped arriving (#95863)

posthog[bot]d40193725adc
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 25bafd9af12b..bcac1b73df42 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -552,6 +552,10 @@ snapshots:
hash: v1.k794b7964.1b4b561bf3d2b2bf3681dbfd41384e2e5fe179ff7e9fb5bf8062a842a2150e6c.-Cik6Fph2GW4TbcAV3kefO2O_MWwi9Nwy1pS5QbGHIE
components-errors-error-display--with-cymbal-errors--light:
hash: v1.k794b7964.94d334030b9d7c6265f6cc444a7ef01d5c3ccb6b1541d2933026def67f914f6b.KE74nO4XH5ah9E_-8Jewf-yx9RNIHGzQ3r2jdkEunOY
+ components-event-health-warning--variants--dark:
+ hash: v1.k794b7964.c2b56521546703744647d4976b098b8858d4c5e54b7cd8d07327500c247d5d3e.qOgtT2nWHhI4ajD3_R1onzl2Q44mRwe2xv5HgoKStpA
+ components-event-health-warning--variants--light:
+ hash: v1.k794b7964.c1eff377ef7dfa01ea441dc1f145ab3f395aad918acc071610749544e0801a50.2OAadQCcCr0bu3sz321p_T4TyhtX1SmxsKKEY8b9dFI
components-eventdetails--nested-properties--dark:
hash: v1.k794b7964.acbbd66bb3841f17a58d897e19c4b073fcbbf0452e959355276b012c7cd6b463.n89wKvwy5vfBtTTyqqi5InfW-EdZ8-pjfT0N1pRafQ0
components-eventdetails--nested-properties--light:
@@ -6612,10 +6616,18 @@ snapshots:
hash: v1.k794b7964.00b57c65346e514c9454e88054c04eb8aef6f1093d64fdc46cbbef3604e7f2d6.89yiroC6COFhV4T8jtCoYYdBQat6ZW24vyN_AW3GRTI
scenes-app-data-management-actions--action--light:
hash: v1.k794b7964.01991f5b587ce8b67319035310436131bdc75c0a13959fe581d282029b14c84f.gOBOxAz7KA0qJWzxJDdwKKsqAGfzX9anWCouWgYrpwM
+ scenes-app-data-management-actions--action-with-unhealthy-events--dark:
+ hash: v1.k794b7964.17e04442462e2205fd44671940fe1590ccb9dae475b2cd36b3f144149a725775.HooKXvFA43P0ElNL6WnmM91ojGV8B88jS3jpIkAlL4E
+ scenes-app-data-management-actions--action-with-unhealthy-events--light:
+ hash: v1.k794b7964.461e7169c71c1e17678bb80070a5f12c87caf45b2cfc80836cd698910d193380.8fBJ18-v0I7TOlJYsbIFQTvWQYgdPeBUvS5odEmYXho
scenes-app-data-management-actions--actions-list--dark:
hash: v1.k794b7964.bd5168e579fa746d3f0fe22cd50e94e879f638b594e39b93ed3cbf329d797045.t0zAJGmPzUfxAEBp7io3QgPwzbXoekfensWiOF3PmVo
scenes-app-data-management-actions--actions-list--light:
hash: v1.k794b7964.cbca06140c5a7e89a6a42b316248dc0bfd96a9081da2ec658f5e2c7d508b8309.8CEchtwyS8jC91RTRJkZHXqoKwGQCTQNNpamYIuRZPU
+ scenes-app-data-management-actions--actions-list-with-unhealthy-events--dark:
+ hash: v1.k794b7964.c188cf9fdafafc9337286694bc7c8b4f847ea5f2a85bdae3b92d21601124fa5d.1yOJeOAdutnp6VWC0o7XA48ShWG_W63R3I8v_nckE1o
+ scenes-app-data-management-actions--actions-list-with-unhealthy-events--light:
+ hash: v1.k794b7964.e160bd00755e167eeacbd565aa396b79e89ff3940a1e333c3f780c830f879802.oXwyuYEPIV4EILW_OmstTIk28yFMV9Wjtra_gNMyQPk
scenes-app-data-management-actions--new-action--dark:
hash: v1.k794b7964.ba971e6b4e8a8e72c512b1edc53fc699eff7142f207aed6e1d22e4cc79d18c9c.WK1mMQL1L81fqQ7rDdXG0tr5I9kdtzLDkznyHOd7bN8
scenes-app-data-management-actions--new-action--light:
@@ -8243,7 +8255,7 @@ snapshots:
scenes-app-notebooks-widget-views--action-views--dark:
hash: v1.k794b7964.9a752af48c274e00d922b4491c01aaef874019b886d91f65e891a8d4ce18361a.a8f4IjMdEHKLV_5jRIII-5EsmnVYuCpmuohpIwZVNZw
scenes-app-notebooks-widget-views--action-views--light:
- hash: v1.k794b7964.acacd9778acd50d8bdd19a72e832b5ad928d8b19b521d3351a40092da61761ef.B2zbSS1kO4fN0OvqNanW87Id7-F1INxhDhDFl6kbwJ8
+ hash: v1.k794b7964.5eaedc2da89fa2785c527ccee76911ad5f78a1cbf986c47a355ee300cb8cc49c.LwtCxJc2uTX-xwC9Rog-EsXcjXJSh8ulBC53vBrYJQM
scenes-app-notebooks-widget-views--cohort-views--dark:
hash: v1.k794b7964.6a87a3642aa629e7ff3c6a24c2e2ae99e3c8603632a269fe6a3f26fcce06c02f.6JLTYAgJWEQpMmzewJGy9_3heCCSQx0qHX8vUbdj4V0
scenes-app-notebooks-widget-views--cohort-views--light:
diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts
index 3dc69f1f51a6..e7282477b8ba 100644
--- a/frontend/src/lib/api.ts
+++ b/frontend/src/lib/api.ts
@@ -3113,10 +3113,11 @@ const api = {
event_type?: EventDefinitionType
search?: string
ordering?: string
+ names?: string[]
}): Promise<CountedPaginatedResponse<EventDefinition>> {
return new ApiRequest()
.eventDefinitions(teamId)
- .withQueryString(toParams({ limit, ...params }))
+ .withQueryString(toParams({ limit, ...params }, true))
.get()
},
async primaryProperties({
diff --git a/products/actions/frontend/components/ActionStep.tsx b/products/actions/frontend/components/ActionStep.tsx
index e177e3cdf84b..8b716b81651b 100644
--- a/products/actions/frontend/components/ActionStep.tsx
+++ b/products/actions/frontend/components/ActionStep.tsx
@@ -29,6 +29,7 @@ import {
type ScreenNameMatching,
isScreenNameFilter,
} from '../utils/screenName'
+import { EventHealthWarning } from './EventHealthWarning'
import { EventName } from './EventName'
const learnMoreLink = 'https://posthog.com/docs/data/actions?utm_medium=in-product&utm_campaign=action-page'
@@ -65,7 +66,10 @@ export function ActionStep({
)}
<div className="deprecated-space-y-4">
<div className="flex items-center justify-between">
- <b>Match Group #{index + 1}</b>
+ <div className="flex items-center gap-2">
+ <b>Match Group #{index + 1}</b>
+ <EventHealthWarning event={step.event} />
+ </div>
{!isOnlyStep && (
<LemonButton
diff --git a/products/actions/frontend/components/ActionsTable.tsx b/products/actions/frontend/components/ActionsTable.tsx
index 3bc968457e77..83092592c77d 100644
--- a/products/actions/frontend/components/ActionsTable.tsx
+++ b/products/actions/frontend/components/ActionsTable.tsx
@@ -35,6 +35,7 @@ import {
import { ACTIONS_PER_PAGE, actionsLogic } from '../logics/actionsLogic'
import { ActionStepConditions, ActionStepSummary } from '../utils/actionStepDescription'
import { deleteActionWithWarning } from '../utils/deleteAction'
+import { EventHealthWarning } from './EventHealthWarning'
export function ActionsTable(): JSX.Element {
const { actionsList, actionCount, actionsResponseLoading, page, filters, searchTerm } = useValues(actionsLogic)
@@ -109,11 +110,14 @@ export function ActionsTable(): JSX.Element {
return (
<span>
{action.steps.map((step, index) => (
- <Tooltip key={index} title={<ActionStepConditions step={step} />} placement="right">
- <div className="w-fit">
- <ActionStepSummary step={step} />
- </div>
- </Tooltip>
+ <div key={index} className="flex items-center gap-1 flex-wrap">
+ <Tooltip title={<ActionStepConditions step={step} />} placement="right">
+ <div className="w-fit">
+ <ActionStepSummary step={step} />
+ </div>
+ </Tooltip>
+ <EventHealthWarning event={step.event} />
+ </div>
))}
</span>
)
diff --git a/products/actions/frontend/components/EventHealthWarning.stories.tsx b/products/actions/frontend/components/EventHealthWarning.stories.tsx
new file mode 100644
index 000000000000..17dfbac00a6d
--- /dev/null
+++ b/products/actions/frontend/components/EventHealthWarning.stories.tsx
@@ -0,0 +1,56 @@
+import { Meta, StoryObj } from '@storybook/react'
+
+import { mswDecorator } from '~/mocks/browser'
+
+import { EventHealthWarning } from './EventHealthWarning'
+
+const meta: Meta<typeof EventHealthWarning> = {
+ title: 'Components/Event Health Warning',
+ component: EventHealthWarning,
+ parameters: {
+ mockDate: '2023-02-15',
+ docs: {
+ description: {
+ component:
+ 'Warns that the event an action match group points at stopped arriving, so the group quietly matches nothing new. Steps are OR-ed, so the rest of the action keeps matching. Shown on the actions list next to the group it affects, and in the step editor. Nothing renders while the event definition is still loading, or when the event is healthy.',
+ },
+ },
+ },
+ decorators: [
+ mswDecorator({
+ get: {
+ '/api/projects/:team_id/event_definitions/': {
+ count: 2,
+ results: [
+ { id: '1', name: 'purchase_completed', last_seen_at: '2023-02-14T10:00:00Z' },
+ { id: '2', name: 'trial_started', last_seen_at: '2022-11-01T10:00:00Z' },
+ ],
+ },
+ },
+ }),
+ ],
+ tags: ['autodocs'],
+}
+export default meta
+type Story = StoryObj<typeof EventHealthWarning>
+
+const VARIANTS: { label: string; event: string | null }[] = [
+ { label: 'Healthy event, nothing is shown', event: 'purchase_completed' },
+ { label: 'Event last seen months ago', event: 'trial_started' },
+ { label: 'Event with no definition, deleted or never sent', event: 'checkout_abandoned' },
+ { label: 'Step that matches all events', event: null },
+]
+
+export const Variants: Story = {
+ render: () => (
+ <div className="flex flex-col gap-2 max-w-2xl">
+ {VARIANTS.map(({ label, event }) => (
+ <div key={label} className="flex items-center gap-2 border rounded p-2 bg-surface-primary">
+ <span className="text-xs text-secondary w-80 shrink-0">{label}</span>
+ <span className="font-mono text-xs">{event ?? 'All events'}</span>
+ <EventHealthWarning event={event} />
+ </div>
+ ))}
+ </div>
+ ),
+}
diff --git a/products/actions/frontend/components/EventHealthWarning.tsx b/products/actions/frontend/components/EventHealthWarning.tsx
new file mode 100644
index 000000000000..3f58a8ce62e4
--- /dev/null
+++ b/products/actions/frontend/components/EventHealthWarning.tsx
@@ -0,0 +1,49 @@
+import { useActions, useValues } from 'kea'
+import { useEffect } from 'react'
+
+import { LemonTag } from '@posthog/lemon-ui'
+
+import { dayjs } from 'lib/dayjs'
+import { Tooltip } from 'lib/lemon-ui/Tooltip'
+
+import { EventHealthIssue, actionEventHealthLogic } from '../logics/actionEventHealthLogic'
+
+function issueExplanation(issue: EventHealthIssue): JSX.Element {
+ if (issue.status === 'stale') {
+ return (
+ <>
+ PostHog last saw this event <b>{dayjs(issue.lastSeenAt).fromNow()}</b>. This match group matches nothing
+ newer than that, so recent results can be incomplete.
+ </>
+ )
+ }
+ return (
+ <>
+ PostHog has no definition for this event. Either it was never sent, or someone deleted the definition in
+ data management. This match group matches nothing new.
+ </>
+ )
+}
+
+/** Warns that the event a match group points at stopped arriving, so the group quietly matches nothing new. */
+export function EventHealthWarning({ event }: { event?: string | null }): JSX.Element | null {
+ const { eventHealthIssues } = useValues(actionEventHealthLogic)
+ const { requestEventNames } = useActions(actionEventHealthLogic)
+
+ useEffect(() => {
+ requestEventNames([event])
+ }, [event, requestEventNames])
+
+ const issue = event ? eventHealthIssues[event] : undefined
+ if (!issue) {
+ return null
+ }
+
+ return (
+ <Tooltip title={issueExplanation(issue)}>
+ <LemonTag type="warning" data-attr="action-event-health-warning">
+ {issue.status === 'stale' ? 'Stale' : 'Not seen'}
+ </LemonTag>
+ </Tooltip>
+ )
+}
diff --git a/products/actions/frontend/logics/actionEventHealthLogic.test.ts b/products/actions/frontend/logics/actionEventHealthLogic.test.ts
new file mode 100644
index 000000000000..27262a5c3310
--- /dev/null
+++ b/products/actions/frontend/logics/actionEventHealthLogic.test.ts
@@ -0,0 +1,108 @@
+import { expectLogic } from 'kea-test-utils'
+
+import { dayjs } from 'lib/dayjs'
+
+import { useMocks } from '~/mocks/jest'
+import { initKeaTests } from '~/test/init'
+
+import { actionEventHealthLogic } from './actionEventHealthLogic'
+
+describe('actionEventHealthLogic', () => {
+ let logic: ReturnType<typeof actionEventHealthLogic.build>
+ let requestedSearches: URLSearchParams[]
+
+ beforeEach(() => {
+ requestedSearches = []
+
+ useMocks({
+ get: {
+ '/api/projects/:team/event_definitions/': ({ request }) => {
+ const params = new URL(request.url).searchParams
+ requestedSearches.push(params)
+ const names = params.getAll('names')
+ const results = [
+ { id: '1', name: 'fresh_event', last_seen_at: dayjs().subtract(1, 'hour').toISOString() },
+ { id: '2', name: 'stale_event', last_seen_at: dayjs().subtract(90, 'day').toISOString() },
+ { id: '3', name: 'constructor', last_seen_at: dayjs().subtract(1, 'hour').toISOString() },
+ { id: '4', name: '__proto__', last_seen_at: dayjs().subtract(1, 'hour').toISOString() },
+ ].filter((definition) => names.includes(definition.name))
+ return [200, { count: results.length, results }]
+ },
+ },
+ })
+
+ initKeaTests()
+ logic = actionEventHealthLogic()
+ logic.mount()
+ })
+
+ // The whole point of the warning: an event nobody sends any more, and an event with no
+ // definition at all, are both actions that silently match nothing.
+ it.each([
+ ['fresh_event', undefined],
+ ['stale_event', 'stale'],
+ ['deleted_event', 'missing'],
+ ])('reports %s as %s', async (event, status) => {
+ logic.actions.requestEventNames([event])
+ await expectLogic(logic).toFinishAllListeners()
+ expect(logic.values.eventHealthIssues[event]?.status).toEqual(status)
+ })
+
+ // A page of actions asks row by row. Without batching that is one request per row.
+ it('asks for a burst of event names in a single request', async () => {
+ logic.actions.requestEventNames(['fresh_event'])
+ logic.actions.requestEventNames(['stale_event'])
+ logic.actions.requestEventNames([null, undefined])
+ await expectLogic(logic).toFinishAllListeners()
+
+ expect(requestedSearches).toHaveLength(1)
+ expect(requestedSearches[0].getAll('names')).toEqual(['fresh_event', 'stale_event'])
+ })
+
+ // A page of many actions, or of long event names, used to go out as one oversized URL that a
+ // proxy rejects whole. Nothing wrote to `definitions` on failure, so every tag on the page
+ // stayed absent and the same URL went out again on the next burst.
+ it('splits a burst too long for one URL across requests', async () => {
+ const names = Array.from({ length: 40 }, (_, index) => `event_${index}_${'x'.repeat(100)}`)
+
+ logic.actions.requestEventNames(names)
+ await expectLogic(logic).toFinishAllListeners()
+
+ expect(requestedSearches.length).toBeGreaterThan(1)
+ for (const search of requestedSearches) {
+ expect(search.toString().length).toBeLessThan(4000)
+ }
+ expect(requestedSearches.flatMap((search) => search.getAll('names'))).toEqual(names)
+ })
+
+ it('does not ask again for an event it already resolved', async () => {
+ logic.actions.requestEventNames(['fresh_event'])
+ await expectLogic(logic).toFinishAllListeners()
+ logic.actions.requestEventNames(['fresh_event'])
+ await expectLogic(logic).toFinishAllListeners()
+
+ expect(requestedSearches).toHaveLength(1)
+ })
+
+ // The endpoint splits each `names` value on commas, so it answers about `purchase` and
+ // `completed` instead. The full name then looks like it has no definition, which drew a
+ // "Not seen" tag on a step that matches fine.
+ it('stays quiet about an event name containing a comma', async () => {
+ logic.actions.requestEventNames(['purchase,completed'])
+ await expectLogic(logic).toFinishAllListeners()
+
+ expect(requestedSearches).toHaveLength(0)
+ expect(logic.values.eventHealthIssues['purchase,completed']).toBeUndefined()
+ })
+
+ // Held through a normal object these names read as already resolved, so the request never went
+ // out, and the health map handed back a value off Object.prototype. Both drew a "Not seen" tag
+ // on a healthy event.
+ it.each(['constructor', '__proto__'])('treats %s as an ordinary event name', async (event) => {
+ logic.actions.requestEventNames([event])
+ await expectLogic(logic).toFinishAllListeners()
+
+ expect(requestedSearches[0]?.getAll('names')).toEqual([event])
+ expect(logic.values.eventHealthIssues[event]).toBeUndefined()
+ })
+})
diff --git a/products/actions/frontend/logics/actionEventHealthLogic.ts b/products/actions/frontend/logics/actionEventHealthLogic.ts
new file mode 100644
index 000000000000..4ce72f4214e6
--- /dev/null
+++ b/products/actions/frontend/logics/actionEventHealthLogic.ts
@@ -0,0 +1,158 @@
+import { MakeLogicType, actions, kea, path, reducers, selectors } from 'kea'
+import { loaders } from 'kea-loaders'
+
+import api from 'lib/api'
+import { isDefinitionStale } from 'lib/utils/definitions'
+
+import { EventDefinition } from '~/types'
+
+/** Why an action match group matches nothing new, or is about to stop. */
+export type EventHealthIssue = { status: 'stale'; lastSeenAt: string } | { status: 'missing' }
+
+/** Definitions found, keyed by event name. A name that resolved to nothing maps to `null`. */
+export type EventDefinitionsByName = Record<string, EventDefinition | null>
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface actionEventHealthLogicValues {
+ definitions: EventDefinitionsByName
+ definitionsLoading: boolean
+ eventHealthIssues: Record<string, EventHealthIssue>
+ requestedNames: string[]
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface actionEventHealthLogicActions {
+ requestEventNames: (names: (string | null | undefined)[]) => {
+ names: (string | null | undefined)[]
+ }
+ requestEventNamesFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ requestEventNamesSuccess: (
+ definitions: EventDefinitionsByName,
+ payload?: {
+ names: (string | null | undefined)[]
+ }
+ ) => {
+ definitions: EventDefinitionsByName
+ payload?: {
+ names: (string | null | undefined)[]
+ }
+ }
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface actionEventHealthLogicMeta {
+ __keaTypeGenInternalSelectorTypes: {
+ eventHealthIssues: (definitions: EventDefinitionsByName) => Record<string, EventHealthIssue>
+ }
+}
+
+export type actionEventHealthLogicType = MakeLogicType<
+ actionEventHealthLogicValues,
+ actionEventHealthLogicActions,
+ Record<string, any>,
+ actionEventHealthLogicMeta
+>
+
+/**
+ * The `names` filter on `event_definitions` splits every value it receives on commas, so an event
+ * name that contains one is asked about as two different names and never comes back. PostHog cannot
+ * answer for such a name, and no tag is better than a "Not seen" tag on a step that matches fine.
+ */
+function isResolvableName(name: string | null | undefined): name is string {
+ return !!name && !name.includes(',')
+}
+
+/**
+ * Proxies reject a request line longer than about 4k, the limit `propertyDefinitionsModel` already
+ * batches against. One batch spends `names=` plus the encoded name on every event, and an event
+ * name holds up to 400 characters, so a count cap alone would not bound the URL. Budget for the
+ * names and leave the rest of the 4k for the path and `limit`.
+ */
+const MAX_NAMES_QUERY_LENGTH = 3000
+
+function chunkByQueryLength(names: string[]): string[][] {
+ const chunks: string[][] = []
+ let chunk: string[] = []
+ let length = 0
+ for (const name of names) {
+ const cost = 'names='.length + encodeURIComponent(name).length + 1
+ if (chunk.length > 0 && length + cost > MAX_NAMES_QUERY_LENGTH) {
+ chunks.push(chunk)
+ chunk = []
+ length = 0
+ }
+ chunk.push(name)
+ length += cost
+ }
+ if (chunk.length > 0) {
+ chunks.push(chunk)
+ }
+ return chunks
+}
+
+export const actionEventHealthLogic = kea<actionEventHealthLogicType>([
+ path(['products', 'actions', 'actionEventHealthLogic']),
+ actions({
+ requestEventNames: (names: (string | null | undefined)[]) => ({ names }),
+ }),
+ reducers({
+ requestedNames: [
+ [] as string[],
+ {
+ requestEventNames: (state, { names }) => [...new Set([...state, ...names.filter(isResolvableName)])],
+ },
+ ],
+ }),
+ loaders(({ values }) => ({
+ definitions: [
+ // Event names come from the customer, so one can be `constructor` or `__proto__`. These
+ // maps carry no prototype, so `in` and an indexed read see only names PostHog resolved,
+ // and a write to `__proto__` adds a key instead of re-parenting the map.
+ Object.create(null) as EventDefinitionsByName,
+ {
+ requestEventNames: async (_, breakpoint) => {
+ // One page of actions asks for its events row by row, so wait for the burst to settle.
+ await breakpoint(50)
+ const missing = values.requestedNames.filter((name) => !(name in values.definitions))
+ if (!missing.length) {
+ return values.definitions
+ }
+ const resolved: EventDefinitionsByName = Object.assign(Object.create(null), values.definitions)
+ for (const name of missing) {
+ resolved[name] = null
+ }
+ for (const chunk of chunkByQueryLength(missing)) {
+ const response = await api.eventDefinitions.list({ names: chunk, limit: chunk.length })
+ breakpoint()
+ for (const definition of response.results) {
+ resolved[definition.name] = definition
+ }
+ }
+ return resolved
+ },
+ },
+ ],
+ })),
+ selectors({
+ eventHealthIssues: [
+ (s) => [s.definitions],
+ (definitions: EventDefinitionsByName): Record<string, EventHealthIssue> => {
+ const issues: Record<string, EventHealthIssue> = Object.create(null)
+ for (const [name, definition] of Object.entries(definitions)) {
+ if (!definition) {
+ issues[name] = { status: 'missing' }
+ } else if (definition.last_seen_at && isDefinitionStale(definition)) {
+ issues[name] = { status: 'stale', lastSeenAt: definition.last_seen_at }
+ }
+ }
+ return issues
+ },
+ ],
+ }),
+])
diff --git a/products/actions/frontend/pages/Action.stories.tsx b/products/actions/frontend/pages/Action.stories.tsx
index e4b9b72181e6..c42577d238d6 100644
--- a/products/actions/frontend/pages/Action.stories.tsx
+++ b/products/actions/frontend/pages/Action.stories.tsx
@@ -152,6 +152,13 @@ const meta: Meta = {
decorators: [
mswDecorator({
get: {
+ // Every event these actions point at is arriving, so no step carries a health warning.
+ '/api/projects/:team_id/event_definitions/': ({ request }) =>
+ toPaginatedResponse(
+ new URL(request.url).searchParams
+ .getAll('names')
+ .map((name, index) => ({ id: `${index}`, name, last_seen_at: '2023-02-14T10:00:00Z' }))
+ ),
'/api/projects/:team_id/actions/': toPaginatedResponse([MOCK_ACTION, MOCK_SCREEN_ACTION]),
'/api/projects/:team_id/actions/1/': MOCK_ACTION,
'/api/projects/:team_id/actions/2/': MOCK_SCREEN_ACTION,
@@ -181,3 +188,25 @@ export const NewAction: Story = {
pageUrl: urls.createAction(),
},
}
+
+const unhealthyEventsDecorator = mswDecorator({
+ get: {
+ // `$pageview` stopped arriving months ago and `$autocapture` has no definition at all.
+ '/api/projects/:team_id/event_definitions/': toPaginatedResponse([
+ { id: '1', name: '$pageview', last_seen_at: '2022-11-01T10:00:00Z' },
+ { id: '2', name: '$screen', last_seen_at: '2023-02-14T10:00:00Z' },
+ { id: '3', name: '$identify', last_seen_at: '2023-02-14T10:00:00Z' },
+ ]),
+ },
+})
+
+export const ActionsListWithUnhealthyEvents: Story = {
+ decorators: [unhealthyEventsDecorator],
+}
+
+export const ActionWithUnhealthyEvents: Story = {
+ parameters: {
+ pageUrl: urls.action(MOCK_ACTION.id),
+ },
+ decorators: [unhealthyEventsDecorator],
+}