Skip to content

Commit 286f4dd

Browse files
committed
✨ Add setSessionProfilerEnabled API for Android and iOS
1 parent a0600f8 commit 286f4dd

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ android {
2222
dependencies {
2323
compile 'com.facebook.react:react-native:0.20.+'
2424
compile ('com.instabug.library:instabug:4.13.0'){
25-
exclude group: 'com.android.support'
25+
exclude group: 'com.android.support:appcompat-v7'
2626
}
2727

2828
}

android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,6 +1359,24 @@ public void setEnableInAppNotificationSound(boolean shouldPlaySound) {
13591359
}
13601360
}
13611361

1362+
/**
1363+
* Enable/disable session profiler
1364+
*
1365+
* @param sessionProfilerEnabled desired state of the session profiler feature
1366+
*/
1367+
@ReactMethod
1368+
public void setSessionProfilerEnabled(boolean sessionProfilerEnabled) {
1369+
try {
1370+
if(sessionProfilerEnabled) {
1371+
Instabug.setSessionProfilerState(Feature.State.ENABLED);
1372+
} else {
1373+
Instabug.setSessionProfilerState(Feature.State.DISABLED);
1374+
}
1375+
} catch (Exception e) {
1376+
e.printStackTrace();
1377+
}
1378+
}
1379+
13621380
private InstabugCustomTextPlaceHolder.Key getStringToKeyConstant(String key) {
13631381
switch (key) {
13641382
case SHAKE_HINT:

index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,16 @@ module.exports = {
146146
Instabug.hasRespondedToSurveyWithToken(surveyToken, surveyTokenCallback);
147147
},
148148

149+
/**
150+
* The session profiler is enabled by default and it attaches to the bug and
151+
* crash reports the following information during the last 60 seconds before the report is sent.
152+
* @param {boolean} sessionProfilerEnabled - A boolean parameter to enable or disable the feature.
153+
*
154+
*/
155+
setSessionProfilerEnabled: function (sessionProfilerEnabled) {
156+
Instabug.setSessionProfilerEnabled(sessionProfilerEnabled);
157+
},
158+
149159
/**
150160
* Sets a block of code to be executed just before the SDK's UI is presented.
151161
* This block is executed on the UI thread. Could be used for performing any

ios/RNInstabug/InstabugReactBridge.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,10 @@ - (dispatch_queue_t)methodQueue {
377377
[Instabug setThresholdForReshowingSurveyAfterDismiss:sessionCount daysCount:daysCount];
378378
}
379379

380+
RCT_EXPORT_METHOD(setSessionProfilerEnabled:(BOOL)sessionProfilerEnabled) {
381+
[Instabug setSessionProfilerEnabled:sessionProfilerEnabled];
382+
}
383+
380384
RCT_EXPORT_METHOD(isRunningLive:(RCTResponseSenderBlock)callback) {
381385
BOOL result = NO;
382386
#if TARGET_OS_SIMULATOR

0 commit comments

Comments
 (0)