From a8bff7d9df812361a99cf0567fdca190b6166f70 Mon Sep 17 00:00:00 2001 From: Giancarlo Buenaflor Date: Fri, 13 Dec 2024 18:06:41 +0100 Subject: [PATCH] improvement: check for `SentryTracer` type in TTID (#2497) * fix * update * update CHANGELOG --- CHANGELOG.md | 3 +++ .../lib/src/navigation/time_to_initial_display_tracker.dart | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e74d44cf00..9bc18f5313 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +### Improvements + +- Check for type before casting in TTID ([#2497](https://github.com/getsentry/sentry-dart/pull/2497)) ### Fixes diff --git a/flutter/lib/src/navigation/time_to_initial_display_tracker.dart b/flutter/lib/src/navigation/time_to_initial_display_tracker.dart index 5213d4587c..3509dc6c4d 100644 --- a/flutter/lib/src/navigation/time_to_initial_display_tracker.dart +++ b/flutter/lib/src/navigation/time_to_initial_display_tracker.dart @@ -51,11 +51,13 @@ class TimeToInitialDisplayTracker { final _endTimestamp = endTimestamp ?? await determineEndTime(); if (_endTimestamp == null) return; - final tracer = transaction as SentryTracer; + if (transaction is! SentryTracer) { + return; + } final ttidSpan = transaction.startChild( SentrySpanOperations.uiTimeToInitialDisplay, - description: '${tracer.name} initial display', + description: '${transaction.name} initial display', startTimestamp: startTimestamp, );