Comment out stripe usage reporting

This commit is contained in:
Owen
2026-02-09 20:30:28 -08:00
parent ed40eae655
commit f531def0d2
3 changed files with 35 additions and 45 deletions

View File

@@ -18,7 +18,6 @@ import { sendToClient } from "#dynamic/routers/ws";
import { build } from "@server/build"; import { build } from "@server/build";
import { s3Client } from "@server/lib/s3"; import { s3Client } from "@server/lib/s3";
import cache from "@server/lib/cache"; import cache from "@server/lib/cache";
import privateConfig from "@server/private/lib/config";
interface StripeEvent { interface StripeEvent {
identifier?: string; identifier?: string;
@@ -48,39 +47,31 @@ export class UsageService {
return; return;
} }
this.bucketName = process.env.S3_BUCKET || undefined; // this.bucketName = process.env.S3_BUCKET || undefined;
if ( // // Periodically check and upload events
// Only set up event uploading if usage reporting is enabled and bucket name is configured // setInterval(() => {
privateConfig.getRawPrivateConfig().flags.usage_reporting && // this.checkAndUploadEvents().catch((err) => {
this.bucketName // logger.error("Error in periodic event upload:", err);
) { // });
// Periodically check and upload events // }, 30000); // every 30 seconds
setInterval(() => {
this.checkAndUploadEvents().catch((err) => {
logger.error("Error in periodic event upload:", err);
});
}, 30000); // every 30 seconds
// Handle graceful shutdown on SIGTERM // // Handle graceful shutdown on SIGTERM
process.on("SIGTERM", async () => { // process.on("SIGTERM", async () => {
logger.info( // logger.info(
"SIGTERM received, uploading events before shutdown..." // "SIGTERM received, uploading events before shutdown..."
); // );
await this.forceUpload(); // await this.forceUpload();
logger.info("Events uploaded, proceeding with shutdown"); // logger.info("Events uploaded, proceeding with shutdown");
}); // });
// Handle SIGINT as well (Ctrl+C) // // Handle SIGINT as well (Ctrl+C)
process.on("SIGINT", async () => { // process.on("SIGINT", async () => {
logger.info( // logger.info("SIGINT received, uploading events before shutdown...");
"SIGINT received, uploading events before shutdown..." // await this.forceUpload();
); // logger.info("Events uploaded, proceeding with shutdown");
await this.forceUpload(); // process.exit(0);
logger.info("Events uploaded, proceeding with shutdown"); // });
process.exit(0);
});
}
} }
/** /**
@@ -139,9 +130,9 @@ export class UsageService {
} }
// Log event for Stripe // Log event for Stripe
if (privateConfig.getRawPrivateConfig().flags.usage_reporting) { // if (privateConfig.getRawPrivateConfig().flags.usage_reporting) {
await this.logStripeEvent(featureId, value, customerId); // await this.logStripeEvent(featureId, value, customerId);
} // }
return usage || null; return usage || null;
} catch (error: any) { } catch (error: any) {
@@ -282,9 +273,9 @@ export class UsageService {
} }
}); });
if (privateConfig.getRawPrivateConfig().flags.usage_reporting) { // if (privateConfig.getRawPrivateConfig().flags.usage_reporting) {
await this.logStripeEvent(featureId, value || 0, customerId); // await this.logStripeEvent(featureId, value || 0, customerId);
} // }
} catch (error) { } catch (error) {
logger.error( logger.error(
`Failed to update count usage for ${orgId}/${featureId}:`, `Failed to update count usage for ${orgId}/${featureId}:`,

View File

@@ -96,7 +96,6 @@ export const privateConfigSchema = z.object({
enable_redis: z.boolean().optional().default(false), enable_redis: z.boolean().optional().default(false),
use_pangolin_dns: z.boolean().optional().default(false), use_pangolin_dns: z.boolean().optional().default(false),
use_org_only_idp: z.boolean().optional().default(false), use_org_only_idp: z.boolean().optional().default(false),
usage_reporting: z.boolean().optional().default(false)
}) })
.optional() .optional()
.prefault({}), .prefault({}),

View File

@@ -26,14 +26,12 @@ import {
verifyValidLicense verifyValidLicense
} from "#private/middlewares"; } from "#private/middlewares";
import { ActionsEnum } from "@server/auth/actions"; import { ActionsEnum } from "@server/auth/actions";
import { import {
unauthenticated as ua, unauthenticated as ua,
authenticated as a authenticated as a
} from "@server/routers/integration"; } from "@server/routers/integration";
import { logActionAudit } from "#private/middlewares"; import { logActionAudit } from "#private/middlewares";
import config from "#private/lib/config"; import { tierMatrix } from "@server/lib/billing/tierMatrix";
import { build } from "@server/build";
export const unauthenticated = ua; export const unauthenticated = ua;
export const authenticated = a; export const authenticated = a;
@@ -57,7 +55,7 @@ authenticated.delete(
authenticated.get( authenticated.get(
"/org/:orgId/logs/action", "/org/:orgId/logs/action",
verifyValidLicense, verifyValidLicense,
verifyValidSubscription, verifyValidSubscription(tierMatrix.actionLogs),
verifyApiKeyOrgAccess, verifyApiKeyOrgAccess,
verifyApiKeyHasAction(ActionsEnum.exportLogs), verifyApiKeyHasAction(ActionsEnum.exportLogs),
logs.queryActionAuditLogs logs.queryActionAuditLogs
@@ -66,7 +64,7 @@ authenticated.get(
authenticated.get( authenticated.get(
"/org/:orgId/logs/action/export", "/org/:orgId/logs/action/export",
verifyValidLicense, verifyValidLicense,
verifyValidSubscription, verifyValidSubscription(tierMatrix.logExport),
verifyApiKeyOrgAccess, verifyApiKeyOrgAccess,
verifyApiKeyHasAction(ActionsEnum.exportLogs), verifyApiKeyHasAction(ActionsEnum.exportLogs),
logActionAudit(ActionsEnum.exportLogs), logActionAudit(ActionsEnum.exportLogs),
@@ -76,7 +74,7 @@ authenticated.get(
authenticated.get( authenticated.get(
"/org/:orgId/logs/access", "/org/:orgId/logs/access",
verifyValidLicense, verifyValidLicense,
verifyValidSubscription, verifyValidSubscription(tierMatrix.accessLogs),
verifyApiKeyOrgAccess, verifyApiKeyOrgAccess,
verifyApiKeyHasAction(ActionsEnum.exportLogs), verifyApiKeyHasAction(ActionsEnum.exportLogs),
logs.queryAccessAuditLogs logs.queryAccessAuditLogs
@@ -85,7 +83,7 @@ authenticated.get(
authenticated.get( authenticated.get(
"/org/:orgId/logs/access/export", "/org/:orgId/logs/access/export",
verifyValidLicense, verifyValidLicense,
verifyValidSubscription, verifyValidSubscription(tierMatrix.logExport),
verifyApiKeyOrgAccess, verifyApiKeyOrgAccess,
verifyApiKeyHasAction(ActionsEnum.exportLogs), verifyApiKeyHasAction(ActionsEnum.exportLogs),
logActionAudit(ActionsEnum.exportLogs), logActionAudit(ActionsEnum.exportLogs),
@@ -95,6 +93,7 @@ authenticated.get(
authenticated.put( authenticated.put(
"/org/:orgId/idp/oidc", "/org/:orgId/idp/oidc",
verifyValidLicense, verifyValidLicense,
verifyValidSubscription(tierMatrix.orgOidc),
verifyApiKeyOrgAccess, verifyApiKeyOrgAccess,
verifyApiKeyHasAction(ActionsEnum.createIdp), verifyApiKeyHasAction(ActionsEnum.createIdp),
logActionAudit(ActionsEnum.createIdp), logActionAudit(ActionsEnum.createIdp),
@@ -104,6 +103,7 @@ authenticated.put(
authenticated.post( authenticated.post(
"/org/:orgId/idp/:idpId/oidc", "/org/:orgId/idp/:idpId/oidc",
verifyValidLicense, verifyValidLicense,
verifyValidSubscription(tierMatrix.orgOidc),
verifyApiKeyOrgAccess, verifyApiKeyOrgAccess,
verifyApiKeyIdpAccess, verifyApiKeyIdpAccess,
verifyApiKeyHasAction(ActionsEnum.updateIdp), verifyApiKeyHasAction(ActionsEnum.updateIdp),