import { ConfigService } from '../config_service'; import { LsFetch } from '../fetch'; import { AdditionalContext } from '../api_types'; import { FeatureFlagService } from '../feature_flags'; import { ContextResolution } from '../advanced_context/context_resolvers/advanced_context_resolver'; import { GitLabApiClient } from '../api'; import { TRACKING_EVENTS } from './constants'; import { GitlabRealm, ICodeSuggestionContextUpdate, SuggestionSource, TelemetryTracker } from './tracking_types'; interface ContextItem { file_extension: string; type: AdditionalContext['type']; resolution_strategy: ContextResolution['strategy']; byte_size: number; } export interface ISnowplowCodeSuggestionContext { schema: string; data: { prefix_length?: number; suffix_length?: number; language?: string | null; gitlab_realm?: GitlabRealm; model_engine?: string | null; model_name?: string | null; api_status_code?: number | null; debounce_interval?: number | null; suggestion_source?: SuggestionSource; gitlab_global_user_id?: string | null; gitlab_instance_id?: string | null; gitlab_host_name?: string | null; gitlab_saas_duo_pro_namespace_ids: number[] | null; gitlab_instance_version: string | null; is_streaming?: boolean; is_invoked?: boolean | null; options_count?: number | null; accepted_option?: number | null; /** * boolean indicating whether the feature is enabled * and we sent context in the request */ has_advanced_context?: boolean | null; /** * boolean indicating whether request is direct to cloud connector */ is_direct_connection?: boolean | null; total_context_size_bytes?: number; content_above_cursor_size_bytes?: number; content_below_cursor_size_bytes?: number; /** * set of final context items sent to AI Gateway */ context_items?: ContextItem[] | null; /** * total tokens used in request to model provider */ input_tokens?: number | null; /** * total output tokens recieved from model provider */ output_tokens?: number | null; /** * total tokens sent as context to AI Gateway */ context_tokens_sent?: number | null; /** * total context tokens used in request to model provider */ context_tokens_used?: number | null; }; } export declare const EVENT_VALIDATION_ERROR_MSG = "Telemetry event context is not valid - event won't be tracked."; export declare class SnowplowTracker implements TelemetryTracker { #private; constructor(lsFetch: LsFetch, configService: ConfigService, featureFlagService: FeatureFlagService, api: GitLabApiClient); isEnabled(): boolean; setCodeSuggestionsContext(uniqueTrackingId: string, context: Partial): void; updateCodeSuggestionsContext(uniqueTrackingId: string, contextUpdate: Partial): void; updateSuggestionState(uniqueTrackingId: string, newState: TRACKING_EVENTS): void; rejectOpenedSuggestions(): void; } export {};