truncateReason function

String truncateReason(
  1. String reason
)

Truncates reason to kMaxReasonChars (capture-only telemetry is never allowed to grow unbounded, and never blocks a transition).

Implementation

String truncateReason(String reason) => reason.length <= kMaxReasonChars
    ? reason
    : reason.substring(0, kMaxReasonChars);