Source
A Source object represents a configured analytics connection. Obtain one from Metrix's Sources service when integration code needs provider capabilities or data fetching. Dashboard templates do not normally call these methods directly.
use verbb\metrix\Metrix;
$source = Metrix::$plugin->getSources()->getSourceByHandle(
'analytics',
enabledOnly: true,
connectedOnly: true,
);
if ($source && $source->supportsDimensions()) {
$dimensions = $source->fetchAvailableDimensions();
}
Properties
Type: string|int|null
The unique identifier for the source.
Type: string|null
The name of the source.
Type: string|null
The handle of the source.
Type: bool|null
Whether the source is enabled.
Provider-specific credentials (API keys, OAuth tokens, site IDs, etc.) live in each Source type’s settings — not as shared attributes on every Source.
Methods
Returns: bool
Whether the source has the credentials it needs.
Returns: bool
Whether the source is currently connected (credentials / OAuth).
Returns: array
Capability flags: realtime, dimensions, connection, oauth, analyticsScope.
Returns: bool
Whether a realtime widget can call this source.
Returns: bool
Whether dimension breakdowns (table/pie) are supported.
Returns: bool
Whether View analytics scope (path/hostname) can be applied.
Returns: void
Mutates a provider request to honour View scope.
Returns: array
Metrics the provider can expose.
Returns: array
Dimensions the provider can expose.
Returns: array
Historical / period data for a widget.
Returns: array
Returns a real-time payload when the provider supports it. Implementing this method makes supportsRealtime() return true.
Returns: bool
Validates credentials / connection.
Returns: string|null
Provider branding for the CP.