feat: usage base billed - license key check - move to private api (#15222)
Co-authored-by: Omar López <[email protected]>
This commit is contained in:
1 parent
53c37a9ddf
commit
e16662e655
16 files changed
+586
-59
No files matched your search
@@ -0,0 +1,32 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
|
||||
import LicenseKeyService, { UsageEvent } from "@calcom/ee/common/server/LicenseKeyService";
|
||||
|
||||
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);
|
||||
}
|
||||
return query(args);
|
||||
},
|
||||
},
|
||||
user: {
|
||||
async create({ args, query }) {
|
||||
try {
|
||||
const licenseKeyService = await LicenseKeyService.create();
|
||||
await licenseKeyService.incrementUsage(UsageEvent.USER);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
return query(args);
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user