Skip to content

✨ Add build number and RFC 7231 formatting to user agent#26

Merged
williamchong merged 2 commits intolikecoin:mainfrom
williamchong:develop
Mar 30, 2026
Merged

✨ Add build number and RFC 7231 formatting to user agent#26
williamchong merged 2 commits intolikecoin:mainfrom
williamchong:develop

Conversation

@williamchong
Copy link
Copy Markdown
Member

Use expo-application for native version and build number instead of package.json alone. Properly case OS name and semicolon-separate fields.

Before: 3ook-com-app/1.1.0 (ios 18.0)
After: 3ook-com-app/1.1.0 (iOS; 18.0) Build/42

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the WebView user agent string to include native app version/build metadata (via expo-application) and formats the UA string closer to RFC-style product tokens + comment, improving server-side identification of app clients.

Changes:

  • Add expo-application usage to fetch native app version and build number with a fallback to package.json version.
  • Normalize OS name casing and formatting in the UA comment.
  • Replace inline userAgent template with a shared USER_AGENT constant.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

const USER_AGENT = (() => {
const appVersion = Application.nativeApplicationVersion ?? packageJson.version;
const buildNumber = Application.nativeBuildVersion ?? '0';
const osName = Platform.OS === 'ios' ? 'iOS' : 'Android';
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

osName falls back to 'Android' for any non-iOS platform. If this file ever runs on web (or other RN platforms), the UA will be incorrect. Prefer explicitly handling android (and optionally web) or deriving from Platform.OS with proper casing.

Suggested change
const osName = Platform.OS === 'ios' ? 'iOS' : 'Android';
const osNameMap: Record<string, string> = { ios: 'iOS', android: 'Android', web: 'Web' };
const osName = osNameMap[Platform.OS] ?? Platform.OS;

Copilot uses AI. Check for mistakes.
app/index.tsx Outdated
Comment on lines +24 to +26
const buildNumber = Application.nativeBuildVersion ?? '0';
const osName = Platform.OS === 'ios' ? 'iOS' : 'Android';
return `3ook-com-app/${appVersion} (${osName}; ${Platform.Version}) Build/${buildNumber}`;
Copy link

Copilot AI Mar 27, 2026

Choose a reason for hiding this comment

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

Defaulting nativeBuildVersion to '0' means the app will always send Build/0 when the build number isn't available (e.g., certain dev/web contexts). That can be misleading for server-side logging/feature flags; consider omitting the Build/... product token entirely when nativeBuildVersion is null/undefined.

Suggested change
const buildNumber = Application.nativeBuildVersion ?? '0';
const osName = Platform.OS === 'ios' ? 'iOS' : 'Android';
return `3ook-com-app/${appVersion} (${osName}; ${Platform.Version}) Build/${buildNumber}`;
const buildNumber = Application.nativeBuildVersion;
const buildToken = buildNumber ? ` Build/${buildNumber}` : '';
const osName = Platform.OS === 'ios' ? 'iOS' : 'Android';
return `3ook-com-app/${appVersion} (${osName}; ${Platform.Version})${buildToken}`;

Copilot uses AI. Check for mistakes.
Use expo-application for native version and build number instead of
package.json alone. Properly case OS name and semicolon-separate fields.

Before: 3ook-com-app/1.1.0 (ios 18.0)
After:  3ook-com-app/1.1.0 (iOS; 18.0) Build/42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Align with standard UA convention where OS name and version form
a single token (e.g. "iOS 18.0"), not separate semicolon-delimited fields.
@williamchong williamchong requested a review from nwingt March 30, 2026 05:30
@williamchong williamchong merged commit 9d9db63 into likecoin:main Mar 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants