Skip to content

Commit

Permalink
- Updated Sentry integration
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeny-s committed Nov 28, 2024
1 parent 345b9e4 commit 5ee31d0
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ API_KEY=API_KEY
TELEGRAM_BOT_TOKEN=TELEGRAM_BOT_TOKEN
SOLANA_AMOUNT_PER_TOKEN=10000000

SENTRY_DNS=SENTRY_DNS
SENTRY_DSN=SENTRY_DNS
2 changes: 1 addition & 1 deletion src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ const sessions = new LocalSession({
@Module({
imports: [
SentryModule.forRoot(),
ConfigModule.forRoot(),
ScheduleModule.forRoot(),
TickerFetcherModule,
TickerModule,
ConfigModule.forRoot(),
TypeOrmModule.forRoot({
type: 'postgres',
host: process.env.PG_HOST,
Expand Down
14 changes: 7 additions & 7 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ import { AppModule } from './app.module';
import * as Sentry from '@sentry/node';
import { nodeProfilingIntegration } from '@sentry/profiling-node';

async function bootstrap() {
initSentry();

const app = await NestFactory.create(AppModule);
await app.listen(process.env.PORT || 3000);
}

const initSentry = () => {
Sentry.init({
dsn: process.env.SENTRY_DSN,
Expand All @@ -14,11 +21,4 @@ const initSentry = () => {
});
};

async function bootstrap() {
initSentry();

const app = await NestFactory.create(AppModule);
await app.listen(process.env.PORT || 3000);
}

bootstrap();
3 changes: 3 additions & 0 deletions src/position-processor/position-processor.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { TelegramBotService } from '../telegram-bot/telegram-bot.service';
import { UsersService } from '../user';
import { SolanaAmmClientService } from '../solana-client/solana-amm-client.service';
import { User } from '../user/user.entity';
import * as Sentry from '@sentry/node';

@Injectable()
export class PositionProcessorService {
Expand Down Expand Up @@ -51,6 +52,7 @@ export class PositionProcessorService {
`Purchased the token: ${position.raydiumPool}`,
);
} catch (e) {
Sentry.captureException(e);
this.logger.error(`Something is wrong: ${e.message}`);
}
}
Expand Down Expand Up @@ -87,6 +89,7 @@ export class PositionProcessorService {
`Sold the token: ${position.raydiumPool}`,
);
} catch (e) {
Sentry.captureException(e);
this.logger.error(`Something is wrong: ${e.message}`);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/telegram-bot/telegram-bot.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ export class TelegramBotService {

const positions = await this.positionService.getAll();

await ctx.reply(`Positions:`);

for (const position of positions) {
await ctx.reply(
`ID: ${position.id}, Status: ${position.status}, Pool: ${position.raydiumPool} `,
Expand Down
2 changes: 2 additions & 0 deletions src/ticker-fetcher/ticker-fetcher.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Injectable, Logger } from '@nestjs/common';
import { PumpFunClientService } from '../pump-fun-client/pump-fun-client.service';
import { TickerService } from '../ticker/ticker.service';
import { Cron } from '@nestjs/schedule';
import * as Sentry from '@sentry/node';

const HISTORY_TIME_RANGE_SECONDS = 3600;

Expand Down Expand Up @@ -36,6 +37,7 @@ export class TickerFetcherService {

await this.tickerService.bulkAdd(coins);
} catch (e) {
Sentry.captureException(e);
this.logger.error(`Something went wrong. Error: ${e.message}`);
}

Expand Down
2 changes: 2 additions & 0 deletions src/token-watcher/token-watcher.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Cron } from '@nestjs/schedule';
import { TickerService } from '../ticker/ticker.service';
import { PositionService } from '../position/position.service';
import { SolanaAmmClientService } from '../solana-client/solana-amm-client.service';
import * as Sentry from '@sentry/node';

@Injectable()
export class TokenWatcherService {
Expand Down Expand Up @@ -78,6 +79,7 @@ export class TokenWatcherService {
}
}
} catch (e) {
Sentry.captureException(e);
this.logger.error(`Something went wrong. Error: ${e.message}`);
}

Expand Down

0 comments on commit 5ee31d0

Please sign in to comment.