Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

fix: Funnels count validation

Blue Mousefc4b69214344
diff --git a/backend/apps/cloud/src/project/project.controller.ts b/backend/apps/cloud/src/project/project.controller.ts
index 93b1068c5..79cde1fb9 100644
--- a/backend/apps/cloud/src/project/project.controller.ts
+++ b/backend/apps/cloud/src/project/project.controller.ts
@@ -437,7 +437,9 @@ export class ProjectController {
)
}
- const project = await this.projectService.getFullProject(funnelDTO.pid)
+ const project = await this.projectService.getFullProject(funnelDTO.pid, [
+ 'funnels',
+ ])
if (!project) {
throw new NotFoundException('Project not found.')
@@ -445,6 +447,12 @@ export class ProjectController {
this.projectService.allowedToManage(project, userId)
+ if (_size(project.funnels) >= MAX_FUNNELS) {
+ throw new ForbiddenException(
+ `You cannot create more than ${MAX_FUNNELS}. Please contact us to increase the limit.`,
+ )
+ }
+
await trackCustom(ip, headers['user-agent'], {
ev: 'FUNNEL_CREATED',
meta: {
@@ -483,9 +491,7 @@ export class ProjectController {
)
}
- const project = await this.projectService.getFullProject(funnelDTO.pid, [
- 'funnels',
- ])
+ const project = await this.projectService.getFullProject(funnelDTO.pid)
if (!project) {
throw new NotFoundException('Project not found.')
@@ -493,12 +499,6 @@ export class ProjectController {
this.projectService.allowedToManage(project, userId)
- if (_size(project.funnels) >= MAX_FUNNELS) {
- throw new ForbiddenException(
- `You cannot create more than ${MAX_FUNNELS}. Please contact us to increase the limit.`,
- )
- }
-
const oldFunnel = await this.projectService.getFunnel(
funnelDTO.id,
project.id,