Backtrace <3 Node.js. Why? Node.js applications are becoming more commonplace in many enterprises due to their ease of use for microservices. At Backtrace, we provide a better debugging experience for your entire application stack, and to do that, we incorporate Node.js as a key component.
We are happy to announce the next version of the backtrace-node library to take advantage of the newest features of Node.js. What’s new in backtrace-node? TypeScript support, client rate limits, event emitter, and more! In the article below we introduce 10 reasons on why you should check out our newest version of the Backtrace-node.
1. Full TypeScript support
How can you use TypeScript support? You don’t need to download additional npm packages with @types/backtrace-node. All you have to do is to install the newest Backtrace-node package. The package has already all definitions types that you can use in your project!
2. File attachment support
Plenty developers gave us positive feedback about file attachment support in Backtrace C# and Backtrace-Android libraries. Game developers that use our Unity and Unreal Engine plugins cannot imagine “send” methods without file attachments. Now, Backtrace-node allows developer to pass paths to any file on user hard drive!
3. Promise API
The modern NodeJS API requires async/await syntax. By using these you can avoid callback patterns and make your code even simpler. We can see more and more solutions supporting the Promise API, so do we! Now, the reportAsync method allows you to wait for sending reports to Backtrace. You can still use an old Backtrace-node API. Please check available parameters in the reportSync/reportAsync methods.
4. Event emitter support
The event emitter is a common pattern in the Node.js world. From any class that inherits from the Event emitter you can trigger events that other class can receive by using ‘on’ method. The Backtrace-node gives you more opportunities to check what your application wants to send to Backtrace and when. You can use the event emitter to learn when you hit a report limit per minute or when the server returns response.
5. Client rate limiting
Backtrace-node supports client rate limiting! You can define how many reports per one minute you want to send to Backtrace by adding the additional option to the BacktraceClientOptions object. Now, when you reach the defined limit, the client will skip the current report. You can still learn which report won’t be available on the server by using event-emitter and ‘rate-limit’ events or by checking BacktraceResult – object that will return the reportSync/reportAsync method.
Now, Backtrace-node supports sampling attribute. By using this argument, you can prevent sending reports to the server. You can define sampling value in the BacktraceClientOptions.Sampling option which accepts values from 0 to 1, where 1 means sampling algorithm will skill all reports. If you want to know when Backtrace-node skips a report, please check BacktraceResult object, or use ‘sampling-hit’ event.
7. Better diagnostic experience with BacktraceResult
Backtrace-node now returns to send result object. By using BacktraceResult you can learn what happened with the request. When Backtrace-Node will hit the rate limit or sampling decides to skip the report, you can use the result object to learn what happened. If you are use the promise API you can wait until Backtrace will receive an event. BacktraceResult allows you to retrieve objectId and message from server!
Now, the Backtrace-node supports the Memorize method! What can you do with it? Depending on an application or a situation you would like to add dynamically attributes that should be available only in next request. The Memorize method allows you to add dynamic key-value data to attributes that will be available only in the next report.
9. Legacy support
10. Sample demos