Skip to content

Commit bb00436

Browse files
authored
[Mob 3185]: Flutter API: sessionProfilerEnabled (#52)
1) Android API Mapping 2) IOS API Mapping 3) Flutter API Mapping 4) Adds tests for new API 5) updates Readme 6) updated Changelog
1 parent 2c4eec0 commit bb00436

File tree

7 files changed

+48
-2
lines changed

7 files changed

+48
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Master
2+
3+
* Adds setSessionProfilerEnabled API mapping.
4+
15
## Version 0.0.3 (2019-03-21)
26

37
* Divides the library into separate modules: (`Instabug`, `BugReporting`, `InstabugLog`).

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ The section below contains the APIs we're planning to implement for our 1.0 rele
4242
| `getUserAttributes()` | `getAllUserAttributes()`<br>`+ userAttributes:` |
4343
| `logUserEventWithName(String name)` | `logUserEvent(String name)`<br>`+ logUserEventWithName:` |
4444
| `show()` | `show()`<br>`+ show` |
45-
| | `setSessionProfilerState(Feature.State state)`<br>`sessionProfilerEnabled` |
45+
| `setSessionProfilerEnabled(bool sessionProfilerEnabled)` | `setSessionProfilerState(Feature.State state)`<br>`sessionProfilerEnabled` |
4646
| | `setPrimaryColor(@ColorInt int primaryColorValue)`<br>`tintColor` |
4747
| | `onReportSubmitHandler(Report.OnReportCreatedListener listener)`<br>`willSendReportHandler`. |
4848
| | `setUserData(String userData)`<br>`userData` |

android/src/main/java/com/instabug/instabugflutter/InstabugFlutterPlugin.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.instabug.bug.invocation.Option;
1010
import com.instabug.chat.Chats;
1111
import com.instabug.chat.Replies;
12+
import com.instabug.library.Feature;
1213
import com.instabug.library.Instabug;
1314
import com.instabug.library.InstabugColorTheme;
1415
import com.instabug.library.InstabugCustomTextPlaceHolder;
@@ -386,4 +387,17 @@ public static Method getMethod(Class clazz, String methodName, Class... paramete
386387
}
387388
return null;
388389
}
390+
391+
/**
392+
* Enable/disable session profiler
393+
*
394+
* @param sessionProfilerEnabled desired state of the session profiler feature
395+
*/
396+
public void setSessionProfilerEnabled(boolean sessionProfilerEnabled) {
397+
if (sessionProfilerEnabled) {
398+
Instabug.setSessionProfilerState(Feature.State.ENABLED);
399+
} else {
400+
Instabug.setSessionProfilerState(Feature.State.DISABLED);
401+
}
402+
}
389403
}

example/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class _MyAppState extends State<MyApp> {
5252
Instabug.logUserEventWithName('Aly Event');
5353
Instabug.setValueForStringWithKey('What\'s the problem', IBGCustomTextPlaceHolderKey.REPORT_BUG);
5454
Instabug.setValueForStringWithKey('Send some ideas', IBGCustomTextPlaceHolderKey.REPORT_FEEDBACK);
55-
55+
Instabug.setSessionProfilerEnabled(false);
5656
} on PlatformException {
5757
platformVersion = 'Failed to get platform version.';
5858
}

ios/Classes/InstabugFlutterPlugin.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,16 @@ + (void) setValue: (NSString*) value forStringWithKey: (NSString*) key {
289289
[Instabug setValue:value forStringWithKey:constants[key]];
290290
}
291291

292+
/**
293+
* Enable/disable session profiler
294+
*
295+
* @param sessionProfilerEnabled desired state of the session profiler feature
296+
*/
297+
+ (void) setSessionProfilerEnabled:(NSString*) sessionProfilerEnabled {
298+
BOOL boolValue = [sessionProfilerEnabled boolValue];
299+
[Instabug setSessionProfilerEnabled:boolValue];
300+
}
301+
292302
+ (NSDictionary *)constants {
293303
return @{
294304
@"InvocationEvent.shake": @(IBGInvocationEventShake),

lib/Instabug.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,13 @@ class Instabug {
203203
final List<dynamic> params = <dynamic>[value, key.toString()];
204204
await _channel.invokeMethod<Object>('setValue:forStringWithKey:', params);
205205
}
206+
207+
/// Enable/disable session profiler
208+
/// [sessionProfilerEnabled] desired state of the session profiler feature.
209+
static void setSessionProfilerEnabled(bool sessionProfilerEnabled) async {
210+
final List<dynamic> params = <dynamic>[sessionProfilerEnabled];
211+
await _channel.invokeMethod<Object>('setSessionProfilerEnabled:', params);
212+
}
206213
}
207214

208215

test/instabug_flutter_test.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,17 @@ test('startWithToken:invocationEvents: Test', () async {
283283
]);
284284
});
285285

286+
test('setSessionProfilerEnabled: Test', () async {
287+
const bool sessionProfilerEnabled = true;
288+
final List<dynamic> args = <dynamic>[sessionProfilerEnabled];
289+
Instabug.setSessionProfilerEnabled(sessionProfilerEnabled);
290+
expect(log, <Matcher>[
291+
isMethodCall('setSessionProfilerEnabled:',
292+
arguments: args,
293+
)
294+
]);
295+
});
296+
286297
}
287298

288299

0 commit comments

Comments
 (0)