import type { PickByPrefix } from '../common/ts/pick-by-prefix.js'; import type { AnyJson } from '../../private/common/json.js'; import type { MonorailEventPublic } from './monorail.js'; type ProvideMetadata = () => Partial | Promise>; type MetadataErrorHandling = 'auto' | 'mute-and-report' | 'bubble'; /** * Any key in T that has a numeric value. */ type NumericKeyOf = { [K in keyof T]: T[K] extends number ? (K extends string ? K : never) : never; }[keyof T]; export interface RuntimeMetadataManager { /** Add some public metadata -- this should not contain any PII. */ addPublicMetadata: (getData: ProvideMetadata, onError?: MetadataErrorHandling) => Promise; /** * Add some potentially sensitive metadata -- this may include PII, but unnecessary data should never be tracked * (this is a good fit for command args for instance). */ addSensitiveMetadata: (getData: ProvideMetadata, onError?: MetadataErrorHandling) => Promise; /** Get a snapshot of the tracked public data. */ getAllPublicMetadata: () => Partial; /** Get a snapshot of the tracked sensitive data. */ getAllSensitiveMetadata: () => Partial; /** Run a function, monitoring how long it takes, and adding the elapsed time to a running total. */ runWithTimer: (field: NumericKeyOf) => (fn: () => Promise) => Promise; } export type PublicSchema = T extends RuntimeMetadataManager ? TPublic : never; export type SensitiveSchema = T extends RuntimeMetadataManager ? TSensitive : never; /** * Creates a container for metadata collected at runtime. * The container provides async-safe functions for extracting the gathered metadata, and for setting it. * * @param defaultPublicMetadata - Optional, default data for the container. * @returns A container for the metadata. */ export declare function createRuntimeMetadataContainer>(defaultPublicMetadata?: Partial): RuntimeMetadataManager; type CmdFieldsFromMonorail = PickByPrefix & PickByPrefix & PickByPrefix & PickByPrefix & PickByPrefix; declare const coreData: RuntimeMetadataManager>; export declare const getAllPublicMetadata: () => Partial, getAllSensitiveMetadata: () => Partial<{ commandStartOptions: { startTime: number; startCommand: string; startTopic?: string; startArgs: string[]; }; } & { environmentFlags: string; } & PickByPrefix<{ args: string; error_message?: string | null; app_name?: string | null; metadata?: string | null; store_fqdn?: string | null; cmd_all_environment_flags?: string | null; cmd_dev_tunnel_custom?: string | null; env_plugin_installed_all?: string | null; env_shopify_variables?: string | null; }, "store_", never>>, addPublicMetadata: (getData: ProvideMetadata, onError?: MetadataErrorHandling) => Promise, addSensitiveMetadata: (getData: ProvideMetadata<{ commandStartOptions: { startTime: number; startCommand: string; startTopic?: string; startArgs: string[]; }; } & { environmentFlags: string; } & PickByPrefix<{ args: string; error_message?: string | null; app_name?: string | null; metadata?: string | null; store_fqdn?: string | null; cmd_all_environment_flags?: string | null; cmd_dev_tunnel_custom?: string | null; env_plugin_installed_all?: string | null; env_shopify_variables?: string | null; }, "store_", never>>, onError?: MetadataErrorHandling) => Promise, runWithTimer: (field: NumericKeyOf) => (fn: () => Promise) => Promise; export type Public = PublicSchema; export type Sensitive = SensitiveSchema; export {};