Skip to content

fix: Still write user-agent when os-context conflicts#229

Merged
untitaker merged 2 commits intomasterfrom
fix/os-context-conflicts
Aug 29, 2019
Merged

fix: Still write user-agent when os-context conflicts#229
untitaker merged 2 commits intomasterfrom
fix/os-context-conflicts

Conversation

@untitaker
Copy link
Copy Markdown
Member

Problem

The os context is defined as "the OS of the device that sent the event" in the docs. Previously the server backfilled the os context based on the User-Agent only for JS events.

We recently changed this (getsentry/sentry#10679) to do this for all events from all platforms. Therefore we can no longer have certainty which device the OS context is referring to: For SDKs that send OS contexts, it likely refers to the device where the event originated, as the docs define. For SDKs that do not send OS contexts, it can be whatever is in the user-agent.

As a concrete example:

  • PHP sends an OS context. Therefore the OS context refers to the server's OS.
  • Python does not send an OS context. Therefore the OS context refers to the HTTP client's OS.

However, the way the UI displays things makes it confusing. There, the browser context and OS context are pulled together and shown in one line:

context

This makes users expect something that is the opposite of what the interface docs suggest: The OS context (the one stored in the os key) is expected to refer to the client device.

Solution

  • Write user-agent derived OS context into a different key for anything but JS.
  • Prefer client_os over os for this bar (keep fallback to os for JS).

This needs to be deployed AFTER the UI knows to prefer client_os over os for this bar.

Copy link
Copy Markdown
Member

@jan-auer jan-auer left a comment

Choose a reason for hiding this comment

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

Excellent description, thanks! G2G once updated 👍

On the side, is the reason we're not setting client_os all the time that we do not want to break JS events?

Comment thread general/src/store/normalize/user_agent.rs Outdated
version: Annotated::from(version),
..OsContext::default()
})));
contexts.insert(
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.

Please add a variant Context::ClientOs(Box<OsContext>) and return "client_os" from fn Context::default_key. That way, we only maintain this logic in one place and make it more reusable.

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.

Oh and I'm realizing that our enum derive only lowercases fields, where it should probably snake_case. Would that be possible to change with this PR?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't think that is a good idea. the Context enum deals with context types (not default keys) but client_os is not its own context type yet.

I tried to implement this and it creates multiple possible representations for the same JSON: {"contexts": {"os": ...}} will be deserialized into an OsContext but can be serialized from a ClientOs variant as well.

Co-Authored-By: Jan Michael Auer <jan.auer@sentry.io>
@untitaker
Copy link
Copy Markdown
Member Author

On the side, is the reason we're not setting client_os all the time that we do not want to break JS events?

Yes, particularly search.

@untitaker untitaker requested a review from jan-auer August 28, 2019 20:52
@untitaker untitaker merged commit 04ecc50 into master Aug 29, 2019
@untitaker untitaker deleted the fix/os-context-conflicts branch August 29, 2019 11:10
jan-auer added a commit that referenced this pull request Aug 29, 2019
* master:
  feat: Implement data scrubbers in Relay (#227)
  fix: Still write user-agent when os-context conflicts (#229)
  ref: change default to sentry.io from ingest.sentry.io
  test: Merge integration tests in Travis config (#228)
  test: Run Kafka on Travis (#226)
  ref: Make uaparser optional (#224)
  fix: Move insta to dev-dependencies
  doc: Add some Docker info to README
  deploy: Add a pipeline step to create Sentry release
  build: Do not push Docker images to Dockerhub (#223)
  build: Use 8 core machines on Cloud Build
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.

2 participants