Skip to content

Commit 6c160e6

Browse files
Adwin Ronald Rossadwinross
Adwin Ronald Ross
authored andcommitted
docs(ios): update feature documentation
1 parent e81bf22 commit 6c160e6

11 files changed

+146
-3
lines changed

Diff for: docs/ios/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,11 @@
77
All the features supported by the Measure SDK are listed below.
88

99
* [App launch](features/feature_app_launch.md)
10+
* [Crash tracking](features/feature_crash_tracking.md)
1011
* [Network monitoring](features/feature_network_monitoring.md)
1112
* [Network changes](features/feature_network_changes.md)
13+
* [Gesture tracking](features/feature_gesture_tracking.md)
14+
* [Layout Snapshots](features/feature_layout_snapshots.md)
15+
* [Navigation & Lifecycle](features/feature_navigation_and_lifecycle.md)
16+
* [CPU monitoring](features/feature_cpu_monitoring.md)
17+
* [Memory monitoring](features/feature_memory_monitoring.md)

Diff for: docs/ios/features/feature_app_lifecycle.md

Whitespace-only changes.

Diff for: docs/ios/features/feature_cpu_monitoring.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Feature - CPU Monitoring
2+
3+
Measure SDK captures CPU usage periodically (defaults to 3 seconds) when the app is in the foreground.
4+
5+
## How it works
6+
7+
Measure SDK calculates CPU usage by retrieving task and thread information from the system. It uses `task_info` to gather overall task details and `task_threads` to obtain a list of active threads. Then, `thread_info` is used to extract CPU usage from each thread. The CPU usage of all threads is summed up and converted into a percentage of the total available CPU time.
8+
9+
## Data collected
10+
11+
Check out the data collected by Measure in the [CPU Usage Event](../../api/sdk/README.md#cpu_usage) section.

Diff for: docs/ios/features/feature_crash_tracking.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Feature - Crash Tracking
2+
3+
Measure tracks all crashes automatically, no additional code is required to enable this feature.
4+
5+
## How it works
6+
7+
We rely on [PLCrashReporter](https://github.com/microsoft/plcrashreporter) to detect crashes. Once a crash is detected, most recent [attribute](../../api/sdk/README.md#attributes) is saved with the crash report. On next launch, this crash report along with all the events in the previous session are exported to the server.
8+
9+
## Data collected
10+
11+
Checkout the data collected by Measure for each crash in
12+
the [Exception Event](../../api/sdk/README.md#exception) section.

Diff for: docs/ios/features/feature_gesture_tracking.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Feature - Gesture Tracking
2+
3+
Measure SDK captures gestures such as click, long click, and scroll events automatically.
4+
5+
## How it works
6+
7+
Gesture tracking consists of two main components:
8+
9+
1. [Gesture detection](#gesture-detection)
10+
2. [Gesture target detection](#gesture-target-detection)
11+
12+
### Gesture detection
13+
14+
Measure SDK detects touch events by swizzling `UIWindow`'s `sendEvent` method. It processes touch events to classify them into different gesture types:
15+
16+
- **Click**: A touch event that lasts for less than 500 ms.
17+
- **Long Click**: A touch event that lasts for more than 500 ms.
18+
- **Scroll**: A touch movement exceeding 3.5 points in any direction.
19+
20+
### Gesture target detection
21+
22+
Gesture target detection identifies the UI element interacted with during a gesture. It first determines the view at the touch location and then searches its subviews to find the most relevant target. For scroll detection, it checks if the interacted element is a scrollable view like `UIScrollView`, `UIDatePicker`, or `UIPickerView`.
23+
24+
#### Benchmark results
25+
26+
- On average, it takes **4 ms** to identify the clicked view in a view hierarchy with a depth of **1,500**.
27+
- For more common scenarios, a view hierarchy with a depth of **20** takes approximately **0.2 ms**.

Diff for: docs/ios/features/feature_layout_snapshots.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Feature — Layout Snapshots
2+
3+
Layout snapshots provide a lightweight way to capture the structure of your UI at key user interactions.
4+
They are automatically collected during click events (with throttling) and store the layout hierarchy as SVG rather than
5+
full screenshots.
6+
This approach gives valuable context about the UI state during user interactions while being significantly more
7+
efficient to capture and store than traditional screenshots.
8+
9+
| Screenshot | Layout snapshot |
10+
|-------------------------------------------------------|--------------------------------------------------|
11+
| ![Screenshot](../../android/images/layoutSnapshotScreenshot.png) | ![Layout Snapshot](../../android/images/layoutSnapshot.png) |
12+
13+
## How it works
14+
15+
Once a [gesture is detected](feature_gesture_tracking.md), the layout is parsed by going over every element, recording dimensions and size information.
16+
The result is then converted into an SVG and tracked as an [attachment](../../api/sdk/README.md#attachments).
17+
18+
## Impact on Performance

Diff for: docs/ios/features/feature_memory_monitoring.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Feature - Memory Monitoring
2+
3+
Measure SDK captures memory usage periodically (defaults to 2 seconds) when the app is in the foreground.
4+
5+
## How it works
6+
7+
Measure SDK calculates memory usage by retrieving task-level memory information using the `task_info` API with the `TASK_VM_INFO` flavor. It extracts the `phys_footprint` value, which represents the physical memory footprint of the app in kilobytes. If the footprint value is unavailable, it falls back to using `resident_size`, which represents the resident memory size allocated to the process.
8+
9+
## Data collected
10+
11+
Check out the data collected by Measure in the [Memory Usage Absolute](../../api/sdk/README.md#memory_usage_absolute) section.
+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Feature - Navigation & Lifecycle
2+
3+
Measure SDK captures lifecycle and navigation events automatically, this includes the following:
4+
5+
1. [Application lifecycle](#application-lifecycle)
6+
2. [View Controller lifecycle](#view-controller-lifecycle)
7+
3. [SwiftUI lifecycle](#swiftui-lifecycle)
8+
9+
## Application lifecycle
10+
11+
Measure automatically tracks the following Application lifecycle events:
12+
13+
1. Background
14+
2. Foreground
15+
3. Terminated
16+
17+
### How it works
18+
19+
Measure SDK listens for system notifications to track application lifecycle events. It uses `didEnterBackgroundNotification` to detect when the app moves to the background, `willEnterForegroundNotification` when the app returns to the foreground, and `willTerminateNotification` to capture when the app is about to be terminated. These notifications enable Measure to accurately record app state transitions.
20+
21+
### Data collected
22+
23+
Checkout all the data collected for App lifecycle in the [App Lifecycle Event](../../api/sdk/README.md#lifecycle_app) section.
24+
25+
## View Controller lifecycle
26+
27+
Measure automatically tracks the following View Controller lifecycle events:
28+
29+
1. viewDidLoad
30+
2. viewWillAppear
31+
3. viewDidAppear
32+
4. viewWillDisappear
33+
5. viewDidDisappear
34+
6. didReceiveMemoryWarning
35+
7. initWithNibName
36+
8. initWithCoder
37+
38+
You can also track `loadView` and `deinit` by from `MeasureViewController` for swift and `MSRViewController` for ObjC.
39+
40+
### How it works
41+
42+
Measure SDK uses method swizzling to intercept View Controller lifecycle methods. This technique dynamically replaces method implementations at runtime, allowing Measure to capture lifecycle events without requiring manual integration.
43+
44+
### Data collected
45+
46+
Checkout all the data collected for View Controller lifecycle in the [View Controller Lifecycle Event](../../api/sdk/README.md#lifecycle_view_controller) section.
47+
48+
## SwiftUI lifecycle
49+
50+
Measure can track SwiftUI component's `onAppear` and `onDisappear` if you wrap your view with the `MsrMoniterView`.
51+
52+
### How it works
53+
54+
Measure SDK provides `MsrMoniterView`, a wrapper view that listens for SwiftUI lifecycle events. The `MsrMoniterView` ensures that each appearance event is only triggered once per lifecycle instance. Additionally, you can use the `moniterWithMsr` extension to conveniently wrap any SwiftUI view.
55+
56+
### Data collected
57+
58+
Checkout all the data collected for SwiftUI lifecycle in the [SwiftUI Lifecycle Event](../../api/sdk/README.md#lifecycle_swift_ui) section.

Diff for: ios/MeasureSDK.xcodeproj/project.pbxproj

+1
Original file line numberDiff line numberDiff line change
@@ -1373,6 +1373,7 @@
13731373
52F377352CB41DDF006147E8 /* Frameworks */,
13741374
52F377362CB41DDF006147E8 /* Resources */,
13751375
52F377602CB41F5F006147E8 /* Embed Frameworks */,
1376+
52B7F0DD2D6D97DC001498BC /* ShellScript */,
13761377
);
13771378
buildRules = (
13781379
);

Diff for: ios/README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,13 @@ Measure.shared.trackScreenView("Home")
173173
174174
# Features
175175
176+
* [App launch](../docs/ios/features/feature_app_launch.md)
176177
* [Crash tracking](../docs/ios/features/feature_crash_tracking.md)
177178
* [Network monitoring](../docs/ios/features/feature_network_monitoring.md)
178179
* [Network changes](../docs/ios/features/feature_network_changes.md)
179180
* [Gesture tracking](../docs/ios/features/feature_gesture_tracking.md)
180181
* [Layout Snapshots](../docs/ios/features/feature_layout_snapshots.md)
181182
* [Navigation & Lifecycle](../docs/ios/features/feature_navigation_and_lifecycle.md)
182-
* [App Lifecycle](../docs/ios/features/feature_app_lifecycle.md)
183-
* [App launch](../docs/ios/features/feature_app_launch.md)
184183
* [CPU monitoring](../docs/ios/features/feature_cpu_monitoring.md)
185184
* [Memory monitoring](../docs/ios/features/feature_memory_monitoring.md)
186185

Diff for: ios/Tests/MeasureSDKTests/Gestures/GestureTargetFinderTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import XCTest
1111
final class GestureTargetFinderTests: XCTestCase {
1212
var targetFinder: BaseGestureTargetFinder!
1313
var window: UIWindow!
14-
let viewDepth = 1500
14+
let viewDepth = 20
1515

1616
override func setUp() {
1717
super.setUp()

0 commit comments

Comments
 (0)