Add target and tenant fields

This commit is contained in:
Kiran K 2023-11-27 12:49:41 +05:30
parent 303dc81727
commit e08671161d
2 changed files with 11 additions and 3 deletions

View File

@ -59,11 +59,16 @@ const reportEvent = async ({ action, crud, group, actor, description, productId
// Find team info for the product
if (productId && !group) {
try {
const productInfo = await productController.get(productId);
const product = await productController.get(productId);
retracedEvent.group = {
id: productInfo.teamId,
name: productInfo.teamName,
id: product.teamId,
name: product.teamName,
};
retracedEvent.target = {
id: product.id,
name: product.name,
};
} catch (err: any) {
console.error('Error getting product info. Event not reported to Retraced.', err);

View File

@ -34,6 +34,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
actor: {
id: profile.email,
name: `${profile.firstName} ${profile.lastName}`,
fields: {
tenant: profile.requested.tenant,
},
},
productId: profile.requested.product,
});