Contentful Personalization & Analytics
    Preparing search index...

    Interface ResolverMethodsInternal

    These methods assist in resolving values via Resolvers

    interface ResolverMethods {
        getCustomFlag: (
            name: string,
            changes?: {
                key: string;
                meta: { experienceId: string; variantIndex: number };
                type: "Variable";
                value: string | number | boolean | Record<string, JSONType> | null;
            }[],
        ) => unknown;
        getCustomFlags: (
            changes?: {
                key: string;
                meta: { experienceId: string; variantIndex: number };
                type: "Variable";
                value: string | number | boolean | Record<string, JSONType> | null;
            }[],
        ) => Flags;
        getMergeTagValue: (
            embeddedEntryNodeTarget: {
                fields: {
                    nt_fallback?: string;
                    nt_mergetag_id: string;
                    nt_name: string;
                };
                metadata: {
                    concepts?: {
                        sys: { id: string; linkType: "TaxonomyConcept"; type: "Link" };
                    }[];
                    tags: { sys: { id: string; linkType: "Tag"; type: "Link" } }[];
                };
                sys: {
                    contentType: {
                        sys: { id: "nt_mergetag"; linkType: "ContentType"; type: "Link" };
                    };
                    createdAt: any;
                    environment: {
                        sys: { id: string; linkType: "Environment"; type: "Link" };
                    };
                    id: string;
                    locale?: string;
                    publishedVersion: number;
                    revision: number;
                    space: { sys: { id: string; linkType: "Space"; type: "Link" } };
                    type: "Entry";
                    updatedAt: any;
                };
            },
            profile?: {
                audiences: string[];
                id: string;
                location: {
                    city?: string;
                    continent?: string;
                    coordinates?: { latitude: number; longitude: number };
                    country?: string;
                    countryCode?: string;
                    postalCode?: string;
                    region?: string;
                    regionCode?: string;
                    timezone?: string;
                };
                random: number;
                session: {
                    activeSessionLength: number;
                    averageSessionLength: number;
                    count: number;
                    id: string;
                    isReturningVisitor: boolean;
                    landingPage: {
                        path: string;
                        query: Record<string, string>;
                        referrer: string;
                        search: string;
                        title?: string;
                        url: string;
                        [key: string]: JSONType;
                    };
                };
                stableId: string;
                traits: Record<string, JSONType>;
            },
        ) => string
        | undefined;
        personalizeEntry: <
            S extends EntrySkeletonType = EntrySkeletonType,
            L extends string = string,
        >(
            entry: Entry<S, undefined, L>,
            personalizations?: {
                experienceId: string;
                sticky?: boolean;
                variantIndex: number;
                variants: Record<string, string>;
            }[],
        ) => ResolvedData<S, undefined, L> & <
            S extends EntrySkeletonType,
            M extends ChainModifiers = ChainModifiers,
            L extends string = string,
        >(
            entry: Entry<S, M, L>,
            personalizations?: {
                experienceId: string;
                sticky?: boolean;
                variantIndex: number;
                variants: Record<string, string>;
            }[],
        ) => ResolvedData<S, M, L>;
    }

    Implemented by

    Index

    Properties

    getCustomFlag: (
        name: string,
        changes?: {
            key: string;
            meta: { experienceId: string; variantIndex: number };
            type: "Variable";
            value: string | number | boolean | Record<string, JSONType> | null;
        }[],
    ) => unknown

    Get the specified Custom Flag's value from the supplied changes.

    Type Declaration

      • (
            name: string,
            changes?: {
                key: string;
                meta: { experienceId: string; variantIndex: number };
                type: "Variable";
                value: string | number | boolean | Record<string, JSONType> | null;
            }[],
        ): unknown
      • Parameters

        • name: string

          The name or key of the Custom Flag.

        • Optionalchanges: {
              key: string;
              meta: { experienceId: string; variantIndex: number };
              type: "Variable";
              value: string | number | boolean | Record<string, JSONType> | null;
          }[]

          Optional changes array.

          • key: string

            Key identifying the subject of the change.

          • meta: { experienceId: string; variantIndex: number }

            Metadata describing the originating experience and variant index.

            • experienceId: string

              Identifier of the personalization or experiment experience.

            • variantIndex: number

              Index of the variant within the experience configuration.

              Typically corresponds to the array index in the experience's distribution.

          • type: "Variable"

            Discriminator for a variable change.

          • value: string | number | boolean | Record<string, JSONType> | null

            New value for the variable identified by ChangeBase.key.

        Returns unknown

        The current value of the Custom Flag if found.

    The changes array can be sourced from the data returned when emitting any personalization event.

    getCustomFlags: (
        changes?: {
            key: string;
            meta: { experienceId: string; variantIndex: number };
            type: "Variable";
            value: string | number | boolean | Record<string, JSONType> | null;
        }[],
    ) => Flags

    Get all resolved Custom Flags from the supplied changes.

    Type Declaration

      • (
            changes?: {
                key: string;
                meta: { experienceId: string; variantIndex: number };
                type: "Variable";
                value: string | number | boolean | Record<string, JSONType> | null;
            }[],
        ): Flags
      • Parameters

        • Optionalchanges: {
              key: string;
              meta: { experienceId: string; variantIndex: number };
              type: "Variable";
              value: string | number | boolean | Record<string, JSONType> | null;
          }[]

          Optional changes array.

          • key: string

            Key identifying the subject of the change.

          • meta: { experienceId: string; variantIndex: number }

            Metadata describing the originating experience and variant index.

            • experienceId: string

              Identifier of the personalization or experiment experience.

            • variantIndex: number

              Index of the variant within the experience configuration.

              Typically corresponds to the array index in the experience's distribution.

          • type: "Variable"

            Discriminator for a variable change.

          • value: string | number | boolean | Record<string, JSONType> | null

            New value for the variable identified by ChangeBase.key.

        Returns Flags

        The resolved Custom Flag map.

    The changes array can be sourced from the data returned when emitting any personalization event.

    getMergeTagValue: (
        embeddedEntryNodeTarget: {
            fields: {
                nt_fallback?: string;
                nt_mergetag_id: string;
                nt_name: string;
            };
            metadata: {
                concepts?: {
                    sys: { id: string; linkType: "TaxonomyConcept"; type: "Link" };
                }[];
                tags: { sys: { id: string; linkType: "Tag"; type: "Link" } }[];
            };
            sys: {
                contentType: {
                    sys: { id: "nt_mergetag"; linkType: "ContentType"; type: "Link" };
                };
                createdAt: any;
                environment: {
                    sys: { id: string; linkType: "Environment"; type: "Link" };
                };
                id: string;
                locale?: string;
                publishedVersion: number;
                revision: number;
                space: { sys: { id: string; linkType: "Space"; type: "Link" } };
                type: "Entry";
                updatedAt: any;
            };
        },
        profile?: {
            audiences: string[];
            id: string;
            location: {
                city?: string;
                continent?: string;
                coordinates?: { latitude: number; longitude: number };
                country?: string;
                countryCode?: string;
                postalCode?: string;
                region?: string;
                regionCode?: string;
                timezone?: string;
            };
            random: number;
            session: {
                activeSessionLength: number;
                averageSessionLength: number;
                count: number;
                id: string;
                isReturningVisitor: boolean;
                landingPage: {
                    path: string;
                    query: Record<string, string>;
                    referrer: string;
                    search: string;
                    title?: string;
                    url: string;
                    [key: string]: JSONType;
                };
            };
            stableId: string;
            traits: Record<string, JSONType>;
        },
    ) => string
    | undefined

    Resolve a merge tag to a value based on the current (or provided) profile.

    Type Declaration

      • (
            embeddedEntryNodeTarget: {
                fields: {
                    nt_fallback?: string;
                    nt_mergetag_id: string;
                    nt_name: string;
                };
                metadata: {
                    concepts?: {
                        sys: { id: string; linkType: "TaxonomyConcept"; type: "Link" };
                    }[];
                    tags: { sys: { id: string; linkType: "Tag"; type: "Link" } }[];
                };
                sys: {
                    contentType: {
                        sys: { id: "nt_mergetag"; linkType: "ContentType"; type: "Link" };
                    };
                    createdAt: any;
                    environment: {
                        sys: { id: string; linkType: "Environment"; type: "Link" };
                    };
                    id: string;
                    locale?: string;
                    publishedVersion: number;
                    revision: number;
                    space: { sys: { id: string; linkType: "Space"; type: "Link" } };
                    type: "Entry";
                    updatedAt: any;
                };
            },
            profile?: {
                audiences: string[];
                id: string;
                location: {
                    city?: string;
                    continent?: string;
                    coordinates?: { latitude: number; longitude: number };
                    country?: string;
                    countryCode?: string;
                    postalCode?: string;
                    region?: string;
                    regionCode?: string;
                    timezone?: string;
                };
                random: number;
                session: {
                    activeSessionLength: number;
                    averageSessionLength: number;
                    count: number;
                    id: string;
                    isReturningVisitor: boolean;
                    landingPage: {
                        path: string;
                        query: Record<string, string>;
                        referrer: string;
                        search: string;
                        title?: string;
                        url: string;
                        [key: string]: JSONType;
                    };
                };
                stableId: string;
                traits: Record<string, JSONType>;
            },
        ): string
        | undefined
      • Parameters

        • embeddedEntryNodeTarget: {
              fields: {
                  nt_fallback?: string;
                  nt_mergetag_id: string;
                  nt_name: string;
              };
              metadata: {
                  concepts?: {
                      sys: { id: string; linkType: "TaxonomyConcept"; type: "Link" };
                  }[];
                  tags: { sys: { id: string; linkType: "Tag"; type: "Link" } }[];
              };
              sys: {
                  contentType: {
                      sys: { id: "nt_mergetag"; linkType: "ContentType"; type: "Link" };
                  };
                  createdAt: any;
                  environment: {
                      sys: { id: string; linkType: "Environment"; type: "Link" };
                  };
                  id: string;
                  locale?: string;
                  publishedVersion: number;
                  revision: number;
                  space: { sys: { id: string; linkType: "Space"; type: "Link" } };
                  type: "Entry";
                  updatedAt: any;
              };
          }

          The merge‑tag entry node to resolve.

          • fields: { nt_fallback?: string; nt_mergetag_id: string; nt_name: string }
            • Optionalnt_fallback?: string

              Fallback value to use when the merge tag cannot be resolved.

            • nt_mergetag_id: string

              Internal identifier of the merge tag.

            • nt_name: string

              Human-readable name of the merge tag.

          • metadata: {
                concepts?: {
                    sys: { id: string; linkType: "TaxonomyConcept"; type: "Link" };
                }[];
                tags: { sys: { id: string; linkType: "Tag"; type: "Link" } }[];
            }

            Contentful metadata, including tags.

          • sys: {
                contentType: {
                    sys: { id: "nt_mergetag"; linkType: "ContentType"; type: "Link" };
                };
                createdAt: any;
                environment: { sys: { id: string; linkType: "Environment"; type: "Link" } };
                id: string;
                locale?: string;
                publishedVersion: number;
                revision: number;
                space: { sys: { id: string; linkType: "Space"; type: "Link" } };
                type: "Entry";
                updatedAt: any;
            }

            System fields extended to constrain the content type to nt_mergetag.

        • Optionalprofile: {
              audiences: string[];
              id: string;
              location: {
                  city?: string;
                  continent?: string;
                  coordinates?: { latitude: number; longitude: number };
                  country?: string;
                  countryCode?: string;
                  postalCode?: string;
                  region?: string;
                  regionCode?: string;
                  timezone?: string;
              };
              random: number;
              session: {
                  activeSessionLength: number;
                  averageSessionLength: number;
                  count: number;
                  id: string;
                  isReturningVisitor: boolean;
                  landingPage: {
                      path: string;
                      query: Record<string, string>;
                      referrer: string;
                      search: string;
                      title?: string;
                      url: string;
                      [key: string]: JSONType;
                  };
              };
              stableId: string;
              traits: Record<string, JSONType>;
          }

          Optional profile.

          • audiences: string[]

            List of audience identifiers that this profile currently belongs to.

          • id: string

            Primary identifier of the profile.

          • location: {
                city?: string;
                continent?: string;
                coordinates?: { latitude: number; longitude: number };
                country?: string;
                countryCode?: string;
                postalCode?: string;
                region?: string;
                regionCode?: string;
                timezone?: string;
            }

            Geo-location information associated with the profile.

            • Optionalcity?: string

              City name associated with the location.

            • Optionalcontinent?: string

              Continent name associated with the location.

            • Optionalcoordinates?: { latitude: number; longitude: number }

              Geographical coordinates for the location.

              • latitude: number

                Latitude component of the coordinates.

              • longitude: number

                Longitude component of the coordinates.

            • Optionalcountry?: string

              Country name associated with the location.

            • OptionalcountryCode?: string

              Country code associated with the location.

              Validated to exactly COUNTRY_CODE_LENGTH characters, typically an ISO 3166-1 alpha-2 code.

            • OptionalpostalCode?: string

              Postal or ZIP code associated with the location.

            • Optionalregion?: string

              Region or state name associated with the location.

            • OptionalregionCode?: string

              Region or state code associated with the location.

            • Optionaltimezone?: string

              Time zone identifier associated with the location.

              Typically an IANA time zone string (e.g., "Europe/Berlin").

          • random: number

            Random value associated with the profile.

            Often used for deterministic bucketing (e.g., in experiments).

          • session: {
                activeSessionLength: number;
                averageSessionLength: number;
                count: number;
                id: string;
                isReturningVisitor: boolean;
                landingPage: {
                    path: string;
                    query: Record<string, string>;
                    referrer: string;
                    search: string;
                    title?: string;
                    url: string;
                    [key: string]: JSONType;
                };
            }

            Aggregated session statistics for the profile.

            • activeSessionLength: number

              Duration of the active session.

            • averageSessionLength: number

              Average session duration across all sessions represented by this record.

              The unit should match SessionStatistics.activeSessionLength.

            • count: number

              Number of sessions associated with this profile or identifier.

              Often used in combination with SessionStatistics.averageSessionLength.

            • id: string

              Unique identifier for this session statistics record.

            • isReturningVisitor: boolean

              Indicates whether the visitor has been seen before.

              true typically means the visitor has at least one prior session.

            • landingPage: {
                  path: string;
                  query: Record<string, string>;
                  referrer: string;
                  search: string;
                  title?: string;
                  url: string;
                  [key: string]: JSONType;
              }

              Landing page for the session.

              Represents the first page the user visited in this session.

              Page

              • path: string

                Path component of the page URL (e.g., /products/123).

              • query: Record<string, string>

                Parsed query parameters for the page.

              • referrer: string

                Referrer URL that led to the current page.

              • search: string

                Raw search string including the leading ? (e.g., "?q=test").

              • Optionaltitle?: string

                Title of the page as seen by the user.

              • url: string

                Full URL of the page.

          • stableId: string

            Stable, long-lived identifier of the profile.

            Intended to remain constant across sessions and devices when possible. Usually equal to id.

          • traits: Record<string, JSONType>

            Traits describing the profile (user-level attributes).

            Traits

        Returns string | undefined

        The resolved value (type depends on the tag).

    Merge tags are references to profile data that can be substituted into content. The profile can be sourced from the data returned when emitting any personalization event.

    personalizeEntry: <
        S extends EntrySkeletonType = EntrySkeletonType,
        L extends string = string,
    >(
        entry: Entry<S, undefined, L>,
        personalizations?: {
            experienceId: string;
            sticky?: boolean;
            variantIndex: number;
            variants: Record<string, string>;
        }[],
    ) => ResolvedData<S, undefined, L> & <
        S extends EntrySkeletonType,
        M extends ChainModifiers = ChainModifiers,
        L extends string = string,
    >(
        entry: Entry<S, M, L>,
        personalizations?: {
            experienceId: string;
            sticky?: boolean;
            variantIndex: number;
            variants: Record<string, string>;
        }[],
    ) => ResolvedData<S, M, L>

    Resolve a Contentful entry to a personalized variant using the current or provided selected personalizations.

    Entry skeleton type.

    Chain modifiers.

    Locale code.

    Param: entry

    The entry to personalize.

    Optional selections.

    The resolved entry data.

    Selected personalizations can be sourced from the data returned when emitting any personalization event.