CML
    Preparing search index...

    Type Alias CmcdEncodeOptions

    Options for encoding CMCD values.

    type CmcdEncodeOptions = {
        baseUrl?: string;
        customHeaderMap?: Partial<CmcdHeaderMap>;
        events?: string[];
        filter?: (key: CmcdKey) => boolean;
        formatters?: Partial<CmcdFormatterMap>;
        reportingMode?: CmcdReportingMode;
        version?: CmcdVersion;
    }
    Index

    Properties

    baseUrl?: string

    Base URL (typically the manifest or current request URL) used to convert absolute nor values into paths relative to this base, per the CMCD specification. This option does not modify values that are already relative paths, but CMCD version 1 still URL-encodes them on emission. If omitted, nor values are emitted unchanged (subject to the version 1 URL-encoding rule). If baseUrl is not a valid URL, the encoder ignores it.

    customHeaderMap?: Partial<CmcdHeaderMap>

    A map of CMCD header fields to custom CMCD keys.

    events?: string[]

    Array of event names to filter.

    filter?: (key: CmcdKey) => boolean

    A filter function for CMCD keys.

    Type Declaration

      • (key: CmcdKey): boolean
      • Parameters

        • key: CmcdKey

          The CMCD key to filter.

        Returns boolean

        true if the key should be included, false otherwise.

    A map of CMCD keys to custom formatters. A formatter replaces the value rule of its key. The encoder does not apply the type, length, and token rules of the key to the output. The encoder still applies these rules to the output:

    • It drops an empty value. An empty value is undefined, null, an empty string, an empty array, or a number that is not finite.
    • It drops a default value, with or without parameters. The default value is false, or 1 for pr. The exceptions are pr on a pr event and bg on a b event.
    • It wraps a string for e, ot, sf, st, and sta in SfToken.
    • It replaces a ts that is not a finite number with the current time.

    The encoder does not call a formatter for an empty value, for false, or for v. It also skips the formatter of a key that it does not send. The formatters of ot and e still run when a rule needs their value.

    reportingMode?: CmcdReportingMode

    The reporting mode to use.

    CmcdReportingMode.REQUEST

    version?: CmcdVersion

    The version of the CMCD specification to use. If omitted, the version is inferred from the data's v key, defaulting to CMCD_V2.

    CMCD_V2