Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ Maintaining this file:

## [Unreleased]

## [2.3.2] - 2026-11-03

### Added

- `slowRenderingDetection` configuration option. Set it to `false` to stop
`slowRenders` and `frozenRenders` spans on iOS and Android.

### Changed

- iOS: requires `MiddlewareRum` 2.3.1 or a newer 2.3.x. Add the Middleware specs
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,17 @@ Views will get blurred hiding sensitive information in session recording.
</MiddlewareSanitizedView>
```

### Slow rendering detection

The native SDK reports `slowRenders` and `frozenRenders` spans. To turn them off, pass `slowRenderingDetection: false`. Relaunch the app for the change to apply, because a JS reload keeps the native settings.

```js
const MiddlewareConfig: ReactNativeConfiguration = {
// ...
slowRenderingDetection: false,
};
```

## Contributing

See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public boolean getCaptureResponseBodies() {
return Boolean.TRUE.equals(Keys.CAPTURE_RESPONSE_BODIES.get(map));
}

public boolean isSlowRenderingDetectionEnabled() {
return !Boolean.FALSE.equals(Keys.SLOW_RENDERING_DETECTION.get(map));
}

/** Lowercase header names; empty when unset. */
public List<String> getIgnoreHeaders() {
final List<String> headers = new ArrayList<>();
Expand Down Expand Up @@ -97,5 +101,6 @@ private interface Keys {
MapKey RECORDING_OPTIONS = new MapKey("recordingOptions");
BooleanKey CAPTURE_NETWORK_HEADERS = new BooleanKey("captureNetworkHeaders");
BooleanKey CAPTURE_RESPONSE_BODIES = new BooleanKey("captureResponseBodies");
BooleanKey SLOW_RENDERING_DETECTION = new BooleanKey("slowRenderingDetection");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ public void initialize(ReadableMap configMap, Promise promise) {
.setCaptureNetworkHeaders(mapReader.getCaptureNetworkHeaders())
.setCaptureResponseBodies(mapReader.getCaptureResponseBodies())
.setIgnoreHeaders(mapReader.getIgnoreHeaders());
if (!mapReader.isSlowRenderingDetectionEnabled()) {
builder.disableSlowRenderingDetection();
}
final ReadableMap recordingOptionsMap = mapReader.getRecordingOptions();
if (recordingOptionsMap != null) {
builder.setRecordingOptions(recordingOptionsFromMap(recordingOptionsMap));
Expand Down
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ PODS:
- ReactCommon/turbomodule/core (= 0.73.1)
- fmt (6.2.1)
- glog (0.3.5)
- middleware-react-native (2.3.1):
- middleware-react-native (2.3.2):
- glog
- MiddlewareRum (~> 2.3.1)
- RCT-Folly (= 2022.05.16.00)
Expand Down Expand Up @@ -1267,7 +1267,7 @@ SPEC CHECKSUMS:
FBReactNativeSpec: df0ebe69acd14ce0be0269cf75b6e338a727259b
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2
middleware-react-native: e00b9051ee939e646dd44c58dc64dde55992ca1a
middleware-react-native: e669eab32b32f3f798ba150e043a92b719e7776b
MiddlewareRum: 90091571a8a411f82016ac5f98a228f9f9949fa5
PLCrashReporter: db59ef96fa3d25f3650040d02ec2798cffee75f2
RCT-Folly: cd21f1661364f975ae76b3308167ad66b09f53f5
Expand Down
3 changes: 3 additions & 0 deletions ios/MiddlewareReactNative.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ class MiddlewareReactNative: NSObject {
if let recordingOptions = config["recordingOptions"] as? [String: Any] {
_ = builder.recordingOptions(mapRecordingOptions(recordingOptions))
}
if (config["slowRenderingDetection"] as? Bool) == false {
_ = builder.disableSlowRenderingDetection()
}

// sysctl-derived, so it is unaffected by the dispatch below.
let appStart = ((try? processStartTime()) ?? Date()).timeIntervalSince1970 * 1000
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@middleware.io/middleware-react-native",
"version": "2.3.1",
"version": "2.3.2",
"description": "Middleware React Native real user monitoring SDK",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
21 changes: 21 additions & 0 deletions src/__tests__/tracePropagation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,24 @@ describe('network capture options', () => {
expect(native[0].ignoreHeaders).toEqual(['cookie']);
});
});

describe('slowRenderingDetection', () => {
const nativeConfig = (config: Record<string, unknown>) => {
const { rum, captured } = loadRum();
rum.init({ ...CONFIG, ...config });
return captured.native[0];
};

it('leaves the native default in place when unset', () => {
expect(nativeConfig({})).not.toHaveProperty('slowRenderingDetection');
});

it('passes an explicit value to native', () => {
expect(nativeConfig({ slowRenderingDetection: false })).toMatchObject({
slowRenderingDetection: false,
});
expect(nativeConfig({ slowRenderingDetection: true })).toMatchObject({
slowRenderingDetection: true,
});
});
});
9 changes: 9 additions & 0 deletions src/middlewareRum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ export interface ReactNativeConfiguration {
* `captureNetworkHeaders` on.
*/
ignoreHeaders?: Set<string> | string[];
/**
* Set to `false` to stop the native SDK reporting `slowRenders` and
* `frozenRenders` spans. Enabled by default. Native settings are read once per
* process, so a JS reload does not change this; relaunch the app.
*/
slowRenderingDetection?: boolean;
}

export interface MiddlewareRumType {
Expand Down Expand Up @@ -297,6 +303,9 @@ export const MiddlewareRum: MiddlewareRumType = {
...(config.recordingOptions !== undefined && {
recordingOptions: config.recordingOptions,
}),
...(config.slowRenderingDetection !== undefined && {
slowRenderingDetection: config.slowRenderingDetection,
}),
};

setGlobalAttributes(attributes);
Expand Down
1 change: 1 addition & 0 deletions src/native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export interface NativeSdKConfiguration {
maskAllTextInputs?: boolean;
maskAllImages?: boolean;
};
slowRenderingDetection?: boolean;
}

export type AppStartInfo = {
Expand Down
Loading