Skip to content

Commit 445841a

Browse files
committed
check if revenue is enabled
1 parent d6d11a5 commit 445841a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

backend/apps/cloud/src/revenue/revenue.controller.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,12 +385,22 @@ export class RevenueAnalyticsController {
385385
): Promise<RevenueBreakdownDto> {
386386
this.logger.log({ userId, ...dto }, 'GET /log/revenue/breakdown')
387387

388-
const project = await this.projectService.getFullProject(dto.pid)
388+
const project = await this.projectService.getFullProject(
389+
dto.pid,
390+
undefined,
391+
['stripeApiKeyEnc', 'paddleApiKeyEnc'],
392+
)
389393

390394
if (_isEmpty(project)) {
391395
throw new NotFoundException('Project not found')
392396
}
393397

398+
if (!project.paddleApiKeyEnc && !project.stripeApiKeyEnc) {
399+
throw new BadRequestException(
400+
'Revenue tracking is not configured for this project',
401+
)
402+
}
403+
394404
this.projectService.allowedToView(project, userId)
395405

396406
const safeTimezone = this.analyticsService.getSafeTimezone(dto.timezone)

0 commit comments

Comments
 (0)