Skip to content

Commit

Permalink
Merge pull request #5780 from Countly/crash-app-version
Browse files Browse the repository at this point in the history
[SER-1600] [crashes] Process app version as string
  • Loading branch information
ArtursKadikis authored Nov 20, 2024
2 parents 7a63ebc + 771c9c6 commit 087d777
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Fixes:
- [script] Fixing bug with "delete_old_members" script that led to malformed requests
- [core] Fixed bug where changing passwords results in the loss of the "Global Admin" role
- [crash] Fixed bug in crash ingestion for scenarios where the "app version" is not a string.

## Version 24.05.17
Fixes:
Expand Down
3 changes: 3 additions & 0 deletions plugins/crashes/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,9 @@ plugins.setConfigs("crashes", {
}
updateUser.hadAnyNonfatalCrash = report.ts;
}
if ('app_version' in report && typeof report.app_version !== 'string') {
report.app_version += '';
}
let updateData = {$inc: {}};
updateData.$inc["data.crashes"] = 1;
if (Object.keys(updateUser).length) {
Expand Down
31 changes: 30 additions & 1 deletion plugins/crashes/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3091,6 +3091,35 @@ describe('Testing Crashes', function() {
});
});

describe('Crash app version', async() => {
it('should process crash app version as string', async() => {
const crashData = {
"_error": "error",
"_app_version": 123, // app version is number
"_os": "android",
};

await request.get('/i')
.query({ app_key: APP_KEY, device_id: DEVICE_ID, crash: JSON.stringify(crashData) })
.expect(200);

const crashGroupQuery = JSON.stringify({
latest_version: { $in: [`${crashData._app_version}`] },
});
let crashGroupResponse = await request
.get('/o')
.query({ method: 'crashes', api_key: API_KEY_ADMIN, app_id: APP_ID, query: crashGroupQuery });
const crashGroup = crashGroupResponse.body.aaData[0];
crashGroupResponse = await request
.get(`/o?`)
.query({ method: 'crashes', api_key: API_KEY_ADMIN, app_id: APP_ID, group: crashGroup._id });

const crash = crashGroupResponse.body.data[0];

crash.app_version.should.equal(`${crashData._app_version}`);
});
});

describe('Reset app', function() {
it('should reset data', function(done) {
var params = {app_id: APP_ID, period: "reset"};
Expand Down Expand Up @@ -3144,4 +3173,4 @@ describe('Testing Crashes', function() {
});
});
});
});
});

0 comments on commit 087d777

Please sign in to comment.