Skip to main content

Views, labels, and user context

Views, labels, and user context are the three things you attach to records rather than send on their own. Each applies to every record that follows it, so setting them once shapes everything the SDK reports afterwards.

View tracking​

Name each screen with startView when it is shown, and clear it with endView. Records carry the current view name:

m.global.cxRum.callfunc("startView", "Home")
m.global.cxRum.callfunc("startView", "Player") ' replaces Home
m.global.cxRum.callfunc("endView") ' clears the current view

Labels​

setLabels adds labels, or changes existing ones, on every record that follows. getLabels returns the channel-wide set as it currently stands:

' initialized with labels: { tier: "free" }
m.global.cxRum.callfunc("setLabels", { tier: "premium", ab_test: "b" })

labels = m.global.cxRum.callfunc("getLabels") ' { tier: "premium", ab_test: "b" }

Labels passed to a single log or error apply to that record only. Keys are lowercased as described under Custom logs.

Note

Two separate 512-character limits apply, each measured on the serialized labels: one on the channel-wide set (coralogix_roku_initialize() plus every setLabels), and one on the labels passed to a single call. The SDK ignores a setLabels call that takes the channel-wide set over its limit, and drops an oversized per-call set from that record. Both drop the labels whole rather than truncating them, and both warn on the console.

User context​

Set the viewer with setUserContext after a sign-in, or clear it after a sign-out. Records from then on carry the new user:

m.global.cxRum.callfunc("setUserContext", {
user_id: "user-1",
user_name: "Jane",
user_email: "[email protected]",
user_metadata: { plan: "family" }
})

m.global.cxRum.callfunc("setUserContext", {}) ' signed out

setUserContext replaces the whole user: a field you don't pass is cleared. Fields: user_id, user_name, user_email, account_id, account_name (strings) and user_metadata (an object). The SDK refuses a call with an unknown field and warns on the console.

Note

The user context is limited to 512 characters once serialized, and user_metadata is where that limit is usually reached. Over it, the SDK refuses the whole context, including the fields that fit, keeps the previous user, and warns on the console. The same limit applies to the user_context you pass to coralogix_roku_initialize().

Last updated on
Was this page helpful?