Skip to content

Commit 710aaeb

Browse files
authored
feat: pass user id in req headers (#664)
1 parent 70633f0 commit 710aaeb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/DataSource.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
VariableOption,
1111
VariableWithMultiSupport,
1212
} from '@grafana/data';
13-
import { FetchResponse, getTemplateSrv, TemplateSrv } from '@grafana/runtime';
13+
import { config, FetchResponse, getTemplateSrv, TemplateSrv } from '@grafana/runtime';
1414
import { isArray, isObject } from 'lodash';
1515
import { lastValueFrom } from 'rxjs';
1616
import { map } from 'rxjs/operators';
@@ -50,7 +50,10 @@ export class DataSource extends DataSourceApi<GrafanaQuery, GenericOptions> {
5050

5151
this.variables = new VariableSupport(this, this.templateSrv);
5252
this.withCredentials = instanceSettings.withCredentials !== undefined;
53-
this.headers = { 'Content-Type': 'application/json' };
53+
this.headers = {
54+
'Content-Type': 'application/json',
55+
'X-Grafana-User-Id': config.bootData.user.id,
56+
};
5457
if (typeof instanceSettings.basicAuth === 'string' && instanceSettings.basicAuth.length > 0) {
5558
this.headers['Authorization'] = instanceSettings.basicAuth;
5659
}

0 commit comments

Comments
 (0)