Skip to content

Track mobile app version on API requests for retrocompatibility monitoring #12159

@stilla

Description

@stilla

Problem

We have no way to know which version of the mobile app is actively making API requests. This makes it impossible to safely deprecate or evolve API behavior, since we can't tell whether old client versions are still in the wild.

Currently:

  • No version header is sent by the mobile app
  • API middlewares don't parse or capture any client version signal
  • PostHog has zero data on app_version or any client version property — mobile traffic is only identifiable by $os/$browser (web SDK)

Solution

1. Mobile app — send a version header

Have the app include a version header on every API request:

X-Polar-Client-Version: mobile/1.2.3

2. API — parse the header in middleware

Extend LogCorrelationIdMiddleware (or add a new one) in server/polar/middlewares.py to extract and bind the version:

client_version = dict(scope.get("headers", [])).get(b"x-polar-client-version", b"").decode()
structlog.contextvars.bind_contextvars(client_version=client_version)

Also set it on the Logfire/Sentry root span for tracing.

3. PostHog — track as a backend event property

Forward client_version as a property on backend events so we can build a dashboard showing active version distribution over time — the key signal for retrocompatibility decisions.

Sent by @maximevast from Mobile app version monitoring for API retrocompatibility.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

Status
No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions