mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-22 07:01:07 +03:00
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:
@@ -38,6 +38,10 @@ export class StripeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async getProductIdFromSubscription(subscriptionId: string) {
|
public async getProductIdFromSubscription(subscriptionId: string) {
|
||||||
|
if (!subscriptionId || subscriptionId.trim() === '') {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.stripe) {
|
if (!this.stripe) {
|
||||||
throw new Error('Stripe is not initialized')
|
throw new Error('Stripe is not initialized')
|
||||||
}
|
}
|
||||||
@@ -62,8 +66,7 @@ export class StripeManager {
|
|||||||
|
|
||||||
return productId
|
return productId
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error getting product ID from subscription:', error)
|
return ''
|
||||||
throw error
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -293,8 +293,7 @@ const saveChatflow = async (
|
|||||||
dbResponse = await appServer.AppDataSource.getRepository(ChatFlow).save(chatflow)
|
dbResponse = await appServer.AppDataSource.getRepository(ChatFlow).save(chatflow)
|
||||||
}
|
}
|
||||||
|
|
||||||
const subscriptionDetails = await usageCacheManager.getSubscriptionDataFromCache(subscriptionId)
|
const productId = await appServer.identityManager.getProductIdFromSubscription(subscriptionId)
|
||||||
const productId = subscriptionDetails?.productId || ''
|
|
||||||
|
|
||||||
await appServer.telemetry.sendTelemetry(
|
await appServer.telemetry.sendTelemetry(
|
||||||
'chatflow_created',
|
'chatflow_created',
|
||||||
|
|||||||
@@ -1036,9 +1036,7 @@ export const utilBuildChatflow = async (req: Request, isInternal: boolean = fals
|
|||||||
const orgId = org.id
|
const orgId = org.id
|
||||||
organizationId = orgId
|
organizationId = orgId
|
||||||
const subscriptionId = org.subscriptionId as string
|
const subscriptionId = org.subscriptionId as string
|
||||||
|
const productId = await appServer.identityManager.getProductIdFromSubscription(subscriptionId)
|
||||||
const subscriptionDetails = await appServer.usageCacheManager.getSubscriptionDataFromCache(subscriptionId)
|
|
||||||
const productId = subscriptionDetails?.productId || ''
|
|
||||||
|
|
||||||
await checkPredictions(orgId, subscriptionId, appServer.usageCacheManager)
|
await checkPredictions(orgId, subscriptionId, appServer.usageCacheManager)
|
||||||
|
|
||||||
|
|||||||
@@ -276,9 +276,7 @@ export const upsertVector = async (req: Request, isInternal: boolean = false) =>
|
|||||||
|
|
||||||
const orgId = org.id
|
const orgId = org.id
|
||||||
const subscriptionId = org.subscriptionId as string
|
const subscriptionId = org.subscriptionId as string
|
||||||
|
const productId = await appServer.identityManager.getProductIdFromSubscription(subscriptionId)
|
||||||
const subscriptionDetails = await appServer.usageCacheManager.getSubscriptionDataFromCache(subscriptionId)
|
|
||||||
const productId = subscriptionDetails?.productId || ''
|
|
||||||
|
|
||||||
const executeData: IExecuteFlowParams = {
|
const executeData: IExecuteFlowParams = {
|
||||||
componentNodes: appServer.nodesPool.componentNodes,
|
componentNodes: appServer.nodesPool.componentNodes,
|
||||||
|
|||||||
Reference in New Issue
Block a user