Skip to content

Commit b0f79d2

Browse files
committed
RUM-8375: post-review fixes
1 parent f3d13bd commit b0f79d2

File tree

15 files changed

+469
-26
lines changed

15 files changed

+469
-26
lines changed

dd-sdk-android-core/src/main/kotlin/com/datadog/android/core/internal/attributes/LocalAttribute.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fun MutableMap<String, Any?>.enrichWithConstantAttribute(
7373
attribute: LocalAttribute.Constant
7474
) = enrichWithLocalAttribute(
7575
attribute.key,
76-
attribute.value
76+
attribute
7777
)
7878

7979
/**

features/dd-sdk-android-rum/api/apiSurface

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ class com.datadog.android.rum.tracking.ActivityViewTrackingStrategy : ActivityLi
254254
override fun onActivityStopped(android.app.Activity)
255255
override fun equals(Any?): Boolean
256256
override fun hashCode(): Int
257-
fun android.os.Bundle?.convertToRumViewAttributes(): MutableMap<String, Any?>
257+
fun android.os.Bundle?.convertToRumViewAttributes(): Map<String, Any?>
258258
interface com.datadog.android.rum.tracking.ComponentPredicate<T>
259259
fun accept(T): Boolean
260260
fun getViewName(T): String?
@@ -1520,6 +1520,12 @@ data class com.datadog.android.rum.model.ResourceEvent
15201520
fun toJson(): com.google.gson.JsonElement
15211521
companion object
15221522
fun fromJson(kotlin.String): OperationType
1523+
data class com.datadog.android.rum.model.RumRect
1524+
constructor(kotlin.Number, kotlin.Number, kotlin.Number, kotlin.Number)
1525+
fun toJson(): com.google.gson.JsonElement
1526+
companion object
1527+
fun fromJson(kotlin.String): RumRect
1528+
fun fromJsonObject(com.google.gson.JsonObject): RumRect
15231529
data class com.datadog.android.rum.model.RumVitalEvent
15241530
constructor(kotlin.Long, Application, kotlin.String? = null, kotlin.String? = null, kotlin.String? = null, kotlin.String? = null, RumVitalEventSession, RumVitalEventSource? = null, RumVitalEventView, Usr? = null, Account? = null, Connectivity? = null, Display? = null, Synthetics? = null, CiTest? = null, Os? = null, Device? = null, Dd, Context? = null, Container? = null, RumVitalEventVital)
15251531
val type: kotlin.String
@@ -2069,6 +2075,48 @@ data class com.datadog.android.rum.model.ViewEvent
20692075
fun toJson(): com.google.gson.JsonElement
20702076
companion object
20712077
fun fromJson(kotlin.String): State
2078+
data class com.datadog.android.rum.model.ViewPerformanceData
2079+
constructor(Cls? = null, Fcp? = null, Fid? = null, Inp? = null, Lcp? = null)
2080+
fun toJson(): com.google.gson.JsonElement
2081+
companion object
2082+
fun fromJson(kotlin.String): ViewPerformanceData
2083+
fun fromJsonObject(com.google.gson.JsonObject): ViewPerformanceData
2084+
data class Cls
2085+
constructor(kotlin.Number, kotlin.Long? = null, kotlin.String? = null, PreviousRect? = null, PreviousRect? = null)
2086+
fun toJson(): com.google.gson.JsonElement
2087+
companion object
2088+
fun fromJson(kotlin.String): Cls
2089+
fun fromJsonObject(com.google.gson.JsonObject): Cls
2090+
data class Fcp
2091+
constructor(kotlin.Long)
2092+
fun toJson(): com.google.gson.JsonElement
2093+
companion object
2094+
fun fromJson(kotlin.String): Fcp
2095+
fun fromJsonObject(com.google.gson.JsonObject): Fcp
2096+
data class Fid
2097+
constructor(kotlin.Long, kotlin.Long, kotlin.String? = null)
2098+
fun toJson(): com.google.gson.JsonElement
2099+
companion object
2100+
fun fromJson(kotlin.String): Fid
2101+
fun fromJsonObject(com.google.gson.JsonObject): Fid
2102+
data class Inp
2103+
constructor(kotlin.Long, kotlin.Long? = null, kotlin.String? = null)
2104+
fun toJson(): com.google.gson.JsonElement
2105+
companion object
2106+
fun fromJson(kotlin.String): Inp
2107+
fun fromJsonObject(com.google.gson.JsonObject): Inp
2108+
data class Lcp
2109+
constructor(kotlin.Long, kotlin.String? = null, kotlin.String? = null)
2110+
fun toJson(): com.google.gson.JsonElement
2111+
companion object
2112+
fun fromJson(kotlin.String): Lcp
2113+
fun fromJsonObject(com.google.gson.JsonObject): Lcp
2114+
data class PreviousRect
2115+
constructor(kotlin.Number, kotlin.Number, kotlin.Number, kotlin.Number)
2116+
fun toJson(): com.google.gson.JsonElement
2117+
companion object
2118+
fun fromJson(kotlin.String): PreviousRect
2119+
fun fromJsonObject(com.google.gson.JsonObject): PreviousRect
20722120
data class com.datadog.android.telemetry.model.TelemetryConfigurationEvent
20732121
constructor(Dd, kotlin.Long, kotlin.String, Source, kotlin.String, Application? = null, Session? = null, View? = null, Action? = null, kotlin.Number? = null, kotlin.collections.List<kotlin.String>? = null, Telemetry)
20742122
val type: kotlin.String

features/dd-sdk-android-rum/api/dd-sdk-android-rum.api

Lines changed: 206 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema",
3+
"$id": "rum/_rect-schema.json",
4+
"title": "RumRect",
5+
"type": "object",
6+
"description": "Schema for DOMRect-like rectangles describing an element's bounding client rect",
7+
"required": ["x", "y", "width", "height"],
8+
"properties": {
9+
"x": {
10+
"type": "number",
11+
"description": "The x coordinate of the element's origin",
12+
"readOnly": true
13+
},
14+
"y": {
15+
"type": "number",
16+
"description": "The y coordinate of the element's origin",
17+
"readOnly": true
18+
},
19+
"width": {
20+
"type": "number",
21+
"description": "The element's width",
22+
"readOnly": true
23+
},
24+
"height": {
25+
"type": "number",
26+
"description": "The element's height",
27+
"readOnly": true
28+
}
29+
}
30+
}
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema",
3+
"$id": "rum/_view-performance-schema.json",
4+
"title": "ViewPerformanceData",
5+
"type": "object",
6+
"description": "Schema for view-level RUM performance data (Web Vitals, etc.)",
7+
"properties": {
8+
"cls": {
9+
"type": "object",
10+
"description": "Cumulative Layout Shift",
11+
"required": ["score"],
12+
"properties": {
13+
"score": {
14+
"type": "number",
15+
"description": "Total layout shift score that occurred on the view",
16+
"$comment": "Replaces the deprecated `view.cumulative_layout_shift`",
17+
"minimum": 0,
18+
"readOnly": true
19+
},
20+
"timestamp": {
21+
"type": "integer",
22+
"description": "Timestamp in ns of the largest layout shift contributing to CLS",
23+
"$comment": "Replaces the deprecated `view.cumulative_layout_shift_time`",
24+
"minimum": 0,
25+
"readOnly": true
26+
},
27+
"target_selector": {
28+
"type": "string",
29+
"description": "CSS selector path of the first element (in document order) of the largest layout shift contributing to CLS",
30+
"$comment": "Replaces the deprecated `view.cumulative_layout_shift_target_selector`",
31+
"readOnly": true
32+
},
33+
"previous_rect": {
34+
"description": "Bounding client rect of the element before the layout shift",
35+
"allOf": [{ "$ref": "_rect-schema.json" }]
36+
},
37+
"current_rect": {
38+
"description": "Bounding client rect of the element after the layout shift",
39+
"allOf": [{ "$ref": "_rect-schema.json" }]
40+
}
41+
},
42+
"readOnly": true
43+
},
44+
"fcp": {
45+
"type": "object",
46+
"description": "First Contentful Paint",
47+
"required": ["timestamp"],
48+
"properties": {
49+
"timestamp": {
50+
"type": "integer",
51+
"description": "Timestamp in ns of the first rendering",
52+
"$comment": "Replaces the deprecated `view.first_contentful_paint`",
53+
"minimum": 0,
54+
"readOnly": true
55+
}
56+
},
57+
"readOnly": true
58+
},
59+
"fid": {
60+
"type": "object",
61+
"description": "First Input Delay",
62+
"required": ["duration", "timestamp"],
63+
"properties": {
64+
"duration": {
65+
"type": "integer",
66+
"description": "Duration in ns of the first input event delay",
67+
"$comment": "Replaces the deprecated `view.first_input_delay`",
68+
"minimum": 0,
69+
"readOnly": true
70+
},
71+
"timestamp": {
72+
"type": "integer",
73+
"description": "Timestamp in ns of the first input event",
74+
"$comment": "Replaces the deprecated `view.first_input_time`",
75+
"minimum": 0,
76+
"readOnly": true
77+
},
78+
"target_selector": {
79+
"type": "string",
80+
"description": "CSS selector path of the first input target element",
81+
"$comment": "Replaces the deprecated `view.first_input_target_selector`",
82+
"readOnly": true
83+
}
84+
},
85+
"readOnly": true
86+
},
87+
"inp": {
88+
"type": "object",
89+
"description": "Interaction to Next Paint",
90+
"required": ["duration"],
91+
"properties": {
92+
"duration": {
93+
"type": "integer",
94+
"description": "Longest duration in ns between an interaction and the next paint",
95+
"$comment": "Replaces the deprecated `view.interaction_to_next_paint`",
96+
"minimum": 0,
97+
"readOnly": true
98+
},
99+
"timestamp": {
100+
"type": "integer",
101+
"description": "Timestamp in ns of the start of the INP interaction",
102+
"$comment": "Replaces the deprecated `view.interaction_to_next_paint_time`",
103+
"minimum": 0,
104+
"readOnly": true
105+
},
106+
"target_selector": {
107+
"type": "string",
108+
"description": "CSS selector path of the interacted element for the INP interaction",
109+
"$comment": "Replaces the deprecated `view.interaction_to_next_paint_target_selector`",
110+
"readOnly": true
111+
}
112+
},
113+
"readOnly": true
114+
},
115+
"lcp": {
116+
"type": "object",
117+
"description": "Largest Contentful Paint",
118+
"required": ["timestamp"],
119+
"properties": {
120+
"timestamp": {
121+
"type": "integer",
122+
"description": "Timestamp in ns of the largest contentful paint",
123+
"$comment": "Replaces the deprecated `view.largest_contentful_paint`",
124+
"minimum": 0,
125+
"readOnly": true
126+
},
127+
"target_selector": {
128+
"type": "string",
129+
"description": "CSS selector path of the largest contentful paint element",
130+
"$comment": "Replaces the deprecated `view.largest_contentful_paint_target_selector`",
131+
"readOnly": true
132+
},
133+
"resource_url": {
134+
"type": "string",
135+
"description": "URL of the largest contentful paint element",
136+
"readOnly": true
137+
}
138+
},
139+
"readOnly": true
140+
}
141+
}
142+
}

features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/tracking/ActivityViewTrackingStrategy.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ constructor(
110110
* Maps the Bundle key - value properties into compatible attributes for the Rum Events.
111111
* @param intent the [Intent] we need to transform. Returns an empty Map if this is null.
112112
*/
113-
private fun convertToRumAttributes(intent: Intent?): MutableMap<String, Any?> {
113+
private fun convertToRumAttributes(intent: Intent?): Map<String, Any?> {
114114
if (intent == null) return mutableMapOf()
115115

116116
val attributes = mutableMapOf<String, Any?>()

features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/tracking/BundleExt.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ internal const val ARGUMENT_TAG = "view.arguments"
1313
/**
1414
* Converts this bundle into a Map of attributes to be included in a RUM View event.
1515
*/
16-
fun Bundle?.convertToRumViewAttributes(): MutableMap<String, Any?> {
17-
if (this == null) return mutableMapOf()
16+
fun Bundle?.convertToRumViewAttributes(): Map<String, Any?> {
17+
if (this == null) return emptyMap()
1818

1919
val attributes = mutableMapOf<String, Any?>()
2020

features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/tracking/FragmentViewTrackingStrategy.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ internal constructor(
7676
AndroidXFragmentLifecycleCallbacks(
7777
argumentsProvider = {
7878
if (trackArguments) {
79-
it.arguments.convertToRumViewAttributes()
79+
it.arguments.convertToRumViewAttributes().toMutableMap()
8080
} else {
8181
mutableMapOf()
8282
}.enrichWithConstantAttribute(ViewScopeInstrumentationType.FRAGMENT)
@@ -103,7 +103,7 @@ internal constructor(
103103
OreoFragmentLifecycleCallbacks(
104104
argumentsProvider = {
105105
if (trackArguments) {
106-
it.arguments.convertToRumViewAttributes()
106+
it.arguments.convertToRumViewAttributes().toMutableMap()
107107
} else {
108108
mutableMapOf()
109109
}.enrichWithConstantAttribute(ViewScopeInstrumentationType.FRAGMENT)

features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/tracking/NavigationViewTrackingStrategy.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class NavigationViewTrackingStrategy(
9797
val rumMonitor = withSdkCore { GlobalRumMonitor.get(it) }
9898
componentPredicate.runIfValid(destination, internalLogger) {
9999
val attributes = if (trackArguments) {
100-
arguments.convertToRumViewAttributes()
100+
arguments.convertToRumViewAttributes().toMutableMap()
101101
} else {
102102
mutableMapOf()
103103
}

features/dd-sdk-android-rum/src/test/kotlin/com/datadog/android/rum/ActivityViewTrackingStrategyTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ internal class ActivityViewTrackingStrategyTest :
107107
verify(rumMonitor.mockInstance).startView(
108108
mockActivity,
109109
mockActivity.resolveViewName(),
110-
mapOf(ViewScopeInstrumentationType.ACTIVITY.key.string to ViewScopeInstrumentationType.ACTIVITY.value)
110+
mapOf(ViewScopeInstrumentationType.ACTIVITY.key.string to ViewScopeInstrumentationType.ACTIVITY)
111111
)
112112
}
113113

@@ -163,7 +163,7 @@ internal class ActivityViewTrackingStrategyTest :
163163
val expectedAttributes = mapOf<String, Any?>(
164164
"view.intent.action" to action,
165165
"view.intent.uri" to uri,
166-
ViewScopeInstrumentationType.ACTIVITY.key.string to ViewScopeInstrumentationType.ACTIVITY.value
166+
ViewScopeInstrumentationType.ACTIVITY.key.string to ViewScopeInstrumentationType.ACTIVITY
167167
)
168168

169169
testedStrategy.register(rumMonitor.mockSdkCore, mockActivity)
@@ -223,7 +223,7 @@ internal class ActivityViewTrackingStrategyTest :
223223
verify(rumMonitor.mockInstance).startView(
224224
mockActivity,
225225
fakeName,
226-
mapOf(ViewScopeInstrumentationType.ACTIVITY.key.string to ViewScopeInstrumentationType.ACTIVITY.value)
226+
mapOf(ViewScopeInstrumentationType.ACTIVITY.key.string to ViewScopeInstrumentationType.ACTIVITY)
227227
)
228228
}
229229

@@ -244,7 +244,7 @@ internal class ActivityViewTrackingStrategyTest :
244244
verify(rumMonitor.mockInstance).startView(
245245
mockActivity,
246246
mockActivity.resolveViewName(),
247-
mapOf(ViewScopeInstrumentationType.ACTIVITY.key.string to ViewScopeInstrumentationType.ACTIVITY.value)
247+
mapOf(ViewScopeInstrumentationType.ACTIVITY.key.string to ViewScopeInstrumentationType.ACTIVITY)
248248
)
249249
}
250250

0 commit comments

Comments
 (0)