# Add Event Listeners for Tableau Next Components

The SDK supports various events that your component can listen for and apply event handling logic to.

Supported events include:

- `COMPONENT_LOADED`: Generated when the component loads completely.

- `UPDATED_FILTERS`: Generated when the component filters update.

- `UPDATED_SELECTIONS`: Generated when the component selections update.

- `UPDATED_TIME_RANGE`: Generated when the time range for `AnalyticsMetric` updates.

- `RECEIVED_DATASOURCES`: Generated when the data sources for `AnalyticsDashboard` loads.

- `RECEIVED_FIELDS`: Generated when fields associated with a component loads.

- `RECEIVED_FILTERS`: Generated when a list of applied filters for a component loads.

- `RECEIVED_FILTER_FIELD_VALUES`: Generated when filter field values associated with a component field loads.

- `RECEIVED_INTERACTION_DETAILS`: Generated when the interaction details associated with a component loads.

- `RECEIVED_LAYOUT`: Generated when an applied layout for `AnalyticsMetric` loads.

- `RECEIVED_METADATA`: Generated when the metadata for a component loads.

- `RECEIVED_PAGES`: Generated when a list of page labels for `AnalyticsDashboard` loads.

- `RECEIVED_SELECTIONS`: Generated when a list of applied selections for `AnalyticsVisualization` loads.

- `DEFAULT`: Generated when any unnamed event occurs.

- `ERROR`: Generated when an error occurs. Use this to listen for errors.

## Example for Event Handling for Component Loaded

```javascript
analyticsComponent.addEventListener(EventName.COMPONENT_LOADED, (event) => {
  // Implement event handling logic
});
```

## Example for Error Handling

Use the `analyticsEventTarget` to listen for `EventName.ERROR`, with a callback to handle errors that are thrown if the SDK initialization fails due to wrong `orgUrl` or `authCredentials`.

```javascript
analyticsEventTarget.addEventListener(EventName.ERROR, (errorEvent) => {
		console.log("Received a global error event", errorEvent)
});
```
