Skip to content
Snippets Groups Projects
Closed Wrap `createFlash` arguments in a object and add support for sentry
  • Wrap `createFlash` arguments in a object and add support for sentry

  • Closed Epic created by Ezekiel Kigbo

    Purpose

    Implementation of RFC gitlab-org/frontend/rfcs#63 (closed)

    We currently use createFlash pretty extensively through the codebase to display feedback to a user after some kind of action, including reporting errors. We have now also introduced Sentry js and are starting to make use of Sentry.captureException to capture errors.

    Solution

    1. Rename createFlash to oldCreateFlash and update all imports to import { oldCreateFlash as createFlash } from '~/flash'
    2. Add the new createFlash to the codebase, taking an object
    3. Each js and vue file that uses the current createFlash should be updated to use the new create flash function:
    • Update import:
    // Before
    import { oldCreateFlash as createFlash } from '~/flash'
    
    // After
    import createFlash from '~/flash'
    • Update the ordered arguments, with their named equivalents
    // Before
    ...
    .catch(error => {
      createFlash('Error message to display', 'warning');
    });
    
    // After
    .catch(error => {
      createFlash({ message: 'Error message to display', type: 'warning' });
    });
    1. For cases where we also capture the error in sentry, we should add the new captureError: true and error arguments
    // Before 
    ...
    .catch(e => {
      Sentry.captureException(e);
      createFlash(s__('OnDemandScans|Could not run the scan. Please try again.'));
    });
    
    // After
    ...
    .catch(e => {
      createFlash({ 
       message: s__('OnDemandScans|Could not run the scan. Please try again.'),
       captureError: true,
       error: e
      });
    });
    1. Remove the old createFlash method
    Edited by Dheeraj Joshi

    Linked items 0

  • Link items together to show that they're related or that one is blocking others.

    Activity

    • All activity
    • Comments only
    • History only
    • Newest first
    • Oldest first