You install the Node Agent by adding a dependency on the
trackjs-node package and including it in your application. The agent is lightweight and dependency free.
Once installed, the agent listens for errors and other events to be reported back to your TrackJS Dashboard. The agent should be installed as early in your initialization process as possible so that the environment can be fully instrumented.
In addition to
token, there are lots of options you can pass when installing the agent to better integrate with your application. Options can be used to:
- add custom context to your errors
- disable agent behaviors
- customize reporting behavior
If you need the agent to do something specialized, checkout the onError option that allows you to manipulate errors before they are reported.
If you don’t know whether your script will run on the client or server, you’ll need to put an adapter around the agent to provide this isomorphism. Here is an example:
The TrackJS-Node agent is written in Typescript and publishes types in the package. It will allow you to discover the options available on the agent.