import { isIdentifierRef } from "@gooddata/sdk-model";
import { useBackendWithCorrelation } from "@gooddata/sdk-ui";
/**
 * @internal
 */
export function useBackendWithInsightWidgetCorrelation({ insight, widget, backend }) {
    // Create correlation headers for telemetry
    let correlationData = {};
    // Add insight ID if available
    if (isIdentifierRef(insight.insight?.ref)) {
        correlationData = {
            visualizationId: insight.insight.ref.identifier,
        };
    }
    // Add widget ID if available
    if (isIdentifierRef(widget.ref)) {
        correlationData = {
            ...correlationData,
            widgetId: widget.ref.identifier,
        };
    }
    return useBackendWithCorrelation(backend, correlationData);
}
