Chore/product id telemetry (#5329)
* add telemetry for productId * updated multiple services (chatflows, buildChatflow, upsertVector) to use the new method for fetching product ID from subscriptions, improving consistency and error handling
This commit is contained in:
parent
ac794ab6eb
commit
7ab586c865
|
|
@ -38,6 +38,10 @@ export class StripeManager {
|
|||
}
|
||||
|
||||
public async getProductIdFromSubscription(subscriptionId: string) {
|
||||
if (!subscriptionId || subscriptionId.trim() === '') {
|
||||
return ''
|
||||
}
|
||||
|
||||
if (!this.stripe) {
|
||||
throw new Error('Stripe is not initialized')
|
||||
}
|
||||
|
|
@ -62,8 +66,7 @@ export class StripeManager {
|
|||
|
||||
return productId
|
||||
} catch (error) {
|
||||
console.error('Error getting product ID from subscription:', error)
|
||||
throw error
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -293,8 +293,7 @@ const saveChatflow = async (
|
|||
dbResponse = await appServer.AppDataSource.getRepository(ChatFlow).save(chatflow)
|
||||
}
|
||||
|
||||
const subscriptionDetails = await usageCacheManager.getSubscriptionDataFromCache(subscriptionId)
|
||||
const productId = subscriptionDetails?.productId || ''
|
||||
const productId = await appServer.identityManager.getProductIdFromSubscription(subscriptionId)
|
||||
|
||||
await appServer.telemetry.sendTelemetry(
|
||||
'chatflow_created',
|
||||
|
|
|
|||
|
|
@ -1036,9 +1036,7 @@ export const utilBuildChatflow = async (req: Request, isInternal: boolean = fals
|
|||
const orgId = org.id
|
||||
organizationId = orgId
|
||||
const subscriptionId = org.subscriptionId as string
|
||||
|
||||
const subscriptionDetails = await appServer.usageCacheManager.getSubscriptionDataFromCache(subscriptionId)
|
||||
const productId = subscriptionDetails?.productId || ''
|
||||
const productId = await appServer.identityManager.getProductIdFromSubscription(subscriptionId)
|
||||
|
||||
await checkPredictions(orgId, subscriptionId, appServer.usageCacheManager)
|
||||
|
||||
|
|
|
|||
|
|
@ -276,9 +276,7 @@ export const upsertVector = async (req: Request, isInternal: boolean = false) =>
|
|||
|
||||
const orgId = org.id
|
||||
const subscriptionId = org.subscriptionId as string
|
||||
|
||||
const subscriptionDetails = await appServer.usageCacheManager.getSubscriptionDataFromCache(subscriptionId)
|
||||
const productId = subscriptionDetails?.productId || ''
|
||||
const productId = await appServer.identityManager.getProductIdFromSubscription(subscriptionId)
|
||||
|
||||
const executeData: IExecuteFlowParams = {
|
||||
componentNodes: appServer.nodesPool.componentNodes,
|
||||
|
|
|
|||
Loading…
Reference in New Issue