From f531def0d261f7b8a9b7555c3b487169e5c2ced9 Mon Sep 17 00:00:00 2001 From: Owen Date: Mon, 9 Feb 2026 20:30:28 -0800 Subject: [PATCH] Comment out stripe usage reporting --- server/lib/billing/usageService.ts | 65 ++++++++++++--------------- server/private/lib/readConfigFile.ts | 1 - server/private/routers/integration.ts | 14 +++--- 3 files changed, 35 insertions(+), 45 deletions(-) diff --git a/server/lib/billing/usageService.ts b/server/lib/billing/usageService.ts index 6f95b96a..c4ae2925 100644 --- a/server/lib/billing/usageService.ts +++ b/server/lib/billing/usageService.ts @@ -18,7 +18,6 @@ import { sendToClient } from "#dynamic/routers/ws"; import { build } from "@server/build"; import { s3Client } from "@server/lib/s3"; import cache from "@server/lib/cache"; -import privateConfig from "@server/private/lib/config"; interface StripeEvent { identifier?: string; @@ -48,39 +47,31 @@ export class UsageService { return; } - this.bucketName = process.env.S3_BUCKET || undefined; + // this.bucketName = process.env.S3_BUCKET || undefined; - if ( - // Only set up event uploading if usage reporting is enabled and bucket name is configured - privateConfig.getRawPrivateConfig().flags.usage_reporting && - this.bucketName - ) { - // Periodically check and upload events - setInterval(() => { - this.checkAndUploadEvents().catch((err) => { - logger.error("Error in periodic event upload:", err); - }); - }, 30000); // every 30 seconds + // // Periodically check and upload events + // setInterval(() => { + // this.checkAndUploadEvents().catch((err) => { + // logger.error("Error in periodic event upload:", err); + // }); + // }, 30000); // every 30 seconds - // Handle graceful shutdown on SIGTERM - process.on("SIGTERM", async () => { - logger.info( - "SIGTERM received, uploading events before shutdown..." - ); - await this.forceUpload(); - logger.info("Events uploaded, proceeding with shutdown"); - }); + // // Handle graceful shutdown on SIGTERM + // process.on("SIGTERM", async () => { + // logger.info( + // "SIGTERM received, uploading events before shutdown..." + // ); + // await this.forceUpload(); + // logger.info("Events uploaded, proceeding with shutdown"); + // }); - // Handle SIGINT as well (Ctrl+C) - process.on("SIGINT", async () => { - logger.info( - "SIGINT received, uploading events before shutdown..." - ); - await this.forceUpload(); - logger.info("Events uploaded, proceeding with shutdown"); - process.exit(0); - }); - } + // // Handle SIGINT as well (Ctrl+C) + // process.on("SIGINT", async () => { + // logger.info("SIGINT received, uploading events before shutdown..."); + // await this.forceUpload(); + // logger.info("Events uploaded, proceeding with shutdown"); + // process.exit(0); + // }); } /** @@ -139,9 +130,9 @@ export class UsageService { } // Log event for Stripe - if (privateConfig.getRawPrivateConfig().flags.usage_reporting) { - await this.logStripeEvent(featureId, value, customerId); - } + // if (privateConfig.getRawPrivateConfig().flags.usage_reporting) { + // await this.logStripeEvent(featureId, value, customerId); + // } return usage || null; } catch (error: any) { @@ -282,9 +273,9 @@ export class UsageService { } }); - if (privateConfig.getRawPrivateConfig().flags.usage_reporting) { - await this.logStripeEvent(featureId, value || 0, customerId); - } + // if (privateConfig.getRawPrivateConfig().flags.usage_reporting) { + // await this.logStripeEvent(featureId, value || 0, customerId); + // } } catch (error) { logger.error( `Failed to update count usage for ${orgId}/${featureId}:`, diff --git a/server/private/lib/readConfigFile.ts b/server/private/lib/readConfigFile.ts index 3a5597a0..6ddd3b99 100644 --- a/server/private/lib/readConfigFile.ts +++ b/server/private/lib/readConfigFile.ts @@ -96,7 +96,6 @@ export const privateConfigSchema = z.object({ enable_redis: z.boolean().optional().default(false), use_pangolin_dns: z.boolean().optional().default(false), use_org_only_idp: z.boolean().optional().default(false), - usage_reporting: z.boolean().optional().default(false) }) .optional() .prefault({}), diff --git a/server/private/routers/integration.ts b/server/private/routers/integration.ts index 25861a54..8109bd35 100644 --- a/server/private/routers/integration.ts +++ b/server/private/routers/integration.ts @@ -26,14 +26,12 @@ import { verifyValidLicense } from "#private/middlewares"; import { ActionsEnum } from "@server/auth/actions"; - import { unauthenticated as ua, authenticated as a } from "@server/routers/integration"; import { logActionAudit } from "#private/middlewares"; -import config from "#private/lib/config"; -import { build } from "@server/build"; +import { tierMatrix } from "@server/lib/billing/tierMatrix"; export const unauthenticated = ua; export const authenticated = a; @@ -57,7 +55,7 @@ authenticated.delete( authenticated.get( "/org/:orgId/logs/action", verifyValidLicense, - verifyValidSubscription, + verifyValidSubscription(tierMatrix.actionLogs), verifyApiKeyOrgAccess, verifyApiKeyHasAction(ActionsEnum.exportLogs), logs.queryActionAuditLogs @@ -66,7 +64,7 @@ authenticated.get( authenticated.get( "/org/:orgId/logs/action/export", verifyValidLicense, - verifyValidSubscription, + verifyValidSubscription(tierMatrix.logExport), verifyApiKeyOrgAccess, verifyApiKeyHasAction(ActionsEnum.exportLogs), logActionAudit(ActionsEnum.exportLogs), @@ -76,7 +74,7 @@ authenticated.get( authenticated.get( "/org/:orgId/logs/access", verifyValidLicense, - verifyValidSubscription, + verifyValidSubscription(tierMatrix.accessLogs), verifyApiKeyOrgAccess, verifyApiKeyHasAction(ActionsEnum.exportLogs), logs.queryAccessAuditLogs @@ -85,7 +83,7 @@ authenticated.get( authenticated.get( "/org/:orgId/logs/access/export", verifyValidLicense, - verifyValidSubscription, + verifyValidSubscription(tierMatrix.logExport), verifyApiKeyOrgAccess, verifyApiKeyHasAction(ActionsEnum.exportLogs), logActionAudit(ActionsEnum.exportLogs), @@ -95,6 +93,7 @@ authenticated.get( authenticated.put( "/org/:orgId/idp/oidc", verifyValidLicense, + verifyValidSubscription(tierMatrix.orgOidc), verifyApiKeyOrgAccess, verifyApiKeyHasAction(ActionsEnum.createIdp), logActionAudit(ActionsEnum.createIdp), @@ -104,6 +103,7 @@ authenticated.put( authenticated.post( "/org/:orgId/idp/:idpId/oidc", verifyValidLicense, + verifyValidSubscription(tierMatrix.orgOidc), verifyApiKeyOrgAccess, verifyApiKeyIdpAccess, verifyApiKeyHasAction(ActionsEnum.updateIdp),