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.

822 B
Raw Blame
import { createHmac } from 'crypto'

export function pseudonymize(secret: string | Buffer, namespace: string, value: string): string {
    // Length-prefix the namespace so the join is unambiguous even if a value contains the delimiter.
    return createHmac('sha256', secret).update(`${namespace.length}:${namespace}:${value}`).digest('hex').slice(0, 32)
}

/** Namespace for the per-team image content-HMAC key (see ml-mirror-image-scrub/content-ref.ts). */
export const PSEUDONYM_IMAGE_CONTENT_KEY = 'image-content-key'
/** Namespace for the global URL-HMAC key, which hashes a remote image's URL rather than its bytes. */
export const PSEUDONYM_IMAGE_URL_KEY = 'image-url-key'
export const PSEUDONYM_IMAGE_URL_GLOBAL_VALUE = 'global-v1'

export const PSEUDONYM_TEAM = 'team'
export const PSEUDONYM_SESSION = 'session'