-
Notifications
You must be signed in to change notification settings - Fork 253
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
97819cb
commit 4937450
Showing
6 changed files
with
57 additions
and
28 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import createRollupConfig from "../../.rollup/index.mjs"; | ||
|
||
export default createRollupConfig({ | ||
input: "src/client-ip.ts", | ||
external: ["@bugsnag/core/lib/json-payload"] | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Plugin } from 'packages/core/types' | ||
import assign from '@bugsnag/core/lib/es-utils/assign' | ||
|
||
/* | ||
* Prevent collection of user IPs | ||
*/ | ||
const plugin: Plugin = { | ||
load: client => { | ||
// @ts-expect-error _config is private API | ||
if (client._config.collectUserIp) return | ||
|
||
client.addOnError(event => { | ||
// If user.id is explicitly undefined, it will be missing from the payload. It needs | ||
// removing so that the following line replaces it | ||
if (event.getUser() && typeof event.getUser().id === 'undefined') { | ||
const _user = event.getUser() | ||
event.setUser('[REDACTED]', _user.email, _user.name) | ||
} | ||
event.request = assign({ clientIp: '[REDACTED]' }, event.request) | ||
}) | ||
}, | ||
// @ts-expect-error _config is private API | ||
configSchema: { | ||
collectUserIp: { | ||
defaultValue: () => true, | ||
message: 'should be true|false', | ||
validate: (value: boolean) => value === true || value === false | ||
} | ||
} | ||
} | ||
|
||
export default plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"include": ["src/**/*.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters