Skip to content

Commit 0e6bfda

Browse files
antonisclaude
andcommitted
feat(core): Expose pauseAppHangTracking and resumeAppHangTracking APIs
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ef27341 commit 0e6bfda

13 files changed

Lines changed: 173 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- Add `textComponentNames` option to `annotateReactComponents` for custom text components ([#6169](https://github.com/getsentry/sentry-react-native/pull/6169))
2020
- Expose `addConsoleInstrumentationFilter` from `@sentry/core` ([#6180](https://github.com/getsentry/sentry-react-native/pull/6180))
2121
- Expose experimental `captureSurfaceViews` option for Android Session Replay ([#6175](https://github.com/getsentry/sentry-react-native/pull/6175))
22+
- Expose `pauseAppHangTracking` and `resumeAppHangTracking` APIs on iOS ([#6192](https://github.com/getsentry/sentry-react-native/pull/6192))
2223

2324
### Fixes
2425

packages/core/android/src/main/java/io/sentry/react/RNSentryModuleImpl.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,14 @@ public void disableShakeDetection() {
279279
stopShakeDetection();
280280
}
281281

282+
public void pauseAppHangTracking() {
283+
// No-op: App hang tracking is iOS-only
284+
}
285+
286+
public void resumeAppHangTracking() {
287+
// No-op: App hang tracking is iOS-only
288+
}
289+
282290
public void fetchModules(Promise promise) {
283291
final AssetManager assets = this.getReactApplicationContext().getResources().getAssets();
284292
try (InputStream stream = new BufferedInputStream(assets.open(modulesPath))) {

packages/core/android/src/newarch/java/io/sentry/react/RNSentryModule.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,16 @@ public void disableShakeDetection() {
234234
this.impl.disableShakeDetection();
235235
}
236236

237+
@Override
238+
public void pauseAppHangTracking() {
239+
this.impl.pauseAppHangTracking();
240+
}
241+
242+
@Override
243+
public void resumeAppHangTracking() {
244+
this.impl.resumeAppHangTracking();
245+
}
246+
237247
@Override
238248
public void invalidate() {
239249
this.impl.invalidate();

packages/core/android/src/oldarch/java/io/sentry/react/RNSentryModule.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,16 @@ public void disableShakeDetection() {
234234
this.impl.disableShakeDetection();
235235
}
236236

237+
@ReactMethod
238+
public void pauseAppHangTracking() {
239+
this.impl.pauseAppHangTracking();
240+
}
241+
242+
@ReactMethod
243+
public void resumeAppHangTracking() {
244+
this.impl.resumeAppHangTracking();
245+
}
246+
237247
@Override
238248
public void invalidate() {
239249
this.impl.invalidate();

packages/core/etc/sentry-react-native.api.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,9 @@ export { OpenAiClient }
490490

491491
export { OpenAiOptions }
492492

493+
// @public
494+
export function pauseAppHangTracking(): void;
495+
493496
// @public
494497
export const primitiveTagIntegration: () => Integration;
495498

@@ -554,6 +557,9 @@ export const reactNavigationIntegration: (input?: Partial<ReactNavigationIntegra
554557
options: ReactNavigationIntegrationOptions;
555558
};
556559

560+
// @public
561+
export function resumeAppHangTracking(): void;
562+
557563
export { rewriteFramesIntegration }
558564

559565
export { Scope }

packages/core/ios/RNSentry.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,10 @@ + (SentryUser *_Nullable)userFrom:(NSDictionary *)userKeys
798798
// the 'tracesSampleRate' or 'tracesSampler' option.
799799
}
800800

801+
RCT_EXPORT_METHOD(pauseAppHangTracking) { [SentrySDKWrapper pauseAppHangTracking]; }
802+
803+
RCT_EXPORT_METHOD(resumeAppHangTracking) { [SentrySDKWrapper resumeAppHangTracking]; }
804+
801805
/**
802806
* Calls captureReplay on the native replay integration and returns
803807
* the BOOL result indicating whether the capture succeeded.

packages/core/ios/SentrySDKWrapper.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212

1313
+ (BOOL)crashedLastRun;
1414

15+
+ (void)pauseAppHangTracking;
16+
17+
+ (void)resumeAppHangTracking;
18+
1519
+ (BOOL)debug;
1620

1721
+ (NSString *)releaseName;

packages/core/ios/SentrySDKWrapper.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ + (BOOL)crashedLastRun
1818
return [SentrySDK crashedLastRun];
1919
}
2020

21+
+ (void)pauseAppHangTracking
22+
{
23+
[SentrySDK pauseAppHangTracking];
24+
}
25+
26+
+ (void)resumeAppHangTracking
27+
{
28+
[SentrySDK resumeAppHangTracking];
29+
}
30+
2131
+ (void)configureScope:(void (^)(SentryScope *scope))callback
2232
{
2333
[SentrySDK configureScope:callback];

packages/core/src/js/NativeRNSentry.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ export interface Spec extends TurboModule {
6060
encodeToBase64(data: number[]): Promise<string | undefined | null>;
6161
enableShakeDetection(): void;
6262
disableShakeDetection(): void;
63+
pauseAppHangTracking(): void;
64+
resumeAppHangTracking(): void;
6365
}
6466

6567
export type NativeStackFrame = {

packages/core/src/js/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,18 @@ export { SDK_NAME, SDK_VERSION } from './version';
9898
export type { ReactNativeOptions, NativeLogEntry } from './options';
9999
export { ReactNativeClient } from './client';
100100

101-
export { init, wrap, nativeCrash, flush, close, withScope, crashedLastRun, appLoaded } from './sdk';
101+
export {
102+
init,
103+
wrap,
104+
nativeCrash,
105+
flush,
106+
close,
107+
withScope,
108+
crashedLastRun,
109+
appLoaded,
110+
pauseAppHangTracking,
111+
resumeAppHangTracking,
112+
} from './sdk';
102113
export { TouchEventBoundary, withTouchEventBoundary } from './touchevents';
103114
export { GlobalErrorBoundary, withGlobalErrorBoundary } from './GlobalErrorBoundary';
104115
export type { GlobalErrorBoundaryProps } from './GlobalErrorBoundary';

0 commit comments

Comments
 (0)