Skip to content

Commit

Permalink
Merge pull request #4027 from Cookiezaurs/master
Browse files Browse the repository at this point in the history
[bugfix][view] Views were not recorded in cases when in same request there was action with new view name.
  • Loading branch information
Cookiezaurs authored Mar 9, 2023
2 parents aab4ec7 + 7f18b6e commit b9bf592
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions plugins/views/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1462,6 +1462,9 @@ const escapedViewSegments = { "name": true, "segment": true, "height": true, "wi
options.upsert = false;
}
common.db.collection(collection).findAndModify(query, {}, update, options, function(err2, view2) {
if (err2) {
log.e(err);
}
if (view2 && view2.value) {
callback(err, view2.value);
common.readBatcher.invalidate(collection, query, {}, false);
Expand All @@ -1485,6 +1488,9 @@ const escapedViewSegments = { "name": true, "segment": true, "height": true, "wi
options.upsert = false;
}
common.db.collection(collection).findAndModify(query, {}, update, options, function(err, view) {
if (err) {
log.e(err);
}
if (view && view.value) {
callback(err, view.value);
}
Expand Down Expand Up @@ -1715,8 +1721,10 @@ const escapedViewSegments = { "name": true, "segment": true, "height": true, "wi
if (haveVisit) {
common.db.collection('app_userviews' + params.app_id).findOneAndUpdate({'_id': params.app_user.uid}, {$max: lastView}, {upsert: true, new: false, projection: projection}, function(err2, view2) {
for (let p = 0; p < results.length; p++) {
var currEvent = results[p];
recordMetrics(params, currEvent, params.app_user, view2 && view2.ok ? view2.value : null, viewInfo);
if (results[p]) {
var currEvent = results[p];
recordMetrics(params, currEvent, params.app_user, view2 && view2.ok ? view2.value : null, viewInfo);
}
}
});
}
Expand All @@ -1726,6 +1734,10 @@ const escapedViewSegments = { "name": true, "segment": true, "height": true, "wi
plugins.dispatch("/plugins/drill", {params: params, dbAppUser: params.app_user, events: runDrill});
}

}, function(onfail) {
log.e(JSON.stringify(onfail || ""));
}).catch(function(rejection) {
log.e(rejection);
});
resolve();
});
Expand Down Expand Up @@ -1803,6 +1815,9 @@ const escapedViewSegments = { "name": true, "segment": true, "height": true, "wi
currEvent.viewAlias = escapedMetricVal;
resolve(currEvent);
}
else {
resolve(false);
}
});
}
else if (currEvent.segmentation.view) {
Expand All @@ -1812,6 +1827,9 @@ const escapedViewSegments = { "name": true, "segment": true, "height": true, "wi
currEvent.viewAlias = common.db.encode(view._id + "");
resolve(currEvent);
}
else {
resolve(false);
}
});
}
else {
Expand Down

0 comments on commit b9bf592

Please sign in to comment.