Skip to content

Commit

Permalink
fix: Finish transaction for external view controllers (#3440)
Browse files Browse the repository at this point in the history
View controllers from frameworks in inAppIncludes option are not being swizzled, and so, their transactions are not being closed, but we do start the transaction, because start happens with swizzling of UIViewController.


Co-authored-by: Philipp Hofmann <[email protected]>
Co-authored-by: Andrew McKnight <[email protected]>
  • Loading branch information
3 people authored Nov 29, 2023
1 parent e0291c9 commit 8b39743
Show file tree
Hide file tree
Showing 20 changed files with 919 additions and 82 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

### Fixes

- Finish transaction for external view controllers (#3440)
- Fix inaccurate number of frames for transactions (#3439)

## 8.16.0
Expand Down
12 changes: 12 additions & 0 deletions Samples/iOS-Swift/iOS-External/ExternalViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Foundation
import Sentry
import UIKit

class ExternalViewController: UIViewController {

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
SentrySDK.reportFullyDisplayed()
}

}
10 changes: 10 additions & 0 deletions Samples/iOS-Swift/iOS-External/iOS_External.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#import <Foundation/Foundation.h>

//! Project version number for iOS_External.
FOUNDATION_EXPORT double iOS_ExternalVersionNumber;

//! Project version string for iOS_External.
FOUNDATION_EXPORT const unsigned char iOS_ExternalVersionString[];

// In this header, you should import all the public headers of your framework using statements like
// #import <iOS_External/PublicHeader.h>
289 changes: 289 additions & 0 deletions Samples/iOS-Swift/iOS-Swift.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Samples/iOS-Swift/iOS-Swift/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
options.attachViewHierarchy = true
options.environment = "test-app"
options.enableTimeToFullDisplayTracing = true

options.add(inAppInclude: "iOS_External")

let isBenchmarking = ProcessInfo.processInfo.arguments.contains("--io.sentry.test.benchmarking")

Expand Down
25 changes: 25 additions & 0 deletions Samples/iOS-Swift/iOS-Swift/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,15 @@
<action selector="uiClickTransaction:" destination="BYZ-38-t0r" eventType="touchUpInside" id="UJy-CY-NIQ"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="tvP-G7-z60">
<rect key="frame" x="0.0" y="308" width="259" height="28"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" title="External View Controller"/>
<connections>
<segue destination="oCp-Df-BWS" kind="show" id="iFk-us-OK4"/>
</connections>
</button>
</subviews>
</stackView>
</subviews>
Expand Down Expand Up @@ -389,6 +398,22 @@
</objects>
<point key="canvasLocation" x="1020" y="1685"/>
</scene>
<!--External View Controller-->
<scene sceneID="FBQ-Cn-whQ">
<objects>
<viewController id="oCp-Df-BWS" customClass="ExternalViewController" customModule="iOS_External" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="xra-iw-aq3">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<viewLayoutGuide key="safeArea" id="Hqn-KI-o6p"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
</view>
<navigationItem key="navigationItem" id="AWo-oj-ODl"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="CiN-t1-bFc" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="649" y="2399"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="0gQ-IO-Fn5">
<objects>
Expand Down
Loading

0 comments on commit 8b39743

Please sign in to comment.