Skip to content

Commit

Permalink
feat/AN-4211 add X-Api-Client header to all requests (#91)
Browse files Browse the repository at this point in the history
* add X-Api-Client header to all requests

* updarte Changelog
  • Loading branch information
MGJamJam authored Jul 11, 2024
1 parent aac3b28 commit 11ad70a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Development

### Added

- `X-Api-Client` header

## 1.1.0

### Added
Expand Down
5 changes: 4 additions & 1 deletion src/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,10 @@ export class DataSource extends DataSourceApi<
}

request(url: string, method: string, payload?: any): Observable<Record<any, any>> {
const headers: Record<string, string> = { 'X-Api-Key': this.apiKey };
const headers: Record<string, string> = {
'X-Api-Key': this.apiKey,
'X-Api-Client': 'analytics-grafana-datasource',
};
if (this.tenantOrgId != null) {
headers['X-Tenant-Org-Id'] = this.tenantOrgId;
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/licenses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ async function fetchLicensesForEndpoint(
mapperFunc: (license: AnalyticsLicense) => SelectableValue,
tenantOrgId?: string
) {
const headers: Record<string, string> = { 'X-Api-Key': apiKey}
const headers: Record<string, string> = { '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,
Expand Down

0 comments on commit 11ad70a

Please sign in to comment.