: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 { CompatMessage } from '../../../../types'
import type { Scope } from '../../scope'
import type { EmitSpec, FollowupSpec } from '../../spec/emitSpec'
import type { Pattern } from '../predicate'
import { Rule } from './base'
import type { DispatchEngine } from './dispatch'
export class EmitRule extends Rule {
constructor(
on: Pattern,
followups: FollowupSpec[],
private readonly emit: EmitSpec
) {
super(on, followups)
}
produce(scope: Scope, engine: DispatchEngine, allowDrop: boolean): CompatMessage[] {
const message = engine.coercer.buildMessage(this.emit, scope, allowDrop)
if (!message) {
return []
}
engine.budget.chargeMessages(1)
return [message]
}
}