Skip to content

Commit 55052a7

Browse files
chore: add ios native APIs
1 parent 5c8f2cf commit 55052a7

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

ios/RNInstabug/InstabugAPMBridge.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
- (void)startUITrace:(NSString *)name;
2828
- (void)endUITrace;
2929

30+
- (void)setScreenRenderEnabled:(BOOL)isEnabled;
31+
3032
extern NSMutableDictionary *traces;
3133

3234
@end

ios/RNInstabug/InstabugAPMBridge.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ - (id) init
124124
[IBGAPM endUITrace];
125125
}
126126

127+
// Enables or disables screen render.
128+
RCT_EXPORT_METHOD(setScreenRenderEnabled:(BOOL)isEnabled) {
129+
IBGAPM.screenRenderingEnabled = isEnabled;
130+
}
127131

128132

129133

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
@@ -139,3 +139,11 @@ export const endUITrace = () => {
139139
export const _ibgSleep = () => {
140140
NativeAPM.ibgSleep();
141141
};
142+
143+
/**
144+
* Enables or disables Screen Render feature
145+
* @param isEnabled
146+
*/
147+
export const setScreenRenderEnabled = (isEnabled: boolean) => {
148+
NativeAPM.setScreenRenderEnabled(isEnabled);
149+
};

src/native/NativeAPM.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ export interface ApmNativeModule extends NativeModule {
4848
startUITrace(name: string): void;
4949
endUITrace(): void;
5050
ibgSleep(): void;
51+
52+
// Screen Rendering //
53+
setScreenRenderEnabled(isEnabled: boolean): void;
5154
}
5255

5356
export const NativeAPM = NativeModules.IBGAPM;

0 commit comments

Comments
 (0)