Hooks

useDocyrusContactActivity

Merges a record's audit log, comments, related events and tasks, and status updates into one typed timeline for ContactActivityPanel, with upcoming items, a relationship summary and comment and status mutations.

iOSAndroidExpo Go

Installation

pnpm dlx @docyrus/cli add @docyrus/rn-hooks-use-docyrus-contact-activity
Required Packages(1 package)
pnpm add @tanstack/react-query

The hook needs a QueryClientProvider above it. It is also re-exported from @/components/docyrus-native/contact-activity-panel.

Usage

import { useDocyrusClient } from '@docyrus/signin/react-native';

import { ContactActivityPanel } from '@/components/docyrus-native/contact-activity-panel';
import { useDocyrusContactActivity } from '@/hooks/docyrus-native/use-docyrus-contact-activity';

export function ContactActivity({ contactId, meId }: { contactId: string; meId: string }) {
  const client = useDocyrusClient();

  const { panelProps } = useDocyrusContactActivity({
    client,
    appSlug: 'base',
    dataSourceSlug: 'contact',
    recordId: contactId,
    relationSlug: 'contact',
    currentUserId: meId
  });

  return <ContactActivityPanel {...panelProps} contactName="Ada Lovelace" />;
}

Sources

SourceRequestBecomes
auditGET {record}/activitiesrecord_create, record_update, file, trace, … rows (comment operations are skipped)
commentsGET {record}/commentscomment cards. Replies stay off the timeline and are served by onLoadReplies
eventsGET /v1/apps/{eventApp}/data-sources/{eventDs}/items filtered by eventRelationSlug ?? relationSlugcall or meeting cards, classified by classifyEvent or eventTypeNames
tasksGET /v1/apps/{taskApp}/data-sources/{taskDs}/items filtered by taskRelationSlug ?? relationSlugtask rows plus open-task counts and upcoming tasks
statusUpdatesGET /v1/apps/{activityApp}/data-sources/{activityDs}/items for this recordstatus_update rows
filesGET {record}/filesfile rows carrying a real PostAttachment (name, size, MIME, signed URL). With this on, the audit log's bare UPLOAD_FILE traces are dropped — same upload, less information

{record} is /v1/apps/:appSlug/data-sources/:dataSourceSlug/items/:recordId. Users come from /v1/users unless you pass users. Events and tasks are only fetched when a relation slug is set. Every query lives under the ['docyrus-contact-activity', {record}] prefix, which useDocyrusLogActivity invalidates after each log, so a mounted timeline refreshes by itself.

CreatePostPayload.attachments are NativeFiles on native. Like web, the hook currently posts only message and parentId.

API Reference

UseDocyrusContactActivityOptions

OptionTypeDefaultDescription
clientContactActivityClient-REST client with get / post / patch / delete. RestApiClient fits (required)
appSlugstring-Owning record's app (required)
dataSourceSlugstring-Owning record's data source (required)
recordIdstring-Owning record id (required)
relationSlugstring-Back-relation slug on events and tasks. Without it those sources stay off
eventRelationSlugstringrelationSlugEvent back-relation override
taskRelationSlugstringrelationSlugTask back-relation override
sourcesContactActivitySourcesall trueToggle audit, comments, events, tasks, statusUpdates, files
eventAppSlugstring'base'Events app
eventDataSourceSlugstring'event'Events data source
taskAppSlugstring'base'Tasks app
taskDataSourceSlugstring'task'Tasks data source
activityAppSlugstring'base'Status-activity app
activityDataSourceSlugstring'activity'Status-activity data source
usersChatUser[]-Users instead of fetching /v1/users
currentUserIdstring-Current user id
activityTypesActivityType[]-Passed to the panel's type filter
eventTypeNamesEventTypeNameHints{ call: ['call', 'phone'], meeting: ['meeting', 'visit', 'demo'] }Name substrings used to classify events
classifyEvent(event: Record<string, unknown>) => 'call' | 'meeting'-Custom classifier (wins over eventTypeNames)
relatedColumns{ events?: string[]; tasks?: string[] }-Extra relation columns fetched on the event / task sources and surfaced as related chips in the detail sheet. Relation slugs are per-tenant and an unknown column fails the whole request, so nothing is requested unless you name it
limitnumber100Page size per source
enabledbooleantrueToggle every query

UseDocyrusContactActivityResult

FieldTypeDescription
activitiesContactActivity[]Merged timeline, newest first
upcomingUpcomingActivity[]Future tasks and events, soonest first
relationshipSummaryRelationshipSummaryLast contact, next activity, open tasks
usersChatUser[]Resolved users
currentUserChatUser | undefinedResolved current user
panelPropsContactActivityPanelDataSpread onto <ContactActivityPanel />
isLoadingbooleanAny source loading
errorError | nullFirst source error
isMutatingbooleanAny mutation pending
mutationErrorError | nullFirst mutation error
refetch() => Promise<unknown>Invalidate every source
createComment(payload: CreatePostPayload) => Promise<void>Post a comment or reply
deleteComment(commentId: string) => Promise<void>Delete a comment
updateStatus(input: UpdateStatusInput) => Promise<void>PATCH the record, then log a status update
isUpdatingStatusbooleanStatus mutation pending

UpdateStatusInput

FieldTypeDescription
statusFieldSlugstringStatus field slug (required)
valuestringNew status option id (required)
secondaryValuestring | nullSub-status option id
descriptionstring | nullNote
followupDatestring | nullFollow-up date
writeCompanionsbooleanAlso PATCH the __<slug>_* companion columns. Default true. Set false for a plain field-select

Notes

  • Files are on by default. The documents source adds one request per record; pass sources={{ files: false }} to keep the previous behaviour (uploads then stay as bare audit traces).
  • Related chips. A comment's assigned_to becomes a related chip automatically (resolved against the users list). Everything else is opt-in through relatedColumns — the hook never guesses a tenant's relation slugs.

Type Exports

TypeDescription
UseDocyrusContactActivityOptions / UseDocyrusContactActivityResultOptions and result
ContactActivityClientMinimal REST client interface
ContactActivitySourcesSource toggles
EventTypeNameHintsCall / meeting name hints
UpdateStatusInputStatus mutation input
ContactActivityPanelDataThe panel props the hook fills

On this page