1 | #!/usr/bin/env node
|
2 |
|
3 | var os = require('os');
|
4 | var raven = require('../');
|
5 |
|
6 | function usage() {
|
7 | var path = require('path');
|
8 | console.log('usage:', path.basename(process.argv[1]), 'test [SENTRY_DSN]');
|
9 | }
|
10 |
|
11 | if (process.argv[2] !== 'test') {
|
12 | usage();
|
13 | process.exit(1);
|
14 | }
|
15 |
|
16 | var dsn = process.argv.slice(3).join(' ') || process.env.SENTRY_DSN;
|
17 | if (!dsn) {
|
18 | usage();
|
19 | console.log();
|
20 | console.log('Error: No configuration detected!');
|
21 | console.log('You must either pass a DSN to the command or set the SENTRY_DSN environment variable.');
|
22 | process.exit(1);
|
23 | }
|
24 |
|
25 | console.log('Using DSN configuration:');
|
26 | console.log(' ', dsn);
|
27 | console.log();
|
28 |
|
29 | var client = new raven.Client(dsn);
|
30 |
|
31 | console.log('Sending a test message...');
|
32 |
|
33 | client.on('logged', function(result) {
|
34 | console.log('success!');
|
35 | console.log('Event ID was', client.getIdent(result));
|
36 | });
|
37 | client.on('error', function(err) {
|
38 | console.log('error!');
|
39 | throw err;
|
40 | });
|
41 |
|
42 | try {
|
43 | test
|
44 | } catch (ex) {
|
45 | client.captureException(ex, {
|
46 | message: 'This is a test message generated using ``raven test``',
|
47 | level: 'info',
|
48 | logger: 'sentry.test',
|
49 | transaction: 'bin:raven at main',
|
50 | request: {
|
51 | method: 'GET',
|
52 | url: 'http://example.com'
|
53 | },
|
54 | extra: {
|
55 | user: process.getuid && process.getuid(),
|
56 | loadavg: os.loadavg()
|
57 | }
|
58 | });
|
59 | }
|