Summary: This diff updates the check which triggers crash notifications. We got a user feedback that crash reporter used to report non fatal crash too and it used to annoy users with bombardment of crash notifications. Reviewed By: passy Differential Revision: D13878272 fbshipit-source-id: 75446f08f806e8f28a6f68953c0a001fd18a7dc0
74 lines
2.7 KiB
JavaScript
74 lines
2.7 KiB
JavaScript
/**
|
|
* Copyright 2018-present Facebook.
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
* @format
|
|
*/
|
|
import {shouldParseAndroidLog} from '../crashReporterUtility.js';
|
|
import type {DeviceLogEntry, LogLevel} from 'flipper';
|
|
|
|
function getAndroidLog(
|
|
date: Date,
|
|
type: LogLevel,
|
|
tag: string,
|
|
message: string,
|
|
): DeviceLogEntry {
|
|
return {date, type, tag, message, app: 'testapp', pid: 0, tid: 0};
|
|
}
|
|
|
|
test('test shouldParseAndroidLog function for type error and tag is AndroidRuntime', () => {
|
|
const referenceDate = new Date();
|
|
let log: DeviceLogEntry = getAndroidLog(
|
|
new Date(referenceDate.getTime() + 10000), //This log arrives 10 secs after the refernce time
|
|
'error',
|
|
'AndroidRuntime',
|
|
'Possible runtime crash',
|
|
);
|
|
let shouldParseTheLog = shouldParseAndroidLog(log, referenceDate);
|
|
expect(shouldParseTheLog).toEqual(true);
|
|
});
|
|
test('test shouldParseAndroidLog function for type non-error', () => {
|
|
const referenceDate = new Date();
|
|
let log: DeviceLogEntry = getAndroidLog(
|
|
new Date(referenceDate.getTime() + 10000), //This log arrives 10 secs after the refernce time
|
|
'debug',
|
|
'fb4a.activitymanager',
|
|
'Possible debug info in activitymanager',
|
|
);
|
|
let shouldParseTheLog = shouldParseAndroidLog(log, referenceDate);
|
|
expect(shouldParseTheLog).toEqual(false);
|
|
});
|
|
test('test shouldParseAndroidLog function for the older android log', () => {
|
|
const referenceDate = new Date();
|
|
let log: DeviceLogEntry = getAndroidLog(
|
|
new Date(referenceDate.getTime() - 10000), //This log arrives 10 secs before the refernce time
|
|
'error',
|
|
'fb4a.activitymanager',
|
|
'Possible error info in activitymanager',
|
|
);
|
|
let shouldParseTheLog = shouldParseAndroidLog(log, referenceDate);
|
|
expect(shouldParseTheLog).toEqual(false);
|
|
});
|
|
test('test shouldParseAndroidLog function for the fatal log', () => {
|
|
const referenceDate = new Date();
|
|
let log: DeviceLogEntry = getAndroidLog(
|
|
new Date(referenceDate.getTime() + 10000), //This log arrives 10 secs after the refernce time
|
|
'fatal',
|
|
'arbitrary tag',
|
|
'Possible error info in activitymanager',
|
|
);
|
|
let shouldParseTheLog = shouldParseAndroidLog(log, referenceDate);
|
|
expect(shouldParseTheLog).toEqual(true);
|
|
});
|
|
test('test shouldParseAndroidLog function for the error log which does not staisfy our tags check', () => {
|
|
const referenceDate = new Date();
|
|
let log: DeviceLogEntry = getAndroidLog(
|
|
new Date(referenceDate.getTime() + 10000), //This log arrives 10 secs after the refernce time
|
|
'error',
|
|
'arbitrary tag',
|
|
'Possible error info in fb4a',
|
|
);
|
|
let shouldParseTheLog = shouldParseAndroidLog(log, referenceDate);
|
|
expect(shouldParseTheLog).toEqual(false);
|
|
});
|