Crash-crash, sayang. Pemantauan otomatis kesalahan fatal aplikasi seluler

Halo! Nama saya Dmitry, saya insinyur rilis di tim Kecepatan CI / CD Avito. Selama beberapa tahun, saya dan kolega saya telah bertanggung jawab atas segala hal yang berkaitan dengan rilis aplikasi seluler kami dan tidak hanya. Terakhir kali saya berbicara tentang sistem rilis aplikasi seluler berbasis kontrak kami . Hari ini kita akan berbicara tentang bagaimana kita mengotomatiskan pengumpulan informasi dari Firebase tentang kesalahan fatal baru dalam aplikasi seluler.





Bermasalah



  .     .  , .



,   , Fabric,   vadimsmal YourDestiny Fabricio.     , Jira-   ,  Git-Blame    c -.



  Google Fabric,   Firebase, .



,   .   ,  Firebase API   , .





Google Cloud Functions



  ,  â€”     .



Firebase  Google Cloud Functions . serverless FaaS  Google,   Google.  Firebase-Crashlytics   (  deprecated). call-back     crashlytics- .  â€” “onNew”( crashlytics) “onVelocityAlert” ( crashlytics).





  . Firebase-Google Cloud Functions,   , .  ,  JS  Google Cloud:



const functions = require('firebase-functions');
const rp = require('request-promise');

function sendEvent(event) {
    return rp({
        method: 'POST',
        uri: functions.config().crashlytics.crash_collector_url,
        body: event,
        json: true,
    });
}

exports.NewIssueEvent = functions.crashlytics.issue().onNew(async (issue) => {
    await processEvent(issue, 'NewIssueEvent')
});

exports.RegressedEvent = functions.crashlytics.issue().onRegressed(async (issue) => {await processEvent(issue, 'RegressedEvent')});

exports.VelocityAlertEvent = functions.crashlytics.issue().onVelocityAlert(async (issue) => {await processEvent(issue, 'VelocityAlertEvent')});

const processEvent = async (event, type) =>{
    if (isActualEvent(event)) {
        await sendEvent(event);
        console.log(`Posted ${type} ${event.issueId} successfully to crash collector`);
    }
    else{
        console.log(`It's old event or not Avito. Do nothing`);
    }
}

const isActualEvent = (event) =>{
    const {appInfo} = event;
    const {appName, latestAppVersion} = appInfo;
    const version = latestAppVersion &&  parseFloat(latestAppVersion.split(' ')[0]);
    console.log(`Event appName: ${appName} version: ${version}`);
    return appName === 'Avito' && version > 60.0
}


, ,  , .



  .  Firebase-Crashlytics fatal ( -) non-fatal ( crashlytics).     “onNew” ,   -   ,   .



BigQuery



Google  Firebase  BigQuery. BigQuery â€” ,   .   2019  c Firebase â€” Batch Table.



:



  1.  ,   , .
  2.  â€” fatal non-fatal.
  3. ,   ( ) .


:





   BigQuery : , .  BigQuery   , .    â€”   17:00,    Firebase-Crashlytics  BigQuery ,   :



SELECT issue_id, is_fatal, COUNT(*) as crashes_counter, 
COUNT(DISTINCT installation_uuid) AS affected_users 
FROM `android.firebase_crashlytics.{table}` 
WHERE issue_id in ( {issues_id_string} ) 
GROUP BY issue_id, is_fatal 
LIMIT 1000


,  . , , ,   - “onVelocityAlert”  Google Cloud Function.       ,   N   .   “onVelocityAlert” ,  Google,   ,   .





  «» , .   VelocityAlert   Firebase-Crashlytics .   Firebase   -,   VelocityAlert. , .  , ,    .   .



  VelocityAlert  . ,    VelocityAlert   .



:







  . .



,  Fabric    :



  1.  Git-Blame.
  2.  .
  3.   -.


   â€”  Git-Blame.  ,   Jira,   ,  Git-Blame , .   , .



  Nupokati.   ,      BigQuery,    â€”  â€” daily report     .





  daily report



    , .  , , ,   .



daily report VelocityAlert      -   .   , ,   .





Google Cloud Functions



  . ,  Firebase . , Firebase-crashlytics Google Cloud Functions deprecated 1  2020 .   .     .





Cloud Functions    BigQuery. : daily report, velocityAlerts,   -.     .



SELECT 
issue_id, 
issue_title, 
is_fatal, 
COUNT(issue_id) as crashes_counter, 
ARRAY_AGG (distinct application.display_version) AS versions, 
COUNT(DISTINCT installation_uuid) AS affected_users 
FROM `android.firebase_crashlytics.{table}`
WHERE is_fatal=true 
GROUP BY issue_title, issue_id, is_fatal 
HAVING ARRAY_LENGTH(versions)=1 AND "{version}" in UNNEST(versions)
ORDER BY crashes_counter DESC




.   Firebase  .     .        BigQuery , .



, :



  • BigQuery , ,   .
  •  BigQuery. ,   .
  •      BigQuery ,  .     .
  • BigQuery streaming.   .
  •  Google Cloud Platform.   .



All Articles