Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

feat: add user and tags

  • Loading branch information...
christophehurpeau committed Nov 15, 2016
1 parent 73f7d73 commit 6f1604e38a2083109a786b2e9b51d938a5ae70a1
Showing with 63 additions and 33 deletions.
  1. +7 −3 README.md
  2. +19 −8 lib-node6-dev/index.js
  3. +1 −1 lib-node6-dev/index.js.map
  4. +19 −8 lib-node6/index.js
  5. +1 −1 lib-node6/index.js.map
  6. +8 −8 package.json
  7. +8 −4 src/index.js
@@ -18,10 +18,14 @@ import SentryHandler from 'nightingale-sentry';
configure([
{
handlers: [new SentryHandler(ravenUrl, levels.ERROR)]
handlers: [
new SentryHandler(ravenUrl, levels.ERROR, {
// getUser: ({ context }) => context.user && { id: context.user.id },
// getTags: ({ context }) => context.tags,
}),
],
}
])
]);
```

[npm-image]: https://img.shields.io/npm/v/nightingale-sentry.svg?style=flat-square

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

@@ -26,17 +26,17 @@
"raven": "^0.12.1"
},
"devDependencies": {
"babel-eslint": "^7.0.0",
"babel-preset-es2015-node6": "^0.3.0",
"eslint": "^3.6.1",
"eslint-config-airbnb-base": "^8.0.0",
"eslint-config-pob": "^7.6.0",
"babel-eslint": "^7.1.0",
"babel-preset-es2015-node6": "^0.4.0",
"eslint": "^3.10.1",
"eslint-config-airbnb-base": "^10.0.1",
"eslint-config-pob": "^9.0.1",
"eslint-plugin-babel": "^3.3.0",
"eslint-plugin-import": "^1.16.0",
"eslint-plugin-import": "^2.2.0",
"komet": "^0.1.3",
"komet-karma": "^0.2.3",
"pob-babel": "^9.0.0",
"pob-release": "^2.2.2",
"pob-babel": "^12.7.1",
"pob-release": "^2.3.0",
"tcomb-forked": "^3.4.0"
}
}
@@ -11,10 +11,11 @@ const mapToSentryLevel = {
[levels.EMERGENCY]: 'fatal',
};

const createHandler = (ravenUrl) => {
const createHandler = (ravenUrl, { getUser = () => {}, getTags = () => {} } = {}) => {
const ravenClient = new RavenClient(ravenUrl);

return ({ level, metadata, extra }) => {
return (record) => {
const { key, level, metadata, extra } = record;
let error = metadata && metadata.error;

if (!error) {
@@ -33,14 +34,17 @@ const createHandler = (ravenUrl) => {
ravenClient.captureError(
error,
{
logger: key,
level: mapToSentryLevel[level] || 'error',
extra: extraData,
user: getUser(record),
tags: getTags(record),
},
);
};
};

export default function SentryHandler(ravenUrl: string, minLevel: number) {
export default function SentryHandler(ravenUrl: string, minLevel: number, options) {
this.minLevel = minLevel;
this.handle = createHandler(ravenUrl);
this.handle = createHandler(ravenUrl, options);
}

0 comments on commit 6f1604e

Please sign in to comment.
You can’t perform that action at this time.