# Settings

**Kind**: interface | **Module**: [Insights](https://docs.interop.io/browser/reference/javascript/insights/index.md)

**Source**: https://docs.interop.io/browser/reference/javascript/insights/settings/index.html

## Properties

- **`addHardwareDataToAttributes`** (`boolean`, optional) default: `false`
  In io.Connect Desktop: if `true`, the platform will add CPU, memory, and OS information
  to the resource attributes of the published signals.
- **`additionalAttributes`** (`{ [x: string]: unknown } | (() => { [x: string]: unknown })`, optional)
  Additional properties to publish as part of each OpenTelemetry signal, specified as key/value pairs. You can use environment variables as values. Environment variables must start and end with a percent sign (e.g., `%MyEnvVar%`), and can contain a fallback value (e.g., `%MyEnvVar?DefaultValue%`).
- **`additionalResourceAttributes`** (`{ [x: string]: unknown } | (() => { [x: string]: unknown })`, optional)
  Additional properties to publish as part of the OpenTelemetry resource definition for all OpenTelemetry signals, specified as key/value pairs. You can use environment variables as values. Environment variables must start and end with a percent sign (e.g., `%MyEnvVar%`), and can contain a fallback value (e.g., `%MyEnvVar?DefaultValue%`).
- **`addResourceAttributesToAttributes`** (`boolean`, optional) default: `false`
  Whether to add resource attributes to signal attributes.
- **`applicationName`** (`string`, optional)
  Application name to use in telemetry information. By default, it's populated by io.Connect.
- **`appStartMeasurement`** (`"legacy" | "dom-ready" | "loaded" | "loader" | "interop-ready" | "explicit"`, optional) default: `"dom-ready"`
  When an application is considered started for the sake of measuring
  metrics and spans (affects apps, workspaces and layouts):
  * interop-ready - when its io.Connect API has registered with the gateway
  * dom-ready - for an application with a window, when the window's DOM is ready - and that
    alone: an API that registers before the document is ready does not count, it would skew
    the measurement; without a window (node, exe), as interop-ready
  * loaded - for an application with a window, when the window's page has loaded (Electron's
    did-finish-load); otherwise as interop-ready
  * loader - for an application with a window, when the window's loader has been hidden - by
    the application (hideLoader()) or by the platform (loader.hideOnLoad); a window without
    a loader counts as with dom-ready, an application without a window as with interop-ready
  * explicit - when the application says so: its io.Insights startupTraceFinished() invokes
    the platform's "T42.ACS.AppStartupFinished" interop method (an application without
    io.Insights can invoke it itself); nothing else counts
  * legacy - as interop-ready for the applications; a workspace waits for its applications' DOM
    ready, as it did before, and the layout startup is measured the way it used to be, without
    waiting for the applications
  A workspace counts as started when the applications it starts up front have, by the same
  rule; a layout, when its restored applications have. In every mode the gateway counts as
  started when the platform has discovered its endpoint.
- **`enabled`** (`boolean`, required)
  Whether library is enabled.
  If disabled, API is still usable, but methods are no-ops.
- **`errorlessMode`** (`boolean`, optional) default: `false`
  If `true`, the library will swallow all errors, instead of propagating them.
- **`failOnInitError`** (`boolean`, optional)
  If failure to initialize library will throw upstream error.
- **`finalExportTimeoutMs`** (`number`, optional) default: `0`
  Interval in milliseconds to wait for any remaining telemetry data
  to be exported during shutdown of the platform.

  This is the maximum awaiting interval and the platform may shutdown
  before it expires if all telemetry data has already been published.

  If `0`, the final export is fire-and-forget: it is started - which also ends, and thereby
  publishes, the spans that are still open - but the shutdown doesn't wait for it, so only
  what makes it out before the process exits is published. On an abnormal exit of the
  platform, `lastChanceExportOnError.exportTimeoutMs` is used instead.
- **`flushOnClose`** (`boolean`, optional) default: `true`
  If `true`, the outstanding telemetry is got out when the application is being closed.

  In an io.Connect Desktop window, through the window's close handler - which requires close
  handlers to be enabled in the application configuration: what has ended so far is exported,
  or the library is shut down altogether - see `flushOnCloseMode`.

  In any page, when it goes away for good (a reload, a navigation away, the window closing -
  `pagehide`, not an entry into the back/forward cache, which may come back): every span that
  is still open - a request in flight, an open WebSocket connection, a span the application has
  not ended yet - is ended there and then, and the ended spans are flushed. A span is only
  exported once it has ended, so whatever the page was in the middle of would be lost with it
  otherwise. The spans are ended as they stand: their status is left alone, and they are marked
  with the `endedByShutdown` attribute and `endedByShutdownReason: "pagehide"`, so they can be
  told apart from spans that ran to completion - they have no outcome, and their duration is
  the time until the page left. The trace duration and result metrics record them too; filter
  on the marker where that matters. The flush at unload is best effort: browsers limit the
  requests that outlive a page to about 64 KB in total, so a page with very many open spans may
  not get them all out. The application startup span is completed first, with its summaries
  (see instrumentAppStartup's parentSpanEnd), and everything goes out in one flush. Browsers
  only - in NodeJS the final export (waitForFinalExport) does the same at shutdown.

  If `false`, nothing is flushed when the page or the window goes away: the spans the page
  going away ends regardless (the startup span, the connection spans) go out with the next
  scheduled export, if the page lives that long.
- **`flushOnCloseMode`** (`"flush" | "shutdown"`, optional) default: `"flush"`
  What `flushOnClose` does in the close handler of an io.Connect Desktop window. The
  platform asks a window's close handlers before the window closes - also when the close
  ends up prevented (another close handler's word, the user cancelling the confirmation),
  and when it only asks whether the window can close.
  * flush - the traces, metrics and logs that are ready are exported, within a second, and
    nothing else: no span is ended and the library goes on working, so a close that does
    not happen costs nothing. The spans that are still open are ended and flushed when the
    page really goes away (`pagehide`, see `flushOnClose`) - best effort, as any flush at
    unload is
  * shutdown - the handler being asked is taken for the close itself: every span that is
    still open is ended (marked `endedByShutdown`, `endedByShutdownReason: "close"`), the
    telemetry is exported, within a second, and the library stops. Nothing is left to the
    flush at unload - and a window whose close is prevented after all stays open with its
    long-running spans cut and io.Insights stopped. For windows whose close is not
    prevented
- **`headers`** (`{ [x: string]: string } | (() => { [x: string]: string }) | (() => Promise<{ [x: string]: string }>)`, optional)
  Additional headers to send in HTTP requests, e.g. when using HTTP exporters.
- **`lastChanceExportOnError`** (`boolean | LastChanceExportOnErrorSettings`, optional) default: `true`
  In io.Connect Desktop, gets the telemetry describing an abnormal exit out before the
  platform exits: a startup error, an unhandled error (crash) at any later point, an exit
  with an error code, or a shutdown before the startup has completed (restarts excluded).
  The final export waits for up to LastChanceExportOnErrorSettings.exportTimeoutMs instead
  of `finalExportTimeoutMs`, and - with a late initialization (`lateInit`) - io.Insights is
  initialized after all, within LastChanceExportOnErrorSettings.initTimeoutMs, when the
  platform goes down before it was, so the telemetry buffered so far, the error included,
  still gets published.

  `true` (the default) uses the default settings; an object configures them; `false`
  switches it off - an abnormal exit then waits for the final export as long as a normal one
  would, and telemetry buffered before a late initialization is lost.
- **`lateInit`** (`boolean | LateInitSettings`, optional) default: `false`
  In io.Connect Desktop, initializes io.Insights late in the startup - right after the SSO
  authentication has completed (see LateInitSettings.initStage) - rather than as early as
  possible. The startup telemetry gathered until then is buffered and published once
  io.Insights is initialized.

  Early initialization makes the startup trace richer and helps telemetry be published even
  in the case of an early startup error; a late one lets a "pre-sso" autoStart application
  provide additional OTEL attributes at runtime before io.Insights gets initialized (see
  LateInitSettings.attributesTimeoutMs), and lets the platform's own export requests carry
  the SSO login from the first one on (see `ssoAuth`).

  `true` switches it on with the default settings; an object also configures it. Has no
  effect when io.Insights is disabled.
- **`logs`** (`LogsSettings`, optional)
- **`logSettingsOnStartup`** (`boolean`, optional) default: `true`
  If the library should log the settings used to initialize it.
- **`maskingSettings`** (`MaskingSettings`, optional)
  How masked attribute values (`attributeSettings` entries with `mode: "mask"`) are keyed -
  see `MaskingSettings`. The traces, the metrics and the logs share these; when the library
  is built, `maskSecret` is resolved to the effective secret the mode stands for - first
  of all, so that it is what the settings logged on startup show (with `logMaskingSecret`)
  and what the `settings` of the API carry.
- **`metrics`** (`MetricsSettings`, optional)
- **`platformStartMeasurement`** (`"legacy" | "shell-visible" | "shell-and-layout"`, optional) default: `"shell-visible"`
  When the platform is considered started for the sake of measuring
  the platform_startup metric and the interopio.desktop.startup span:
  * shell-visible - when the platform has finished initializing AND the shell application is
    visible, whichever comes last (shellVisibleTimeoutMs caps the wait for the shell)
  * shell-and-layout - as shell-visible, AND the default global layout has loaded: its
    applications ready as appStartMeasurement defines it (its components restored, with
    "legacy"). With no default layout to restore, the same as shell-visible
  * legacy - when the platform has finished initializing, without waiting for the shell

  The value goes on the platform_startup metric and the startup span as the
  platformStartMeasurement attribute; appStartMeasurement goes on the app_startup,
  workspace_startup and layout_startup metrics and the application, workspace and layout spans
  the same way, so that measurements made under different settings can be told apart.
- **`platformVersion`** (`string`, optional)
  If provided, this value will be added to the metrics and span attributes
  and to the span filtering context (see 'filters' in TracesSettings).
- **`registerGlobalOTELObjects`** (`boolean | "force"`, optional) default: `true`
  Whether the library should register its own instances of the OTEL SDK global objects,
  e.g. MeterProvider. This is useful for controlling which instance of the SDK is used,
  in applications that initialize their own SDK.

  If `true`, the io.Insights library will register its own OTEL SDK global object instances
  if none are already registered. This means an already initialized SDK will be used in preference
  to the one initialized by io.Insights.

  If `"force"`, the io.Insights library will register its own OTEL SDK global object instances
  unconditionally, regardless of any existing registrations. This means any already initialized SDK
  will not be used and the library will always use its own instance.

  If `false`, the io.Insights library will not register its own OTEL SDK global object instances. The
  library will require an already initialized OTEL SDK instance.
- **`requestSettings`** (`boolean`, optional) default: `true`
  For Node applications: whether to attempt to request io.Insights settings
  from the platform when initializing;
- **`serviceId`** (`string`, optional)
  If provided, this value will be added to the metrics and traces service.instance.id attribute,
  unless an OTEL service object (e.g. TraceProvider) has been provided to the library with
  a different setting.
- **`serviceName`** (`string`, optional)
  If provided, this value will be added to the metrics and traces service.name attribute,
  unless an OTEL service object (e.g. TraceProvider) has been provided to the library with
  a different setting.
- **`serviceVersion`** (`string`, optional)
  If provided, this value will be added to the metrics and traces service.version attribute,
  unless an OTEL service object (e.g. TraceProvider) has been provided to the library with
  a different setting.
  attribute.
- **`shellVisibleTimeoutMs`** (`number`, optional) default: `60000`
  In io.Connect Desktop, with `platformStartMeasurement: "shell-visible"` or
  `"shell-and-layout"`: how long, in milliseconds, the end of the platform startup waits for
  the shell application to be visible (and the default layout to load) once the platform has
  finished initializing. When it expires, the startup ends without them (a warning is logged),
  so that a shell which never comes up doesn't keep the startup trace open - a trace that
  isn't ended isn't published. If `0`, the startup doesn't wait at all.
- **`ssoAuth`** (`SSOAuthSettings`, optional)
  Settings for injecting the io.Connect SSO login information into the headers of the
  OpenTelemetry export requests. Can be overridden for the traces, the metrics and the logs
  in their own settings. See SSOAuthSettings.
- **`suppressDoubleInitializationWarnings`** (`boolean`, optional) default: `false`
  Suppress double initialization warnings from the OTEL SDK.
- **`traces`** (`TracesSettings`, optional)
- **`useExistingOTELSDK`** (`boolean`, optional) default: `false`
  If `true`, io.Insights publishes through the host application's own
  OTEL SDK instead of building providers of its own: the tracer, meter
  and logger providers are taken from the OTEL API globals
  unconditionally (the globals are never absent - unregistered APIs
  return proxy/noop providers, so there is no meaningful fallback).

  Ordering matters: the trace and logs globals are proxies that
  late-bind, so signals emitted before the host registers its SDK are
  dropped and start flowing once it does; the metrics global is a
  snapshot, which io.Insights compensates for by re-resolving it per
  meter creation - but meters created before the host registered stay
  bound to the noop. Register the host SDK before initializing
  io.Insights for full coverage.

  In this mode io.Insights registers nothing: registerGlobalOTELObjects
  is effectively ignored, the global propagator is whatever the host
  registered (header injection rides it), resource attributes come from
  the host's providers (io.Insights resource settings are unused), and
  waitForFinalExport is best-effort - flushing on shutdown is the host
  SDK's responsibility.
- **`userId`** (`string`, optional)
  If provided, this value will be added to the metrics and traces user.id attribute,
  unless an OTEL service object (e.g. TraceProvider) has been provided to the library with
  a different setting.

## Related types

- [LastChanceExportOnErrorSettings](https://docs.interop.io/browser/reference/javascript/insights/lastchanceexportonerrorsettings/index.md)
- [LateInitSettings](https://docs.interop.io/browser/reference/javascript/insights/lateinitsettings/index.md)
- [LogsSettings](https://docs.interop.io/browser/reference/javascript/insights/logssettings/index.md)
- [MaskingSettings](https://docs.interop.io/browser/reference/javascript/insights/maskingsettings/index.md)
- [MetricsSettings](https://docs.interop.io/browser/reference/javascript/insights/metricssettings/index.md)
- [SSOAuthSettings](https://docs.interop.io/browser/reference/javascript/insights/ssoauthsettings/index.md)
- [TracesSettings](https://docs.interop.io/browser/reference/javascript/insights/tracessettings/index.md)
