Sentry-php: reporting to multiple projects

my main question: is it possible to make Sentry SDK route events to different DSNs / projects during runtime?

I’ve run into a problem when integrating the Sentry SDK into my employers codebase. On the backend, we have a fairly large system running on PHP. The system is deployed to a bunch of servers, and has a lot of configuration options and a few external API-integrations. In the case of misconfigurations, failed webservice calls etc., certain “high-level” errors are reported to our technical support staff, as they often can resolve these issues without involving the developers. Developers, on the other hand, are mostly concerned with the PHP errors / exceptions. To me, it makes sense to route PHP and these high-level errors to different projects, but I see no clear way of doing so without making ugly hacks.

You could configure the Environment property of sentry events depending on what “level” of error you encounter. Then technical support staff can filter issues in the dashboard on one environment, while developers filter on another.

Something like

SentrySdk.Init(o =>
    o.BeforeSend = @event =>
        @event.Environment = DetermineEnvironment(@event);
        return @event;

That’s for dotnet, but I imagine it is similar for other SDK’s.


I’m intending to use the environment property for marking errors from different staging steps, but it appears to be possible to do filtering based on tags as well. Still, I believe this solution defies the “philosophy” of having one project per service… I’ll add a JavaScript integration at a later stage; that will require a separate project / DSN. So, using the filtering approach, I’ll end up with 1 project for JS and 1 project for PHP and system errors.