Skip to content

feat(electron): allow custom user agent for session activity#9066

Merged
wobsoriano merged 4 commits into
mainfrom
jw/user-agent-setting
Jul 1, 2026
Merged

feat(electron): allow custom user agent for session activity#9066
wobsoriano merged 4 commits into
mainfrom
jw/user-agent-setting

Conversation

@jeremy-clerk

@jeremy-clerk jeremy-clerk commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a userAgent option to createClerkBridge() for Electron apps that want to control how the app appears in UserProfile session activity.

The option sets Electron's app.userAgentFallback, and the README now shows the setup alongside the existing bridge configuration.

Summary by CodeRabbit

  • New Features

    • Electron apps can now pass a custom userAgent when creating the Clerk bridge to improve UserProfile session activity attribution.
  • Bug Fixes

    • User-agent fallback now preserves platform-related information when available.
    • If platform details can’t be derived (including malformed fallbacks), the configured userAgent is used.
  • Documentation

    • Updated the Electron “Getting Started” guide with the new userAgent configuration example.

@changeset-bot

changeset-bot Bot commented Jul 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 679d52f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@clerk/electron Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Jul 1, 2026 8:23pm
swingset Ready Ready Preview, Comment Jul 1, 2026 8:23pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Repository UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 6b0dde49-1f01-4997-a0eb-0d099488eb4e

📥 Commits

Reviewing files that changed from the base of the PR and between c68c2b4 and 679d52f.

📒 Files selected for processing (2)
  • packages/electron/src/main/__tests__/create-clerk-bridge.test.ts
  • packages/electron/src/main/create-clerk-bridge.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/electron/src/main/tests/create-clerk-bridge.test.ts
  • packages/electron/src/main/create-clerk-bridge.ts

📝 Walkthrough

Walkthrough

Adds an optional userAgent option to CreateClerkBridgeOptions and updates createClerkBridge to derive app.userAgentFallback from it while preserving platform details when available. Tests, README guidance, and a changeset were added.

Changes

Electron userAgent Option

Layer / File(s) Summary
Type declaration for userAgent option
packages/electron/src/shared/types.ts
Adds optional userAgent?: string to CreateClerkBridgeOptions with documentation.
Bridge fallback construction
packages/electron/src/main/create-clerk-bridge.ts
Imports app, adds buildUserAgentFallback, and conditionally sets app.userAgentFallback from options.userAgent.
Tests for userAgent behavior
packages/electron/src/main/__tests__/create-clerk-bridge.test.ts
Adds a default app.userAgentFallback, resets it per test, and verifies the new fallback-building behavior.
Docs and changeset
packages/electron/README.md, .changeset/electron-user-agent.md
Adds a README example showing userAgent usage and a changeset for the new patch release.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: wobsoriano

Poem

A bunny twitched its whiskers bright,
and set a fallback just right 🐰
With user-agent in the breeze,
platform crumbs stay where they please,
and session tags hop true tonight.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding custom user agent support for Electron session activity.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Jul 1, 2026

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@9066

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@9066

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@9066

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@9066

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@9066

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@9066

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@9066

@clerk/expo

npm i https://pkg.pr.new/@clerk/expo@9066

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@9066

@clerk/express

npm i https://pkg.pr.new/@clerk/express@9066

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@9066

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@9066

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@9066

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@9066

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@9066

@clerk/react

npm i https://pkg.pr.new/@clerk/react@9066

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@9066

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@9066

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@9066

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@9066

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@9066

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@9066

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@9066

commit: 679d52f

const passkeys = options.passkeys ? setupPasskeysMain() : null;

if (options.userAgent) {
app.userAgentFallback = options.userAgent;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment thread packages/electron/src/main/create-clerk-bridge.ts Fixed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/electron/src/main/__tests__/create-clerk-bridge.test.ts`:
- Around line 13-14: Add a test assertion for the plain createClerkBridge({
storage }) path to verify app.userAgentFallback remains unchanged when no
userAgent is provided. Update the create-clerk-bridge test around the
createClerkBridge and app mock setup so it explicitly checks the default
behavior alongside the existing userAgentFallback case, ensuring the omitted
userAgent branch does not modify the fallback.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Repository UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 8353bbde-4e9c-4740-a3a4-69c3eb6d617c

📥 Commits

Reviewing files that changed from the base of the PR and between d6d62f0 and c68c2b4.

📒 Files selected for processing (5)
  • .changeset/electron-user-agent.md
  • packages/electron/README.md
  • packages/electron/src/main/__tests__/create-clerk-bridge.test.ts
  • packages/electron/src/main/create-clerk-bridge.ts
  • packages/electron/src/shared/types.ts
✅ Files skipped from review due to trivial changes (3)
  • packages/electron/src/shared/types.ts
  • packages/electron/README.md
  • .changeset/electron-user-agent.md

Comment thread packages/electron/src/main/__tests__/create-clerk-bridge.test.ts
@wobsoriano wobsoriano merged commit 04bbfe9 into main Jul 1, 2026
51 checks passed
@wobsoriano wobsoriano deleted the jw/user-agent-setting branch July 1, 2026 21:08
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