## Filter: wpd_alpha_insights_register_data_sources

Register custom data sources with the data source registry. Data sources provide entity data to the warehouse (e.g. orders, products, expenses).

### Description

The registry collects data source instances that implement `WPDAI_Custom_Data_Source_Interface` (typically by extending `WPDAI_Custom_Data_Source_Base`). Each source returns one or more entity names via `get_entity_names()`; the registry maps each entity name to that source. The warehouse then calls `fetch_data( $data_warehouse )` on the source when data for that entity is requested. You do not usually add to this filter directly—instead you extend the base class and instantiate it; the base class hooks into this filter automatically.

#### Location

File: `includes/classes/WPDAI_Custom_Data_Source_Registry.php`

Context: During registry initialization.

### Parameters

Parameter | Type | Description
--- | --- | ---
(none) | — | First argument is the existing array of sources (default empty). You add instances to this array and return it.

#### Return

Type: array

Array of objects implementing `WPDAI_Custom_Data_Source_Interface`. Each source must implement `get_entity_names()`, `get_entity_name()`, and `fetch_data( WPDAI_Data_Warehouse $data_warehouse )`.

### Example Usage

#### Register a custom data source (usually via base class)

    // Typical approach: extend WPDAI_Custom_Data_Source_Base and instantiate.
    // The base class adds itself to this filter. Manual registration:
    add_filter( 'wpd_alpha_insights_register_data_sources', 'add_my_data_sources' );
    function add_my_data_sources( $sources ) {
        $sources[] = new My_Custom_Data_Source();
        return $sources;
    }

### Related

- wpd_alpha_insights_reserved_entity_names – Reserved entity names
- Developers → Custom Data Sources – Creating custom data sources