Skip to content
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

fix: upgrade ua-parser-js to track correct device models #3406

Draft
wants to merge 15 commits into
base: dev
Choose a base branch
from

Conversation

ygit
Copy link
Member

@ygit ygit commented Dec 6, 2024

Description

  • Upgraded ua-parser-js to track correct device models

Sample user agents -

UserAgent: os:web_iOS,os_version:16.6,sdk:web,sdk_version:0.12.25,device_model:Apple_mobile_iPhone/Mobile_Safari_16.6,env:debug,domain:LOCAL,is_prebuilt:true,framework:react-web,framework_version:18.2.0,framework_sdk_version:0.10.25
UserAgent: os:web_iOS,os_version:16.6,sdk:web,sdk_version:0.12.25,device_model:Apple_tablet_iPad/Mobile_Safari_16.6,env:debug,domain:LOCAL,is_prebuilt:true,framework:react-web,framework_version:18.2.0,framework_sdk_version:0.10.25
UserAgent: os:web_Android,os_version:10.0,sdk:web,sdk_version:0.12.25,device_model:SM-F946U/Brave_131.0.0.0,env:debug,domain:LOCAL,is_prebuilt:true,framework:react-web,framework_version:18.2.0,framework_sdk_version:0.10.25
UserAgent: os:web_Windows,os_version:10,sdk:web,sdk_version:0.12.25,device_model:Chrome_116.0.0.0,env:debug,domain:LOCAL,is_prebuilt:true,framework:react-web,framework_version:18.2.0,framework_sdk_version:0.10.25
UserAgent: os:web_Chromecast_Linux,os_version:1.54.248666,sdk:web,sdk_version:0.12.25,device_model:Google_smarttv_Chromecast/Brave_131.0.0.0,env:debug,domain:LOCAL,is_prebuilt:true,framework:react-web,framework_version:18.2.0,framework_sdk_version:0.10.25

Pre-launch Checklist

  • The Documentation is updated accordingly, or this PR doesn't require it.
  • I updated/added relevant documentation.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

Merging:

  • Squash merge to dev
  • Merge commit to publish-alpha and main

@ygit ygit added enhancement New feature or request sdk labels Dec 6, 2024
Copy link

vercel bot commented Dec 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
dashboard-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 9, 2024 0:25am
storybook-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 9, 2024 0:25am

@ygit ygit closed this Dec 6, 2024
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${event.metadata.token}`,
user_agent_v2: event.metadata.userAgent,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this optional?

@@ -15,7 +15,7 @@ export interface HMSSessionFeedback {

export interface HMSSessionInfo {
peer: HMSSessionPeerInfo;
agent: string;
agent?: string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

most likely should not be optional

export const isIOS = parsedUserAgent.getOS()?.name?.toLowerCase() === 'ios';
export const isMacOS = parsedUserAgent.getOS()?.name?.toLowerCase() === 'mac os';
export const isMacOS = parsedUserAgent.getOS()?.name?.toLowerCase() === 'macos';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this a typo earlier or the new version made this change?

}

function getDeviceType(device?: string, type?: string) {
return device && device.length > 0 ? `${device}_${type}` : type;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

length check probably not needed

* @returns {Promise<UAParser.IOS>} OS name and version
*/
async function getOSFromUserAgent(): Promise<UAParser.IOS> {
const os = await parsedUserAgent.getOS().withClientHints();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it might fail in older devices/browsers no? should we add a try catch and do feature check there as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request sdk
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants