Overview
Activities track significant events in Memos, such as memo comments. They serve as an audit log and power the notification system. Activities are automatically created by the system and cannot be directly created or modified by users.List Activities
Retrieves a paginated list of activities. Activities are returned in reverse chronological order (newest first).
GET /api/v1/activities
Query Parameters
Maximum number of activities to return. Default: 100, Maximum: 1000If not specified or set to 0, defaults to 100 activities.
Token for retrieving the next page of results (from previous response)
Response
Array of activity objects
Token for retrieving the next page. Omitted if no more pages.
Activity Filtering
Activities referencing deleted content (like deleted memos) are automatically filtered out of the response rather than causing errors.
Example Response
Get Activity
Retrieves a single activity by its ID.
GET /api/v1/activities/{activity_id}
Path Parameters
The numeric ID of the activity to retrieve. Format:
activities/{id}Response
Returns an activity object (same structure as in List Activities).Error Responses
Invalid Argument - Invalid activity name format
Not Found - Activity does not exist or references deleted content
Internal Error - Failed to retrieve activity from database
Activity Types
MEMO_COMMENT
Triggered when a user creates a comment on a memo. Payload Structure:Details about the comment activity
- Notifications: Alert the original memo’s author about new comments
- Activity feed: Show recent commenting activity across the platform
- Analytics: Track engagement on specific memos
Activity Levels
Activity levels indicate the importance or severity of an activity. Currently, most activities use the INFO level.
INFO
Standard informational activities:- User comments on memos
- Regular user interactions
- Non-critical system events
WARN
Warning-level activities (future use):- Approaching resource limits
- Deprecated feature usage
- Non-breaking issues
ERROR
Error-level activities (future use):- Failed operations
- System errors affecting users
- Critical issues requiring attention
Integration with Notifications
Activities are closely tied to the notification system. When certain activities occur, notifications are automatically created for relevant users.
Activity → Notification Mapping
MEMO_COMMENT Activity: When a user comments on someone else’s memo:- An activity is created with type
MEMO_COMMENT - A notification is sent to the original memo’s creator
- The notification links to the activity via
activity_id
- Listing user notifications
- Marking notifications as read
- Filtering notifications by activity type
Implementation Details
Automatic Creation
Activities are created automatically by the system:- Comment Creation: When
CreateMemoCommentis called - System Events: When significant system events occur
- Background Jobs: From scheduled tasks and background workers
Storage
Activities are stored in theactivity table with:
- Unique auto-incrementing ID
- Creator ID (user who triggered the activity)
- Type enum (e.g., MEMO_COMMENT)
- Level enum (INFO, WARN, ERROR)
- Created timestamp
- Payload (JSON-serialized activity-specific data)
Retention
Activities are retained indefinitely by default. Consider implementing cleanup policies for:- Activities older than X months
- Activities referencing deleted content
- Low-priority INFO-level activities
Performance Considerations
- Activities are indexed by creator_id and create_time for fast queries
- Pagination is strongly recommended for listing activities
- The system gracefully handles activities referencing deleted content
Use Cases
Audit Log
Track important user actions:- By user: Check
creatorfield - By date: Parse
create_timefield - By type: Filter on
typefield
User Activity Feed
Show recent activity for a specific user:- List activities
- Filter by
creatormatching the user’s ID - Display in a timeline view
Engagement Analytics
Track engagement metrics:- Count MEMO_COMMENT activities to measure interaction
- Analyze activity timestamps for usage patterns
- Identify most active users or most commented memos
Real-time Updates
Poll for new activities:Best Practices
Pagination
- Always use
page_sizeto limit results - Store and use
next_page_tokenfor subsequent requests - Don’t assume all activities fit in one page
Error Handling
- Handle 404 errors gracefully (activity may reference deleted content)
- Implement retries for 500-level errors
- Cache activity data to reduce API calls
Privacy
- Respect memo visibility when displaying activities
- Don’t expose private memo activities to unauthorized users
- Filter activities based on user permissions in your application
Performance
- Use reasonable page sizes (50-100 items)
- Implement client-side caching for recently fetched activities
- Consider rate limiting when polling for new activities