@pbvision/fastify-firestore-service 0.0.38 → 0.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/api.md +8 -0
- package/package.json +2 -2
- package/src/api/api.js +30 -0
package/docs/api.md
CHANGED
|
@@ -23,6 +23,7 @@ This library is used to define APIs.
|
|
|
23
23
|
- [Asynchronous Processing](#asynchronous-processing)
|
|
24
24
|
- [Cross Origin (CORS)](#cross-origin-cors)
|
|
25
25
|
- [Calling other APIs](#calling-other-apis)
|
|
26
|
+
- [Sentry Context](#sentry-context)
|
|
26
27
|
- [Niche Concepts](#niche-concepts)
|
|
27
28
|
- [Other API Input Data Options](#other-api-input-data-options)
|
|
28
29
|
- [Custom Middleware](#custom-middleware)
|
|
@@ -542,6 +543,13 @@ static CORS_ORIGIN = '*'
|
|
|
542
543
|
pass some information in a cookie, see the `redirectToWebApp()` helper method.
|
|
543
544
|
|
|
544
545
|
|
|
546
|
+
## Sentry Context
|
|
547
|
+
By default, query parameter, path parameter and body parameters are included as
|
|
548
|
+
context for reports to Sentry. To disable this, set
|
|
549
|
+
`MAY_SHARE_INPUTS_WITH_SENTRY` to false. Note that headers are _not_ included
|
|
550
|
+
by default. You can override what's included by overriding the `getInputsToTrackWithSentry()` method.
|
|
551
|
+
|
|
552
|
+
|
|
545
553
|
# Niche Concepts
|
|
546
554
|
This section explains niche functionality.
|
|
547
555
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pbvision/fastify-firestore-service",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.40",
|
|
4
4
|
"description": "Web Framework using Fastify and Firestore ORM",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@fastify/static": "^6.12",
|
|
43
43
|
"@fastify/swagger": "^8.1.0",
|
|
44
44
|
"@fastify/swagger-ui": "^2.0.1",
|
|
45
|
-
"@pbvision/firestore-orm": "^0.0.
|
|
45
|
+
"@pbvision/firestore-orm": "^0.0.20",
|
|
46
46
|
"@sentry/node": "^7.91.0",
|
|
47
47
|
"fastify": "^4.10.0",
|
|
48
48
|
"fastify-plugin": "^4.5.1",
|
package/src/api/api.js
CHANGED
|
@@ -2,6 +2,7 @@ import assert from 'node:assert'
|
|
|
2
2
|
import querystring from 'node:querystring'
|
|
3
3
|
|
|
4
4
|
import S from '@pbvision/schema'
|
|
5
|
+
import * as Sentry from '@sentry/node'
|
|
5
6
|
|
|
6
7
|
import fetchWrapper from '../fetch-wrapper.js'
|
|
7
8
|
|
|
@@ -214,6 +215,7 @@ class API {
|
|
|
214
215
|
}
|
|
215
216
|
reply.logRequestBodyOnError = this.constructor.LOG_REQUEST_BODY_ON_ERROR
|
|
216
217
|
reply.apiName = this.constructor.name
|
|
218
|
+
this.__trackInputsWithSentry()
|
|
217
219
|
}
|
|
218
220
|
|
|
219
221
|
/**
|
|
@@ -405,6 +407,34 @@ class API {
|
|
|
405
407
|
return ret
|
|
406
408
|
}
|
|
407
409
|
|
|
410
|
+
/**
|
|
411
|
+
* Adds inputs from the query string, path params and body to the Sentry
|
|
412
|
+
* context. This provides helpful debugging information but should only be
|
|
413
|
+
* used if these fields don't include sensitive information.
|
|
414
|
+
*/
|
|
415
|
+
__trackInputsWithSentry () {
|
|
416
|
+
const inputs = this.getInputsToTrackWithSentry()
|
|
417
|
+
// istanbul ignore else
|
|
418
|
+
if (inputs) {
|
|
419
|
+
Sentry.setContext('inputs', inputs)
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Returns a map of inputs to track in Sentry's context.
|
|
425
|
+
*
|
|
426
|
+
* By default, includes the query string, path params and body. This provides
|
|
427
|
+
* helpful debugging information but should only be
|
|
428
|
+
* used if these fields don't include sensitive information.
|
|
429
|
+
*/
|
|
430
|
+
getInputsToTrackWithSentry () {
|
|
431
|
+
return {
|
|
432
|
+
...this.req.query,
|
|
433
|
+
...this.req.params,
|
|
434
|
+
...this.req.body
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
408
438
|
/**
|
|
409
439
|
* Redirects to a URL optionally with query string and cookie.
|
|
410
440
|
*
|