Skip to content

Commit 5b4c7f2

Browse files
Add new API APM.setNetworkEnabledIOS
1 parent 5ab29d8 commit 5b4c7f2

File tree

4 files changed

+56
-13
lines changed

4 files changed

+56
-13
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,23 @@ You can disable Repro Steps using the following API:
202202
Instabug.setReproStepsMode(Instabug.reproStepsMode.disabled);
203203
```
204204
205+
## APM
206+
207+
### Network metric is enabled by default. To disable it:
208+
209+
* #### In iOS:
210+
Call `APM.setNetworkEnabledIOS(false)`
211+
212+
* #### In Android:
213+
In build.gradle, set `networkInterceptingEnabled` to `false`
214+
```
215+
Instabug {
216+
APM {
217+
networkInterceptingEnabled false
218+
}
219+
}
220+
```
221+
205222
## Update Guide
206223
### Updating to versions 8.0-8.4.x
207224

ios/RNInstabug/InstabugReactBridge.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,12 @@
100100
- (void)logError:(NSString *)log;
101101
- (void)clearLogs;
102102

103+
/*
104+
+------------------------------------------------------------------------+
105+
| Network Logging |
106+
+------------------------------------------------------------------------+
107+
*/
108+
109+
- (void)setNetworkLoggingEnabled:(BOOL)isEnabled;
110+
103111
@end

ios/RNInstabug/InstabugReactBridge.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,14 @@ - (dispatch_queue_t)methodQueue {
339339
callback(@[[NSNumber numberWithBool:result]]);
340340
}
341341

342+
RCT_EXPORT_METHOD(setNetworkLoggingEnabled:(BOOL)isEnabled) {
343+
if(isEnabled) {
344+
IBGNetworkLogger.enabled = YES;
345+
} else {
346+
IBGNetworkLogger.enabled = NO;
347+
}
348+
}
349+
342350
RCT_EXPORT_METHOD(networkLog:(NSDictionary *) networkData) {
343351
NSString* url = networkData[@"url"];
344352
NSString* method = networkData[@"method"];

modules/APM.js

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,49 @@
11
import {
2-
NativeModules
2+
NativeModules,
3+
Platform,
34
} from 'react-native';
45
import Trace from '../models/Trace';
5-
let { IBGAPM } = NativeModules;
6+
let { Instabug, IBGAPM } = NativeModules;
7+
68

79
/**
810
* APM
911
* @exports APM
1012
*/
1113
export default {
12-
1314
/**
14-
* Enables and disables APM
15+
* Enables or disables APM
1516
* @param {boolean} isEnabled
1617
*/
1718
setEnabled(isEnabled) {
1819
IBGAPM.setEnabled(isEnabled);
1920
},
2021

2122
/**
22-
* Enables and disables App Launch
23-
* @param {boolean} isEnabled
24-
*/
23+
* Enables or disables APM App Launch
24+
* @param {boolean} isEnabled
25+
*/
2526
setAppLaunchEnabled(isEnabled) {
2627
IBGAPM.setEnabled(isEnabled);
2728
},
2829

2930
/**
30-
* Enables and disables App Launch
31-
* @param {boolean} isEnabled
32-
*/
31+
* Enables or disables APM Network Metric
32+
* @param {boolean} isEnabled
33+
*/
34+
setNetworkEnabledIOS(isEnabled) {
35+
if (Platform.OS === 'ios') {
36+
Instabug.setNetworkLoggingEnabled(isEnabled);
37+
}
38+
},
39+
40+
/**
41+
* Starts a custom trace
42+
* @param {string} name
43+
*/
3344
startTrace(name) {
34-
const id = Date.now() + "";
45+
const id = Date.now() + '';
3546
IBGAPM.startTrace(name, id);
3647
return new Trace(id, name);
3748
},
38-
39-
}
49+
};

0 commit comments

Comments
 (0)