@leagueutil/sentry-error-logger
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -88,4 +88,6 @@ const Sentry = require("@sentry/node"); | ||
const { response } = originalError; | ||
const requestId = (response && response.data.league_request_id) || "none"; | ||
const errorCode = (response && response.data.error_code) || "none"; | ||
const requestId = | ||
(response && response.data && response.data.league_request_id) || "none"; | ||
const errorCode = | ||
(response && response.data && response.data.error_code) || "none"; | ||
return { requestId, errorCode }; | ||
@@ -92,0 +94,0 @@ } |
@@ -10,2 +10,4 @@ /* eslint-disable no-undef */ | ||
const mockSetTags = jest.fn((tags) => tags); | ||
jest.mock("@sentry/node", () => { | ||
@@ -17,3 +19,3 @@ return { | ||
setUser: jest.fn(), | ||
setTags: jest.fn(), | ||
setTags: mockSetTags, | ||
setLevel: jest.fn(), | ||
@@ -65,2 +67,8 @@ setFingerprint: jest.fn(), | ||
expect(Sentry.captureException).toHaveBeenCalledWith(exception); | ||
expect(mockSetTags.mock.results[0].value).toStrictEqual({ | ||
environment: "dev", | ||
error_code: "ERR_TEST", | ||
league_request_id: "12345", | ||
tenant_id: "league", | ||
}); | ||
}); | ||
@@ -90,2 +98,8 @@ | ||
expect(Sentry.captureException).toHaveBeenCalledWith(exception); | ||
expect(mockSetTags.mock.results[0].value).toStrictEqual({ | ||
league_request_id: "none", | ||
error_code: "none", | ||
environment: "dev", | ||
tenant_id: "league", | ||
}); | ||
}); | ||
@@ -92,0 +106,0 @@ |
{ | ||
"name": "@leagueutil/sentry-error-logger", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Setup a project to initialize and use Sentry to send error events within a cloud node function", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
22373
520