Skip to content

Commit a6333c5

Browse files
refactor!: #262 remove deprecated methods (#288)
* refactor: #262 remove deprecated methods * Updated README * sync package.json
1 parent 0237b83 commit a6333c5

File tree

6 files changed

+19
-258
lines changed

6 files changed

+19
-258
lines changed

README.md

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -126,21 +126,6 @@ client.send(error)
126126
});
127127
```
128128

129-
### Legacy `sendWithCallback`
130-
131-
```javascript
132-
client.sendWithCallback(new Error(), {}, function (response){ });
133-
```
134-
135-
The client still provides a legacy `send()` method that supports callbacks instead of `Promises`.
136-
137-
**This method is deprecated and will be removed in the future.**
138-
139-
The callback should be a node-style callback: `function(err, response) { /*...*/ }`.
140-
*Note*: If the callback only takes one parameter (`function(response){ /*...*/ }`)
141-
it will only be called when the transmission is successful. This is included for
142-
backwards compatibility; the Node-style callback should be preferred.
143-
144129
### Send Parameters
145130

146131
The `send()` method accepts a series of optional named parameters, defined as follows:
@@ -227,11 +212,10 @@ You can attach user information to every Raygun Crash Report.
227212
It will be transmitted with the error sent, and a count of affected customers will appear on the dashboard in the error group view.
228213
If you provide an email address, and the user has associated a Gravatar with it, their picture will be also displayed.
229214

230-
This package offers three different ways to do that:
215+
This package offers two different ways to do that:
231216

232217
1. Provide the `userInfo` parameter in the `send()` method.
233218
2. Implement the `user(request)` method.
234-
3. Call to the `setUser(user)` method (not recommended and deprecated).
235219

236220
#### User information object
237221

@@ -263,7 +247,7 @@ userInfo = {
263247
For legacy support reasons, you can also provide the `string` identifier directly as the user information:
264248

265249
```js
266-
setUser("123");
250+
raygunClient.send(error, { userInfo: "123" });
267251
```
268252

269253
#### `userInfo` parameter in `send()`
@@ -274,7 +258,7 @@ Provide the `userInfo` optional parameter in the `send()` method call:
274258
client.send(new Error(), { userInfo });
275259
```
276260

277-
This provided user information will take priority over the `user(request)` and `setUser(user)` methods.
261+
This provided user information will take priority over the `user(request)` method.
278262

279263
#### Implement `raygunClient.user(req)`
280264

@@ -302,13 +286,6 @@ raygunClient.user = function (req) {
302286
**Param**: *req*: the current request.
303287
**Returns**: The current user's identifier, or an object that describes the user.
304288

305-
#### Global `setUser(user)` method (Deprecated)
306-
307-
You can set the user information globally by calling `setUser(user)` and providing the user information.
308-
309-
This is not recommended, the method has been marked as _deprecated_ and will be eventually removed.
310-
It is advised to update your code to set it with the `user(request)` method or provide the `userInfo` in the `send()` call.
311-
312289
### Version tracking
313290

314291
Call setVersion(*string*) on a RaygunClient to set the version of the calling application. This is expected to be of the format x.x.x.x, where x is a positive integer. The version will be visible in the dashboard.

lib/raygun.ts

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
import {
1212
BreadcrumbMessage,
13-
callVariadicCallback,
14-
Callback,
1513
CustomData,
1614
Hook,
1715
Message,
@@ -151,7 +149,6 @@ class Raygun {
151149
}
152150

153151
this.expressHandler = this.expressHandler.bind(this);
154-
this.sendWithCallback = this.sendWithCallback.bind(this);
155152
this.send = this.send.bind(this);
156153

157154
this._offlineStorage =
@@ -173,16 +170,6 @@ class Raygun {
173170
return null;
174171
}
175172

176-
/**
177-
* Sets a user globally.
178-
* @deprecated Implement user(request) callback or provide userInfo in send() method call instead
179-
* @param user - as RawUserData
180-
*/
181-
setUser(user: UserMessageData) {
182-
this._user = user;
183-
return this;
184-
}
185-
186173
/**
187174
* If you're using the `raygunClient.expressHandler`, you can send custom data along by setting this function.
188175
*
@@ -362,36 +349,6 @@ class Raygun {
362349
}
363350
}
364351

365-
/**
366-
* @deprecated sendWithCallback is a deprecated method. Instead, use send, which supports async/await calls.
367-
*
368-
* See: https://github.com/MindscapeHQ/raygun4node/issues/262
369-
*/
370-
sendWithCallback(
371-
exception: Error | string,
372-
customData?: CustomData,
373-
callback?: Callback<IncomingMessage>,
374-
request?: RequestParams,
375-
tags?: Tag[],
376-
) {
377-
// call async send but redirect response to provided legacy callback
378-
this.send(exception, {
379-
customData,
380-
request,
381-
tags,
382-
})
383-
.then((response) => {
384-
if (callback) {
385-
callVariadicCallback(callback, null, response);
386-
}
387-
})
388-
.catch((error) => {
389-
if (callback) {
390-
callVariadicCallback(callback, error, null);
391-
}
392-
});
393-
}
394-
395352
private reportUncaughtExceptions() {
396353
const [major, minor] = process.versions.node
397354
.split(".")

lib/types.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -193,31 +193,6 @@ export type RaygunOptions = {
193193
reportUncaughtExceptions?: boolean;
194194
};
195195

196-
// TODO: Remove all Callback related types when sendWithCallback is finally removed
197-
// See: https://github.com/MindscapeHQ/raygun4node/issues/262
198-
export type CallbackNoError<T> = (t: T | null) => void;
199-
export type CallbackWithError<T> = (e: Error | null, t: T | null) => void;
200-
201-
export function isCallbackWithError<T>(
202-
cb: Callback<T>,
203-
): cb is CallbackWithError<T> {
204-
return cb.length > 1;
205-
}
206-
207-
export function callVariadicCallback<T>(
208-
callback: Callback<T>,
209-
error: Error | null,
210-
result: T | null,
211-
) {
212-
if (isCallbackWithError(callback)) {
213-
return callback(error, result);
214-
} else {
215-
return callback(result);
216-
}
217-
}
218-
219-
export type Callback<T> = CallbackNoError<T> | CallbackWithError<T>;
220-
221196
/**
222197
* Internal type, sent to the Raygun API as part of MessageDetails
223198
*/

package-lock.json

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/raygun_async_send_test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ test("async send complex", {}, function (t) {
3535

3636
let client = new Raygun.Client()
3737
.init({ apiKey: API_KEY })
38-
.setUser("callum@mindscape.co.nz")
3938
.setVersion("1.0.0.0");
4039

4140
client

test/raygun_send_test.js

Lines changed: 0 additions & 163 deletions
This file was deleted.

0 commit comments

Comments
 (0)