-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RUMM-1649 WebViewTracking integration test added #714
RUMM-1649 WebViewTracking integration test added #714
Conversation
20b2f5d
to
27b27ea
Compare
27b27ea
to
85b4528
Compare
Most of the changes coming from the merge from |
85b4528
to
048ee6b
Compare
WebViewScenarioTest uses an actual website to test WebView Tracking feature
048ee6b
to
1d95970
Compare
I isolated updating |
…ng test plan this is done by switching crash reporting `.xctestplan` to not include new tests automatically and removing Webviews test from the existing list.
as this is now possible for Browser SDK views.
"skippedTests" : [ | ||
"IntegrationTests", | ||
"LoggingScenarioTests", | ||
"RUMManualInstrumentationScenarioTests", | ||
"RUMMobileVitalsScenarioTests", | ||
"RUMModalViewsScenarioTests", | ||
"RUMNavigationControllerScenarioTests", | ||
"RUMResourcesScenarioTests", | ||
"RUMScrubbingScenarioTests", | ||
"RUMSwiftUIScenarioTests", | ||
"RUMTabBarControllerScenarioTests", | ||
"RUMTapActionScenarioTests", | ||
"TracingManualInstrumentationScenarioTests", | ||
"TracingURLSessionScenarioTests", | ||
"TrackingConsentScenarioTests" | ||
"selectedTests" : [ | ||
"CrashReportingWithLoggingScenarioTests\/testCrashReportingCollectOrSendWithLoggingScenario()", | ||
"CrashReportingWithRUMScenarioTests\/testCrashReportingCollectOrSendWithRUMScenario()" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is on purpose. By default, all new integration tests are added to both XCTest plans (integration and crash reporting), meaning we will run it twice on CI. To avoid this, I disabled "add new tests automatically" in crash reporting XCTest plan. Apparently, this means changing from opt-out to opt-in in .xctestplan
👍.
sent from Browser SDK.
85da275
to
6c260e5
Compare
I added more assertions on data received from Browser SDK, this includes checks like:
|
if let eventType = json["type"] as? String, | ||
eventType == "resource", | ||
var resource = json["resource"] as? [String: Any], | ||
let method = resource["method"] as? String { | ||
resource["method"] = method.uppercased() | ||
json["resource"] = resource | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to do case-insensitive comparison instead of transforming the payload?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not if we want to keep using RUMEventMatcher
. This matcher decodes certain RUM event model from Data
:
func model<DM: Decodable>(file: StaticString = #file, line: UInt = #line) throws -> DM
RUM events schema defines uppercased values for resource.method
:
"method": {
"type": "string",
"description": "HTTP method of the resource",
"enum": ["POST", "GET", "HEAD", "PUT", "DELETE", "PATCH"],
"readOnly": true
},
Because our RUMDataModels
definition is strict about this and Browser SDK seems not, receiving lowercased method name from WebView (e.g. "get"
instead of "GET"
) leads to decoding error. IMO this is an inconsistency in Browser SDK and we need to patch it in order to leverage strict validation with RUMEventMatcher
and RUMSessionMatcher
in our tests.
However, I think we can move this patch to a better place. Residing here in RUMEventMatcher
, it is applied globally to all our test data, but the only problematic test is WebViewScenarioTest.swift
where we consume real Browser SDK events. I'd vote for transforming data directly in WebViewScenarioTest.swift
before passing it to the matcher, as this will minimalize the impact of this patch and be more explanatory. WDYT on this @maxep ?
Alternatively, we could resign from using strict matchers and assert all values as [String: Any]
on events deserialized with JSONSerialization
. This way we can perform case-insensitive comparison, but we lose all other strict validation from RUMSessionMatcher
. Adding this validation back would require bloating WebViewScenarioTest.swift
with manual deserialization code and duplication of all validation concepts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree! it would be better to move it where the transformation is needed. It clarify that we relax the rule for this specific use case only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to WebViewScenarioTest.swift
✅. I also talked with browser-sdk
team - they will fix it in future release.
Such fix is required, as some queries in hybrid apps (e.g. count all resources by resource.method
) might be giving odd results (i.e. considering "post" and "POST" as separate methods).
…ot all events within our tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
What and why?
Adding integration test to WebView tracking feature.
How?
In this new test, the app opens a WebView which loads Browser SDK instrumented content. The iOS SDK should transport all RUM events and Logs received from Browser SDK.
Review checklist