Skip to content

Commit 9044a9c

Browse files
authored
[Mob 3188] - Flutter API: userData (#54)
Android API Mapping IOS API Mapping Flutter API Mapping Adds tests for new API updates Readme updated Changelog Changed setPrimaryColor and setSessionProfilerEnabled to use NSNumber instead of NSString
1 parent 748eb40 commit 9044a9c

File tree

7 files changed

+42
-4
lines changed

7 files changed

+42
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## Master
22

3+
* Adds setUserData API mapping.
34
* Adds setPrimaryColor API mapping.
45
* Adds setSessionProfilerEnabled API mapping.
56

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ The section below contains the APIs we're planning to implement for our 1.0 rele
4545
| `setSessionProfilerEnabled(bool sessionProfilerEnabled)` | `setSessionProfilerState(Feature.State state)`<br>`sessionProfilerEnabled` |
4646
|`setPrimaryColor(Color color)` | `setPrimaryColor(@ColorInt int primaryColorValue)`<br>`tintColor` |
4747
| | `onReportSubmitHandler(Report.OnReportCreatedListener listener)`<br>`willSendReportHandler`. |
48-
| | `setUserData(String userData)`<br>`userData` |
48+
|`setUserData(String userData)` | `setUserData(String userData)`<br>`userData` |
4949
| | `addFileAttachment(Uri fileUri, String fileNameWithExtension)`<br>`+ addFileAttachmentWithURL:` |
5050
| | `addFileAttachment(byte[] data, String fileNameWithExtension)` `+ addFileAttachmentWithData:` |
5151
| | `clearFileAttachment()`<br>`+ clearFileAttachments` |

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,4 +414,13 @@ public void run() {
414414
}
415415
});
416416
}
417+
418+
/**
419+
* Adds specific user data that you need to be added to the reports
420+
*
421+
* @param userData
422+
*/
423+
public void setUserData(String userData) {
424+
Instabug.setUserData(userData);
425+
}
417426
}

example/lib/main.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class _MyAppState extends State<MyApp> {
5656
Color c = const Color.fromRGBO(255, 0, 255, 1.0);
5757
Color c = const Color.fromRGBO(255, 0, 0, 1.0);
5858
Instabug.setPrimaryColor(c);
59+
Instabug.setUserData("This is some useful data");
5960
} on PlatformException {
6061
platformVersion = 'Failed to get platform version.';
6162
}

ios/Classes/InstabugFlutterPlugin.m

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ + (void) setValue: (NSString*) value forStringWithKey: (NSString*) key {
296296
*
297297
* @param sessionProfilerEnabled desired state of the session profiler feature
298298
*/
299-
+ (void) setSessionProfilerEnabled:(NSString*) sessionProfilerEnabled {
299+
+ (void)setSessionProfilerEnabled:(NSNumber *)sessionProfilerEnabled {
300300
BOOL boolValue = [sessionProfilerEnabled boolValue];
301301
[Instabug setSessionProfilerEnabled:boolValue];
302302
}
@@ -306,8 +306,17 @@ + (void) setSessionProfilerEnabled:(NSString*) sessionProfilerEnabled {
306306
*
307307
* @param color The value of the primary color
308308
*/
309-
+ (void) setPrimaryColor:(NSString*) color {
310-
Instabug.tintColor = UIColorFromRGB([color longLongValue]);
309+
+ (void)setPrimaryColor:(NSNumber *)color {
310+
Instabug.tintColor = UIColorFromRGB([color longValue]);
311+
}
312+
313+
/**
314+
* Adds specific user data that you need to be added to the reports
315+
*
316+
* @param userData
317+
*/
318+
+ (void)setUserData:(NSString *)userData {
319+
[Instabug setUserData:userData];
311320
}
312321

313322

lib/Instabug.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,13 @@ class Instabug {
220220
await _channel.invokeMethod<Object>('setPrimaryColor:', params);
221221
}
222222

223+
/// Adds specific user data that you need to be added to the reports
224+
/// [userData] data to be added
225+
static void setUserData(String userData) async {
226+
final List<dynamic> params = <dynamic>[userData];
227+
await _channel.invokeMethod<Object>('setUserData:', params);
228+
}
229+
223230
}
224231

225232

test/instabug_flutter_test.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,17 @@ test('startWithToken:invocationEvents: Test', () async {
306306
]);
307307
});
308308

309+
test('setUserData: Test', () async {
310+
String s = "This is a String";
311+
final List<dynamic> args = <dynamic>[s];
312+
Instabug.setUserData(s);
313+
expect(log, <Matcher>[
314+
isMethodCall('setUserData:',
315+
arguments: args,
316+
)
317+
]);
318+
});
319+
309320
}
310321

311322

0 commit comments

Comments
 (0)