Skip to content

Commit fadabc3

Browse files
committed
update and activate sentry configuration + sentry multiple enviroment
1 parent 27e2fb0 commit fadabc3

File tree

19 files changed

+110
-77
lines changed

19 files changed

+110
-77
lines changed

package-lock.json

Lines changed: 32 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"description": "Harmony One Telegram Bot",
55
"main": "dist/bot.js",
66
"scripts": {
7-
"build": "tsc",
7+
"build": "tsc && npm run sentry:sourcemaps",
88
"start": "node dist/bot.js",
99
"dev": "env-cmd ts-node-dev src/bot.ts",
1010
"test": "jest",
1111
"typeorm": "typeorm-ts-node-commonjs -d src/database/datasource.ts",
1212
"lint": "eslint . --ext .ts",
13-
"sentry:sourcemaps": "sentry-cli sourcemaps inject --org hiddenstate --project harmony-ai-bot ./dist && sentry-cli sourcemaps upload --org hiddenstate --project harmony-ai-bot ./dist",
13+
"sentry:sourcemaps": "sentry-cli sourcemaps inject --org harmony-23 --project harmony1bot ./dist && sentry-cli sourcemaps upload --org harmony-23 --project harmony1bot ./dist",
1414
"prepare": "husky install"
1515
},
1616
"repository": {
@@ -44,7 +44,7 @@
4444
"@babel/core": "^7.22.15",
4545
"@babel/preset-env": "^7.22.15",
4646
"@babel/preset-typescript": "^7.22.15",
47-
"@sentry/cli": "^2.20.7",
47+
"@sentry/cli": "^2.39.1",
4848
"@types/express": "^4.17.14",
4949
"@types/jest": "^29.5.4",
5050
"@types/node": "^18.15.11",
@@ -125,4 +125,4 @@
125125
"web3-utils": "^4.0.5",
126126
"websocket": "^1.0.34"
127127
}
128-
}
128+
}

src/bot.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Sentry } from './instrument'
1+
import { Sentry } from './monitoring/instrument'
22
import express from 'express'
33
import asyncHandler from 'express-async-handler'
44
import {
@@ -97,15 +97,6 @@ bot.use(
9797

9898
ES.init()
9999

100-
try {
101-
console.log('FCO:::: Sentry.isInitialized()', Sentry.isInitialized())
102-
throw new Error('ERROR')
103-
} catch (e) {
104-
console.log('FCO::::: HERE', e)
105-
Sentry.captureException(e)
106-
console.log('FCO::::: AFTER')
107-
}
108-
109100
bot.use(async (ctx: BotContext, next: NextFunction): Promise<void> => {
110101
ctx.transient = {
111102
refunded: false,

src/config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,10 @@ export default {
163163
},
164164
betteruptime: { botHeartBitId: process.env.BOT_HEARTBIT_ID ?? '' },
165165
telegramPayments: { token: process.env.TELEGRAM_PAYMENTS_TOKEN ?? '' },
166-
sentry: { dsn: process.env.SENTRY_DSN },
166+
sentry: {
167+
dsn: process.env.SENTRY_DSN,
168+
env: process.env.SENTRY_ENVIRONMENT ?? 'local'
169+
},
167170
es: {
168171
url: process.env.ES_URL ?? '',
169172
username: process.env.ES_USERNAME ?? '',

src/instrument.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/modules/1country/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { GrammyError, InlineKeyboard } from 'grammy'
22
import { AxiosError } from 'axios'
3-
import * as Sentry from '@sentry/node'
3+
import { Sentry } from '../../monitoring/instrument'
44
import { type Logger, pino } from 'pino'
55

66
import { chatService } from '../../database/services'

src/modules/errorhandler.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { AxiosError } from 'axios'
2-
import * as Sentry from '@sentry/node' // Import Sentry for error capturing
2+
import { Sentry } from '../monitoring/instrument'
33
import { RequestState, type OnCallBackQueryData, type OnMessageContext } from './types'
44
import { sleep } from './sd-images/utils'
55
import { type Logger } from 'pino'
@@ -9,8 +9,6 @@ import { now } from '../utils/perf'
99
import OpenAI from 'openai'
1010
import config from '../config'
1111

12-
// const MAX_TRIES = 3 // Define the maximum number of retries
13-
1412
class ErrorHandler {
1513
public maxTries = 3
1614

src/modules/hmny/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { GrammyError } from 'grammy'
2-
import * as Sentry from '@sentry/node'
2+
import { Sentry } from '../../monitoring/instrument'
33
import { type Logger, pino } from 'pino'
44
import {
55
type OnMessageContext,

src/modules/llms/dalleBot.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
sendMessage
1818
} from './utils/helpers'
1919
import { type LlmCompletion } from './api/llmApi'
20-
import * as Sentry from '@sentry/node'
20+
import { Sentry } from '../../monitoring/instrument'
2121
import { LlmsBase } from './llmsBase'
2222
import config from '../../config'
2323
import { now } from '../../utils/perf'

src/modules/llms/llmsBase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
splitTelegramMessage
2626
} from './utils/helpers'
2727
import { type LlmCompletion, deleteCollection } from './api/llmApi'
28-
import * as Sentry from '@sentry/node'
28+
import { Sentry } from '../../monitoring/instrument'
2929
import { now } from '../../utils/perf'
3030
import { type ModelParameters, type ChatModel, type LLMModel } from './utils/types'
3131
import { ErrorHandler } from '../errorhandler'

0 commit comments

Comments
 (0)