Skip to content

Commit 087d777

Browse files
Merge pull request #5780 from Countly/crash-app-version
[SER-1600] [crashes] Process app version as string
2 parents 7a63ebc + 771c9c6 commit 087d777

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Fixes:
33
- [script] Fixing bug with "delete_old_members" script that led to malformed requests
44
- [core] Fixed bug where changing passwords results in the loss of the "Global Admin" role
5+
- [crash] Fixed bug in crash ingestion for scenarios where the "app version" is not a string.
56

67
## Version 24.05.17
78
Fixes:

plugins/crashes/api/api.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,9 @@ plugins.setConfigs("crashes", {
464464
}
465465
updateUser.hadAnyNonfatalCrash = report.ts;
466466
}
467+
if ('app_version' in report && typeof report.app_version !== 'string') {
468+
report.app_version += '';
469+
}
467470
let updateData = {$inc: {}};
468471
updateData.$inc["data.crashes"] = 1;
469472
if (Object.keys(updateUser).length) {

plugins/crashes/tests.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3091,6 +3091,35 @@ describe('Testing Crashes', function() {
30913091
});
30923092
});
30933093

3094+
describe('Crash app version', async() => {
3095+
it('should process crash app version as string', async() => {
3096+
const crashData = {
3097+
"_error": "error",
3098+
"_app_version": 123, // app version is number
3099+
"_os": "android",
3100+
};
3101+
3102+
await request.get('/i')
3103+
.query({ app_key: APP_KEY, device_id: DEVICE_ID, crash: JSON.stringify(crashData) })
3104+
.expect(200);
3105+
3106+
const crashGroupQuery = JSON.stringify({
3107+
latest_version: { $in: [`${crashData._app_version}`] },
3108+
});
3109+
let crashGroupResponse = await request
3110+
.get('/o')
3111+
.query({ method: 'crashes', api_key: API_KEY_ADMIN, app_id: APP_ID, query: crashGroupQuery });
3112+
const crashGroup = crashGroupResponse.body.aaData[0];
3113+
crashGroupResponse = await request
3114+
.get(`/o?`)
3115+
.query({ method: 'crashes', api_key: API_KEY_ADMIN, app_id: APP_ID, group: crashGroup._id });
3116+
3117+
const crash = crashGroupResponse.body.data[0];
3118+
3119+
crash.app_version.should.equal(`${crashData._app_version}`);
3120+
});
3121+
});
3122+
30943123
describe('Reset app', function() {
30953124
it('should reset data', function(done) {
30963125
var params = {app_id: APP_ID, period: "reset"};
@@ -3144,4 +3173,4 @@ describe('Testing Crashes', function() {
31443173
});
31453174
});
31463175
});
3147-
});
3176+
});

0 commit comments

Comments
 (0)