Contentful Personalization & Analytics
    Preparing search index...
    • Type guard for OptimizationEntry.

      Parameters

      • entry: unknown

        Contentful entry or link to test.

      Returns entry is {
          fields: {
              nt_audience?:
                  | {
                      fields: {
                          nt_audience_id: string;
                          nt_description?: string;
                          nt_name?: string;
                          [key: string]: JSONType;
                      };
                      metadata: {
                          concepts?: {
                              sys: { id: string; linkType: "TaxonomyConcept"; type: "Link" };
                          }[];
                          tags: { sys: { id: string; linkType: "Tag"; type: "Link" } }[];
                      };
                      sys: {
                          contentType: {
                              sys: { id: string; 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;
                      };
                  }
                  | null;
              nt_config?: | {
                  components?: (
                      | {
                          baseline: { hidden?: boolean; id: string };
                          type?: "EntryReplacement";
                          variants: { hidden?: (...) | (...) | (...); id: string }[];
                      }
                      | {
                          baseline: {
                              value: string
                              | number
                              | boolean
                              | Record<(...), (...)>
                              | null;
                          };
                          key: string;
                          type: "InlineVariable";
                          valueType: "Boolean"
                          | "Number"
                          | "Object"
                          | "String";
                          variants: { value: (...) | (...) | (...) | (...) | (...) | (...) }[];
                      }
                  )[];
                  distribution?: number[];
                  sticky?: boolean;
                  traffic?: number;
              }
              | null;
              nt_description?: string
              | null;
              nt_experience_id: string;
              nt_name: string;
              nt_type: "nt_experiment" | "nt_personalization";
              nt_variants?: (
                  | { sys: { id: string; linkType: string; type: "Link" } }
                  | {
                      fields: { [key: string]: JSONType };
                      metadata: {
                          concepts?: { sys: { id: ...; linkType: ...; type: ... } }[];
                          tags: { sys: { id: string; linkType: "Tag"; type: "Link" } }[];
                      };
                      sys: {
                          contentType: {
                              sys: { id: string; 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;
                      };
                  }
              )[];
              [key: string]: JSONType;
          };
          metadata: {
              concepts?: {
                  sys: { id: string; linkType: "TaxonomyConcept"; type: "Link" };
              }[];
              tags: { sys: { id: string; linkType: "Tag"; type: "Link" } }[];
          };
          sys: {
              contentType: {
                  sys: { id: string; 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;
          };
      }

      true if the value conforms to OptimizationEntry, otherwise false.

      if (isOptimizationEntry(entry)) {
      console.log(entry.fields.nt_name);
      }