import { DistributedTracingModes, TelemetryClient, Configuration } from 'applicationinsights';
import { NitroConfig, NitroModule } from 'nitropack';

type TNitroAppInsightsConfig = {
    connectionString?: string;
    /**
     * @deprecated since 1.1.0 prefer using applicationinsights:setup hook and modify the configuration object
     */
    autoCollectRequests: boolean;
    /**
     * @deprecated since 1.1.0 prefer using applicationinsights:setup hook and modify the configuration object
     */
    autoCollectConsole: boolean | {
        value: boolean;
        collectConsoleLogs: boolean;
    };
    /**
     * @deprecated since 1.1.0 prefer using applicationinsights:setup hook and modify the configuration object
     */
    autoCollectDependencies: boolean;
    /**
     * @deprecated since 1.1.0 prefer using applicationinsights:setup hook and modify the configuration object
     */
    autoCollectExceptions: boolean;
    /**
     * @deprecated since 1.1.0 prefer using applicationinsights:setup hook and modify the configuration object
     */
    autoCollectPerformance: {
        value: boolean;
        collectExtendedMetrics: boolean;
    };
    /**
     * @deprecated since 1.1.0 prefer using applicationinsights:setup hook and modify the configuration object
     */
    autoCollectHeartbeat: boolean;
    /**
     * @deprecated since 1.1.0 prefer using applicationinsights:setup hook and modify the configuration object
     */
    autoCollectIncomingRequestAzureFunctions: boolean;
    /**
     * @deprecated since 1.1.0 prefer using applicationinsights:setup hook and modify the configuration object
     */
    autoCollectPreAggregatedMetrics: boolean;
    /**
     * @deprecated since 1.1.0 prefer using applicationinsights:setup hook and modify the configuration object
     */
    autoDependencyCorrelation: boolean | {
        value: boolean;
        useAsyncHooks: boolean;
    };
    /**
     * @deprecated since 1.1.0 prefer using applicationinsights:setup hook and modify the configuration object
     */
    enableWebInstrumentation: boolean | {
        value: boolean;
        WebSnippetConnectionString?: string;
    };
    /**
     * @deprecated since 1.1.0 prefer using applicationinsights:setup hook and modify the configuration object
     */
    distributedTracingMode: DistributedTracingModes;
    /**
     * @deprecated since 1.1.0 prefer using applicationinsights:setup hook and modify the configuration object
     */
    sendLiveMetrics: boolean;
    /**
     * @deprecated since 1.1.0 prefer using applicationinsights:setup hook and modify the configuration object
     */
    internalLogging: {
        enableDebugLogging?: boolean;
        enableWarningLogging?: boolean;
    };
    /**
     * @deprecated since 1.1.0 prefer using applicationinsights:setup hook and modify the configuration object
     */
    useDiskRetryCaching: boolean;
};

declare module 'nitropack' {
  interface NitroRuntimeHooks {
    /**
     * @deprecated since 1.1.0 prefer using applicationinsights:setup hook and modify the configuration object
     */
    'applicationinsights:config': (config: TNitroAppInsightsConfig) => void
    /**
     * Triggered when the applicationinsights client is setup but not started
     * If you want to modify azure monitors options you can do it here
     */
    'applicationinsights:setup': (context: { client: TelemetryClient, configuration: Configuration }) => void
    /**
     * Triggered when the applicationinsights client is ready and initialized
     */
    'applicationinsights:ready': (context: { client: TelemetryClient }) => void
  }

  interface NitroRuntimeConfig {
    applicationinsights?: TNitroAppInsightsConfig
  }
}

declare module 'nitropack/config' {
  function defineNitroConfig(config: NitroConfig & {
    runtimeConfig: {
      applicationinsights?: TNitroAppInsightsConfig
    }
  }): NitroConfig;
}

declare const _default: NitroModule;

export { type TNitroAppInsightsConfig, _default as default };
