import { SimpleEventEmitter } from './eventemitter'; import { AgridFlagsResponse, AgridCoreOptions, AgridEventProperties, AgridCaptureOptions, JsonType, AgridRemoteConfig, FeatureFlagValue, AgridFeatureFlagDetails, FeatureFlagDetail, SurveyResponse, AgridFetchResponse, AgridFetchOptions, AgridPersistedProperty, Logger } from './types'; import { RetriableOptions } from './utils'; export declare const maybeAdd: (key: string, value: JsonType | undefined) => Record; export declare function logFlushError(err: any): Promise; export declare enum QuotaLimitedFeature { FeatureFlags = "feature_flags", Recordings = "recordings" } export declare abstract class AgridCoreStateless { readonly apiKey: string; readonly host: string; readonly flushAt: number; readonly preloadFeatureFlags: boolean; readonly disableSurveys: boolean; private maxBatchSize; private maxQueueSize; private flushInterval; private flushPromise; private shutdownPromise; private requestTimeout; private featureFlagsRequestTimeoutMs; private remoteConfigRequestTimeoutMs; private removeDebugCallback?; private disableGeoip; private historicalMigration; private evaluationEnvironments?; protected disabled: boolean; protected disableCompression: boolean; private defaultOptIn; private promiseQueue; protected _events: SimpleEventEmitter; protected _flushTimer?: any; protected _retryOptions: RetriableOptions; protected _initPromise: Promise; protected _isInitialized: boolean; protected _remoteConfigResponsePromise?: Promise; protected _logger: Logger; abstract fetch(url: string, options: AgridFetchOptions): Promise; abstract getLibraryId(): string; abstract getLibraryVersion(): string; abstract getCustomUserAgent(): string | void; abstract getPersistedProperty(key: AgridPersistedProperty): T | undefined; abstract setPersistedProperty(key: AgridPersistedProperty, value: T | null): void; constructor(apiKey: string, options?: AgridCoreOptions); protected logMsgIfDebug(fn: () => void): void; protected wrap(fn: () => void): void; protected getCommonEventProperties(): AgridEventProperties; get optedOut(): boolean; optIn(): Promise; optOut(): Promise; on(event: string, cb: (...args: any[]) => void): () => void; /** * Enables or disables debug mode for detailed logging. * * @remarks * Debug mode logs all Agrid calls to the console for troubleshooting. * This is useful during development to understand what data is being sent. * * {@label Initialization} * * @example * ```js * // enable debug mode * agrid.debug(true) * ``` * * @example * ```js * // disable debug mode * agrid.debug(false) * ``` * * @public * * @param {boolean} [debug] If true, will enable debug mode. */ debug(enabled?: boolean): void; get isDebug(): boolean; get isDisabled(): boolean; private buildPayload; addPendingPromise(promise: Promise): Promise; /*** *** TRACKING ***/ protected identifyStateless(distinctId: string, properties?: AgridEventProperties, options?: AgridCaptureOptions): void; protected identifyStatelessImmediate(distinctId: string, properties?: AgridEventProperties, options?: AgridCaptureOptions): Promise; protected captureStateless(distinctId: string, event: string, properties?: AgridEventProperties, options?: AgridCaptureOptions): void; protected captureStatelessImmediate(distinctId: string, event: string, properties?: AgridEventProperties, options?: AgridCaptureOptions): Promise; protected aliasStateless(alias: string, distinctId: string, properties?: AgridEventProperties, options?: AgridCaptureOptions): void; protected aliasStatelessImmediate(alias: string, distinctId: string, properties?: AgridEventProperties, options?: AgridCaptureOptions): Promise; /*** *** GROUPS ***/ protected groupIdentifyStateless(groupType: string, groupKey: string | number, groupProperties?: AgridEventProperties, options?: AgridCaptureOptions, distinctId?: string, eventProperties?: AgridEventProperties): void; protected getRemoteConfig(): Promise; /*** *** FEATURE FLAGS ***/ protected getFlags(distinctId: string, groups?: Record, personProperties?: Record, groupProperties?: Record>, extraPayload?: Record, fetchConfig?: boolean): Promise; protected getFeatureFlagStateless(key: string, distinctId: string, groups?: Record, personProperties?: Record, groupProperties?: Record>, disableGeoip?: boolean): Promise<{ response: FeatureFlagValue | undefined; requestId: string | undefined; }>; protected getFeatureFlagDetailStateless(key: string, distinctId: string, groups?: Record, personProperties?: Record, groupProperties?: Record>, disableGeoip?: boolean): Promise<{ response: FeatureFlagDetail | undefined; requestId: string | undefined; } | undefined>; protected getFeatureFlagPayloadStateless(key: string, distinctId: string, groups?: Record, personProperties?: Record, groupProperties?: Record>, disableGeoip?: boolean): Promise; protected getFeatureFlagPayloadsStateless(distinctId: string, groups?: Record, personProperties?: Record, groupProperties?: Record>, disableGeoip?: boolean, flagKeysToEvaluate?: string[]): Promise; protected getFeatureFlagsStateless(distinctId: string, groups?: Record, personProperties?: Record, groupProperties?: Record>, disableGeoip?: boolean, flagKeysToEvaluate?: string[]): Promise<{ flags: AgridFlagsResponse['featureFlags'] | undefined; payloads: AgridFlagsResponse['featureFlagPayloads'] | undefined; requestId: AgridFlagsResponse['requestId'] | undefined; }>; protected getFeatureFlagsAndPayloadsStateless(distinctId: string, groups?: Record, personProperties?: Record, groupProperties?: Record>, disableGeoip?: boolean, flagKeysToEvaluate?: string[]): Promise<{ flags: AgridFlagsResponse['featureFlags'] | undefined; payloads: AgridFlagsResponse['featureFlagPayloads'] | undefined; requestId: AgridFlagsResponse['requestId'] | undefined; }>; protected getFeatureFlagDetailsStateless(distinctId: string, groups?: Record, personProperties?: Record, groupProperties?: Record>, disableGeoip?: boolean, flagKeysToEvaluate?: string[]): Promise; /*** *** SURVEYS ***/ getSurveysStateless(): Promise; /*** *** SUPER PROPERTIES ***/ private _props; protected get props(): AgridEventProperties; protected set props(val: AgridEventProperties | undefined); register(properties: AgridEventProperties): Promise; unregister(property: string): Promise; /*** *** QUEUEING AND FLUSHING ***/ protected enqueue(type: string, _message: any, options?: AgridCaptureOptions): void; protected sendImmediate(type: string, _message: any, options?: AgridCaptureOptions): Promise; private prepareMessage; private clearFlushTimer; /** * Helper for flushing the queue in the background * Avoids unnecessary promise errors */ private flushBackground; /** * Flushes the queue of pending events. * * This function will return a promise that will resolve when the flush is complete, * or reject if there was an error (for example if the server or network is down). * * If there is already a flush in progress, this function will wait for that flush to complete. * * It's recommended to do error handling in the callback of the promise. * * {@label Initialization} * * @example * ```js * // flush with error handling * agrid.flush().then(() => { * console.log('Flush complete') * }).catch((err) => { * console.error('Flush failed', err) * }) * ``` * * @public * * @throws AgridFetchHttpError * @throws AgridFetchNetworkError * @throws Error */ flush(): Promise; protected getCustomHeaders(): { [key: string]: string; }; private _flush; private fetchWithRetry; _shutdown(shutdownTimeoutMs?: number): Promise; } //# sourceMappingURL=agrid-core-stateless.d.ts.map