From 373e82803905ff929c5cdc0f252bde9ff82f5a4e Mon Sep 17 00:00:00 2001 From: Cihad Tekin Date: Wed, 18 Dec 2024 22:06:58 +0300 Subject: [PATCH] [star-rating] Fixed: Cannot parse JSON value in targeting.steps --- plugins/star-rating/api/api.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/star-rating/api/api.js b/plugins/star-rating/api/api.js index 4bf19ef7524..619eed4bc30 100644 --- a/plugins/star-rating/api/api.js +++ b/plugins/star-rating/api/api.js @@ -722,9 +722,15 @@ function uploadFile(myfile, id, callback) { if (!changes.targeting) { changes.targeting = {}; } + if (!changes.targeting.user_segmentation) { + changes.targeting.user_segmentation = '{"query":{},"queryText":""}'; + } + if (!changes.targeting.steps) { + changes.targeting.steps = '[]'; + } changes.targeting.app_id = params.app_id + "";//has to be string // eslint-disable-next-line - createCohort(params, type, widgetId, changes.targeting, function(cohortId) { //create cohort using this + createCohort(params, type, widgetId, changes.targeting, function(cohortId) { //create cohort using this if (cohortId) { //update widget record to have this cohortId common.db.collection("feedback_widgets").findAndModify({ "_id": widgetId }, {}, { $set: { "cohortID": cohortId } }, function(/*err, widget*/) {