Comparing version 1.0.0 to 1.0.1
'use strict'; | ||
var core = require('@sentry/core'); | ||
var utils = require('@sentry/utils'); | ||
var uuid = require('uuid'); | ||
@@ -170,3 +171,3 @@ var cookie = require('cookie'); | ||
name: "toucan-js", | ||
version: "1.0.0", | ||
version: "1.0.1", | ||
}, | ||
@@ -291,3 +292,3 @@ }; | ||
* Builds Exception as per https://docs.sentry.io/development/sdk-dev/event-payloads/exception/, adds it to the event, | ||
* and sends it to Sentry. | ||
* and sends it to Sentry. Inspired by https://github.com/getsentry/sentry-javascript/blob/master/packages/node/src/backend.ts. | ||
* | ||
@@ -297,3 +298,18 @@ * @param event | ||
*/ | ||
async reportException(event, error) { | ||
async reportException(event, maybeError) { | ||
let error; | ||
if (utils.isError(maybeError)) { | ||
error = maybeError; | ||
} | ||
else if (utils.isPlainObject(maybeError)) { | ||
// This will allow us to group events based on top-level keys | ||
// which is much better than creating new group when any key/value change | ||
const message = `Non-Error exception captured with keys: ${utils.extractExceptionKeysForMessage(maybeError)}`; | ||
error = new Error(message); | ||
} | ||
else { | ||
// This handles when someone does: `throw "something awesome";` | ||
// We use synthesized Error here so we can extract a (rough) stack trace. | ||
error = new Error(maybeError); | ||
} | ||
const stacktrace = await this.buildStackTrace(error); | ||
@@ -300,0 +316,0 @@ event.exception = { |
@@ -63,3 +63,3 @@ /** | ||
*/ | ||
captureException(exception: Error): string | undefined; | ||
captureException(exception: unknown): string | undefined; | ||
/** | ||
@@ -134,3 +134,3 @@ * Captures a message event and sends it to Sentry. | ||
* Builds Exception as per https://docs.sentry.io/development/sdk-dev/event-payloads/exception/, adds it to the event, | ||
* and sends it to Sentry. | ||
* and sends it to Sentry. Inspired by https://github.com/getsentry/sentry-javascript/blob/master/packages/node/src/backend.ts. | ||
* | ||
@@ -137,0 +137,0 @@ * @param event |
import { API } from '@sentry/core'; | ||
import { isError, isPlainObject, extractExceptionKeysForMessage } from '@sentry/utils'; | ||
import { v4 } from 'uuid'; | ||
@@ -168,3 +169,3 @@ import { parse } from 'cookie'; | ||
name: "toucan-js", | ||
version: "1.0.0", | ||
version: "1.0.1", | ||
}, | ||
@@ -289,3 +290,3 @@ }; | ||
* Builds Exception as per https://docs.sentry.io/development/sdk-dev/event-payloads/exception/, adds it to the event, | ||
* and sends it to Sentry. | ||
* and sends it to Sentry. Inspired by https://github.com/getsentry/sentry-javascript/blob/master/packages/node/src/backend.ts. | ||
* | ||
@@ -295,3 +296,18 @@ * @param event | ||
*/ | ||
async reportException(event, error) { | ||
async reportException(event, maybeError) { | ||
let error; | ||
if (isError(maybeError)) { | ||
error = maybeError; | ||
} | ||
else if (isPlainObject(maybeError)) { | ||
// This will allow us to group events based on top-level keys | ||
// which is much better than creating new group when any key/value change | ||
const message = `Non-Error exception captured with keys: ${extractExceptionKeysForMessage(maybeError)}`; | ||
error = new Error(message); | ||
} | ||
else { | ||
// This handles when someone does: `throw "something awesome";` | ||
// We use synthesized Error here so we can extract a (rough) stack trace. | ||
error = new Error(maybeError); | ||
} | ||
const stacktrace = await this.buildStackTrace(error); | ||
@@ -298,0 +314,0 @@ event.exception = { |
{ | ||
"name": "toucan-js", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Cloudflare Workers client for Sentry", | ||
@@ -28,2 +28,3 @@ "main": "dist/index.cjs.js", | ||
"@sentry/core": "^5.15.4", | ||
"@sentry/utils": "^5.15.4", | ||
"cookie": "^0.4.0", | ||
@@ -30,0 +31,0 @@ "stacktrace-js": "^2.0.2", |
Sorry, the diff of this file is not supported yet
43521
885
5
+ Added@sentry/utils@^5.15.4