File tree Expand file tree Collapse file tree
packages/plugin-client-ip Expand file tree Collapse file tree Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11{
22 "name" : " @bugsnag/plugin-client-ip" ,
33 "version" : " 8.1.1" ,
4- "main" : " client-ip.js" ,
4+ "main" : " dist/client-ip.js" ,
5+ "types" : " dist/types/client-ip.d.ts" ,
6+ "exports" : {
7+ "." : {
8+ "types" : " ./dist/types/client-ip.d.ts" ,
9+ "default" : " ./dist/client-ip.js" ,
10+ "import" : " ./dist/client-ip.mjs"
11+ }
12+ },
513 "description" : " @bugsnag/js plugin to disable client IP from error reports" ,
614 "homepage" : " https://www.bugsnag.com/" ,
715 "repository" : {
1220 "access" : " public"
1321 },
1422 "files" : [
15- " *.js "
23+ " dist "
1624 ],
1725 "author" : " Bugsnag" ,
1826 "license" : " MIT" ,
2129 },
2230 "peerDependencies" : {
2331 "@bugsnag/core" : " ^8.0.0"
32+ },
33+ "scripts" : {
34+ "build" : " npm run build:npm" ,
35+ "build:npm" : " rollup --config rollup.config.npm.mjs" ,
36+ "clean" : " rm -rf dist/*"
2437 }
2538}
Original file line number Diff line number Diff line change 1+ import createRollupConfig from "../../.rollup/index.mjs" ;
2+
3+ export default createRollupConfig ( {
4+ input : "src/client-ip.ts" ,
5+ external : [ "@bugsnag/core/lib/es-utils/assign" ]
6+ } ) ;
Original file line number Diff line number Diff line change 1+ import { Client , Plugin } from 'packages/core/types'
2+ import assign from '@bugsnag/core/lib/es-utils/assign'
3+
4+ interface InternalClient extends Client {
5+ _config : {
6+ collectUserIp : boolean
7+ }
8+ }
9+
10+ interface ExtendedPlugin extends Plugin {
11+ configSchema : Record < string , ValidationOption >
12+ }
13+
14+ interface ValidationOption {
15+ validate : ( value : unknown ) => boolean
16+ defaultValue : ( ) => unknown
17+ message : string
18+ }
19+
20+ /*
21+ * Prevent collection of user IPs
22+ */
23+ const plugin : ExtendedPlugin = {
24+ load : client => {
25+ if ( ( client as InternalClient ) . _config . collectUserIp ) return
26+
27+ client . addOnError ( event => {
28+ // If user.id is explicitly undefined, it will be missing from the payload. It needs
29+ // removing so that the following line replaces it
30+ if ( event . getUser ( ) && typeof event . getUser ( ) . id === 'undefined' ) {
31+ const _user = event . getUser ( )
32+ event . setUser ( '[REDACTED]' , _user . email , _user . name )
33+ }
34+ event . request = assign ( { clientIp : '[REDACTED]' } , event . request )
35+ } )
36+ } ,
37+ configSchema : {
38+ collectUserIp : {
39+ defaultValue : ( ) => true ,
40+ message : 'should be true|false' ,
41+ validate : ( value : unknown ) => value === true || value === false
42+ }
43+ }
44+ }
45+
46+ export default plugin
Original file line number Diff line number Diff line change 1+ {
2+ "extends" : " ../../tsconfig.json" ,
3+ "include" : [" src/**/*.ts" ]
4+ }
Original file line number Diff line number Diff line change 7474 " packages/plugin-koa" ,
7575 " packages/plugin-restify" ,
7676 " packages/node" ,
77- " packages/plugin-client-ip" ,
7877 " packages/plugin-strip-query-string" ,
7978 " packages/plugin-strip-project-root" ,
8079 " packages/plugin-interaction-breadcrumbs" ,
You can’t perform that action at this time.
0 commit comments