When to call logUserActivity¶
ProjectActivitiesService.logUserActivity writes a lightweight audit line for the project activity feed (stored as action: USER_LOG with actor.log: verb + entity + optional metadata). The UI renders it like: βAlex updated shot Β· β¦β.
Use it when¶
- A user-facing mutation should appear in the project / episode activity timeline (who did what, on which project asset).
- You already have
projectIdon the document you loaded or wrote (story video, project row, etc.). Do not add an extra DB round-trip just to resolveprojectId. - The change maps cleanly to a
UserLogVerb+UserLogEntity(seesharedTypes.ts:UserLogVerb,UserLogEntity). - You want fire-and-forget logging: the method returns immediately; persistence runs on the next tick.
Typical call sites: model or service code that persists episodes, scenes, shots, assets, scripts, etc., where the product expects a human-readable audit trail per project.
Do not use it when¶
projectIdis missing β the call is a no-op by design (avoids hidden lookups).- There is no authenticated actor and you did not pass
actorβ another no-op (e.g. unauthenticated cron); uselogActivity/ explicit flows if you need system attribution instead. - You need the rich activity row (job status, asset gen, lifecycle banners, Spine push by default) β use
logActivity,logProjectLifecycleActivity, orlogAssetGenJobActivityStatusas appropriate. - Workbench flows that already use
WorkbenchService.createStoryActivitywith a typedProjectActivityActionβ keep that path unless you are intentionally migrating a surface to the user-log shape.
Optional fields¶
storyId/sceneId/shotIdβ scope the log for deep links / filtering.metadataβ small structured hints (e.g.{ field: 'description' }); keep it minimal.actorβ only when the acting user is notreq.auth(rare).publishToSpine: trueβ only if realtime fan-out is required; default is off because these logs can be high volume.
Related code¶
- Implementation and contracts:
projectActivities.service.ts(logUserActivity,LogUserActivityInput). - Verb/entity vocabulary:
src/shared/sharedTypes.ts(USER_LOG,UserLogVerb,UserLogEntity).