Function: useActivityLogging()
useActivityLogging():
object
Defined in: web/lib/hooks/use-activity.ts:329
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
category
collection
string
perform
(collection, rkey) => Promise<T>
recordSnapshot
Record<string, unknown>
targetTitle
string
targetUri
string
uiContext
Record<string, unknown>
Returns
Promise<T>
withDeleteLogging()
withDeleteLogging: (
params) =>Promise<void>
Perform a record deletion with activity logging.
Parameters
params
category
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 a preprint with activity tracking
await withActivityLogging({
category: 'preprint_submit',
action: 'create',
targetTitle: 'My Preprint',
perform: async (collection, rkey) => {
return await agent.com.atproto.repo.createRecord({
repo: did,
collection,
rkey, // Use the provided rkey for correlation
record,
});
},
});