Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Fix middleware backwards compatibility #246

Merged
merged 3 commits into from
Dec 14, 2016
Merged

Fix middleware backwards compatibility #246

merged 3 commits into from
Dec 14, 2016

Conversation

LewisJEllis
Copy link
Contributor

@LewisJEllis LewisJEllis commented Dec 14, 2016

  • Changed to use instanceof Raven.constructor instead of instanceof Raven.client
  • Added deprecation warnings; these toplevel functions are the old way to do it and people should have their own instances and use the instance methods instead, rather than having to pass in an instance or let one be created for them.

Based on #245 from @dhritzkiv. Will merge into master and also cherry pick into a releases/1.0.x branch, then publish 1.0.1 and 1.1.1.

/cc @benvinegar

client = client instanceof Raven.Client ? client : new Raven.Client(client);
return client.errorHandler();
connectMiddleware.errorHandler = function (clientOrDSN) {
utils.consoleAlert('top-level Raven.middleware.* methods have been deprecated and will be removed in v2.0; use instance methods instead');
Copy link
Contributor

Choose a reason for hiding this comment

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

"use instance methods instead"

Are people going to know what this is? Can we link to something here, or say the actual code?

Also, what's the harm in keeping this around?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sort of trying to keep that warning from being excessively long, but I'll be more specific about the methods I'm referring to.

Harm is that a user might just pass their DSN string in 3 places and end up with 3 instances, two of which are sort of hidden and probably entirely unnecessary, when they really just want one instance. Might result in situations where e.g. user expects to get breadcrumbs but doesn't. I want to avoid multiple instances entirely unless the user is explicitly asking for them and knows what they're doing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good explanation – I agree. My fear is that people will see that message and have no idea what you're talking about, especially since it's not yet reflected in docs.

Can we do something like:

utils.consoleAlert('top-level Raven.middleware.* methods have been deprecated and will be removed in v2.0; use client.requestHandler()');

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, I updated it to roughly that. Adding a test.

@LewisJEllis LewisJEllis merged commit 195b8a9 into master Dec 14, 2016
@LewisJEllis LewisJEllis deleted the pr/245 branch December 14, 2016 00:52
LewisJEllis added a commit that referenced this pull request Dec 14, 2016
* Fix middleware `client instanceof Raven.Client` check to use `Raven.constructor` (thanks @dhritzkiv)

* Add deprecation warning to top-level middleware

* Add tests for top-level Raven.middleware backwards compat
@LewisJEllis
Copy link
Contributor Author

Published 1.0.1 and 1.1.1; thanks @dhritzkiv!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants