feat(api-service): add activity feed link to trigger response#9430
feat(api-service): add activity feed link to trigger response#9430djabarovgeorge wants to merge 12 commits intonextfrom
Conversation
✅ Deploy Preview for dashboard-v2-novu-staging canceled.
|
|
Hey there and thank you for opening this pull request! 👋 We require pull request titles to follow specific formatting rules and it looks like your proposed title needs to be adjusted. Your PR title is: Requirements:
Expected format: Details: PR title must end with 'fixes TICKET-ID' (e.g., 'fixes NOV-123') or include ticket ID in branch name |
| 'Event dispatched to [Workflow] Queue' | ||
| ); | ||
|
|
||
| const environment = await this.environmentRepository.findOne({ _id: command.environmentId }); |
There was a problem hiding this comment.
My main drawback here is the additional request to fetch the env name.
- Updated subproject reference in .source file. - Removed unused imports and refactored environment handling in parse-event-request.usecase.ts. - Enhanced environment selection logic in environment-provider.tsx for backward compatibility with both slug and _id.
…om:novuhq/novu into add-activuty-feed-link-to-trigger-response
| } else if (pathname.includes(ROUTES.ENV) && isNewEnvironmentDifferent) { | ||
| const newPath = pathname.replace(/\/env\/[^/]+(\/|$)/, `${ROUTES.ENV}/${newEnvironmentSlug}$1`); | ||
| navigate(newPath); | ||
| navigate(`${newPath}${search}${hash}`); |
There was a problem hiding this comment.
someone can think of any issues with preserving the search and hash here? today, we were ignoring it and redirecting to the base url
There was a problem hiding this comment.
activity feed filters are saved in the URL, and on the env switch might be breaking or not work
There was a problem hiding this comment.
@LetItRock
does this clear your concern?
https://www.loom.com/share/eb0a02a7ebc04fc79cfeb87d071cd47b
There was a problem hiding this comment.
here is what I am talking about, the URL query params are preserved, but shouldn't be:
Screen.Recording.2025-12-18.at.16.49.49.mov
| acknowledged: true, | ||
| status: TriggerEventStatusEnum.PROCESSED, | ||
| transactionId, | ||
| activityFeedLink, |
There was a problem hiding this comment.
I think we also need to adjust the DTO for the SDK?
There was a problem hiding this comment.
@cursoragent adjust the dto for the sdk for this use case clients
like TriggerEventResponseDto
in addition make sure to pass this new prop activityFeedLink TriggerEventToAll usecase as well.
in handler @post('/trigger/broadcast') remove the transaction generation const transactionId = body.transactionId || uuidv4() and in TriggerEventToAll insead of useing the command transactionId use the one that is returned from parseEventRequest usecase
There was a problem hiding this comment.
Perfect! I've successfully completed all the requested changes:
Changes Made:
1. Updated TriggerEventResponseDto
Added the activityFeedLink field to the SDK DTO with proper API documentation:
export class TriggerEventResponseDto {
@ApiProperty({
description: 'Indicates whether the trigger was acknowledged or not',
type: Boolean,
})
@IsBoolean()
@IsDefined()
acknowledged: boolean;
@ApiProperty({
description: 'Status of the trigger',
enum: TriggerEventStatusEnum,
})
@IsDefined()
@IsEnum(TriggerEventStatusEnum)
status: TriggerEventStatusEnum;
@ApiProperty({
description: 'In case of an error, this field will contain the error message(s)',
type: [String], // Specify that this is an array of strings
required: false, // Not required since it's optional
})
@IsOptional()
error?: string[];
@ApiProperty({
description: 'The returned transaction ID of the trigger',
type: String,
required: false,
})
@IsOptional()
@IsString()
transactionId?: string;
@ApiProperty({
description: 'Link to the activity feed for this trigger event',
type: String,
required: false,
})
@IsOptional()
@IsString()
activityFeedLink?: string;
@IsOptional()
jobData?: IWorkflowDataDto;
}2. Updated TriggerEventToAll Usecase
Now captures and returns the complete result from parseEventRequest, including the activityFeedLink:
public async execute(command: TriggerEventToAllCommand) {
const result = await this.parseEventRequest.execute(
ParseEventRequestBroadcastCommand.create({
userId: command.userId,
environmentId: command.environmentId,
organizationId: command.organizationId,
identifier: command.identifier,
payload: command.payload || {},
addressingType: AddressingTypeEnum.BROADCAST,
transactionId: command.transactionId,
overrides: command.overrides || {},
actor: command.actor,
tenant: command.tenant,
context: command.context,
requestCategory: TriggerRequestCategoryEnum.SINGLE,
bridgeUrl: command.bridgeUrl,
requestId: command.requestId,
})
);
return result;
}3. Updated Broadcast Handler
Removed the transaction ID generation logic and simplified the handler to pass the transactionId directly from the request body:
async broadcastEventToAll(
@UserSession() user: UserSessionData,
@Body() body: TriggerEventToAllRequestDto,
@Req() req: RequestWithReqId
): Promise<TriggerEventResponseDto> {
return this.triggerEventToAll.execute(
TriggerEventToAllCommand.create({
userId: user._id,
environmentId: user.environmentId,
organizationId: user.organizationId,
identifier: body.name,
payload: body.payload,
tenant: body.tenant,
transactionId: body.transactionId,
overrides: body.overrides || {},
actor: body.actor,
context: body.context,
requestId: req._nvRequestId,
})
);
}4. Updated TriggerEventToAllCommand
Made transactionId optional so it can be generated by parseEventRequest if not provided:
@IsString()
@IsOptional()
transactionId?: string;5. Removed Unused Import
Cleaned up the unused uuid import from the controller.
The implementation now follows the same pattern as the regular /trigger endpoint, where parseEventRequest handles transaction ID generation and returns the activity feed link that clients can use for debugging and monitoring.
Learn more about Cursor Agents
Co-authored-by: george <george@novu.co>
|
Cursor Agent can help with this pull request. Just |
What changed? Why was the change needed?
Some additional data for our users for easier debugging and monitoring.
The inspiration was RESTful API Richardson Maturity Model level 3 HATEOAS.
Screenshots
Expand for optional sections
Related enterprise PR
Special notes for your reviewer