Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ter-bridge into staging-np
  • Loading branch information
ijunaid committed Nov 2, 2023
2 parents ad12fef + a14d8d0 commit aabe526
Show file tree
Hide file tree
Showing 16 changed files with 278 additions and 48 deletions.
16 changes: 14 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
## 23.8.4
* Added a call to enroll users to A/B experiment with experiment ID : `testingEnrollIntoABExperiment:`
* Added a call to exit users from A/B experiment with experiment ID : `testingExitABExperiment:`

* Fixed the exit AB request failure issue on iOS.
* Updated underlying Android SDK version to 23.8.3
* Fixed 'null' value issue for experiment info variants.
* Fixed 'null' pointer error thrown when 'testingGetVariantsForKey' method is called with a key that does not exist.

* Updated underlying Android SDK version to 23.8.4
* Underlying iOS SDK version is 23.8.3

## 23.8.4-np
* Added a call to enroll users to A/B experiment with experiment ID : `testingEnrollIntoABExperiment:`
* Added a call to exit users from A/B experiment with experiment ID : `testingExitABExperiment:`

* Fixed the exit AB request failure issue on iOS.
* Updated underlying Android SDK version to 23.8.3
* Fixed 'null' value issue for experiment info variants.
* Fixed 'null' pointer error thrown when 'testingGetVariantsForKey' method is called with a key that does not exist.

* Updated underlying Android SDK version to 23.8.4
* Underlying iOS SDK version is 23.8.3

## 23.8.3
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ android {
}

dependencies {
implementation 'ly.count.android:sdk:23.8.3'
implementation 'ly.count.android:sdk:23.8.4'
}
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,10 @@ public void callback(RequestResult downloadResult, String error, boolean fullVal

String[] variants = Countly.sharedInstance().remoteConfig().testingGetVariantsForKey(key);

List<String> convertedVariants = Arrays.asList(variants); // TODO: Make better
List<String> convertedVariants = null;
if (variants != null) {
convertedVariants = Arrays.asList(variants);
}

result.success(convertedVariants);
} else if ("remoteConfigTestingGetAllVariants".equals(call.method)) {
Expand Down
2 changes: 1 addition & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'ly.count.android:sdk:23.8.3'
implementation 'ly.count.android:sdk:23.8.4'
implementation 'com.google.firebase:firebase-messaging:20.2.1'
implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0"))
}
Expand Down
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class _MyAppState extends State<MyApp> {
home: Scaffold(
appBar: AppBar(
flexibleSpace: Image(
image: AssetImage("assets/banner.png"),
image: AssetImage('assets/banner.png'),
fit: BoxFit.cover,
),
backgroundColor: Colors.transparent,
Expand Down
66 changes: 61 additions & 5 deletions example/lib/page_feedback_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class FeedbackWidgetsPage extends StatefulWidget {

class _FeedbackWidgetsPageState extends State<FeedbackWidgetsPage> {
final ratingIdController = TextEditingController();
final Random rnd = Random();

@override
void initState() {
Expand Down Expand Up @@ -108,6 +109,28 @@ class _FeedbackWidgetsPageState extends State<FeedbackWidgetsPage> {
}
}

Future<void> showRating() async {
FeedbackWidgetsResponse feedbackWidgetsResponse = await Countly.getAvailableFeedbackWidgets();
List<CountlyPresentableFeedback> widgets = feedbackWidgetsResponse.presentableFeedback;
String? error = feedbackWidgetsResponse.error;

if (error != null) {
print(error);
return;
}

for (CountlyPresentableFeedback widget in widgets) {
if (widget.type == 'rating') {
await Countly.presentFeedbackWidget(widget, 'Close', widgetShown: () {
print('Rating widget shown');
}, widgetClosed: () {
print('Rating widget closed');
});
break;
}
}
}

Future<void> reportSurveyManually() async {
FeedbackWidgetsResponse feedbackWidgetsResponse = await Countly.getAvailableFeedbackWidgets();
List<CountlyPresentableFeedback> widgets = feedbackWidgetsResponse.presentableFeedback;
Expand Down Expand Up @@ -138,7 +161,6 @@ class _FeedbackWidgetsPageState extends State<FeedbackWidgetsPage> {
List<dynamic>? questions = retrievedWidgetData['questions'];

if (questions != null) {
Random rnd = Random();
//iterate over all questions and set random answers
for (int a = 0; a < questions.length; a++) {
Map<dynamic, dynamic> question = questions[a];
Expand All @@ -155,7 +177,7 @@ class _FeedbackWidgetsPageState extends State<FeedbackWidgetsPage> {
if (b != 0) {
str += ',';
}
str += choices[b]['key'];
str += (choices[b] as Map)['key'];
}
}
segments[answerKey] = str;
Expand All @@ -165,11 +187,11 @@ class _FeedbackWidgetsPageState extends State<FeedbackWidgetsPage> {
case 'dropdown':
List<dynamic> choices = question['choices'];
int pick = rnd.nextInt(choices.length);
segments[answerKey] = choices[pick]['key']; //pick the key of random choice
segments[answerKey] = (choices[pick] as Map)['key']; //pick the key of random choice
break;
//text input field
case 'text':
segments[answerKey] = 'Some random text';
segments[answerKey] = 'Some random text${rnd.nextInt(999999)}';
break;
//rating picker
case 'rating':
Expand Down Expand Up @@ -207,7 +229,39 @@ class _FeedbackWidgetsPageState extends State<FeedbackWidgetsPage> {
void reportNPS(CountlyPresentableFeedback chosenWidget) {
Countly.getFeedbackWidgetData(chosenWidget, onFinished: (retrievedWidgetData, error) {
if (error == null) {
Map<String, Object> segments = {'rating': 3, 'comment': 'Filled out comment'};
print(retrievedWidgetData);
Map<String, Object> segments = {'rating': rnd.nextInt(10), 'comment': 'Filled out comment${rnd.nextInt(999999)}'};
Countly.reportFeedbackWidgetManually(chosenWidget, retrievedWidgetData, segments);
}
});
}

Future<void> reportRatingManually() async {
FeedbackWidgetsResponse feedbackWidgetsResponse = await Countly.getAvailableFeedbackWidgets();
List<CountlyPresentableFeedback> widgets = feedbackWidgetsResponse.presentableFeedback;
String? error = feedbackWidgetsResponse.error;

if (error != null) {
return;
}

CountlyPresentableFeedback? chosenWidget;
for (CountlyPresentableFeedback widget in widgets) {
if (widget.type == 'rating') {
chosenWidget = widget;
break;
}
}
if (chosenWidget != null) {
reportRating(chosenWidget);
}
}

void reportRating(CountlyPresentableFeedback chosenWidget) {
Countly.getFeedbackWidgetData(chosenWidget, onFinished: (retrievedWidgetData, error) {
if (error == null) {
print(retrievedWidgetData);
Map<String, Object> segments = {'rating': rnd.nextInt(6), 'comment': 'Filled out comment${rnd.nextInt(999999)}', 'email': 'test${rnd.nextInt(999999)}@yahoo.com'};
Countly.reportFeedbackWidgetManually(chosenWidget, retrievedWidgetData, segments);
}
});
Expand Down Expand Up @@ -236,9 +290,11 @@ class _FeedbackWidgetsPageState extends State<FeedbackWidgetsPage> {
MyButton(text: 'Show Rating using EditBox', color: 'orange', onPressed: ratingIdController.text.isNotEmpty ? presentRatingWidgetUsingEditBox : null),
MyButton(text: 'Show Survey', color: 'orange', onPressed: showSurvey),
MyButton(text: 'Show NPS', color: 'orange', onPressed: showNPS),
MyButton(text: 'Show Rating', color: 'orange', onPressed: showRating),
MyButton(text: 'Show Feedback Widget', color: 'orange', onPressed: showFeedbackWidget),
MyButton(text: 'Report Survey Manually', color: 'orange', onPressed: reportSurveyManually),
MyButton(text: 'Report NPS Manually', color: 'orange', onPressed: reportNPSManually),
MyButton(text: 'Report Rating Manually', color: 'orange', onPressed: reportRatingManually),
],
)),
),
Expand Down
Loading

0 comments on commit aabe526

Please sign in to comment.