import type { AnalyticsTrackingEvent } from "@metamask/analytics-controller"; import type { NetworkControllerMessenger, NetworkControllerRpcEndpointDegradedEvent, NetworkControllerRpcEndpointUnavailableEvent } from "./NetworkController.cjs"; type RpcEndpointUnavailablePayload = NetworkControllerRpcEndpointUnavailableEvent['payload'][0]; type RpcEndpointDegradedPayload = NetworkControllerRpcEndpointDegradedEvent['payload'][0]; /** * The names of the analytics events that {@link NetworkController} emits when an * RPC endpoint becomes unavailable or degraded. */ export type RpcServiceEventName = 'RPC Service Unavailable' | 'RPC Service Degraded'; /** * Configuration that enables {@link NetworkController} to emit analytics events * for unavailable or degraded RPC endpoints. * * The pieces here are client-specific and cannot be derived inside the * controller: deciding whether an endpoint URL is safe to report depends on the * client's lists of known networks, and the sample rate depends on the client's * build environment. */ export type NetworkControllerAnalyticsOptions = { /** * Returns `true` if the given RPC endpoint URL is safe to report verbatim (a * "public" endpoint), or `false` if it must be reported as the literal string * `'custom'` to avoid leaking private servers. Defaults to `() => false`. */ isRpcEndpointUrlPublic?: (endpointUrl: string) => boolean; /** * The proportion of events to emit, between 0 and 1. `1` emits every event, * `0` emits none. Clients typically use a small value (e.g. `0.01`) in * production to stay within their analytics quota, and `1` in development. * Defaults to `0`. */ rpcServiceEventsSampleRate?: number; }; /** * {@link NetworkControllerAnalyticsOptions} with defaults applied, as used * internally once the controller has filled in any omitted properties. */ export type ResolvedNetworkControllerAnalyticsOptions = Required; /** * Hides any API key contained in an RPC endpoint URL by reducing it to its * host, but only when the endpoint is considered public. Non-public endpoints * (and URLs that cannot be parsed) are reported as the literal string * `'custom'`. * * @param endpointUrl - The URL of the RPC endpoint. * @param isPublic - Whether the endpoint is safe to report verbatim. * @returns The sanitized value to report. */ export declare function sanitizeRpcEndpointUrl(endpointUrl: string, isPublic: boolean): string; /** * Builds the "RPC Service Unavailable" analytics tracking event. * * @param payload - The `rpcEndpointUnavailable` event payload. * @param isRpcEndpointUrlPublic - Returns whether the endpoint URL is safe to * report verbatim. * @returns The analytics tracking event. */ export declare function buildRpcServiceUnavailableAnalyticsTrackingEvent(payload: RpcEndpointUnavailablePayload, isRpcEndpointUrlPublic: (endpointUrl: string) => boolean): AnalyticsTrackingEvent; /** * Builds the "RPC Service Degraded" analytics tracking event. * * @param payload - The `rpcEndpointDegraded` event payload. * @param isRpcEndpointUrlPublic - Returns whether the endpoint URL is safe to * report verbatim. * @returns The analytics tracking event. */ export declare function buildRpcServiceDegradedAnalyticsTrackingEvent(payload: RpcEndpointDegradedPayload, isRpcEndpointUrlPublic: (endpointUrl: string) => boolean): AnalyticsTrackingEvent; /** * Emits an "RPC Service Unavailable" analytics event. * * @param messenger - The controller messenger. * @param analyticsOptions - The analytics configuration. * @param payload - The `rpcEndpointUnavailable` event payload. */ export declare function trackRpcServiceUnavailable(messenger: NetworkControllerMessenger, analyticsOptions: ResolvedNetworkControllerAnalyticsOptions, payload: RpcEndpointUnavailablePayload): void; /** * Emits an "RPC Service Degraded" analytics event. * * @param messenger - The controller messenger. * @param analyticsOptions - The analytics configuration. * @param payload - The `rpcEndpointDegraded` event payload. */ export declare function trackRpcServiceDegraded(messenger: NetworkControllerMessenger, analyticsOptions: ResolvedNetworkControllerAnalyticsOptions, payload: RpcEndpointDegradedPayload): void; export {}; //# sourceMappingURL=rpc-service-analytics.d.cts.map