# io.Connect Browser

Source: https://docs.interop.io/insights/configuration/io-connect-browser/index.html

## Overview

**io.Insights** comes as a built-in feature of **io.Connect Browser**. The default OpenTelemetry signals it publishes can be enabled, disabled or customized based on your specific business scenarios.

## Enabling io.Insights

**io.Insights** is disabled by default. To enable **io.Insights** and configure its features in **io.Connect Browser**, use the `otel` property of the configuration object when [initializing your Main app](https://docs.interop.io/browser/developers/browser-platform/setup/index.md):

```javascript
import IOBrowserPlatform from "@interopio/browser-platform";

const config = {
    licenseKey: "my-license-key",
    // Enabling io.Insights and providing settings for publishing data.
    otel: {
        metrics: {
            url: "http://localhost:4242/my-metrics-collector",
            metrics: [
                {
                    type: "app_error",
                    enabled: false
                }
            ]
        }
    }
};

const { io } = await IOBrowserPlatform(config);
```

The `otel` object has the following properties:

| Property | Type | Description |
|----------|------|-------------|
| `metrics` | `object` | Settings for publishing metrics. |

## Metrics

To provide custom settings for publishing metrics, use the `metrics` property of the `otel` object.

The `metrics` object has the following properties:

| Property | Type | Description |
|----------|------|-------------|
| `metrics` | `object[]` | Settings for the default platform metrics. Defaults to `[]`. |
| `publishInterval` | `number` | Interval in milliseconds at which to publish the generated metrics. Defaults to `30000`. |
| `url` | `string` | **Required.** URL pointing to an OpenTelemetry metrics collector. Providing a URL enables **io.Insights** and publishing of the default platform metrics. |

You can enable, disable, or override the settings for the default platform metrics published by **io.Insights** by using the `metrics` property of the `metrics` object.

The following example demonstrates how to disable and customize individual metrics by specifying the predefined metric type in the `metrics` array:

```javascript
import IOBrowserPlatform from "@interopio/browser-platform";

const config = {
    licenseKey: "my-license-key",
    otel: {
        metrics: {
            url: "http://localhost:4242/my-metrics-collector",
            metrics: [
                // Disabling a default metric.
                {
                    type: "app_error",
                    enabled: false
                },
                // Overriding the default settings for a predefined metric.
                {
                    type: "layout_startup",
                    name: "Global Layout Startup",
                    description: "The time it takes to load a Global Layout.",
                    buckets: [
                        10000,
                        15000,
                        20000
                    ]
                }
            ]
        }
    }
};

const { io } = await IOBrowserPlatform(config);
```

Each object in the `metrics` array has the following properties:

| Property | Type | Description |
|----------|------|-------------|
| `buckets` | `number[]` | Specify explicit bucket boundaries for the OpenTelemetry SDK if the metric is a `Histogram`. |
| `description` | `string` | Description for the metric. |
| `enabled` | `boolean` | If `true` (default), will enable publishing the metric. |
| `name` | `string` | Name for the metric. May be used in visualization tools. |
| `type` | `string` | **Required.** Type of the predefined metric. |

The `type` property accepts the following values describing a predefined metric type:

| Value |
|-------|
| `"app_count"` |
| `"app_duration"` |
| `"app_error"` |
| `"app_started"` |
| `"app_startup"` |
| `"app_stopped"` |
| `"layout_startup"` |
| `"platform_error"` |
| `"platform_startup"` |
| `"workspace_count"` |
| `"workspace_started"` |
| `"workspace_startup"` |
| `"workspace_stopped"` |
