sentry¶
The sentry module purpose is to forward log to sentry server. You can choose which level of logs are forwarded to sentry, and add info to every logs using the config.
Each user is uniquely identified with a UUID to help track issues related to each other.
Using This Module¶
First add the module to your project:
npm install --save @obsidianjs/sentry
Then use it in your application (in your main index.js
):
const obsidian = require("@obsidianjs/obsidian");
const sentry = require("@obsidianjs/sentry");
const app = obsidian("my-application");
app.use(sentry, {
config: {
dsnKey: "https://<key>@<server>/<project>",
capturedLevels: [
"error",
"warning",
],
// ...
},
});
app.start();
Config¶
-
dnsKey
¶ The DSN Key of the project on Sentry
E.g.:
"https://5d41402abc4b2a76b9719d911017c592@sentry.io/myproject"
-
capturedLevels
¶ List of log level that will be sent to the Sentry server.
Available levels:
"error"
"warn"
"info"
E.g.:
["error", "warn"]
Note
Uncaught error are not considered as a “log level” and are always forwared to the Sentry server.
-
userInfos
¶ An object with any additional information you want. It will be added to each log sent to the sentry server.
Module API¶
-
class
Sentry
()¶ The sentry module controller.
Warning
You do not need to use this API most of time: once this module is loaded with proper configuration, it will just work and you do not need to access it.
-
Sentry.
addLogLevels
(logLevels)¶ Add levels of logs that are sent to the sentry server (see
capturedLevels
).Arguments: - logLevels (Array.<string>) –
-
Sentry.
addUserInfos
(additionalUserInfos)¶ Add properties to the
userInfos
object.Arguments: - additionalUserInfos (Object) –
-
Sentry.
getLogLevels
()¶ Get the levels of logs sent to the Sentry server (see
capturedLevels
).Returns: Array.<string> –
-
Sentry.
getUserUUID
()¶ Get the user UUID.
Returns: string – The user UUID.
-
Sentry.
setLogLevels
(logLevels)¶ Change the levels of logs that are sent to the Sentry server (see
capturedLevels
).Arguments: - logLevels (Array.<string>) –
-