/**
* Castle Integration. Tracks page views and user login/logout for security
* purposes.
*
* @example
Adding Castle integration to analytics
* ```
*
* import analytics, \{ integrations \} from '\@farfetch/blackout-react/analytics';
*
* analytics.addIntegration('castle', integrations.Castle, \{
* configureOptions: \{
* pk: castle publishable key,
* window?: Overrides the browser window object,
* avoidCookies?: Disables the usage of cookies whenever possible when set to true,
* cookieDomain?: When cookies are used, set the cookie domain scope,
* timeout?: Request timeout for page, form, custom events,
* \},
* debugModeOn?: Boolean - if true, will log tracked events,
* httpClient?: Custom Axios instance to install the interceptor,
* clientIdHeaderName?: Custom name for the header that will be appended via the interceptor,
* configureHttpClient?: Custom function that will be responsible for handling the castle request token,
* \});
* ```
*/
import * as castleJS from '@castleio/castle-js';
import { type EventData, integrations, type LoadIntegrationEventData, type PageviewEventData, type StrippedDownAnalytics, type TrackEventData, type TrackTypesValues } from '@farfetch/blackout-analytics';
import type { AxiosInstance, InternalAxiosRequestConfig } from 'axios';
import type { CastleIntegrationOptions } from './types/index.js';
export declare const CASTLE_MESSAGE_PREFIX = "Castle 2.x -";
/**
* Castle integration.
*/
declare class Castle extends integrations.Integration {
httpClientInterceptor?: number;
isInterceptorAttached?: boolean;
debugModeOn: boolean;
castleJS: typeof castleJS;
httpClient: AxiosInstance;
clientIdHeaderName: string;
static readonly CLIENT_ID_HEADER_NAME = "X-Castle-Request-Token";
/**
* This integration is required, so it should load independently of user consent.
*
* @returns If the integration should load.
*/
static shouldLoad(): boolean;
/**
* Creates an instance of Castle integration.
*
* @param options - Integration options.
* @param loadData - Analytics's load event data.
* @param analytics - Stripped down analytics instance.
*/
constructor(options: CastleIntegrationOptions, loadData: LoadIntegrationEventData, analytics: StrippedDownAnalytics);
/**
* Method that will validate each important option and throw an error if necessary.
*
* @param options - Integration options.
*/
validateOptions(options: CastleIntegrationOptions): void;
/**
* After the validations, this method will apply the options passed in and install
* the interceptor.
*
* @param options - Integration options.
*/
applyOptions(options: CastleIntegrationOptions): void;
/**
* Installs the necessary request interceptor on the axios client.
*
* @param options - Integration options.
*/
installInterceptor(options: CastleIntegrationOptions): Promise;
/**
* Callback that is used on the Axios interceptor to add the correct Castle token
* header.
*
* @param config - Axios config object.
*
* @returns - The modified Axios config object.
*/
onBeforeRequestFullfil: (config: InternalAxiosRequestConfig) => Promise;
/**
* Returns the user object data formatted for the Castle needs.
*
* @param data - Data Track event data.
*
* @returns - The formatted user object.
*/
getUserData(data: TrackEventData | PageviewEventData): castleJS.UserParams;
/**
* Calculates the correct user account created date, if possible.
*
* TODO: Remove this 🔨 when the backend starts to send the correct format date on all endpoints.
*
* @param createdDate - The user trait.
*
* @returns - The ISO date string.
*/
getNormalizedCreatedDate(createdDate: string | null | undefined): string | undefined;
/**
* Track method that will filter by event type: page or track.
*
* @param data - Track event data.
*
* @returns - Promise that will resolve when the method finishes.
*/
track(data: EventData): castleJS.Thenable | null | undefined;
/**
* Method that will handle each type of event to be tracked.
*
* @param data - Data Track event data.
*
* @returns - The resolved promise of each castle call method.
*/
trackEvent(data: TrackEventData): castleJS.Thenable | null;
}
export default Castle;