Skip to content

Activity data

An activity is a stream event such as a subscription, gift, donation, follow, raid, redeem or virtual-currency contribution. Custom widgets receive activities from the activity hooks, Activity Alert scripts receive them as ctx.activity, and Command scripts receive them as ctx.activity when an activity trigger runs.

type identifies one provider-specific event, such as sub, kick_sub or newSponsorEvent. Use it only when the code needs behavior for that exact event.

For behavior shared across providers, use activity_group or contribution_group instead. Synchra assigns these groups to activity types, including types added by new provider integrations. Code using a group therefore continues to match new providers without adding their individual activity types.

if (activity.activity_group === "subscription") {
  showSubscriberWelcome(activity.viewer_display_name)
}

This is more durable than checking every known type:

// Avoid this for provider-independent behavior.
if (["sub", "kick_sub", "newSponsorEvent"].includes(activity.type)) {
  showSubscriberWelcome(activity.viewer_display_name)
}

activity_group describes what happened.

ValueMeaning
subscriptionA subscription, membership or renewal.
subscription_giftOne or more gifted subscriptions.
donationA monetary contribution.
virtual_currencyBits, gifts or other platform currency.
followA new follower or channel subscriber.
raidAn incoming raid.
redeemA reward redemption.

Use this group for most filtering, presentation and behavior.

contribution_group identifies activity types that use compatible contribution values or source settings. For example, Twitch subscriptions and resubs both use twitch_subs, while money-based donation sources use currency_amount.

ValueCompatible activity values
currency_amountMonetary contributions and memberships.
virtual_currencyPlatform currency and gift values.
twitch_subsTwitch subscriptions, resubs and gifted subs.
youtube_membershipsYouTube memberships and membership gifts.
tiktok_superfansTikTok Super Fan events.
rumble_subsRumble subscriptions and gifts.
kick_subsKick subscriptions, resubs and gifts.
followsFollow events across providers.
redeemsReward redemptions across providers.

Use this group when activities should share value calculations or contribution settings. Use activity_group when only the kind of event matters.

Both fields can be null when an activity has no applicable group.

Custom widgets can request activities by group. Filters are combined with OR matching.

const activity = synchra.useLatestActivity({
  activityGroups: ["subscription", "subscription_gift", "donation"],
})

Use contribution groups when the widget works with compatible contribution values:

const activities = synchra.useActivities({
  limit: 20,
  contributionGroups: ["currency_amount", "virtual_currency"],
})

Activity Alert scripts can branch on a group without checking which provider created the alert:

synchra.defineAlertScript({
  onShow(ctx) {
    if (ctx.activity.activity_group !== "donation") return
    ctx.elements.alert?.classList.add("is-donation")
  },
})

Command scripts use the same fields:

export async function run(ctx: ScriptContext) {
  if (ctx.activity?.activity_group !== "subscription_gift") return

  await ctx.sendMessage({
    message: `Thank you, ${ctx.activity.viewer_display_name}!`,
  })
}
FieldMeaning
providerSource provider, such as twitch, youtube or kick.
typeRaw provider-specific activity type.
type_display_nameHuman-readable activity type.
sub_typeRaw tier, reward or provider subtype when available.
sub_type_display_nameHuman-readable subtype.
activity_groupProvider-independent description of what happened.
contribution_groupGroup of activity types with compatible contribution behavior.
FieldMeaning
idSynchra activity ID.
channel_idSynchra channel ID.
provider_message_idEvent ID supplied by the provider.
provider_channel_idChannel ID supplied by the provider.
provider_viewer_idViewer ID supplied by the provider.
viewer_nameViewer username or login.
viewer_display_nameViewer display name.
viewer_profile_picture_urlViewer profile image when available.
viewer_created_atViewer account creation time when available.
created_atActivity time as an ISO timestamp.
gifted_viewersGift recipients when the provider supplies them.
readWhether the activity was marked as read in Synchra.
FieldMeaning
countRaw integer value supplied for the activity.
count_decimal_placeDecimal scaling applied to count.
count_currencyCurrency code for monetary values, otherwise null.
count_nameHuman-readable unit, such as months, bits or viewers.
system_messageProvider-generated event text.
message_partsStructured viewer message text, mentions, links and emotes.

Calculate the numeric value as count / 10 ** count_decimal_place. A count of 1234 with count_decimal_place set to 2 represents 12.34.

Custom widgets can render message_parts with synchra.assembleParts(activity.message_parts). Command scripts also receive the derived amount, message and recipient_display_name fields. Activity Alert scripts can use the formatted values in ctx.vars.

FieldMeaning
colorDefault activity color or gradient.
font_colorSuggested text color, when one is available.