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

V7: Rename autoCaptureSessions -> autoTrackSessions and simplify validation logic #647

Merged
merged 2 commits into from
Nov 15, 2019

Conversation

bengourley
Copy link
Contributor

Per the updated spec, the option to disable sessions is called autoTrackSessions. In addition to making that update, a suggestion made here¹ was incorporated to make the session endpoint always required (this only applies when endpoints is set).

Previously the validation of the autoCaptureSessions field was dependent on whether a session endpoint was provided, which made the logic unnecessarily complex.

¹https://github.com/bugsnag/bugsnag-js/pull/630/files#r343663933

@@ -23,8 +23,8 @@ var bugsnagClient = bugsnag({
appVersion: '1.2.3',

// Bugsnag can track the number of “sessions” that happen in your application,
// and calculate a crash rate for each release. This defaults to false.
autoCaptureSessions: true,
// and calculate a crash rate for each release. This defaults to true.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the default value has not been updated in this PR, this comment was out of date.

@@ -18,11 +18,6 @@ const sessionDelegate = {
return sessionClient
}

if (!sessionClient.config.endpoints.sessions) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The config schema now validates that endpoints.sessions must now be defined so this branch of code is obsolete.

@@ -37,11 +37,6 @@ const sendSessionSummary = client => sessionCounts => {
return
}

if (!client.config.endpoints.sessions) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As above, commenting here too for an equivalent change… the config schema now validates that endpoints.sessions must now be defined so this branch of code is obsolete.

@@ -8,7 +8,7 @@
var API_KEY = decodeURIComponent(window.location.search.match(/API_KEY=([^&]+)/)[1])
var bugsnagClient = bugsnag({
apiKey: API_KEY,
endpoints: { notify: ENDPOINT },
endpoints: { notify: ENDPOINT, sessions: '/noop' },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Loads of the end-to-end tests that relied on being allowed to not set a custom session endpoint now need some value to satisfy the config validation, but all of these tests only make assertions about errors.

I've set it to this value here (and many other places), which hopefully which suggests it's not used at all to appease the config validation.

@bugsnagbot
Copy link
Collaborator

bugsnagbot commented Nov 14, 2019

@bugsnag/browser bundle size diff

Minified Minfied + Gzipped
Before 40.88 kB 12.24 kB
After 40.62 kB 12.16 kB
± -263 bytes -74 bytes

Generated by 🚫 dangerJS against aa74d61

… simplify validation logic

Per the updated spec, the option to disable sessions is called `autoTrackSessions`. In addition to
making that update, a suggestion made here¹ was incorporated to make the session endpoint always
required (this only applies when endpoints is set). Previously the validation of the
`autoCaptureSessions` field was dependent on whether a session endpoint was provided, which made the
logic unnecessarily complex.

¹https://github.com/bugsnag/bugsnag-js/pull/630/files#r343663933
@bengourley bengourley merged commit 775576a into v7 Nov 15, 2019
@bengourley bengourley deleted the v7-session-opts branch November 15, 2019 15:04
@bengourley bengourley mentioned this pull request Apr 14, 2020
Merged
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.

3 participants