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!

code review fixes

Blue Mouse18d6cf3855c6
diff --git a/admin/src/commands/UsersCommand.tsx b/admin/src/commands/UsersCommand.tsx
index e63d079bb..df510f473 100644
--- a/admin/src/commands/UsersCommand.tsx
+++ b/admin/src/commands/UsersCommand.tsx
@@ -269,19 +269,34 @@ export function UsersCommand({ onBack, initialUser, showListOnBack = true }: Use
if (target === 'entitlementOverrides' && selectedUser) {
const websiteOverride = numberValue(parsed, 'websites')
const apiOverride = numberValue(parsed, 'apiRateLimitPerHour')
+ const entitlements =
+ planEntitlements[getEffectivePlanType(selectedUser) || PlanType.standard]
const purchasedWebsiteAddons =
(selectedUser as User & { purchasedWebsiteAddons?: number })
.purchasedWebsiteAddons ??
numberValue(selectedUser.addonOverrides, 'websites') ??
numberValue(selectedUser.addonOverrides, 'additionalWebsites') ??
0
-
- if (typeof websiteOverride === 'number') {
- update.maxProjects = websiteOverride + purchasedWebsiteAddons
+ const includedWebsites =
+ websiteOverride ??
+ (typeof entitlements.websites === 'number'
+ ? entitlements.websites
+ : Math.max(
+ planEntitlements[PlanType.standard].websites,
+ (selectedUser.maxProjects || 0) - purchasedWebsiteAddons,
+ ))
+ const apiRateLimitPerHour =
+ apiOverride ??
+ (typeof entitlements.apiRateLimitPerHour === 'number'
+ ? entitlements.apiRateLimitPerHour
+ : selectedUser.maxApiKeyRequestsPerHour)
+
+ if (typeof includedWebsites === 'number') {
+ update.maxProjects = includedWebsites + purchasedWebsiteAddons
}
- if (typeof apiOverride === 'number') {
- update.maxApiKeyRequestsPerHour = apiOverride
+ if (typeof apiRateLimitPerHour === 'number') {
+ update.maxApiKeyRequestsPerHour = apiRateLimitPerHour
}
}
diff --git a/backend/apps/cloud/src/project/project.controller.ts b/backend/apps/cloud/src/project/project.controller.ts
index c0d2ac2f7..29bcbb229 100644
--- a/backend/apps/cloud/src/project/project.controller.ts
+++ b/backend/apps/cloud/src/project/project.controller.ts
@@ -1964,21 +1964,22 @@ export class ProjectController {
this.projectService.allowedToView(project, userId, headers['x-password'])
+ const [analyticsPIDs, errorPIDs, captchaPIDs, sessionReplayPIDs] =
+ await Promise.all([
+ this.projectService.getPIDsWhereAnalyticsDataExists([id]),
+ this.projectService.getPIDsWhereErrorsDataExists([id]),
+ this.projectService.getPIDsWhereCaptchaDataExists([id]),
+ this.projectService.getPIDsWhereSessionReplayDataExists([id]),
+ ])
+
const [
isDataExists,
isErrorDataExists,
isCaptchaDataExists,
isReplayDataExists,
- ] = await Promise.all([
- !_isEmpty(
- await this.projectService.getPIDsWhereAnalyticsDataExists([id]),
- ),
- !_isEmpty(await this.projectService.getPIDsWhereErrorsDataExists([id])),
- !_isEmpty(await this.projectService.getPIDsWhereCaptchaDataExists([id])),
- !_isEmpty(
- await this.projectService.getPIDsWhereSessionReplayDataExists([id]),
- ),
- ])
+ ] = [analyticsPIDs, errorPIDs, captchaPIDs, sessionReplayPIDs].map(
+ (pids) => !_isEmpty(pids),
+ )
let role
let isAccessConfirmed = true