Before send
Before Send
Enable event access and modification before sending to Coralogix, supporting content modification.
let options = CoralogixExporterOptions(coralogixDomain: CORALOGIX-DOMAIN,
environment: "ENVIRONMENT",
application: "APP-NAME",
version: "APP-VERSION",
publicKey: "API-KEY",
beforeSend: { cxRum in
var editableCxRum = cxRum
if var sessionContext = editableCxRum["session_context"] as? [String: Any] {
editableCxRum["session_context"] = sessionContext
}
return editableCxRum
})
, and event discarding
let options = CoralogixExporterOptions(coralogixDomain: CORALOGIX-DOMAIN,
environment: "ENVIRONMENT",
application: "APP-NAME",
version: "APP-VERSION",
publicKey: "API-KEY",
beforeSend: { cxRum in
var editableCxRum = cxRum
if var viewContext = editableCxRum["view_context"] as? [String: Any],
let view = viewContext["view"] {
if view == "DetailsViewController" {
return nil
}
}
})
Masked interactions in beforeSend (is_masked_element)
Every user-interaction event carries interaction_context.is_masked_element — the SDK's own observation that the interaction targeted content session replay masked. By default (matching the Browser SDK) only target_element_inner_text is redacted to *** on a masked interaction; identity fields and coordinates are reported as-is, and the replay's tap marker is suppressed. Anything stricter is yours to express here, where it stays auditable in your own code.
The flag is always present. false also covers "could not resolve" — a hybrid payload with no coordinates (React Native scroll/swipe), or no frame geometry to test the point against (session replay not initialized) — so it under-reports rather than over-reports when the SDK has no answer.
Drop masked interaction events entirely:
beforeSend: { cxRum in
let interaction = cxRum["interaction_context"] as? [String: Any]
if interaction?["is_masked_element"] as? Bool == true {
return nil
}
return cxRum
}
Or keep the event but blank the coordinates (they travel inside interaction_context.attributes):
beforeSend: { cxRum in
var editable = cxRum
if var interaction = editable["interaction_context"] as? [String: Any],
interaction["is_masked_element"] as? Bool == true {
var attributes = interaction["attributes"] as? [String: Any] ?? [:]
attributes["x"] = 0
attributes["y"] = 0
interaction["attributes"] = attributes
editable["interaction_context"] = interaction
}
return editable
}
is_masked_element itself is read-only: it records the SDK's observation, so a value written to it in the returned dictionary is ignored and the SDK's value is restored.