Skip to content

Commit 4f98489

Browse files
authored
Merge pull request #203 from vuejs-jp/chore/sentry
Sentry setup
2 parents 99f7b91 + 823d08e commit 4f98489

File tree

11 files changed

+1085
-502
lines changed

11 files changed

+1085
-502
lines changed

apps/peatix-adapter/.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ PEATIX_BASIC_EMAIL=
66
PEATIX_BASIC_PASSWORD=
77
SUPABASE_URL=
88
SUPABASE_KEY=
9+
10+
SENTRY_DSN=

apps/peatix-adapter/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
"@nestjs/config": "3.2.2",
3535
"@nestjs/schematics": "10.1.1",
3636
"@nestjs/testing": "10.3.7",
37+
"@ntegral/nestjs-sentry": "4.0.1",
38+
"@sentry/node": "8.18.0",
3739
"@types/express": "4.17.21",
3840
"@types/jest": "^29.5.12",
3941
"@types/node": "~18.19.0",

apps/peatix-adapter/src/app.module.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
import { Module } from '@nestjs/common'
2+
import { ConfigModule } from '@nestjs/config'
3+
import { configuration } from './env/utils'
4+
import { SentryModule } from '@ntegral/nestjs-sentry'
5+
import { EnvModule } from './env/env.module'
6+
import { EnvService } from './env/env.service'
27

3-
@Module({})
8+
@Module({
9+
imports: [
10+
ConfigModule.forRoot({
11+
envFilePath: '.env',
12+
expandVariables: true,
13+
load: [configuration],
14+
}),
15+
SentryModule.forRootAsync({
16+
imports: [EnvModule],
17+
useFactory: (envService: EnvService) => ({
18+
dsn: envService.SENTRY_DSN,
19+
debug: false,
20+
logLevels: ['error'],
21+
}),
22+
inject: [EnvService],
23+
}),
24+
EnvModule,
25+
26+
]
27+
})
428
export class AppModule {}

apps/peatix-adapter/src/cmd.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import { CommandFactory } from 'nest-commander'
22
import { AfterPurchaseModule } from './after-purchase/after-purchase.module'
33

44
async function bootstrap() {
5-
await CommandFactory.run(AfterPurchaseModule, [
6-
'warn',
7-
'error',
8-
'debug',
9-
'log',
10-
])
5+
await CommandFactory.run(AfterPurchaseModule, {
6+
logger: ['warn', 'error', 'debug', 'log'],
7+
serviceErrorHandler: (error) => {
8+
console.error(error)
9+
}
10+
}).catch((error) => {
11+
console.error(error)
12+
})
1113
}
1214
bootstrap()

apps/peatix-adapter/src/env/env.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,8 @@ export class EnvService {
3131
get SUPABASE_KEY() {
3232
return this.configService.getOrThrow('supabaseKey')
3333
}
34+
35+
get SENTRY_DSN() {
36+
return this.configService.getOrThrow('sentryDsn')
37+
}
3438
}

apps/peatix-adapter/src/env/utils/configuration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ export const configuration = () => ({
44
peatixBasicPassword: process.env.PEATIX_BASIC_PASSWORD || '',
55
supabaseUrl: process.env.SUPABASE_URL || '',
66
supabaseKey: process.env.SUPABASE_KEY || '',
7+
sentryDsn: process.env.SENTRY_DSN || '',
78
})

apps/peatix-adapter/src/main.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
11
import { NestFactory } from '@nestjs/core'
22
import { AppModule } from './app.module'
3+
import { SentryInterceptor } from '@ntegral/nestjs-sentry'
4+
import { HttpException } from '@nestjs/common'
35

46
async function bootstrap() {
57
const app = await NestFactory.create(AppModule)
8+
9+
app.useGlobalInterceptors(
10+
new SentryInterceptor({
11+
filters: [
12+
{
13+
type: HttpException,
14+
filter: (exception: HttpException) => {
15+
return exception.getStatus() < 500
16+
},
17+
},
18+
],
19+
}),
20+
)
21+
622
await app.listen(3000)
723
}
824
bootstrap()

apps/peatix-adapter/src/peatix-order/peatix-order.service.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,11 @@ export class PeatixOrderService extends ScraperPage {
186186
this.logger.log(receipts)
187187

188188
// Peatix 購入情報を Supabase へ反映する
189-
// await this.supabaseService.updateAttendees(receipts)
189+
for (const receipt of receipts) {
190+
this.logger.log(receipt)
191+
// const result = await this.supabaseService.updateAttendees(receipt)
192+
// if (!result) break
193+
}
190194
})
191195
}
192196

apps/peatix-adapter/src/supabase/supabase.service.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ export class SupabaseService {
3333
}
3434

3535
// vuejs-jp/vuefes-2024-backside#226
36-
public async updateAttendees(targets: AttendeeReceipt[]) {
36+
public async updateAttendees(targets: AttendeeReceipt) {
3737
this.getClient()
3838

39-
const targetData = [ ...targets ]
39+
const targetData = { ...targets }
4040

41-
for (const target of targetData) {
42-
const { data, error } = await this.client.from('attendees')
43-
.upsert({ role: target.role, activated_at: new Date().toISOString() })
44-
.eq('receipt_id', target.receipt_id)
45-
.eq('activated_at', null)
46-
if (error) break
47-
}
41+
const { data, error } = await this.client.from('attendees')
42+
.upsert({ role: targetData.role, activated_at: new Date().toISOString() })
43+
.eq('receipt_id', targetData.receipt_id)
44+
.eq('activated_at', null)
45+
if (error) false
46+
47+
return true
4848
}
4949
}

bun.lockb

35.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)