Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork22
Exceptionless JavaScript client
License
exceptionless/Exceptionless.JavaScript
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
The definition of the word exceptionless is: to be without exception. Exceptionless provides real-time error reporting for your JavaScript applications in the browser or in Node.js. It organizes the gathered information into simple actionable data that will help your app become exceptionless!
You can install the npm package vianpm install @exceptionless/browser --save
or via cdnhttps://unpkg.com/@exceptionless/browser
.Next, you just need to call startup during your apps startup to automaticallycapture unhandled errors.
import{Exceptionless}from"https://unpkg.com/@exceptionless/browser";awaitExceptionless.startup((c)=>{c.apiKey="API_KEY_HERE";c.setUserIdentity("12345678","Blake");// set some default datac.defaultData["mydata"]={myGreeting:"Hello World"};c.defaultTags.push("Example","JavaScript","Browser");});try{thrownewError("test");}catch(error){awaitExceptionless.submitException(error);}
You can install the npm package vianpm install @exceptionless/node --save
.Next, you just need to call startup during your apps startup to automaticallycapture unhandled errors.
import{Exceptionless}from"@exceptionless/node";awaitExceptionless.startup((c)=>{c.apiKey="API_KEY_HERE";c.setUserIdentity("12345678","Blake");// set some default datac.defaultData["mydata"]={myGreeting:"Hello World"};c.defaultTags.push("Example","JavaScript","Node");});try{thrownewError("test");}catch(error){awaitExceptionless.submitException(error);}
You can install Exceptionless either in your browser application using ascript
tag, or you can use the Node Package Manager (npm) to install the package.
Use one of the following methods to install Exceptionless into your browser application:
Add the following script tag at the very beginning of your page:
<scripttype="module">import{Exceptionless}from"https://unpkg.com/@exceptionless/browser";awaitExceptionless.startup((c)=>{c.apiKey="API_KEY_HERE";});</script>
- Install the package by running
npm install @exceptionless/browser --save
. - Import Exceptionless and call startup during app startup.
import{Exceptionless}from"@exceptionless/browser";awaitExceptionless.startup((c)=>{c.apiKey="API_KEY_HERE";});
Use this method to install Exceptionless into your Node application:
- Install the package by running
npm install @exceptionless/node --save
. - Import the Exceptionless module in your application:
import{Exceptionless}from"@exceptionless/node";awaitExceptionless.startup((c)=>{c.apiKey="API_KEY_HERE";});
In order to use Exceptionless, theapiKey
setting has to be configured first.You can configure theExceptionlessClient
class by callingawait Exceptionless.startup("API_KEY_HERE");
. If you want to configureadditional client settings you'll want to call thestartup
overload that takesa callback as shown below:
awaitExceptionless.startup((c)=>{c.apiKey="API_KEY_HERE";});
Please see thedocs formore information on configuring the client.
Once configured, Exceptionless will automatically submit any unhandled exceptionsthat happen in your application to the Exceptionless server. The followingsections will show you how to manually submit different event types as well ascustomize the data that is sent:
You may also want to submit log messages, feature usage data or other kinds of events. You can do this very easily with the fluent API:
import{Exceptionless}from"@exceptionless/browser";awaitExceptionless.submitLog("Logging made easy");// You can also specify the log source and log level.// We recommend specifying one of the following log levels: Trace, Debug, Info, Warn, ErrorawaitExceptionless.submitLog("app.logger","This is so easy","Info");awaitExceptionless.createLog("app.logger","This is so easy","Info").addTags("Exceptionless").submit();// Submit feature usagesawaitExceptionless.submitFeatureUsage("MyFeature");awaitExceptionless.createFeatureUsage("MyFeature").addTags("Exceptionless").submit();// Submit a 404awaitExceptionless.submitNotFound("/somepage");awaitExceptionless.createNotFound("/somepage").addTags("Exceptionless").submit();// Submit a custom event typeawaitExceptionless.submitEvent({ message="Low Fuel", type="racecar", source="Fuel System"});
In addition to automatically sending all unhandled exceptions, you may want tomanually send exceptions to the service. You can do so by using code like this:
import{Exceptionless}from"@exceptionless/node";awaitExceptionless.startup("API_KEY_HERE");try{thrownewError("test");}catch(error){awaitExceptionless.submitException(error);}
You can easily include additional information in your error reports using the fluentevent builder API.
import{Exceptionless}from"@exceptionless/node";awaitExceptionless.startup("API_KEY_HERE");try{thrownewError("Unable to create order from quote.");}catch(error){awaitExceptionless.createException(error)// Set the reference id of the event so we can search for it later (reference:id)..setReferenceId("random guid")// Add the order object (the ability to exclude specific fields will be coming in a future version)..setProperty("Order",order)// Set the quote number..setProperty("Quote",123)// Add an order tag..addTags("Order")// Mark critical..markAsCritical()// Set the coordinates of the end user..setGeo(43.595089,-88.444602)// Set the user id that is in our system and provide a friendly name..setUserIdentity(user.Id,user.FullName)// Submit the event..submit();}
The Exceptionless client can also be configured to send data to your self hostedinstance. This is configured by setting theserverUrl
on the defaultExceptionlessClient
when callingstartup
:
awaitExceptionless.startup((c)=>{c.apiKey="API_KEY_HERE";c.serverUrl="https://localhost:5100";});
By default the Exceptionless Client will report all available metadata including potential PII data.You can fine tune the collection of information via Data Exclusions or turning off collection completely.
Please visit thedocsfor detailed information on how to configure the client to meet your requirements.
If you need help, please contact us via in-app support,open an issueorjoin our chat on Discord. We’re always here tohelp if you have any questions!
If you find a bug or want to contribute a feature, feel free to create a pull request.
Clone this repository:
git clone https://github.com/exceptionless/Exceptionless.JavaScript.git
InstallNode.js. Node is used for building and testing purposes.
Install the development dependencies usingnpm.
npm install
Build the project by running the following command.
npm run build
Test the project by running the following command.
npmtest
Thanks to all the people who have contributed!
About
Exceptionless JavaScript client
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Contributors11
Uh oh!
There was an error while loading.Please reload this page.