-
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
Merged
ncreated
merged 7 commits into
feature/hybrid-application
from
buranmert/RUMM-1649-integration-tests
Jan 18, 2022
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
347ea1a
RUMM-1649 WebViewTracking integration test added
buranmert 1d95970
RUMM-1649 PR comments addressed
buranmert da0d544
RUMM-1649 Disable Webviews tracking integration test in Crash Reporti…
ncreated 10fabe3
RUMM-1649 Allow `viewVisit.name` to be `nil` in `RUMSessionMatcher`
ncreated dda0851
RUMM-1649 Remove obsolete TODO
ncreated 6c260e5
RUMM-1649 Add assertions to more properties and to logs
ncreated 1593ae7
RUMM-1649 Apply `resource.method` patch only to Browser SDK events, n…
ncreated File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
* This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
* Copyright 2019-2020 Datadog, Inc. | ||
*/ | ||
|
||
import UIKit | ||
import Datadog | ||
|
||
private struct WebViewTrackingScenarioPredicate: UIKitRUMViewsPredicate { | ||
private let defaultPredicate = DefaultUIKitRUMViewsPredicate() | ||
|
||
func rumView(for viewController: UIViewController) -> RUMView? { | ||
if viewController is ShopistWebviewViewController { | ||
return nil // do not consider the webview itself as RUM view | ||
} else { | ||
return defaultPredicate.rumView(for: viewController) | ||
} | ||
} | ||
} | ||
|
||
final class WebViewTrackingScenario: TestScenario { | ||
static var storyboardName: String = "WebViewTrackingScenario" | ||
|
||
func configureSDK(builder: Datadog.Configuration.Builder) { | ||
_ = builder | ||
.trackUIKitRUMViews(using: WebViewTrackingScenarioPredicate()) | ||
.enableLogging(true) | ||
.enableRUM(true) | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
Datadog/Example/Scenarios/WebView/WebViewTrackingFixtureViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
* This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
* Copyright 2019-2020 Datadog, Inc. | ||
*/ | ||
|
||
import UIKit | ||
import WebKit | ||
import Datadog | ||
|
||
class WebViewTrackingFixtureViewController: UIViewController, WKNavigationDelegate { | ||
override func viewDidAppear(_ animated: Bool) { | ||
super.viewDidAppear(animated) | ||
|
||
// An action sent from native iOS SDK. | ||
Global.rum.addUserAction(type: .custom, name: "Native action") | ||
|
||
// Opens a webview configured to pass all its Browser SDK events to native iOS SDK. | ||
show(ShopistWebviewViewController(), sender: nil) | ||
} | ||
} | ||
|
||
class ShopistWebviewViewController: UIViewController { | ||
private let request = URLRequest(url: URL(string: "https://shopist.io")!) | ||
private var webView: WKWebView! | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
let controller = WKUserContentController() | ||
controller.addDatadogMessageHandler(allowedWebViewHosts: ["shopist.io"]) | ||
let config = WKWebViewConfiguration() | ||
config.userContentController = controller | ||
|
||
webView = WKWebView(frame: UIScreen.main.bounds, configuration: config) | ||
view.addSubview(webView) | ||
} | ||
|
||
override func viewDidAppear(_ animated: Bool) { | ||
super.viewDidAppear(animated) | ||
webView.load(request) | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
Datadog/Example/Scenarios/WebView/WebViewTrackingScenario.storyboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19529" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="Y6W-OH-hqX"> | ||
<device id="retina6_1" orientation="portrait" appearance="light"/> | ||
<dependencies> | ||
<deployment identifier="iOS"/> | ||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19519"/> | ||
<capability name="Safe area layout guides" minToolsVersion="9.0"/> | ||
<capability name="System colors in document resources" minToolsVersion="11.0"/> | ||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> | ||
</dependencies> | ||
<scenes> | ||
<!--Web View Tracking Fixture View Controller--> | ||
<scene sceneID="s0d-6b-0kx"> | ||
<objects> | ||
<viewController id="Y6W-OH-hqX" customClass="WebViewTrackingFixtureViewController" customModule="Example" customModuleProvider="target" sceneMemberID="viewController"> | ||
<view key="view" contentMode="scaleToFill" id="5EZ-qb-Rvc"> | ||
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/> | ||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
<viewLayoutGuide key="safeArea" id="vDu-zF-Fre"/> | ||
<color key="backgroundColor" systemColor="systemBackgroundColor"/> | ||
</view> | ||
</viewController> | ||
<placeholder placeholderIdentifier="IBFirstResponder" id="Ief-a0-LHa" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/> | ||
</objects> | ||
<point key="canvasLocation" x="114" y="80"/> | ||
</scene> | ||
</scenes> | ||
<resources> | ||
<systemColor name="systemBackgroundColor"> | ||
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> | ||
</systemColor> | ||
</resources> | ||
</document> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
👍.