ntegral / nestjs-sentry-example Goto Github PK
View Code? Open in Web Editor NEWSample nestjs project using the @ntegral/nestjs-sentry npm package
Sample nestjs project using the @ntegral/nestjs-sentry npm package
Hello,
I was trying to use this package to connect to sentry but I'm having this error.
node_modules/@ntegral/nestjs-sentry/dist/sentry.interfaces.d.ts:4:10 - error TS2305: Module '"../../../@nestjs/common"' has no exported member 'ConsoleLoggerOptions'.
4 import { ConsoleLoggerOptions } from "@nestjs/common";
~~~~~~~~~~~~~~~~~~~~
node_modules/@ntegral/nestjs-sentry/dist/sentry.service.d.ts:1:10 - error TS2305: Module '"../../../@nestjs/common"' has no exported member 'ConsoleLogger'.
1 import { ConsoleLogger } from '@nestjs/common';
Im using the following versions on package.json
"@ntegral/nestjs-sentry": "^3.0.3",
"@nestjs/common": "^7.6.18",
"@nestjs/config": "^0.6.3",
"@nestjs/core": "^7.6.18",
Am I missing something?
If I rewrite app.controller.ts
into
import { Controller, Get } from '@nestjs/common';
import { InjectSentry, SentryService } from '@ntegral/nestjs-sentry';
import { AppService } from './app.service';
@Controller()
export class AppController {
constructor(
@InjectSentry() private readonly client: SentryService,
private readonly appService: AppService,
) {}
@Get()
getHello(): string {
this.client.error('error reported via this.client.error') // <-- this is being reported to Sentry
throw Error('thrown error from the example'); // <-- this is not being reported to Sentry
return this.appService.getHello();
}
}
I don't see unexpected errors (emulated here by throw Error()
) reported to Sentry. Is this intentional? How am I supposed to hook up the library to have those errors reported?
Hi,
thanks for the example. I do get the errors reported to Sentry (after replacing the DSN, of course), but npm test
unfortunately fails:
FAIL src/app.controller.spec.ts
AppController
root
✕ should return "Hello World!" (5 ms)
● AppController › root › should return "Hello World!"
Nest can't resolve dependencies of the AppController (?, AppService). Please make sure that the argument SentryToken at index [0] is available in the RootTestModule context.
Potential solutions:
- If SentryToken is a provider, is it part of the current RootTestModule?
- If SentryToken is exported from a separate @Module, is that module imported within RootTestModule?
@Module({
imports: [ /* the Module containing SentryToken */ ]
})
at Injector.lookupComponentInParentModules (../node_modules/@nestjs/core/injector/injector.js:188:19)
at Injector.resolveComponentInstance (../node_modules/@nestjs/core/injector/injector.js:144:33)
at resolveParam (../node_modules/@nestjs/core/injector/injector.js:98:38)
at async Promise.all (index 0)
at Injector.resolveConstructorParams (../node_modules/@nestjs/core/injector/injector.js:113:27)
at Injector.loadInstance (../node_modules/@nestjs/core/injector/injector.js:46:9)
at Injector.loadController (../node_modules/@nestjs/core/injector/injector.js:59:9)
at async Promise.all (index 0)
at InstanceLoader.createInstancesOfControllers (../node_modules/@nestjs/core/injector/instance-loader.js:52:9)
● AppController › root › should return "Hello World!"
TypeError: Cannot read properties of undefined (reading 'getHello')
17 | describe('root', () => {
18 | it('should return "Hello World!"', () => {
> 19 | expect(appController.getHello()).toBe('Hello World!');
| ^
20 | });
21 | });
22 | });
at Object.<anonymous> (app.controller.spec.ts:19:28)
Test Suites: 1 failed, 1 total
For sake of completeness: npm run test:e2e
does pass.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.