Skip to content

Commit 4aaa669

Browse files
committed
Add MAUI AutomationId to generic element info
1 parent ebac4e3 commit 4aaa669

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/Sentry.Maui/Internal/Extensions.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,26 @@ public static void AddElementInfo(this IDictionary<string, string> data,
5353
// The element ID seems to be mostly useless noise
5454
//data.Add(prefix + nameof(element.Id), element.Id.ToString());
5555

56-
if (element.StyleId != null)
56+
if (element.AutomationId is { } automationId)
57+
{
58+
data.Add(prefix + nameof(Element.AutomationId), automationId);
59+
}
60+
61+
if (element.StyleId is { } styleId)}
5762
{
5863
// The StyleId correlates to the element's name if one is set in XAML
5964
// TODO: Is there a better way to get this?
60-
data.Add(prefix + "Name", element.StyleId);
65+
data.Add(prefix + "Name", styleId);
6166
}
6267

63-
if (options.IncludeTitleInBreadcrumbs && element is ITitledElement { Title: { } } titledElement)
68+
if (options.IncludeTitleInBreadcrumbs && element is ITitledElement { Title: { } title })
6469
{
65-
data.Add(prefix + nameof(titledElement.Title), titledElement.Title);
70+
data.Add(prefix + nameof(ITitledElement.Title), title);
6671
}
6772

68-
if (options.IncludeTextInBreadcrumbs && element is IText { Text: { } } textElement)
73+
if (options.IncludeTextInBreadcrumbs && element is IText { Text: { } text })
6974
{
70-
data.Add(prefix + nameof(textElement.Text), textElement.Text);
75+
data.Add(prefix + nameof(IText.Text), text);
7176
}
7277
}
7378

0 commit comments

Comments
 (0)