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.

1.5 KB
Raw Blame
import { MakeLogicType, actions, kea, path } from 'kea'

import { RecordingCommentForm } from 'scenes/session-recordings/player/commenting/playerFrameCommentOverlayLogic'

// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface playerCommentModelActions {
    commentEdited: (recordingId: string) => {
        recordingId: string
    }
    startCommenting: (comment: RecordingCommentForm | null) => {
        comment: RecordingCommentForm | null
    }
}

export type playerCommentModelType = MakeLogicType<{}, playerCommentModelActions>

/**
 * used as a message bus for decoupled components to signal that a recording should be commented on
 * the currently active player will listen to this
 * and can e.g. enter or exit comment mode in response
 * it relies on being used when there is always a mounted player with a logic listening for this
 *
 * dispatch into it from another logic with connect({ actions: [playerCommentModel, ['commentEdited']] })
 * or from a component with useActions, so the action creator binds at build time
 * calling playerCommentModel.actions.x() at runtime resolves through kea's wrapper proxy,
 * which throws "is not mounted" once the built instance has been evicted from the build cache
 */
export const playerCommentModel = kea<playerCommentModelType>([
    path(['scenes', 'session-recordings', 'player', 'playerCommentModel']),
    actions({
        startCommenting: (comment: RecordingCommentForm | null) => ({ comment }),
        commentEdited: (recordingId: string) => ({ recordingId }),
    }),
])