Search code examples
getstream-io

In getstram.io, is it a good design to add custom data to an activity


I am experimenting with getstream.io to implement feeds and timelines. I am wondering what is the best approach between simply using actors and objects that are keys to a database or storing more data in the activity. For example, let’s say that I want to add activity to my user feed represented by:

Actor: ‘user_1´,
Verb: ‘post’,
Object: ‘note_3’

Where ´user_1´ and ´note_3´ refers to objects in my application. When retrieving the activities to render them in the UI, I could fetch ´user_1’ from my database to get more details like a picture URL and name. That involves fetching a lot data for each activity. Or I could store more data into the activity by adding custom data such as ´user_url’ and ´user_name or the entire user object.

Has anyone faced the same question? What is the better approach?


Solution

  • _Since this answer was originally provided, Stream added a new feature called Collections which presents a new and potentially preferable approach.


    Both are feasible although the use of identifiers and an enrichment step that incorporates additional data from your backend services is the preferred approach.

    Keeping activities 'light weight' minimises latency and network transit times.

    There is also a limit to the size of activities; plenty for some additional text fields or counters/values, but not enough to feasibly store base64 encoded images or other binary data.

    The docs also provide suggestions on what to store.