From 11ad70a7ee7d6c414cd784b6719251054d18d632 Mon Sep 17 00:00:00 2001 From: Myriam Gantner <48029745+MGJamJam@users.noreply.github.com> Date: Thu, 11 Jul 2024 17:35:15 +0200 Subject: [PATCH] feat/AN-4211 add X-Api-Client header to all requests (#91) * add X-Api-Client header to all requests * updarte Changelog --- CHANGELOG.md | 4 ++++ src/datasource.ts | 5 ++++- src/utils/licenses.ts | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index edbd7e9..784db7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Development +### Added + +- `X-Api-Client` header + ## 1.1.0 ### Added diff --git a/src/datasource.ts b/src/datasource.ts index 19bf35d..6cc15d3 100644 --- a/src/datasource.ts +++ b/src/datasource.ts @@ -253,7 +253,10 @@ export class DataSource extends DataSourceApi< } request(url: string, method: string, payload?: any): Observable> { - const headers: Record = { 'X-Api-Key': this.apiKey }; + const headers: Record = { + 'X-Api-Key': this.apiKey, + 'X-Api-Client': 'analytics-grafana-datasource', + }; if (this.tenantOrgId != null) { headers['X-Tenant-Org-Id'] = this.tenantOrgId; } diff --git a/src/utils/licenses.ts b/src/utils/licenses.ts index 0839d2f..923556c 100644 --- a/src/utils/licenses.ts +++ b/src/utils/licenses.ts @@ -38,9 +38,9 @@ async function fetchLicensesForEndpoint( mapperFunc: (license: AnalyticsLicense) => SelectableValue, tenantOrgId?: string ) { - const headers: Record = { 'X-Api-Key': apiKey} + const headers: Record = { 'X-Api-Key': apiKey, 'X-Api-Client': 'analytics-grafana-datasource' }; if (tenantOrgId != null) { - headers["X-Tenant-Org-Id"] = tenantOrgId + headers['X-Tenant-Org-Id'] = tenantOrgId; } const options = { url: url,