Contentful Personalization & Analytics
    Preparing search index...

    Configuration for InsightsApiClient.

    interface InsightsApiClientConfig {
        baseUrl?: string;
        beaconHandler?: (
            url: string | URL,
            data: {
                events: (
                    | {
                        channel: "mobile"
                        | "server"
                        | "web";
                        componentId: string;
                        componentType: "Entry" | "Variable";
                        componentViewId: string;
                        context: {
                            app?: { name: string; version: string };
                            campaign: {
                                content?: string;
                                medium?: string;
                                name?: string;
                                source?: string;
                                term?: string;
                            };
                            gdpr: { isConsentGiven: boolean };
                            library: { name: string; version: string };
                            locale: string;
                            location?: {
                                city?: (...) | (...);
                                continent?: (...) | (...);
                                coordinates?: (...) | (...);
                                country?: (...) | (...);
                                countryCode?: (...) | (...);
                                postalCode?: (...) | (...);
                                region?: (...) | (...);
                                regionCode?: (...) | (...);
                                timezone?: (...) | (...);
                            };
                            page?: {
                                path: string;
                                query: Record<(...), (...)>;
                                referrer: string;
                                search: string;
                                title?: (...) | (...);
                                url: string;
                                [key: string]: JSONType;
                            };
                            screen?: { name: string; [key: string]: JSONType };
                            userAgent?: string;
                        };
                        experienceId?: string;
                        messageId: string;
                        originalTimestamp: string;
                        sentAt: string;
                        timestamp: string;
                        type: "component";
                        userId?: string;
                        variantIndex: number;
                        viewDurationMs: number;
                    }
                    | {
                        channel: "mobile"
                        | "server"
                        | "web";
                        componentId: string;
                        componentType: "Entry" | "Variable";
                        context: {
                            app?: { name: string; version: string };
                            campaign: {
                                content?: string;
                                medium?: string;
                                name?: string;
                                source?: string;
                                term?: string;
                            };
                            gdpr: { isConsentGiven: boolean };
                            library: { name: string; version: string };
                            locale: string;
                            location?: {
                                city?: (...) | (...);
                                continent?: (...) | (...);
                                coordinates?: (...) | (...);
                                country?: (...) | (...);
                                countryCode?: (...) | (...);
                                postalCode?: (...) | (...);
                                region?: (...) | (...);
                                regionCode?: (...) | (...);
                                timezone?: (...) | (...);
                            };
                            page?: {
                                path: string;
                                query: Record<(...), (...)>;
                                referrer: string;
                                search: string;
                                title?: (...) | (...);
                                url: string;
                                [key: string]: JSONType;
                            };
                            screen?: { name: string; [key: string]: JSONType };
                            userAgent?: string;
                        };
                        experienceId?: string;
                        messageId: string;
                        originalTimestamp: string;
                        sentAt: string;
                        timestamp: string;
                        type: "component_click";
                        userId?: string;
                        variantIndex: number;
                    }
                    | {
                        channel: "mobile"
                        | "server"
                        | "web";
                        componentHoverId: string;
                        componentId: string;
                        componentType: "Entry" | "Variable";
                        context: {
                            app?: { name: string; version: string };
                            campaign: {
                                content?: string;
                                medium?: string;
                                name?: string;
                                source?: string;
                                term?: string;
                            };
                            gdpr: { isConsentGiven: boolean };
                            library: { name: string; version: string };
                            locale: string;
                            location?: {
                                city?: (...) | (...);
                                continent?: (...) | (...);
                                coordinates?: (...) | (...);
                                country?: (...) | (...);
                                countryCode?: (...) | (...);
                                postalCode?: (...) | (...);
                                region?: (...) | (...);
                                regionCode?: (...) | (...);
                                timezone?: (...) | (...);
                            };
                            page?: {
                                path: string;
                                query: Record<(...), (...)>;
                                referrer: string;
                                search: string;
                                title?: (...) | (...);
                                url: string;
                                [key: string]: JSONType;
                            };
                            screen?: { name: string; [key: string]: JSONType };
                            userAgent?: string;
                        };
                        experienceId?: string;
                        hoverDurationMs: number;
                        messageId: string;
                        originalTimestamp: string;
                        sentAt: string;
                        timestamp: string;
                        type: "component_hover";
                        userId?: string;
                        variantIndex: number;
                    }
                )[];
                profile: { id: string; [key: string]: JSONType };
            }[],
        ) => boolean;
        clientId: string;
        environment?: string;
        fetchOptions?: Omit<ProtectedFetchMethodOptions, "apiName">;
    }

    Hierarchy (View Summary)

    • ApiConfig
    • RequestOptions
      • InsightsApiClientConfig
    Index

    Properties

    baseUrl?: string

    Base URL for the API.

    When omitted, the concrete client is expected to construct full URLs internally.

    beaconHandler?: (
        url: string | URL,
        data: {
            events: (
                | {
                    channel: "mobile"
                    | "server"
                    | "web";
                    componentId: string;
                    componentType: "Entry" | "Variable";
                    componentViewId: string;
                    context: {
                        app?: { name: string; version: string };
                        campaign: {
                            content?: string;
                            medium?: string;
                            name?: string;
                            source?: string;
                            term?: string;
                        };
                        gdpr: { isConsentGiven: boolean };
                        library: { name: string; version: string };
                        locale: string;
                        location?: {
                            city?: (...) | (...);
                            continent?: (...) | (...);
                            coordinates?: (...) | (...);
                            country?: (...) | (...);
                            countryCode?: (...) | (...);
                            postalCode?: (...) | (...);
                            region?: (...) | (...);
                            regionCode?: (...) | (...);
                            timezone?: (...) | (...);
                        };
                        page?: {
                            path: string;
                            query: Record<(...), (...)>;
                            referrer: string;
                            search: string;
                            title?: (...) | (...);
                            url: string;
                            [key: string]: JSONType;
                        };
                        screen?: { name: string; [key: string]: JSONType };
                        userAgent?: string;
                    };
                    experienceId?: string;
                    messageId: string;
                    originalTimestamp: string;
                    sentAt: string;
                    timestamp: string;
                    type: "component";
                    userId?: string;
                    variantIndex: number;
                    viewDurationMs: number;
                }
                | {
                    channel: "mobile"
                    | "server"
                    | "web";
                    componentId: string;
                    componentType: "Entry" | "Variable";
                    context: {
                        app?: { name: string; version: string };
                        campaign: {
                            content?: string;
                            medium?: string;
                            name?: string;
                            source?: string;
                            term?: string;
                        };
                        gdpr: { isConsentGiven: boolean };
                        library: { name: string; version: string };
                        locale: string;
                        location?: {
                            city?: (...) | (...);
                            continent?: (...) | (...);
                            coordinates?: (...) | (...);
                            country?: (...) | (...);
                            countryCode?: (...) | (...);
                            postalCode?: (...) | (...);
                            region?: (...) | (...);
                            regionCode?: (...) | (...);
                            timezone?: (...) | (...);
                        };
                        page?: {
                            path: string;
                            query: Record<(...), (...)>;
                            referrer: string;
                            search: string;
                            title?: (...) | (...);
                            url: string;
                            [key: string]: JSONType;
                        };
                        screen?: { name: string; [key: string]: JSONType };
                        userAgent?: string;
                    };
                    experienceId?: string;
                    messageId: string;
                    originalTimestamp: string;
                    sentAt: string;
                    timestamp: string;
                    type: "component_click";
                    userId?: string;
                    variantIndex: number;
                }
                | {
                    channel: "mobile"
                    | "server"
                    | "web";
                    componentHoverId: string;
                    componentId: string;
                    componentType: "Entry" | "Variable";
                    context: {
                        app?: { name: string; version: string };
                        campaign: {
                            content?: string;
                            medium?: string;
                            name?: string;
                            source?: string;
                            term?: string;
                        };
                        gdpr: { isConsentGiven: boolean };
                        library: { name: string; version: string };
                        locale: string;
                        location?: {
                            city?: (...) | (...);
                            continent?: (...) | (...);
                            coordinates?: (...) | (...);
                            country?: (...) | (...);
                            countryCode?: (...) | (...);
                            postalCode?: (...) | (...);
                            region?: (...) | (...);
                            regionCode?: (...) | (...);
                            timezone?: (...) | (...);
                        };
                        page?: {
                            path: string;
                            query: Record<(...), (...)>;
                            referrer: string;
                            search: string;
                            title?: (...) | (...);
                            url: string;
                            [key: string]: JSONType;
                        };
                        screen?: { name: string; [key: string]: JSONType };
                        userAgent?: string;
                    };
                    experienceId?: string;
                    hoverDurationMs: number;
                    messageId: string;
                    originalTimestamp: string;
                    sentAt: string;
                    timestamp: string;
                    type: "component_hover";
                    userId?: string;
                    variantIndex: number;
                }
            )[];
            profile: { id: string; [key: string]: JSONType };
        }[],
    ) => boolean

    Handler used to enqueue events via the Beacon API or a similar mechanism.

    Type Declaration

      • (
            url: string | URL,
            data: {
                events: (
                    | {
                        channel: "mobile"
                        | "server"
                        | "web";
                        componentId: string;
                        componentType: "Entry" | "Variable";
                        componentViewId: string;
                        context: {
                            app?: { name: string; version: string };
                            campaign: {
                                content?: string;
                                medium?: string;
                                name?: string;
                                source?: string;
                                term?: string;
                            };
                            gdpr: { isConsentGiven: boolean };
                            library: { name: string; version: string };
                            locale: string;
                            location?: {
                                city?: (...) | (...);
                                continent?: (...) | (...);
                                coordinates?: (...) | (...);
                                country?: (...) | (...);
                                countryCode?: (...) | (...);
                                postalCode?: (...) | (...);
                                region?: (...) | (...);
                                regionCode?: (...) | (...);
                                timezone?: (...) | (...);
                            };
                            page?: {
                                path: string;
                                query: Record<(...), (...)>;
                                referrer: string;
                                search: string;
                                title?: (...) | (...);
                                url: string;
                                [key: string]: JSONType;
                            };
                            screen?: { name: string; [key: string]: JSONType };
                            userAgent?: string;
                        };
                        experienceId?: string;
                        messageId: string;
                        originalTimestamp: string;
                        sentAt: string;
                        timestamp: string;
                        type: "component";
                        userId?: string;
                        variantIndex: number;
                        viewDurationMs: number;
                    }
                    | {
                        channel: "mobile"
                        | "server"
                        | "web";
                        componentId: string;
                        componentType: "Entry" | "Variable";
                        context: {
                            app?: { name: string; version: string };
                            campaign: {
                                content?: string;
                                medium?: string;
                                name?: string;
                                source?: string;
                                term?: string;
                            };
                            gdpr: { isConsentGiven: boolean };
                            library: { name: string; version: string };
                            locale: string;
                            location?: {
                                city?: (...) | (...);
                                continent?: (...) | (...);
                                coordinates?: (...) | (...);
                                country?: (...) | (...);
                                countryCode?: (...) | (...);
                                postalCode?: (...) | (...);
                                region?: (...) | (...);
                                regionCode?: (...) | (...);
                                timezone?: (...) | (...);
                            };
                            page?: {
                                path: string;
                                query: Record<(...), (...)>;
                                referrer: string;
                                search: string;
                                title?: (...) | (...);
                                url: string;
                                [key: string]: JSONType;
                            };
                            screen?: { name: string; [key: string]: JSONType };
                            userAgent?: string;
                        };
                        experienceId?: string;
                        messageId: string;
                        originalTimestamp: string;
                        sentAt: string;
                        timestamp: string;
                        type: "component_click";
                        userId?: string;
                        variantIndex: number;
                    }
                    | {
                        channel: "mobile"
                        | "server"
                        | "web";
                        componentHoverId: string;
                        componentId: string;
                        componentType: "Entry" | "Variable";
                        context: {
                            app?: { name: string; version: string };
                            campaign: {
                                content?: string;
                                medium?: string;
                                name?: string;
                                source?: string;
                                term?: string;
                            };
                            gdpr: { isConsentGiven: boolean };
                            library: { name: string; version: string };
                            locale: string;
                            location?: {
                                city?: (...) | (...);
                                continent?: (...) | (...);
                                coordinates?: (...) | (...);
                                country?: (...) | (...);
                                countryCode?: (...) | (...);
                                postalCode?: (...) | (...);
                                region?: (...) | (...);
                                regionCode?: (...) | (...);
                                timezone?: (...) | (...);
                            };
                            page?: {
                                path: string;
                                query: Record<(...), (...)>;
                                referrer: string;
                                search: string;
                                title?: (...) | (...);
                                url: string;
                                [key: string]: JSONType;
                            };
                            screen?: { name: string; [key: string]: JSONType };
                            userAgent?: string;
                        };
                        experienceId?: string;
                        hoverDurationMs: number;
                        messageId: string;
                        originalTimestamp: string;
                        sentAt: string;
                        timestamp: string;
                        type: "component_hover";
                        userId?: string;
                        variantIndex: number;
                    }
                )[];
                profile: { id: string; [key: string]: JSONType };
            }[],
        ): boolean
      • Parameters

        • url: string | URL

          Target URL for the batched events.

        • data: {
              events: (
                  | {
                      channel: "mobile"
                      | "server"
                      | "web";
                      componentId: string;
                      componentType: "Entry" | "Variable";
                      componentViewId: string;
                      context: {
                          app?: { name: string; version: string };
                          campaign: {
                              content?: string;
                              medium?: string;
                              name?: string;
                              source?: string;
                              term?: string;
                          };
                          gdpr: { isConsentGiven: boolean };
                          library: { name: string; version: string };
                          locale: string;
                          location?: {
                              city?: (...) | (...);
                              continent?: (...) | (...);
                              coordinates?: (...) | (...);
                              country?: (...) | (...);
                              countryCode?: (...) | (...);
                              postalCode?: (...) | (...);
                              region?: (...) | (...);
                              regionCode?: (...) | (...);
                              timezone?: (...) | (...);
                          };
                          page?: {
                              path: string;
                              query: Record<(...), (...)>;
                              referrer: string;
                              search: string;
                              title?: (...) | (...);
                              url: string;
                              [key: string]: JSONType;
                          };
                          screen?: { name: string; [key: string]: JSONType };
                          userAgent?: string;
                      };
                      experienceId?: string;
                      messageId: string;
                      originalTimestamp: string;
                      sentAt: string;
                      timestamp: string;
                      type: "component";
                      userId?: string;
                      variantIndex: number;
                      viewDurationMs: number;
                  }
                  | {
                      channel: "mobile"
                      | "server"
                      | "web";
                      componentId: string;
                      componentType: "Entry" | "Variable";
                      context: {
                          app?: { name: string; version: string };
                          campaign: {
                              content?: string;
                              medium?: string;
                              name?: string;
                              source?: string;
                              term?: string;
                          };
                          gdpr: { isConsentGiven: boolean };
                          library: { name: string; version: string };
                          locale: string;
                          location?: {
                              city?: (...) | (...);
                              continent?: (...) | (...);
                              coordinates?: (...) | (...);
                              country?: (...) | (...);
                              countryCode?: (...) | (...);
                              postalCode?: (...) | (...);
                              region?: (...) | (...);
                              regionCode?: (...) | (...);
                              timezone?: (...) | (...);
                          };
                          page?: {
                              path: string;
                              query: Record<(...), (...)>;
                              referrer: string;
                              search: string;
                              title?: (...) | (...);
                              url: string;
                              [key: string]: JSONType;
                          };
                          screen?: { name: string; [key: string]: JSONType };
                          userAgent?: string;
                      };
                      experienceId?: string;
                      messageId: string;
                      originalTimestamp: string;
                      sentAt: string;
                      timestamp: string;
                      type: "component_click";
                      userId?: string;
                      variantIndex: number;
                  }
                  | {
                      channel: "mobile"
                      | "server"
                      | "web";
                      componentHoverId: string;
                      componentId: string;
                      componentType: "Entry" | "Variable";
                      context: {
                          app?: { name: string; version: string };
                          campaign: {
                              content?: string;
                              medium?: string;
                              name?: string;
                              source?: string;
                              term?: string;
                          };
                          gdpr: { isConsentGiven: boolean };
                          library: { name: string; version: string };
                          locale: string;
                          location?: {
                              city?: (...) | (...);
                              continent?: (...) | (...);
                              coordinates?: (...) | (...);
                              country?: (...) | (...);
                              countryCode?: (...) | (...);
                              postalCode?: (...) | (...);
                              region?: (...) | (...);
                              regionCode?: (...) | (...);
                              timezone?: (...) | (...);
                          };
                          page?: {
                              path: string;
                              query: Record<(...), (...)>;
                              referrer: string;
                              search: string;
                              title?: (...) | (...);
                              url: string;
                              [key: string]: JSONType;
                          };
                          screen?: { name: string; [key: string]: JSONType };
                          userAgent?: string;
                      };
                      experienceId?: string;
                      hoverDurationMs: number;
                      messageId: string;
                      originalTimestamp: string;
                      sentAt: string;
                      timestamp: string;
                      type: "component_hover";
                      userId?: string;
                      variantIndex: number;
                  }
              )[];
              profile: { id: string; [key: string]: JSONType };
          }[]

          Array of batched insights events to be sent.

          • events: (
                | {
                    channel: "mobile"
                    | "server"
                    | "web";
                    componentId: string;
                    componentType: "Entry" | "Variable";
                    componentViewId: string;
                    context: {
                        app?: { name: string; version: string };
                        campaign: {
                            content?: string;
                            medium?: string;
                            name?: string;
                            source?: string;
                            term?: string;
                        };
                        gdpr: { isConsentGiven: boolean };
                        library: { name: string; version: string };
                        locale: string;
                        location?: {
                            city?: (...) | (...);
                            continent?: (...) | (...);
                            coordinates?: (...) | (...);
                            country?: (...) | (...);
                            countryCode?: (...) | (...);
                            postalCode?: (...) | (...);
                            region?: (...) | (...);
                            regionCode?: (...) | (...);
                            timezone?: (...) | (...);
                        };
                        page?: {
                            path: string;
                            query: Record<(...), (...)>;
                            referrer: string;
                            search: string;
                            title?: (...) | (...);
                            url: string;
                            [key: string]: JSONType;
                        };
                        screen?: { name: string; [key: string]: JSONType };
                        userAgent?: string;
                    };
                    experienceId?: string;
                    messageId: string;
                    originalTimestamp: string;
                    sentAt: string;
                    timestamp: string;
                    type: "component";
                    userId?: string;
                    variantIndex: number;
                    viewDurationMs: number;
                }
                | {
                    channel: "mobile"
                    | "server"
                    | "web";
                    componentId: string;
                    componentType: "Entry" | "Variable";
                    context: {
                        app?: { name: string; version: string };
                        campaign: {
                            content?: string;
                            medium?: string;
                            name?: string;
                            source?: string;
                            term?: string;
                        };
                        gdpr: { isConsentGiven: boolean };
                        library: { name: string; version: string };
                        locale: string;
                        location?: {
                            city?: (...) | (...);
                            continent?: (...) | (...);
                            coordinates?: (...) | (...);
                            country?: (...) | (...);
                            countryCode?: (...) | (...);
                            postalCode?: (...) | (...);
                            region?: (...) | (...);
                            regionCode?: (...) | (...);
                            timezone?: (...) | (...);
                        };
                        page?: {
                            path: string;
                            query: Record<(...), (...)>;
                            referrer: string;
                            search: string;
                            title?: (...) | (...);
                            url: string;
                            [key: string]: JSONType;
                        };
                        screen?: { name: string; [key: string]: JSONType };
                        userAgent?: string;
                    };
                    experienceId?: string;
                    messageId: string;
                    originalTimestamp: string;
                    sentAt: string;
                    timestamp: string;
                    type: "component_click";
                    userId?: string;
                    variantIndex: number;
                }
                | {
                    channel: "mobile"
                    | "server"
                    | "web";
                    componentHoverId: string;
                    componentId: string;
                    componentType: "Entry" | "Variable";
                    context: {
                        app?: { name: string; version: string };
                        campaign: {
                            content?: string;
                            medium?: string;
                            name?: string;
                            source?: string;
                            term?: string;
                        };
                        gdpr: { isConsentGiven: boolean };
                        library: { name: string; version: string };
                        locale: string;
                        location?: {
                            city?: (...) | (...);
                            continent?: (...) | (...);
                            coordinates?: (...) | (...);
                            country?: (...) | (...);
                            countryCode?: (...) | (...);
                            postalCode?: (...) | (...);
                            region?: (...) | (...);
                            regionCode?: (...) | (...);
                            timezone?: (...) | (...);
                        };
                        page?: {
                            path: string;
                            query: Record<(...), (...)>;
                            referrer: string;
                            search: string;
                            title?: (...) | (...);
                            url: string;
                            [key: string]: JSONType;
                        };
                        screen?: { name: string; [key: string]: JSONType };
                        userAgent?: string;
                    };
                    experienceId?: string;
                    hoverDurationMs: number;
                    messageId: string;
                    originalTimestamp: string;
                    sentAt: string;
                    timestamp: string;
                    type: "component_hover";
                    userId?: string;
                    variantIndex: number;
                }
            )[]

            Insights events that should be recorded for this profile.

          • profile: { id: string; [key: string]: JSONType }

            Partial profile information used to associate events with a user.

            • id: string

              Identifier of the profile.

              Used to associate events with an existing profile.

        Returns boolean

        true if the events were successfully queued, false otherwise.

    When provided, this handler is preferred over direct fetch calls. If it returns false, the client falls back to emitting events immediately via fetch.

    clientId: string

    Client identifier used for authentication or tracking.

    environment?: string

    Contentful environment identifier.

    'main'

    fetchOptions?: Omit<ProtectedFetchMethodOptions, "apiName">

    Options used to configure the underlying protected fetch method.

    apiName is derived from the client name and must not be provided here.