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.

2.7 KB
Raw Blame
import { processEvent } from '.'

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

export const languageUrlSplitterApp: LegacyTransformationPlugin = {
    processEvent,
    template: {
        free: true,
        status: 'stable',
        type: 'transformation',
        id: 'plugin-language-url-splitter-app',
        name: 'Language URL stripper',
        description: 'Replace the language from the URL with a custom value',
        icon_url: 'https://res.cloudinary.com/dmukukwp6/image/upload/q_auto,f_auto/builder_hog_01_955c082cad.png',
        category: ['Transformation'],
        code_language: 'javascript',
        code: `return event`,
        inputs_schema: [
            {
                key: 'pattern',
                label: 'Pattern',
                type: 'string',
                default: '^/([a-z]{2})(?=/|#|\\?|$)',
                description: 'Ininitalized with `const regexp = new RegExp($pattern)`',
                required: true,
                templating: false,
            },
            {
                key: 'matchGroup',
                label: 'Match group',
                type: 'string',
                default: '1',
                description: 'Used in: `const value = regexp.match($pathname)[$matchGroup]`',
                required: true,
                templating: false,
            },
            {
                key: 'property',
                label: 'Property',
                type: 'string',
                default: 'locale',
                description: 'Name of the event property we will store the matched value in',
                required: true,
                templating: false,
            },
            {
                key: 'replacePattern',
                label: 'Replacement pattern',
                type: 'string',
                default: '^(/[a-z]{2})(/|(?=/|#|\\?|$))',
                description: 'Initialized with `new RegExp($pattern)`, leave empty to disable path cleanup.',
                required: true,
                templating: false,
            },
            {
                key: 'replaceKey',
                label: 'Replacement key',
                type: 'string',
                default: '$pathname',
                description: 'Where to store the updated path. Keep as `$pathname` to override.',
                required: true,
                templating: false,
            },
            {
                key: 'replaceValue',
                label: 'Replacement value',
                type: 'string',
                default: '/',
                description: '`properties[key] = $pathname.replace(pattern, value)`',
                required: true,
                templating: false,
            },
        ],
    },
}