@@ -10,8 +10,6 @@ export const { MessageApi, SortDirection } = messageApi
10
10
const RETRY_SLEEP_TIME = 100
11
11
const ERR_CODE_UNAUTHENTICATED = 16
12
12
13
- const getClientVersion = ( ) => 'xmtp-js/' + getPackageVersion ( )
14
-
15
13
const clientVersionHeaderKey = 'X-Client-Version'
16
14
17
15
export type GrpcError = Error & { code ?: number }
@@ -82,10 +80,12 @@ export default class ApiClient {
82
80
pathPrefix : string
83
81
maxRetries : number
84
82
private authCache ?: AuthCache
83
+ version : string
85
84
86
85
constructor ( pathPrefix : string , opts ?: ApiClientOptions ) {
87
86
this . pathPrefix = pathPrefix
88
87
this . maxRetries = opts ?. maxRetries || 5
88
+ this . version = 'xmtp-js/' + getPackageVersion ( )
89
89
}
90
90
91
91
// Raw method for querying the API
@@ -100,7 +100,7 @@ export default class ApiClient {
100
100
pathPrefix : this . pathPrefix ,
101
101
mode : 'cors' ,
102
102
headers : new Headers ( {
103
- [ clientVersionHeaderKey ] : getClientVersion ( ) ,
103
+ [ clientVersionHeaderKey ] : this . version ,
104
104
} ) ,
105
105
} ,
106
106
] ,
@@ -125,7 +125,7 @@ export default class ApiClient {
125
125
mode : 'cors' ,
126
126
headers : new Headers ( {
127
127
Authorization : `Bearer ${ authToken } ` ,
128
- [ clientVersionHeaderKey ] : getClientVersion ( ) ,
128
+ [ clientVersionHeaderKey ] : this . version ,
129
129
} ) ,
130
130
} ,
131
131
] ,
@@ -161,7 +161,7 @@ export default class ApiClient {
161
161
signal : abortController . signal ,
162
162
mode : 'cors' ,
163
163
headers : new Headers ( {
164
- [ clientVersionHeaderKey ] : getClientVersion ( ) ,
164
+ [ clientVersionHeaderKey ] : this . version ,
165
165
} ) ,
166
166
} ) . catch ( async ( err : GrpcError ) => {
167
167
if ( isAbortError ( err ) ) {
0 commit comments