10 reasons to try the new backtrace-node update

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

Nowadays, TypeScript is one of the most popular programming languages. Based on the report available here we learnt that Javascript and TypeScript are the most widely used programming languages. We believe that thanks to the type system, the simplicity and the quality of JavaScript code JavaScript was ranked as first most popular language.  Furthermore, TypeScript was positioned twelfth in the overall ranking, above languages like Swift, Go and Ruby.

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!

TypeScript support with Backtrace-node

TypeScript support with Backtrace-node

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!

File attachment support

File attachment support

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.

Support for await syntax with the reportAsync function

Support for await syntax with the reportAsync function

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.

event emitter support

Event emitter support allows for before-send, after-send, and other events.

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.

6. Sampling

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!

Use BacktraceResult object to learn what happened with the request.

Use BacktraceResult object to learn what happened with the request.

8. Memorize

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.

Add key-value pairs that will be used in the next submitted report.

Add key-value pairs that will be used in the next submitted report.

9. Legacy support

All examples below are done using the modern Backtrace-node API. However, if you don’t want to break your code and still you would like to use the old API, nevertheless our library allows you to do that! You can still import the Backtrace-Node library and use the old JavaScript API in TypeScript/JavaScript.

Support for backtrace-node legacy API.

Support for backtrace-node legacy API.

10. Sample demos

No matter if you are using TypeScript or JavaScript you should try our sample demos! Because we know it’s a big change for you and us to bring TypeScript support to your project we decide to help you us much as possible. What did we do? We decide do add full support to Visual Studio Code. Now from debug page you can run our unit tests and …. TypeScript + JavaScript demos with Electron and pure NodeJS application where we describe and show you how to use our solution. Sounds fair? All you have to do is to build application and press f5 in Visual Studio Code!

Demos!

Demos!

Summary

No matter whether you are using TypeScript or JavaScript you should try our sample demos! We know that  the addition of the TypeScript support into your project is a big change for you. Thus, we want to help you as much as possible. We added a full support to Visual Studio Code to make your life easier. Now from the debug page you can run our unit tests and …. combine TypeScript + JavaScript demos with the Electron and pure Node.js application where we describe and show you how to use our solution. Sounds fair? All you have to do is to build an application and press f5 in the Visual Studio Code!

Additional resources:
https://www.npmjs.com/package/backtrace-node 

By | 2019-06-05T21:45:49+00:00 June 4th, 2019|Announcements, Features, Technical Details|