Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set user agent string (sdk name + version) #957

Closed
Tracked by #61
kahest opened this issue Mar 6, 2024 · 4 comments
Closed
Tracked by #61

Set user agent string (sdk name + version) #957

kahest opened this issue Mar 6, 2024 · 4 comments
Labels
SDK parity Behavior that other SDKs provide and we are missing or implement differently

Comments

@kahest
Copy link
Member

kahest commented Mar 6, 2024

Currently, the SDK only sets the x-sentry-auth field in the transport:

h->value = sentry__dsn_get_auth_header(dsn, user_agent);

To align with getsentry/team-sdks#61, we want to send the SDK name and version as User-Agent using the format <sdk-name>/<sdk-version>.

TBD: crashpad/breakpad

@kahest kahest transferred this issue from getsentry/team-sdks Mar 6, 2024
@kahest kahest added the SDK parity Behavior that other SDKs provide and we are missing or implement differently label Mar 6, 2024
@kahest kahest changed the title sentry-native: set user agent string (sdk name + version) Set user agent string (sdk name + version) Mar 6, 2024
@supervacuus
Copy link
Collaborator

Hi @kahest

Currently, the SDK only sets the x-sentry-auth field in the transport:

This is not true. We also set the user-agent to sdk_name/version:

https://github.com/getsentry/sentry-native/blob/master/src/sentry_options.c#L322-L329

Since breakpad uses the same transport as any other envelope, this is also true with minidumps from breakpad.

With crashpad, the current solution is to append the sentry_client as part of a set of X-Sentry-Auth query parameters with the minidump request. The format is the same as with the user-agent above.

@kahest
Copy link
Member Author

kahest commented Mar 6, 2024

@supervacuus I see that this constructs opts->user_agent with name and version, but I couldn't find where this is used to set a user agent header on the transport, but I guess I looked at the wrong place - is this the relevant code?

state->user_agent = sentry__string_clone(options->user_agent);

state->user_agent = sentry__string_to_wstr(opts->user_agent);

@kahest
Copy link
Member Author

kahest commented Mar 6, 2024

@supervacuus Perfect, thanks for confirming - closing this now

@kahest kahest closed this as not planned Won't fix, can't repro, duplicate, stale Mar 6, 2024
@supervacuus
Copy link
Collaborator

supervacuus commented Mar 6, 2024

Similarly, the minidump URL for crashpad is constructed from the DSN and the user-agent:

sentry__dsn_get_minidump_url(const sentry_dsn_t *dsn, const char *user_agent)
{
if (!dsn || !dsn->is_valid || !user_agent) {
return NULL;
}
sentry_stringbuilder_t sb;
init_string_builder_for_url(&sb, dsn);
sentry__stringbuilder_append(&sb, "/minidump/?sentry_client=");
sentry__stringbuilder_append(&sb, user_agent);
sentry__stringbuilder_append(&sb, "&sentry_key=");
sentry__stringbuilder_append(&sb, dsn->public_key);
return sentry__stringbuilder_into_string(&sb);
}

That should also make it clearly visible when checking LB issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SDK parity Behavior that other SDKs provide and we are missing or implement differently
Projects
Archived in project
Development

No branches or pull requests

2 participants