PhoenixKitProjects.Activity (PhoenixKitProjects v0.21.0)

Copy Markdown View Source

Activity logging wrapper for the Projects module.

Summary

Functions

Extracts user.uuid from the LiveView socket assigns.

Resolves an assignment's assignee to a core USER uuid for target_uuid — the field core's activity→notification bridge treats as the recipient (Step 7 wiring). Person-assigned rows resolve through the staff person's linked account (preloaded or by lookup); team/department/unassigned rows resolve nil (multi-recipient fan-out is a later layer — the bridge is one-target-per-entry). Nil-safe at every hop; a staff outage degrades to nil, never blocks the mutation being logged.

Logs a projects activity entry via PhoenixKit.Activity. Swallows errors so it never crashes the caller.

Logs a user-driven mutation that did NOT land cleanly — the success path would have called log/2 with the same action + opts; this variant tags the metadata with db_pending: true so audit-feed readers can distinguish attempted-but-failed actions from completed ones. Per the post-Apr 2026 pipeline standard (publishing-Batch-3 / catalogue-Batch-4 precedent): a Drive/DB outage must NOT erase admin clicks from the activity feed.

Functions

actor_uuid(socket)

@spec actor_uuid(Phoenix.LiveView.Socket.t()) :: binary() | nil

Extracts user.uuid from the LiveView socket assigns.

assignee_target_uuid(arg1)

@spec assignee_target_uuid(map() | nil) :: binary() | nil

Resolves an assignment's assignee to a core USER uuid for target_uuid — the field core's activity→notification bridge treats as the recipient (Step 7 wiring). Person-assigned rows resolve through the staff person's linked account (preloaded or by lookup); team/department/unassigned rows resolve nil (multi-recipient fan-out is a later layer — the bridge is one-target-per-entry). Nil-safe at every hop; a staff outage degrades to nil, never blocks the mutation being logged.

log(action, opts)

@spec log(
  binary(),
  keyword()
) :: term()

Logs a projects activity entry via PhoenixKit.Activity. Swallows errors so it never crashes the caller.

log_failed(action, opts)

@spec log_failed(
  binary(),
  keyword()
) :: term()

Logs a user-driven mutation that did NOT land cleanly — the success path would have called log/2 with the same action + opts; this variant tags the metadata with db_pending: true so audit-feed readers can distinguish attempted-but-failed actions from completed ones. Per the post-Apr 2026 pipeline standard (publishing-Batch-3 / catalogue-Batch-4 precedent): a Drive/DB outage must NOT erase admin clicks from the activity feed.

Identical signature to log/2. Same rescue/catch shape.