Langfuse JS/TS SDKs
    Preparing search index...

    Type Alias MaskFunction

    MaskFunction: (params: { data: any }) => any | Promise<any>

    Function type for masking sensitive data in spans before export.

    Applied to the input and output of observations and traces, and to each observation metadata value, one attribute at a time. Metadata keys are never passed to the mask, so masked metadata keeps its keys. Trace metadata propagated with propagateAttributes is not masked.

    Observation metadata values are passed decoded, e.g. the string "prod", the number 3 or an object, not their JSON encoding. The masked value is JSON-encoded again before export; if it is null or undefined, the metadata key is dropped.

    Type declaration

      • (params: { data: any }): any | Promise<any>
      • Parameters

        • params: { data: any }

          Object containing the data to be masked

          • data: any

            The data that should be masked

        Returns any | Promise<any>

        The masked data, or a promise resolving to it

    const maskFunction: MaskFunction = async ({ data }) => {
    if (typeof data === 'string') {
    return data.replace(/password=\w+/g, 'password=***');
    }
    return data;
    };