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.

826 B
Raw Blame
import { ProcessedPluginEvent } from '~/plugin-scaffold'

import { LegacyDestinationPluginMeta } from '../../types'

export type PaceMetaInput = LegacyDestinationPluginMeta & {
    config: {
        api_key: string
    }
}

export const onEvent = async (event: ProcessedPluginEvent, { config, fetch }: PaceMetaInput): Promise<void> => {
    await fetch('https://data.production.paceapp.com/events', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
            'x-api-key': config.api_key,
        },
        body: JSON.stringify({
            data: {
                ...event,
                properties: Object.fromEntries(
                    Object.entries(event.properties || {}).filter(([key, _]) => !key.startsWith('$'))
                ),
            },
        }),
    })
}