fix: don't wait for telemetry for booking critical path (#16039)
This commit is contained in:
1 parent
76377d2d2c
commit
b9a8b613bb
3 files changed
+247
-82
No files matched your search
@@ -1,29 +1,29 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { waitUntil } from "@vercel/functions";
|
||||
|
||||
import LicenseKeyService, { UsageEvent } from "@calcom/ee/common/server/LicenseKeyService";
|
||||
|
||||
async function incrementUsage(event?: UsageEvent) {
|
||||
try {
|
||||
const licenseKeyService = await LicenseKeyService.create();
|
||||
await licenseKeyService.incrementUsage(event);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
export function usageTrackingExtention() {
|
||||
return Prisma.defineExtension({
|
||||
query: {
|
||||
booking: {
|
||||
async create({ args, query }) {
|
||||
try {
|
||||
const licenseKeyService = await LicenseKeyService.create();
|
||||
await licenseKeyService.incrementUsage();
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
waitUntil(incrementUsage(UsageEvent.USER));
|
||||
return query(args);
|
||||
},
|
||||
},
|
||||
user: {
|
||||
async create({ args, query }) {
|
||||
try {
|
||||
const licenseKeyService = await LicenseKeyService.create();
|
||||
await licenseKeyService.incrementUsage(UsageEvent.USER);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
waitUntil(incrementUsage(UsageEvent.USER));
|
||||
return query(args);
|
||||
},
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user