Skip to content

Commit fcee762

Browse files
Merge pull request #5875 from Countly/SER-2212-undefined-value-as-target-steps-while-editing-a-rating-widget
[star-rating] Fixed: Cannot parse JSON value in targeting.steps
2 parents d57b34b + 373e828 commit fcee762

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

plugins/star-rating/api/api.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,9 +722,15 @@ function uploadFile(myfile, id, callback) {
722722
if (!changes.targeting) {
723723
changes.targeting = {};
724724
}
725+
if (!changes.targeting.user_segmentation) {
726+
changes.targeting.user_segmentation = '{"query":{},"queryText":""}';
727+
}
728+
if (!changes.targeting.steps) {
729+
changes.targeting.steps = '[]';
730+
}
725731
changes.targeting.app_id = params.app_id + "";//has to be string
726732
// eslint-disable-next-line
727-
createCohort(params, type, widgetId, changes.targeting, function(cohortId) { //create cohort using this
733+
createCohort(params, type, widgetId, changes.targeting, function(cohortId) { //create cohort using this
728734
if (cohortId) {
729735
//update widget record to have this cohortId
730736
common.db.collection("feedback_widgets").findAndModify({ "_id": widgetId }, {}, { $set: { "cohortID": cohortId } }, function(/*err, widget*/) {

0 commit comments

Comments
 (0)