What To Store

LAST EDIT Oct 04 2024

Stream allows you to store custom data in your activities. How much data you store in the activities is up to you. Here are a few recommendations:

  • Always send the foreign_id and time fields. Without "foreign_id" and "time," you won't be able to update activities.

  • Keep data normalized when possible to avoid complex update flows. Activity fields like actor and object often contain complex objects like users, posts, or articles. Since the data for those objects can be updated, it is better to store a reference (e.g. their ID or URI) and replace them with the full object at read-time.

  • Store a user id and not the full user object. Otherwise, if someone changes their user image or username, you'll have to update tons of activities.

  • Attach metadata like tags and categories (if applicable) to your activities. This will help our data-science team optimize your feed personalization algorithms. (available on enterprise plans).

  • If you're using ranked feeds we recommend storing counts of the likes and comments. That allows you to take those factors into account when sorting feeds.

  • Activities have a max size. Storing a large amount of text is ok, storing images directly in the activity won't work, you should store the image URL instead.

The process of keeping your data normalized while working with complex objects is called enrichment.