Skip to main content

Function: useActivityLogging()

useActivityLogging(): object

Defined in: web/lib/hooks/use-activity.ts:330

Combined hook for activity-tracked PDS writes.

Returns​

object

Object with activity logging utilities

generateRkey()​

generateRkey: () => string

Generate a new record key (TID) for ATProto records.

Returns​

string

Time-ordered identifier string

Remarks​

TIDs are time-ordered identifiers used as record keys in ATProto. They are guaranteed to be unique per user and sortable by time.

Example​

const rkey = generateRkey();
// Use rkey when creating a new record

logActivity​

logActivity: UseMutationResult<{ activityId: string; }, Error, LogActivityInput>

markFailed​

markFailed: UseMutationResult<{ success: boolean; }, Error, MarkFailedInput>

withActivityLogging()​

withActivityLogging: <T>(params) => Promise<T>

Perform a PDS write with automatic activity logging.

Type Parameters​

• T

Parameters​

params​
action​

ActivityAction

category​

ActivityCategory

collection​

string

perform​

(collection, rkey) => Promise<T>

recordSnapshot​

Record<string, unknown>

Record snapshot; will be serialized to JSON string for the API

targetTitle​

string

targetUri​

string

uiContext​

Record<string, unknown>

UI context metadata; will be serialized to JSON string for the API

Returns​

Promise<T>

withDeleteLogging()​

withDeleteLogging: (params) => Promise<void>

Perform a record deletion with activity logging.

Parameters​

params​
category​

ActivityCategory

perform​

() => Promise<void>

targetTitle​

string

uri​

string

Returns​

Promise<void>

Remarks​

Provides a convenient way to perform PDS writes with automatic activity logging and error handling.

Example​

const { withActivityLogging, generateRkey } = useActivityLogging();

// Create an eprint with activity tracking
await withActivityLogging({
category: 'eprint_submit',
action: 'create',
targetTitle: 'My Eprint',
perform: async (collection, rkey) => {
return await agent.com.atproto.repo.createRecord({
repo: did,
collection,
rkey, // Use the provided rkey for correlation
record,
});
},
});