Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Options: Can not set an array of events for "channels", it returns error. #13

Closed
petervavro opened this issue Feb 12, 2019 · 3 comments
Closed

Comments

@petervavro
Copy link

Hi there,

I am setting up the plugin option :
channels: ['fatal', 'error', 'warning', 'log', 'info', 'debug', 'critical'],

Getting :

{ AssertionError [ERR_ASSERTION]: Unknown event channels fatal, error, warning, log, info, debug, critical
    at module.exports.internals.Podium.internals.Podium.on.internals.Podium.addListener (/project/node_modules/podium/lib/index.js:269:10)
    at Object.exports.register (/project/node_modules/hapi-sentry/index.js:38:17)
    at internals.Server.register (/project/node_modules/hapi/lib/server.js:451:35)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:229:7)
    at Function.Module.runMain (module.js:696:11)
    at startup (bootstrap_node.js:204:16)
    at bootstrap_node.js:625:3
  generatedMessage: false,
  name: 'AssertionError [ERR_ASSERTION]',
  code: 'ERR_ASSERTION',
  actual: false,
  expected: true,
  operator: '==' }

Let me know what is wrong please. Thanks.

@fiws
Copy link
Contributor

fiws commented Feb 12, 2019

Hi.

This option can be set to error, app or internal. The available channels are defined by hapi: https://hapijs.com/api#-request-event
We should improve the validation & documentation for this option.

The default value (error) for this options should be fine, though.
May I ask what you are trying to achieve?

@petervavro
Copy link
Author

Thank you for the question. I am trying to send messages generated by server.log and request.log (e.g. req.log(['error'], errorObject))

How do I achieve that via this plugin please ?

@guischdi
Copy link
Contributor

That's not the purpose of the hapi-sentry hapi plugin. As sentry should be used for error logging, the plugin only catches unhandled errors of the hapi route handlers. If you want to track custom error objects, you have to use on of sentrys captureEvent, captureException or captureMessage methods.

So you have three options:

  1. Replace your req.log(['error'], ...)s with throws and hapi-sentry will capture it.
  2. Do not use hapi-sentry but @sentry/node and use one of the methods mentioned above.
  3. Use hapi-sentry to catch unhandled errors in route handler and additionally use the internal @sentry/node client to capture your own events:
const client = server.plugins['hapi-sentry'].client;
client.captureException/captureMessage/captureEvent(...);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants