Flare logo
Flare Laravel Error Tracking
  • Features
  • Pricing
  • Docs
  • Blog
  • Log in
  • Start tracking
FlareFlare Laravel Error Tracking
    Ctrl K

    1Flare

    • 1.1General
      • Welcome to Flare
      • Getting started
      • Working with errors
      • Working with error occurrences
      • AI powered solutions
      • Searching errors
      • Sharing errors
      • Spike protection
      • Error grouping
      • GitHub integration
      • Jira integration
      • GitLab integration
      • Linear integration
      • Using the API
    • 1.2Notifications
      • Configuring notifications
      • Mail
      • Slack
      • Telegram
      • SMS
      • Webhooks
      • Discord
      • Microsoft Teams

    2Laravel

    • 2.1General
      • Introduction
      • Installation
      • Censoring Collected Data
      • Ignoring Collected Data
      • Laravel Octane
    • 2.2Errors
      • Adding Custom Context
      • Customising Error Grouping
      • Handling Errors
      • Linking To Errors
      • Reporting Errors
      • Sending Logs To Flare
    • 2.3Performance
      • Introduction
      • Sampling
      • Limits
      • Modify Spans And Span Events
    • 2.4Data Collection
      • Application Info
      • Cache Events
      • Console Commands
      • Customise Error Report
      • Database Transactions
      • Dumps
      • Errors When Tracing
      • Exception Context
      • External Http Requests
      • Filesystem Operations
      • Git Information
      • Glows
      • Identifying Users
      • Jobs And Queues
      • Laravel Context
      • Livewire
      • Logs
      • Queries
      • Redis Commands
      • Requests
      • Server Info
      • Solutions
      • Spans
      • Stacktrace Arguments
      • Views
    • 2.5Older Packages
      • Laravel Flare V1
      • Ignition

    3PHP

    • 3.1General
      • Introduction
      • Installation
      • Censoring Collected Data
      • Ignoring Collected Data
    • 3.2Errors
      • Adding Custom Context
      • Customising Error Grouping
      • Handling Errors
      • Linking To Errors
      • Reporting Errors
    • 3.3Performance
      • Introduction
      • Sampling
      • Limits
      • Modify Spans And Events
    • 3.4Data Collection
      • Application Info
      • Application Lifecycle
      • Cache Events
      • Console Commands
      • Customise Error Report
      • Database Transactions
      • Dumps
      • Errors When Tracing
      • Exception Context
      • External Http Requests
      • Filesystem Operations
      • Git Information
      • Glows
      • Identifying Users
      • Logs
      • Queries
      • Redis Commands
      • Requests
      • Routing
      • Server Info
      • Solutions
      • Spans
      • Stacktrace Arguments
      • Views
    • 3.5Older Packages
      • Flare Client PHP V1

    4JavaScript

    • 4.1General
      • Installation
      • Framework integrations
      • Resolving Bundled Code
    • 4.2Errors
      • Reporting errors
      • Client hooks
    • 4.3Data Collection
      • Adding custom context
      • Adding glows
      • Solution Providers

    Adding custom context

    We already collect a lot of context about the environment to help you debug bugs, but if you feel like we're missing something or you can add some application-specific information, you can add some context of your own like this:

    import { flare } from '@flareapp/js';
    
    flare.addContext('version', '2.1.2');
    
    flare.addContext("vuex store content", {
        user: { name: "Adriaan", role: "admin" }
    });
    

    These will show up in the Generic context group in a report's Context tab.

    You can also add custom context groups:

    flare.addContextGroup("custom context group", {
        key: 0,
        anotherKey: "another value",
    });
    

    Or add a group that's handled by Flare (this info will show up in the User tab of the error occurrence UI in Flare):

    flare.addContextGroup("user", {
        email: "adriaan@spatie.be",
        name: "Adriaan",
        role: "admin",
    });
    

    Customizing the report before sending

    Sometimes you want to add in some extra context right as an error report is being created, or you might want to do the opposite and strip some context to protect your users' privacy even more. You can do this by using the beforeSubmit method of the client:

    import { flare } from '@flareapp/js';
    
    flare.beforeSubmit = report => {
        const editedReport = _.deepclone(report);
    
        // Hide a client's useragent
        editedReport.context.request.useragent = null;
    
        return editedReport;
    }
    

    You can also return a promise from this function:

    import { flare } from '@flareapp/js';
    
    flare.beforeSubmit = report => {
        return new Promise(resolve => {
            setTimeout(() => {
                resolve({ ...report, message: "Billing: " + message });
            }, 1000);
        });
    };
    

    If you want to stop a report from being sent to Flare, simply return false from this function:

    import { flare } from '@flareapp/js';
    
    flare.beforeSubmit = function(report) {
        // Some checks you want to do before sending a report, for example if a user is on IE
        const passedChecks = …;
    
        if (!passedChecks) {
            return false;
        }
    
        return report;
    }
    
    Next topic

    On this page

    • Customizing the report before sending
    Reduce your resolution time by tracking all your PHP and JavaScript exceptions using the most advanced Laravel Error Tracker out there.

    Product

    • Home
    • Features
    • Pricing
    • Support

    Resources

    • Blog
    • Changelog
    • Docs
    • Affiliate program
    • Ignition

    Platform

    • Log in
    • Start a free trial

    Social

    • X ↗


    • Service status
    • Terms of use
    • DPA
    • Privacy & cookie policy