Skip to content

feat(client): add AppIdentifier for app/app_version in the user agent#1791

Merged
oliverlaz merged 3 commits into
release-v8from
backport-appidentifier-v8
Jul 2, 2026
Merged

feat(client): add AppIdentifier for app/app_version in the user agent#1791
oliverlaz merged 3 commits into
release-v8from
backport-appidentifier-v8

Conversation

@oliverlaz

@oliverlaz oliverlaz commented Jul 1, 2026

Copy link
Copy Markdown
Member

What

Backport of #1789 to the v8 release line (release-v8).

Adds a new AppIdentifier so downstream SDKs can report the host application in the X-Stream-Client user agent, and refactors getUserAgent to a memoized arrow-function class field, matching the v9 implementation exactly (full parity).

Why

The user agent already identifies the SDK (SdkIdentifier) and the device (DeviceIdentifier), but had no way to report the integrating application. AppIdentifier fills that gap as a distinct, third category.

Changes

  • AppIdentifier type (src/types.ts): { name: string; version?: string }. name maps to wire key app, version to app_version (mirroring how DeviceIdentifier.model maps to device_model).
  • client.appIdentifier (src/client.ts): new optional field, set by downstream SDKs via direct assignment like sdkIdentifier / deviceIdentifier.
  • getUserAgent refactor: now an arrow-function class field with permanent memoization (computed once on first call). The stream-chat-... output format is unchanged; the new app / app_version segments are emitted right after the head, before os / device_model / client_bundle, and only when present.

Example (everything set):

stream-chat-react-native-v2.3.4-llc-v1.2.3|app=Acme|app_version=2.1.0|os=iOS 15.0|device_model=iPhone17,4

Parity note vs v9

This is the same change as #1789. The only differences are mechanical adaptations to the v8 codebase: the tests are written in v8's Mocha + chai style (test/unit/client.js) rather than Vitest, and code is formatted for v8's Prettier config.

Behavior note

Memoization is permanent: the user agent is computed once and cached for the client's lifetime. Identifiers (sdkIdentifier / deviceIdentifier / appIdentifier) must therefore be set before the first getUserAgent() call; previously the string was recomputed on every call. In practice downstream SDKs set these at init, before any request, so this is not expected to affect real integrations.

Semver

Additive and non-breaking: new optional type and field, no existing public behavior changed (feat, so a minor release on the 8.x line).

Testing

  • TDD: added Mocha/chai tests in test/unit/client.js for app + app_version ordering, the name-only case (omits app_version), and permanent memoization.
  • The 6 pre-existing X-Stream-Client header tests are unchanged and still pass.
  • yarn prettier (check), yarn eslint (src), yarn types, and the full unit suite (1457 passing) are green.

Backport of #1789 to the v8 release line.

Introduce an `AppIdentifier` ({ name, version }) that downstream SDKs can set
via `client.appIdentifier` to report the host application as `app` /
`app_version` segments in the `X-Stream-Client` user agent, alongside the
existing SDK and device identifiers.

Also refactor `getUserAgent` to an arrow-function class field and memoize the
result for the client's lifetime. The `stream-chat-...` output format is
unchanged; app segments are emitted after the head, before
os/device_model/client_bundle, and only when set.

Note: memoization is permanent, so identifiers must be set before the first
getUserAgent() call (previously the string was recomputed on each call).
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Size Change: +868 B (+0.16%)

Total Size: 536 kB

📦 View Changed
Filename Size Change
dist/browser.es.js 117 kB +195 B (+0.17%)
dist/browser.full-bundle.min.js 63.9 kB +39 B (+0.06%)
dist/browser.js 119 kB +218 B (+0.18%)
dist/index.es.js 117 kB +191 B (+0.16%)
dist/index.js 119 kB +225 B (+0.19%)

compressed-size-action

@oliverlaz oliverlaz merged commit 8bad3be into release-v8 Jul 2, 2026
4 checks passed
@oliverlaz oliverlaz deleted the backport-appidentifier-v8 branch July 2, 2026 08:28
github-actions Bot pushed a commit that referenced this pull request Jul 2, 2026
## [8.61.0](v8.60.0...v8.61.0) (2026-07-02)

### Features

* **client:** add AppIdentifier for app/app_version in the user agent ([#1791](#1791)) ([8bad3be](8bad3be)), closes [#1789](#1789) [#1789](#1789)

### Chores

* **deps:** upgrade form-data to version 4.0.4 ([#1591](#1591)) ([4c1d042](4c1d042))
github-actions Bot pushed a commit that referenced this pull request Jul 2, 2026
## [8.61.0](v8.60.0...v8.61.0) (2026-07-02)

### Features

* **client:** add AppIdentifier for app/app_version in the user agent ([#1791](#1791)) ([8bad3be](8bad3be)), closes [#1789](#1789) [#1789](#1789)

### Chores

* **deps:** upgrade form-data to version 4.0.4 ([#1591](#1591)) ([4c1d042](4c1d042))
@stream-ci-bot

Copy link
Copy Markdown

🎉 This PR is included in version 8.61.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants