Skip to content

Commit

Permalink
fix: align default value for environment payload attribute with... (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
supervacuus authored Aug 1, 2022
1 parent 2ca30df commit 4a41476
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/sentry_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ sentry_options_new(void)
opts->release = sentry__string_clone(getenv("SENTRY_RELEASE"));
opts->environment = sentry__string_clone(getenv("SENTRY_ENVIRONMENT"));
#endif
if (!opts->environment) {
opts->environment = sentry__string_clone("production");
}
opts->max_breadcrumbs = SENTRY_BREADCRUMBS_MAX;
opts->user_consent = SENTRY_USER_CONSENT_UNKNOWN;
opts->auto_session_tracking = true;
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/test_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ SENTRY_TEST(session_basics)
sentry_options_set_transport(
options, sentry_new_function_transport(send_envelope, &called));
sentry_options_set_release(options, "my_release");

// the default environment is always `production` if not overwritten by the
// OS environment variable `SENTRY_ENVIRONMENT`
// (see https://develop.sentry.dev/sdk/event-payloads/#optional-attributes)
TEST_CHECK_STRING_EQUAL(
sentry_options_get_environment(options), "production");
sentry_options_set_environment(options, "my_environment");
sentry_init(options);

Expand Down

0 comments on commit 4a41476

Please sign in to comment.