Skip to content

Commit 432295e

Browse files
chore: add ios native APIs
1 parent 48fc00a commit 432295e

File tree

10 files changed

+59
-11
lines changed

10 files changed

+59
-11
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,6 @@ android/keystores/debug.keystore
6969

7070
# .idea run configurations
7171
/.run/*
72+
.yarn/
73+
examples/default/.yarn/
74+
examples/default/ios/.xcode.env.local

examples/default/ios/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ target 'InstabugExample' do
1515
config = use_native_modules!
1616
rn_maps_path = '../node_modules/react-native-maps'
1717
pod 'react-native-google-maps', :path => rn_maps_path
18-
18+
pod 'Instabug', :podspec => 'https://ios-releases.instabug.com/custom/faeture-screen_rendering-release/15.1.15/Instabug.podspec'
1919
# Flags change depending on the env values.
2020
flags = get_default_flags()
2121

examples/default/ios/Podfile.lock

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ PODS:
3131
- hermes-engine (0.75.4):
3232
- hermes-engine/Pre-built (= 0.75.4)
3333
- hermes-engine/Pre-built (0.75.4)
34-
- Instabug (15.1.1)
34+
- Instabug (15.1.15)
3535
- instabug-reactnative-ndk (0.1.0):
3636
- DoubleConversion
3737
- glog
@@ -1626,7 +1626,7 @@ PODS:
16261626
- ReactCommon/turbomodule/core
16271627
- Yoga
16281628
- RNInstabug (15.0.1):
1629-
- Instabug (= 15.1.1)
1629+
- Instabug (= 15.1.15)
16301630
- React-Core
16311631
- RNReanimated (3.16.1):
16321632
- DoubleConversion
@@ -1770,6 +1770,7 @@ DEPENDENCIES:
17701770
- fmt (from `../node_modules/react-native/third-party-podspecs/fmt.podspec`)
17711771
- glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`)
17721772
- hermes-engine (from `../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`)
1773+
- Instabug (from `https://ios-releases.instabug.com/custom/faeture-screen_rendering-release/15.1.15/Instabug.podspec`)
17731774
- instabug-reactnative-ndk (from `../node_modules/instabug-reactnative-ndk`)
17741775
- OCMock
17751776
- RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`)
@@ -1850,7 +1851,6 @@ SPEC REPOS:
18501851
trunk:
18511852
- Google-Maps-iOS-Utils
18521853
- GoogleMaps
1853-
- Instabug
18541854
- OCMock
18551855
- SocketRocket
18561856

@@ -1868,6 +1868,8 @@ EXTERNAL SOURCES:
18681868
hermes-engine:
18691869
:podspec: "../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec"
18701870
:tag: hermes-2024-08-15-RNv0.75.1-4b3bf912cc0f705b51b71ce1a5b8bd79b93a451b
1871+
Instabug:
1872+
:podspec: https://ios-releases.instabug.com/custom/faeture-screen_rendering-release/15.1.15/Instabug.podspec
18711873
instabug-reactnative-ndk:
18721874
:path: "../node_modules/instabug-reactnative-ndk"
18731875
RCT-Folly:
@@ -2022,7 +2024,7 @@ SPEC CHECKSUMS:
20222024
Google-Maps-iOS-Utils: f77eab4c4326d7e6a277f8e23a0232402731913a
20232025
GoogleMaps: 032f676450ba0779bd8ce16840690915f84e57ac
20242026
hermes-engine: ea92f60f37dba025e293cbe4b4a548fd26b610a0
2025-
Instabug: 3e7af445c14d7823fcdecba223f09b5f7c0c6ce1
2027+
Instabug: ed81d3e95f406f0e6d808e91a42dae929dfd4908
20262028
instabug-reactnative-ndk: d765ac289d56e8896398d02760d9abf2562fc641
20272029
OCMock: 589f2c84dacb1f5aaf6e4cec1f292551fe748e74
20282030
RCT-Folly: 4464f4d875961fce86008d45f4ecf6cef6de0740
@@ -2090,14 +2092,14 @@ SPEC CHECKSUMS:
20902092
ReactCommon: 6a952e50c2a4b694731d7682aaa6c79bc156e4ad
20912093
RNCClipboard: 2821ac938ef46f736a8de0c8814845dde2dcbdfb
20922094
RNGestureHandler: 511250b190a284388f9dd0d2e56c1df76f14cfb8
2093-
RNInstabug: f17d4e6c679fbc921f2692c223a1c21395589cc5
2095+
RNInstabug: fc1585dd6ede766139ab908b103d43efdcc8899a
20942096
RNReanimated: f42a5044d121d68e91680caacb0293f4274228eb
20952097
RNScreens: c7ceced6a8384cb9be5e7a5e88e9e714401fd958
20962098
RNSVG: 8b1a777d54096b8c2a0fd38fc9d5a454332bbb4d
20972099
RNVectorIcons: 6382277afab3c54658e9d555ee0faa7a37827136
20982100
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
2099-
Yoga: 055f92ad73f8c8600a93f0e25ac0b2344c3b07e6
2101+
Yoga: aa3df615739504eebb91925fc9c58b4922ea9a08
21002102

2101-
PODFILE CHECKSUM: 837b933596e1616ff02cc206bb17dee4f611fdbc
2103+
PODFILE CHECKSUM: 6bf2de63356e1cc43b55c746d85bc4d29167a520
21022104

2103-
COCOAPODS: 1.14.0
2105+
COCOAPODS: 1.15.2

examples/default/src/App.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { GestureHandlerRootView } from 'react-native-gesture-handler';
55
import { NavigationContainer, useNavigationContainerRef } from '@react-navigation/native';
66
import type { SessionMetadata } from 'instabug-reactnative';
77
import Instabug, {
8+
APM,
89
CrashReporting,
910
InvocationEvent,
1011
LaunchType,
@@ -69,7 +70,7 @@ export const App: React.FC = () => {
6970
networkData.url = `${networkData.url}/JS/Obfuscated`;
7071
return networkData;
7172
});
72-
// NetworkLogger.setRequestFilterExpression('false');
73+
APM.setScreenRenderEnabled(false);
7374
});
7475
});
7576

examples/default/src/screens/apm/APMScreen.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,31 @@ export const APMScreen: React.FC<NativeStackScreenProps<HomeStackParamList, 'APM
3737
<ListTile title="Flows" onPress={() => navigation.navigate('AppFlows')} />
3838
<ListTile title="WebViews" onPress={() => navigation.navigate('WebViews')} />
3939
<ListTile title="Complex Views" onPress={() => navigation.navigate('ComplexViews')} />
40+
41+
<ListTile
42+
title="Simulate Slow Frames"
43+
onPress={() => {
44+
// Simulate slow rendering
45+
const heavyComputation = () => {
46+
for (let i = 0; i < 1000000; i++) {
47+
Math.random() * Math.random();
48+
}
49+
};
50+
heavyComputation();
51+
showNotification('Slow Frames', 'Heavy computation executed to simulate slow frames');
52+
}}
53+
/>
54+
<ListTile
55+
title="Simulate Frozen Frames"
56+
onPress={() => {
57+
const freezeDuration = 3000; // 3 seconds
58+
const start = Date.now();
59+
while (Date.now() - start < freezeDuration) {
60+
// Busy wait to block JS thread
61+
}
62+
showNotification('Frozen Frames', `UI frozen for ${freezeDuration / 1000} seconds`);
63+
}}
64+
/>
4065
</Screen>
4166
);
4267
};

ios/RNInstabug/InstabugAPMBridge.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
- (void)startUITrace:(NSString *)name;
2222
- (void)endUITrace;
2323

24+
- (void)setScreenRenderEnabled:(BOOL)isEnabled;
25+
2426
extern NSMutableDictionary *traces;
2527

2628
@end

ios/RNInstabug/InstabugAPMBridge.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ - (id) init
8989
[IBGAPM endUITrace];
9090
}
9191

92+
// Enables or disables screen render.
93+
RCT_EXPORT_METHOD(setScreenRenderEnabled:(BOOL)isEnabled) {
94+
IBGAPM.screenRenderingEnabled = isEnabled;
95+
}
9296

9397

9498

ios/native.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$instabug = { :version => '15.1.1' }
1+
$instabug = { :version => '15.1.15' }
22

33
def use_instabug! (spec = nil)
44
version = $instabug[:version]

src/modules/APM.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,11 @@ export const endUITrace = () => {
115115
export const _ibgSleep = () => {
116116
NativeAPM.ibgSleep();
117117
};
118+
119+
/**
120+
* Enables or disables Screen Render feature
121+
* @param isEnabled
122+
*/
123+
export const setScreenRenderEnabled = (isEnabled: boolean) => {
124+
NativeAPM.setScreenRenderEnabled(isEnabled);
125+
};

src/native/NativeAPM.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ export interface ApmNativeModule extends NativeModule {
4444
startUITrace(name: string): void;
4545
endUITrace(): void;
4646
ibgSleep(): void;
47+
48+
// Screen Rendering //
49+
setScreenRenderEnabled(isEnabled: boolean): void;
4750
}
4851

4952
export const NativeAPM = NativeModules.IBGAPM;

0 commit comments

Comments
 (0)