File tree Expand file tree Collapse file tree
webapp/packages/core-sdk/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import { uploadDriverLibraryExtension } from './Extensions/uploadDriverLibraryEx
1414import { uploadResultDataExtension } from './Extensions/uploadResultDataExtension.js' ;
1515import type { IResponseInterceptor } from './IResponseInterceptor.js' ;
1616import { getSdk , type Sdk } from './sdk.js' ;
17+ import { getRecentlySelectedZone } from './LocalStorage.js' ;
1718
1819function extendedSDK (
1920 client : CustomGraphQLClient ,
@@ -39,7 +40,11 @@ export class GraphQLService {
3940
4041 constructor ( private readonly environmentService : EnvironmentService ) {
4142 const gqlEndpoint = this . environmentService . gqlEndpoint ;
42- this . client = new CustomGraphQLClient ( gqlEndpoint ) ;
43+ this . client = new CustomGraphQLClient ( gqlEndpoint , {
44+ headers : {
45+ zone : getRecentlySelectedZone ( ) ,
46+ } ,
47+ } ) ;
4348 this . sdk = extendedSDK ( this . client ) ;
4449 }
4550
Original file line number Diff line number Diff line change 1+ export enum StorageKey {
2+ DMS_AVAILABILITY_ZONE = 'DMS_AVAILABILITY_ZONE' ,
3+ }
4+
5+ class LocalStorageWrapper {
6+ public set < T extends string = string > ( key : string , value : T ) {
7+ return localStorage . setItem ( key , value ) ;
8+ }
9+
10+ public get ( key : string ) {
11+ return localStorage . getItem ( key ) ;
12+ }
13+
14+ public getOrDefault ( key : string , defaultValue : string ) : string {
15+ if ( localStorage . getItem ( key ) === null ) {
16+ return defaultValue ;
17+ }
18+ return localStorage . getItem ( key ) as string ;
19+ }
20+ }
21+
22+ export const localStorageWrapper = new LocalStorageWrapper ( ) ;
23+
24+ export const getRecentlySelectedZone = ( ) : string => {
25+ const data = localStorageWrapper . get ( StorageKey . DMS_AVAILABILITY_ZONE ) ;
26+ try {
27+ const parsedData = JSON . parse ( data || '[]' ) ;
28+ return parsedData ?. [ 0 ] ?. uid ?? '' ;
29+ } catch ( error ) {
30+ console . error ( error ) ;
31+ return '' ;
32+ }
33+ } ;
Original file line number Diff line number Diff line change @@ -26,3 +26,4 @@ export * from './ServiceError.js';
2626export * from './SessionError.js' ;
2727export * from './manifest.js' ;
2828export * from './getObjectPropertyValue.js' ;
29+ export * from './LocalStorage.js' ;
You can’t perform that action at this time.
0 commit comments