Skip to content

Commit a95ed38

Browse files
committed
Notifications are just for production errors
1 parent a270b68 commit a95ed38

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

src/Server/Coderr.Server.ReportAnalyzer.Abstractions/Incidents/ReportAddedToIncident.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ protected ReportAddedToIncident()
3232
{
3333
}
3434

35+
36+
/// <summary>
37+
/// Which environment the error was received in.
38+
/// </summary>
39+
public string EnvironmentName { get; set; }
40+
3541
/// <summary>
3642
/// Incident that the report was added to.
3743
/// </summary>

src/Server/Coderr.Server.ReportAnalyzer/Inbound/Handlers/Reports/ReportAnalyzer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ await _repository.StoreReportStats(new ReportMapping()
190190
var e = new ReportAddedToIncident(summary, ConvertToCoreReport(report, applicationVersion), isReOpened)
191191
{
192192
IsNewIncident = isNewIncident,
193-
IsStored = storeReport
193+
IsStored = storeReport,
194+
EnvironmentName = report.EnvironmentName
194195
};
195196
await context.SendAsync(e);
196197

src/Server/Coderr.Server.ReportAnalyzer/UserNotifications/Handlers/CheckForNotificationsToSend.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,16 @@ public async Task HandleAsync(IMessageContext context, ReportAddedToIncident e)
5656
{
5757
if (setting.NewIncident != NotificationState.Disabled && e.IsNewIncident == true)
5858
{
59-
await CreateNotification(context, e, setting.AccountId, setting.NewIncident);
59+
if (e.EnvironmentName.Equals("production", StringComparison.OrdinalIgnoreCase) ||
60+
e.EnvironmentName.Equals("prod", StringComparison.OrdinalIgnoreCase)
61+
|| string.IsNullOrEmpty(e.EnvironmentName))
62+
{
63+
await CreateNotification(context, e, setting.AccountId, setting.NewIncident);
64+
}
65+
else
66+
{
67+
_log.Debug("Error was new, but not for the production environment: " + e.EnvironmentName);
68+
}
6069
}
6170
else if (setting.ReopenedIncident != NotificationState.Disabled && e.IsReOpened)
6271
{

src/Server/Coderr.Server.Web/ClientApp/components/manage/account/home/home.vue.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<div class="form-group">
1515
<h5>New incident</h5>
1616
<div>
17-
<p>Notify when a new incident have been received.</p>
17+
<p>Notify when a new incident have been received (only active for errors in your production environments).</p>
1818
</div>
1919
<div>
2020
<label v-if="applicationId">

0 commit comments

Comments
 (0)