Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/lib/ClientError.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CLIENT_METADATA } from './constants';
export enum ErrorCode {
CLIENT_ERROR_CODE_USAGE_LIMIT_REACHED = 'CLIENT_ERROR_CODE_USAGE_LIMIT_REACHED',
CLIENT_ERROR_CODE_VALIDATION_ERROR = 'CLIENT_ERROR_CODE_VALIDATION_ERROR',
Expand Down Expand Up @@ -72,6 +73,7 @@ export class ClientError extends Error {
sendErrorMetric('client_error', code, {
details,
statusCode,
...CLIENT_METADATA,
});
}
}
7 changes: 7 additions & 0 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { version } from '../../package.json';

// Core API
export const DEFAULT_HEADERS = {
'Content-Type': 'application/json',
Expand All @@ -14,3 +16,8 @@ export const CONNECTION_CLOSED_CODE_SIGNALLING_CLIENT_CONNECTION_FAILURE =
'CONNECTION_CLOSED_CODE_SIGNALLING_CLIENT_CONNECTION_FAILURE';
export const CONNECTION_CLOSED_CODE_WEBRTC_FAILURE =
'CONNECTION_CLOSED_CODE_WEBRTC_FAILURE';

export const CLIENT_METADATA = {
client: 'js-sdk',
version,
};
13 changes: 10 additions & 3 deletions src/modules/CoreApiRestClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { ClientError, ErrorCode } from '../lib/ClientError';
import { DEFAULT_API_BASE_URL, DEFAULT_API_VERSION } from '../lib/constants';
import {
CLIENT_METADATA,
DEFAULT_API_BASE_URL,
DEFAULT_API_VERSION,
} from '../lib/constants';
import {
CoreApiRestClientOptions,
PersonaConfig,
Expand Down Expand Up @@ -40,7 +44,6 @@ export class CoreApiRestClient {
400,
);
}
// TODO: why do we need to get the unsafe session token here?
this.sessionToken = await this.unsafe_getSessionToken(personaConfig);
}

Expand All @@ -51,7 +54,11 @@ export class CoreApiRestClient {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.sessionToken}`,
},
body: JSON.stringify({ personaConfig, sessionOptions }),
body: JSON.stringify({
personaConfig,
sessionOptions,
clientMetadata: CLIENT_METADATA,
}),
});

const data = await response.json();
Expand Down