: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 { DateTime } from 'luxon'
import { CyclotronInvocationQueueParametersEmailSchema } from '~/cdp/schema/cyclotron'
import { acceptedSendEmailFields } from '~/cdp/services/hogflows/transactional-email'
import { registerAsyncFunction } from '../async-function-registry'
registerAsyncFunction('sendEmail', {
execute: (args, context, result) => {
const { attachments: _onlyAnAcceptedSendHasFiles, ...stepEmail } = args[0] ?? {}
result.invocation.queueParameters = CyclotronInvocationQueueParametersEmailSchema.parse({
...stepEmail,
...acceptedSendEmailFields(context.invocation.state.send),
type: 'email',
})
},
mock: (args, logs) => {
logs.push({
level: 'info',
timestamp: DateTime.now(),
message: `Async function 'sendEmail' was mocked with arguments:`,
})
logs.push({
level: 'info',
timestamp: DateTime.now(),
message: `sendEmail(${JSON.stringify(args[0], null, 2)})`,
})
return {
success: true,
}
},
})