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: Simplify client configuration and store config privately #656
Conversation
let warningMessage = '' | ||
|
||
if (opts.endpoints && opts.endpoints.notify && !opts.endpoints.sessions) { | ||
warningMessage += 'notify endpoint is set but sessions endpoint is not. No sessions will be sent.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's now impossible to get into this state, as of #647
69d8c07
to
31c7527
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 great API improvement
@@ -53,7 +46,7 @@ describe('plugin: window onerror', () => { | |||
// const client = new Client(VALID_NOTIFIER) | |||
// const payloads = [] | |||
// client.setOptions({ apiKey: 'API_KEY_YEAH' }) | |||
// client.configure() | |||
// client._configure() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's only a comment but I think this should be unchanged. Maybe the all commented code needs updating or just removing? Same for other places in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a backlog ticket to convert all these commented out unit tests into maze runner tests.
I'll undo the change.
@@ -64,7 +59,7 @@ describe('plugin: unhandled rejection', () => { | |||
// it('works with DOMExceptions', done => { | |||
// const client = new Client(VALID_NOTIFIER) | |||
// setOptions({ apiKey: 'API_KEY_YEAH' }) | |||
// client.configure() | |||
// client._configure() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented code as per other comment
31c7527
to
8c2eb11
Compare
The existing configuration routine was laborious and can be simplified to be done in one fell swoop
This is just an implementation detail really – this logic is done internally in each exported notififer – but it removes some methods from the public client interface (making it compliant with the spec).
One benefit of the configuration being done via the constructor is that we can remove some of the "client not configured" errors – it's now impossible to have an instance of a client that's not configured.
Since loads of unit tests create
Client
s directly, this changeset is pretty big, but it does end up removing a lot of boilerplate lines from those tests.The other change in this PR is to store config at
client._config
(_
to signify that it is private) and remove itspublic
definition from the types to match up with the spec.