Conversation
…a impressions view and click
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
Adds support for emitting tracking events for display ads (media) impression view and click, including request models, API paths, DataManager wiring, and tests/documentation.
Changes:
- Add media tracking request bodies and API endpoints for display ad view/click events.
- Introduce
mediaServiceUrlconfiguration and persist it viaPreferencesHelper. - Add unit + integration tests for media tracking and document the new public APIs in the README.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| library/src/main/java/io/constructor/data/remote/ConstructorApi.kt | Adds Retrofit endpoints for media impression tracking via dynamic @Url. |
| library/src/main/java/io/constructor/data/remote/ApiPaths.kt | Adds URL constants for ad behavioral actions and media impression endpoints. |
| library/src/main/java/io/constructor/data/model/tracking/MediaImpressionViewRequestBody.kt | New request body model for display ad view tracking. |
| library/src/main/java/io/constructor/data/model/tracking/MediaImpressionClickRequestBody.kt | New request body model for display ad click tracking. |
| library/src/main/java/io/constructor/data/local/PreferencesHelper.kt | Persists mediaServiceUrl in shared preferences. |
| library/src/main/java/io/constructor/data/interceptor/RequestInterceptor.kt | Attempts to include ad behavioral endpoints in the redaction/behavioral handling list. |
| library/src/main/java/io/constructor/data/DataManager.kt | Builds media-service URLs and routes new tracking calls through Retrofit. |
| library/src/main/java/io/constructor/core/ConstructorIoConfig.kt | Adds mediaServiceUrl to SDK configuration. |
| library/src/main/java/io/constructor/core/ConstructorIo.kt | Exposes trackMediaImpressionView/Click public APIs and internal implementations. |
| library/src/test/java/io/constructor/core/ConstructorIoMediaTrackingTest.kt | Adds MockWebServer-based unit tests for media tracking endpoints. |
| library/src/test/java/io/constructor/core/ConstructorIoIntegrationMediaTrackingTest.kt | Adds real-network integration tests for media tracking endpoints. |
| README.md | Documents new media impression tracking APIs. |
Comments suppressed due to low confidence (1)
README.md:652
- The new Markdown code block under “Media Impression Events” is not closed (missing a terminating ```). This will cause the rest of the README to render as code.
ConstructorIo.trackMediaImpressionClick(
bannerAdId = "abc123",
placementId = "home"
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
library/src/test/java/io/constructor/core/ConstructorIoMediaTrackingTest.kt
Outdated
Show resolved
Hide resolved
library/src/main/java/io/constructor/data/interceptor/RequestInterceptor.kt
Outdated
Show resolved
Hide resolved
Code Review SummaryThis PR adds display ad tracking support for media impression view and click events. The implementation is well-structured and consistent with existing patterns. It correctly introduces a new Detailed Feedback[File: 1. Duplicate data classes — should be a single shared class
// Single class for both view and click:
@JsonClass(generateAdapter = true)
data class MediaImpressionRequestBody(
@Json(name = "banner_ad_id") val bannerAdId: String,
@Json(name = "placement_id") val placementId: String,
...
) : Serializable[File: 2. Missing All other request body classes in the package (e.g. /**
* @suppress
*/
@JsonClass(generateAdapter = true)
data class MediaImpressionViewRequestBody([File: 3. Single-letter field names The fields @Json(name = "c") val c: String, // client version
@Json(name = "i") val i: String, // device identity (GUID)
@Json(name = "s") val s: Int, // session ID[File: 4. In every other // All other request bodies:
@Json(name= "_dt") val _dt: Long?
// New bodies (should follow same pattern):
@Json(name = "_dt") val dt: Long?Additionally, the field is named [File: 5. Missing All comparable tracking methods ( [File: 6. The media service URL ( More critically, for production use with if (preferencesHelper.port != 443) {
builder.port(preferencesHelper.port)
}[File: 7. Missing newline at end of file The diff shows [File: 8. Integration test makes a real network call in The
[File: 9. The 500-error tests use observer.assertError(HttpException::class.java)(using Retrofit's [File: 10. Timeout tests assert The timeout tests set val mockResponse = MockResponse()
.setResponseCode(204)
.setBodyDelay(5, TimeUnit.SECONDS)
mockServer.enqueue(mockResponse)[File: 11. Trailing semicolons in test code val request = awaitRequest(); // line 127 — trailing semicolonKotlin does not require semicolons; these are style inconsistencies. The rest of the PR's test code doesn't use them. Remove them. ConclusionThe overall approach is sound and follows the existing codebase patterns well. The main issues to address before merging are:
|
Add functions to emit tracking events for display ads media impressions view and click