Repository navigation
feat: let wrapper SDKs report their own identity in ClientInfo #2265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'livekit-client': patch | ||
| --- | ||
|
|
||
| Add internal `setWrapperSdkInfo` so SDKs built on top of livekit-client (e.g. Unity WebGL) report their own SDK and version in `ClientInfo`, with livekit-client's version in `other_sdks` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -503,13 +503,38 @@ export interface ObservableMediaElement extends HTMLMediaElement { | |
| handleVisibilityChanged: (entry: IntersectionObserverEntry) => void; | ||
| } | ||
|
|
||
| export type WrapperSdkInfo = { | ||
| /** The `ClientInfo.SDK` enum name of the wrapping SDK, e.g. `'UNITY_WEB'` */ | ||
| sdk: keyof typeof ClientInfo_SDK; | ||
| /** The wrapping SDK's own version */ | ||
| version: string; | ||
| }; | ||
|
|
||
| let wrapperSdkInfo: WrapperSdkInfo | undefined; | ||
|
|
||
| /** | ||
| * For LiveKit SDKs built on top of livekit-client (e.g. Unity WebGL). | ||
| * Reports the wrapper as the client SDK to the server, and moves livekit-client's | ||
| * own version to `ClientInfo.other_sdks`. Pass `undefined` to reset. | ||
| * Meant for wrapper SDKs, not for apps. | ||
| * @experimental | ||
| */ | ||
| export function setWrapperSdkInfo(info: WrapperSdkInfo | undefined) { | ||
| wrapperSdkInfo = info; | ||
| } | ||
|
|
||
| export function getClientInfo(capabilities?: ClientInfo_Capability[]): ClientInfo { | ||
| let sdk = isReactNative() ? ClientInfo_SDK.REACT_NATIVE : ClientInfo_SDK.JS; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The old react native path is still used here, so this does not force an update in the React SDK.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thought: I think this makes sense, but I do wonder if it would be preferable longer term if react native were to also use Also, I'm guessing this isn't a thing today, but in the future if we needed to gate some functionality to only happen on unity web then a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as in Slack: "The current react native way is a bit more hacky in my opinion, so the next step in unifying would be to move react native over to use the function instead of setting the property." |
||
| if (wrapperSdkInfo) { | ||
| sdk = ClientInfo_SDK[wrapperSdkInfo.sdk]; | ||
| } | ||
| const info = new ClientInfo({ | ||
| capabilities, | ||
| sdk: isReactNative() ? ClientInfo_SDK.REACT_NATIVE : ClientInfo_SDK.JS, | ||
| sdk, | ||
| protocol: protocolVersion, | ||
| clientProtocol, | ||
| version, | ||
| version: wrapperSdkInfo?.version ?? version, | ||
| otherSdks: wrapperSdkInfo ? `js:${version}` : undefined, | ||
| }); | ||
|
|
||
| if (isReactNative()) { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.replace(/_/g, '')removes every underscore, givingunitywebandreactnative