countly-sdk-ios icon indicating copy to clipboard operation
countly-sdk-ios copied to clipboard

Ability to programmatically submit a feedback widget.

Open lhunath opened this issue 2 years ago • 2 comments

Feedback widgets are very useful for gauging the progression of the userbase's mood as the application evolves.

Regrettably, Countly currently only offers a locked-in flow for feedback widgets through a custom web view. This is not a great experience in most modern apps which prefer to keep the user both in their current flow and not interrupt their desired current activity, as well as keeping them in the app's design. Respect for branding is also an important factor.

For all of these reasons, it is important that developers have the flexibility to implement feedback in their own way, and Countly should supply an API for them to submit feedback garnered in whatever way developers deem best fitting with the product requirements and UX.

This PR exposes the following API:

- (void)submitFeedbackWidgetWithID:(NSString *)widgetID rating:(NSUInteger)rating
                           comment:(NSString * __nullable)comment email:(NSString * __nullable)email
                 completionHandler:(void (^)(NSError * __nullable error))completionHandler;

It tries to adopt the existing paradigms as much as possible. However, it is clear that there is plenty of room in the entire feedback functionality:

  • The shared NSURLSession is used, rather than Countly's own, which might have been configured differently by the user (URLSessionConfiguration), thus disrespecting this user preference.
  • Submission is only supported via GET requests. The endpoint does not support POST, thus disrespecting alwaysUsePOST.
  • Submitted queries do not include the checksum, thereby failing to perform the extra secretSalt security validation.
  • Submission is happening through a separate endpoint (/i/feedback rather than /i). This is counter to how other reserved events are submitted, such as the regular star rating. It also means we cannot use the traditional queue.
  • It might also make sense to expose star rating to programmatic submission, similar to this one.

lhunath avatar Nov 07 '21 17:11 lhunath

Thank you.

Nice points. This is actually an ongoing task, but details are not finalized yet. Star rating also. We will introduce this functionality most probably on one of the upcoming minor releases. But not sure if we can use your PR as is.

I will keep you informed once there is an update.

erkanyildiz avatar Nov 10 '21 14:11 erkanyildiz

Sure @erkanyildiz, it's here in case some of it is useful in accelerating your goals. I noticed there appears to be some (not yet complete/functional) code in place for loading widgets and then manually submitting them. Such a strongly typed (CountlyFeedbackWidget) approach to programmatic widget submission sounds even better; though it would be good to:

  1. Access the widget's details such as "header text", "comment title", "contact title", "submit label", "thank you text", "appearance details", "targeting details".
  2. Have a strongly typed API for submitting it, allowing me to specify the rating, comment & e-mail address, at least, directly, rather than through a custom dictionary.
- (void)recordResult:(NSDictionary * __nullable)result;

Thank you for your attention, I am trying out this functionality in production and it is incredibly useful!

lhunath avatar Nov 10 '21 15:11 lhunath

Hello, the SDK implements methods to report widgets manually. Thank you for your contribution.

ArtursKadikis avatar Oct 23 '23 10:10 ArtursKadikis