Utils class

Constructors

Utils()

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

applyPayloadLimit(String? payload) → String?
Returns payload unchanged when its length is ≤ 1024 characters, or null when it exceeds the limit. Bodies over the limit are dropped entirely rather than truncated to avoid sending partial/misleading data.
buildCaptureContext({required String url, required List<CxNetworkCaptureRule> rules, required Map<String, String> reqHeaders, Map<String, String>? resHeaders, String? requestPayload, String? responsePayload}) → Map<String, dynamic>
Resolves the first matching CxNetworkCaptureRule for url and returns a map of the capture-sensitive fields (request/response headers and payloads) that should be included in a network telemetry span.
buildCustomSpanNetworkContext() → Map<String, String>
Returns hybrid-network linkage fields for native SDK consumption.
buildTraceParent(String traceId, String spanId, {required bool sampled}) → String
W3C traceparent: version 00, then the sampled flag as 01 or 00.
filterHeaders(Map<String, String> headers, List<String> allowlist) → Map<String, String>
Filters headers to only those whose name (case-insensitive) appears in allowlist. Output keys use the casing from allowlist (mirrors Android SDK behaviour).
generateHex(int length) → String
Generates a hex string of length characters using a cryptographically secure RNG.
networkRequestSampling() → Future<CxNetworkRequestSampling?>
Asks native for the sampled flag of a request starting now. Resolves to null — send no header, echo nothing — when there is no answer: native not initialized, the bridge failing, or no reply within networkRequestSamplingTimeout. Never throws.
reportNetworkRequest(Future<CxNetworkRequestSampling?> sampling, Map<String, dynamic> context) → void
Reports a network request once its start-time sampling answer is in, without holding up the caller. The answer is echoed so native records the request in the session it started in.
resolveNetworkCaptureRule(String url, List<CxNetworkCaptureRule> rules) → CxNetworkCaptureRule?
Returns the first CxNetworkCaptureRule whose url exactly matches or whose urlPattern regex matches url. Returns null if no rule matches.
resolveTraceId() → String
Returns the traceId to use for an outgoing network request.
shouldAddTraceParent(String? requestURLString, CXExporterOptions options) → bool
Header-side rule only. Callers skip network instrumentation entirely when it is switched off. Sampling deliberately plays no part: a sampled-out session keeps propagating so backend traces still correlate.
startNetworkRequestSampling(CXExporterOptions? options) → Future<CxNetworkRequestSampling?>
Starts the sampling question for a request beginning now. Without options Dart init has not run, so there is nothing to ask.

Constants

networkRequestSamplingTimeout → const Duration
How long a request waits for the native sampling answer before it goes out without a traceparent.