Flare Error tracking made for Laravel
Features Pricing Docs Blog Log in Start free trial Free trial
  • Docs
  • Videos

Documentation

  • General

    • Welcome
    • Projects
    • Errors
    • Error occurrences
    • Using the API
    • Sharing error occurrences
    • Spike protection
    • GitHub integration
  • Ignition for Laravel

    • Installation
    • Configuration
    • Security
    • Controlling collected data
    • Sending logs to Flare
    • Linking to errors
    • Identifying users
    • Adding custom context
    • Adding glows
    • Writing custom middleware
  • Flare for generic PHP projects

    • Installation
    • Controlling collected data
    • Identifying users
    • Linking to errors
    • Adding custom context
    • Adding glows
    • Writing custom middleware
  • Javascript error tracking

    • Installation
    • Framework integrations
    • Resolving Bundled Code
    • Reporting errors
    • Client hooks
    • Adding custom context
    • Adding glows
    • Solution Providers
  • Solutions

    • Introduction
    • Adding custom solutions
    • Making solutions runnable
    • Using solution providers
    • Writing good solutions
  • Notifications

    • Configuring notifications
    • Mail
    • Slack
    • Telegram
    • SMS
    • Webhooks
    • Discord
    • Microsoft Teams
  • Team management

    • Using multiple teams
    • Subscribing to a plan
    • Receiving invoices
    • Managing team members
    • Inviting guests to projects

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/flare-client'; 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: "[email protected]", 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/flare-client'; 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/flare-client'; 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/flare-client'; 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; }
Previous topic Next topic

On this page

  • Customizing the report before sending

About Flare

  • Home
  • Features
  • Pricing
  • Support

Resources

  • Blog
  • Changelog
  • Docs
  • Ignition

App

  • Log in
  • Start free trial
SPATIE
  • Service status
  • Terms of use
  • Privacy & cookie policy