import type { EventSpecMetadata } from "./eventSpec/AvoEventSpecFetchTypes"; /** * Recursive type for schema children. * - For object properties: array of EventProperty objects * - For list properties: array of strings (primitive types) or nested structures */ export type SchemaChild = string | EventProperty | SchemaChild[]; /** * Property schema with optional validation results. */ export interface EventProperty { propertyName: string; propertyType: string; encryptedPropertyValue?: string; children?: SchemaChild[]; /** Event/variant IDs that FAILED validation (present if smaller or equal to passed) */ failedEventIds?: string[]; /** Event/variant IDs that PASSED validation (present if smaller than failed) */ passedEventIds?: string[]; } export interface BaseBody { apiKey: string; appName: string; appVersion: string; libVersion: string; env: string; libPlatform: "web"; messageId: string; trackingId: string; createdAt: string; sessionId: string; streamId: string; samplingRate: number; /** Event spec metadata from EventSpecResponse (moved from EventSchemaBody) */ eventSpecMetadata?: EventSpecMetadata; /** RSA public encryption key - allows Inspector to validate encrypted values against tracking plan */ publicEncryptionKey?: string; } export interface SessionStartedBody extends BaseBody { type: "sessionStarted"; } /** * INTERNAL — not part of the public API, and not exported from either entry * point. Per-call gateway coordinates for the web GTM tag template, which passes * them as a third argument to `window.inspector.trackSchemaFromEvent` in the * script-tag build (see src/browser.js). * * They are sent as top-level siblings of `eventProperties` on the track body — * never nested inside the schema, and never read from event data. Every value is * trimmed; empty, whitespace-only and non-string values are treated as absent. * * They only apply on the v2 transport, i.e. when a client is configured. * `POST /inspector/v2/track` decodes both hints and accepts a literal * `appVersion: null` (stored as "unversioned"). Without a client the SDK is on * `POST /inspector/v1/track` and the options are ignored entirely, `appVersion` * included, so the body is exactly the one 3.2.0 built. * * Defined locally (not imported) in both AvoNetworkCallsHandler.ts and * AvoNetworkCallsHandlerLite.ts to keep the lite-sync diff flat. */ export interface TrackOptions { /** Reference of the gateway output this observation was bound for. Omit for a gateway-level observation. */ outputReference?: string; /** Low-cardinality hint identifying the event's upstream source (e.g. "web", "ios"). Never a user identifier. */ originHint?: string; /** App version of the source that produced the event. With originHint set, replaces the SDK's configured version (literal null when omitted); without originHint, overrides it only when provided. */ appVersion?: string; } /** Events of a failed send that are worth queueing again; undefined means all of them. */ type RetryEvents = Array | undefined; export interface EventSchemaBody extends Omit { type: "event"; /** * Nullable only here, and only on v2: with an originHint set and no per-event * appVersion the event is source-scoped, so a literal null is sent rather than * the SDK's configured version. Session-started bodies, and every v1 body, * always carry the string version. */ appVersion: string | null; /** ID of the base event from spec (null if no spec available) */ eventId: string | null; /** Name seen in code */ eventName?: string; eventProperties: EventProperty[]; avoFunction: boolean; eventHash: string | null; /** Branch ID from getEventSpec response when value validation was performed */ validatedBranchId?: string; /** Gateway output this observation was bound for; absent = gateway checkpoint. v2 only. */ outputReference?: string; /** Low-cardinality hint identifying the event's upstream source. v2 only. */ originHint?: string; } export declare class AvoNetworkCallsHandler { private readonly apiKey; private readonly envName; private readonly appName; private readonly appVersion; private readonly libVersion; private readonly publicEncryptionKey?; /** * "gtm-web" for the web GTM tag template, otherwise undefined. It is the * transport switch, decided once in the constructor: undefined keeps the v1 * request byte for byte as 3.2.0 sent it; "gtm-web" selects v2 and is the * X-Avo-Client value. */ private readonly client; private readonly trackingEndpoint; private samplingRate; private sending; /** v2 only: permanent failures in a row for this instance's own events. */ private permanentFailures; /** v2 only: permanent failures in a row per other api key and env, keyed as the send groups are. */ private readonly foreignFailures; /** v2 only: set at most once, when sending can no longer succeed on this page. */ private sendingDisabled; /** v2 only: set when the events themselves can never be sent, so queueing them would only grow the stored queue. */ private queueingDisabled; constructor(apiKey: string, envName: string, appName: string, appVersion: string, libVersion: string, publicEncryptionKey?: string, client?: string); /** * v2 only: true once sending has stopped for this page (see * maxConsecutivePermanentFailures). Always false on v1. */ isSendingDisabled(): boolean; /** * v2 only: true when queueing events would only grow the stored queue, because * they could never be sent under any configuration. Always false on v1. */ isQueueingDisabled(): boolean; private disableSending; /** True while a batch sent through callInspectorWithBatchBody awaits its response. */ isBatchInFlight(): boolean; callInspectorWithBatchBody(inEvents: Array, onCompleted: (error: Error | null, retryEvents?: RetryEvents) => any): void; private fixStreamIds; bodyForSessionStartedCall(): SessionStartedBody; bodyForEventSchemaCall(eventName: string, eventProperties: EventProperty[], eventId: string | null, eventHash: string | null, eventSpecMetadata?: EventSpecMetadata, validatedBranchId?: string, options?: TrackOptions): EventSchemaBody; private createBaseCallBody; /** * Calls Inspector API immediately with a single event (bypasses batching). * Used when event spec validation is available. * Note: Does not drop due to sampling - validated events are always sent. */ callInspectorImmediately(eventBody: EventSchemaBody, onCompleted: (error: Error | null) => any): void; /** * Check if event should be dropped based on sampling rate. */ private shouldDropBySampling; /** * Core Inspector API call logic shared by batch and immediate calls. * * Bodies large enough to be worth it are gzipped (with Content-Encoding: gzip) * to cut network volume ~10x. When CompressionStream is unavailable or * compression fails, the body is sent uncompressed exactly as before — * synchronously in the unavailable case, so legacy timing is preserved. */ private callInspectorApi; private sendEvents; /** * Reports a failure as permanent (second argument true) when retrying the same * request cannot succeed: the browser refused to build it, or the API answered * a 4xx other than 408 and 429. */ private sendTrackingRequest; } export {};