feat: auto-log deal lifecycle events to activity timeline#53
Open
Rishavraaj wants to merge 6 commits intomainfrom
Open
feat: auto-log deal lifecycle events to activity timeline#53Rishavraaj wants to merge 6 commits intomainfrom
Rishavraaj wants to merge 6 commits intomainfrom
Conversation
- Inject ActivityService into DealsService and wire up the backend module factory - Log deal_created, stage_change, field_update, deal_closed, company_linked/unlinked, contact_linked/unlinked, owner_assigned/removed events automatically - Include user data in addOwner/removeOwner repository responses for activity metadata - Pass authenticated actorId from controller to service for all mutating operations - Render system events as human-readable descriptions in ActivityTimeline with formatted field names and date values Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- libs/sales: DealsService unit tests asserting activityService.create is called with correct event type and metadata for deal_created, stage_change, deal_closed, field_update, company_linked/unlinked, contact_linked/unlinked, owner_assigned/removed - apps/web: ActivityTimeline vitest unit tests verifying each system event type renders the correct text in the UI - apps/web-e2e: Playwright e2e tests verifying system events appear in the activity timeline after create, stage edit, and company/contact add/remove actions Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
56effa9 to
61e1560
Compare
Remove unused BadRequestException/NotFoundException imports and add required organizationId field to CreateDealInput test fixtures. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Both methods take req as their first argument (for actorId). The tests were missing it, causing dto to be undefined at runtime. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
/Activity/i matched both the deal title and the section heading, causing a strict mode violation. Switching to exact: true targets only the <h2>Activity</h2> heading. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enhances the deal activity timeline by automatically logging system events
whenever deal state changes — previously only manual comments were tracked.
Backend
ActivityServiceintoDealsServiceand wire it up in the backendmodule factory (
sales.module.ts)actorIdparameter to all mutating deal service methods soevents are attributed to the acting user
deal_created— on deal creationstage_change— when the deal stage changes (stores from/to values)field_update— when title, value, probability, expected close date, orpriority changes (stores field name, old and new value)
deal_closed— whenactualCloseDateis set for the first time (storesoutcome: won/lost and optional lost reason)
company_linked/company_unlinked— when a company is added or removedcontact_linked/contact_unlinked— when a contact is added or removed(with optional role)
owner_assigned/owner_removed— when an owner is added or removedaddOwnerandremoveOwnerinDealsRepositoryto include userdata so the owner's name is available for activity metadata
actorIdfrom the controller via@Req()Frontend
renderSystemEventText()helper inActivityTimelinethat maps eachevent type to a human-readable description
"Mar 27, 2026") for display
"updated X from null to Y"
No database schema changes — the existing
Activitymodel'sactivityTypeand
metadatafields support all new event types.Screenshot
Test plan
Won"
to Mar 27, 2026"
Y"
actualCloseDatewithclosed_wonstage → shows "marked deal asWon"
actualCloseDatewithclosed_lost+ lost reason → shows "markeddeal as Lost: "
Maker"