Skip to content

Commit d76e3d5

Browse files
authored
Merge pull request #35 from RoushTech/release/0.5.0
v0.5.0
2 parents e23fa9c + 104075c commit d76e3d5

25 files changed

+368
-57
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ src/RollbarDotNet/bin/
44
*.lock.json
55
test/RollbarDotNet.Tests/bin/
66
test/RollbarDotNet.Tests/obj/
7+
*.user

CHANGELOG.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,50 @@
1-
# v0.3.0
1+
# 0.5.0
2+
<sup>Released: TBD</sup>
3+
4+
## Features
5+
6+
- IHttpContextAccessor is no longer assumed to be included as part of `AddIdentity()`, we'll add it.
7+
- Testing of dependency injection for web platforms (console apps coming soon).
8+
- Switching to the use of `IOptions<RollbarOptions>` instead of `IConfigurationRoot`.
9+
- Testing for SendMessage calls.
10+
- Person record support (thank you mkdabrowski).
11+
- Exception builder is now injectable.
12+
13+
## Bug Fixes
14+
15+
- Sending a message to Rollbar no longer results in a null reference exception being thrown.
16+
17+
18+
# 0.4.0
19+
<sup>Released: 2016/9/30</sup>
20+
21+
## Features
22+
23+
- Upgrade for .NET Core 1.0 release.
24+
25+
# 0.3.0
226
<sup>Released: 2016/6/12</sup>
327

28+
## Features
29+
430
- Added support for cookies on request body.
531
- Added blacklisting variables by name.
632

7-
# v0.2.0
33+
# 0.2.0
834
<sup>Released: 2016/6/9</sup>
935

36+
## Features
37+
1038
- Rollbar message UUID available after error is reported.
1139
- Removed custom parameters from message body.
1240
- Documentation for required configuration variables
1341

1442

15-
# v0.1.0
43+
# 0.1.0
1644
<sup>Released: 2016/5/31</sup>
1745

1846
Initial release.
1947

48+
## Features
49+
2050
- Ability to send basic logs to Rollbar

Readme.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,19 @@ Place the following in your Startup.ConfigureServices section:
2424

2525
``` csharp
2626
services.AddRollbarWeb(Configuration);
27-
services.AddSingleton(Configuration); // Add IConfigurationRoot service.
2827
```
2928

3029
There is also one that doesn't load the builders for building out environment information for web servers (this will not attempt to crawl for server/client/request information):
3130

3231
``` csharp
3332
services.AddRollbar(Configuration);
34-
services.AddSingleton(Configuration); // Add IConfigurationRoot service.
33+
```
34+
35+
Hook up the rollar configuration using the following code:
36+
37+
``` csharp
38+
services.AddOptions(); // Most apps already are using this, but just in case.
39+
services.Configure<RollbarOptions>(options => Configuration.GetSection("Rollbar").Bind(options));
3540
```
3641

3742
Configure Rollbar from your appSettings.json file like so:
@@ -73,6 +78,34 @@ response.Uuid //Event UUID that can be looked up on the rollbar site.
7378
var response = await this.Rollbar.SendMessage("Hello World!", RollbarLevels.Message);
7479
```
7580

81+
# Calling Without Dependency Injection
82+
83+
Although I *highly recommend* using depdency injection, you can fairly easily configure Rollbar by hand:
84+
85+
``` csharp
86+
var rollbarOptions = Options.Create(new RollbarOptions
87+
{
88+
AccessToken = "token here",
89+
Environment = "development"
90+
});
91+
var rollbar = new Rollbar(
92+
new IBuilder[] {
93+
new ConfigurationBuilder(rollbarOptions),
94+
new EnvironmentBuilder(new SystemDateTime()), // SystemDateTime abstracts DateTime for mocking
95+
new NotifierBuilder()
96+
}
97+
);
98+
99+
try
100+
{
101+
throw new Exception("Testing");
102+
}
103+
catch(Exception exception)
104+
{
105+
await rollbar.SendException(exception); //Err... everything is async, keep that in mind.
106+
}
107+
```
108+
76109
# Blacklists
77110

78111
Blacklisting will replace variables with asterisks ("**********") when data is sent to Rollbar.

RollbarDotNet.sln

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
4-
VisualStudioVersion = 14.0.25123.0
4+
VisualStudioVersion = 14.0.25420.1
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{FBE55ED6-5E60-41F8-B5C0-7C97D04A1A6C}"
77
EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{04899B07-3768-4373-9CB8-1A0DBA28C035}"
99
ProjectSection(SolutionItems) = preProject
10+
CHANGELOG.md = CHANGELOG.md
1011
global.json = global.json
1112
LICENSE.txt = LICENSE.txt
1213
Readme.md = Readme.md

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"projects": [ "src", "test" ],
33
"sdk": {
4-
"version": "1.0.0-preview2-003121"
4+
"version": "1.0.0-preview2-003131"
55
}
66
}

src/RollbarDotNet/Blacklisters/ConfigurationBlacklister.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
public class ConfigurationBlacklister : IBlacklister
1010
{
11-
public ConfigurationBlacklister(IOptions<BlacklistConfiguration> config)
11+
public ConfigurationBlacklister(IOptions<RollbarOptions> config)
1212
{
13-
this.Configuration = config?.Value;
13+
this.Configuration = config?.Value?.Blacklist;
1414
this.RegexChecks = new List<Regex>();
1515
this.StringChecks = new List<string>();
1616
if (this.Configuration != null)

src/RollbarDotNet/Builder/ConfigurationBuilder.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
11
namespace RollbarDotNet.Builder
22
{
3-
using Microsoft.Extensions.Configuration;
3+
using Configuration;
4+
using Microsoft.Extensions.Options;
45
using Payloads;
56
using System;
67

78
public class ConfigurationBuilder : IBuilder
89
{
9-
public ConfigurationBuilder(IConfigurationRoot configuration)
10+
public ConfigurationBuilder(IOptions<RollbarOptions> configuration)
1011
{
11-
this.Configuration = configuration;
12+
this.Configuration = configuration.Value;
1213
}
1314

14-
protected IConfigurationRoot Configuration { get; set; }
15+
protected RollbarOptions Configuration { get; set; }
1516

1617
public void Execute(Payload payload)
1718
{
18-
payload.AccessToken = this.Configuration["Rollbar:AccessToken"];
19-
payload.Data.Environment = this.Configuration["Rollbar:Environment"];
19+
payload.AccessToken = this.Configuration.AccessToken;
20+
payload.Data.Environment = this.Configuration.Environment;
2021

2122
if(string.IsNullOrEmpty(payload.AccessToken))
2223
{
23-
throw new InvalidOperationException("Configuration variable Rollbar:AccessToken must be set.");
24+
throw new InvalidOperationException("Configuration variable for your Rollbar AccessToken must be set (did you include services.Configure<RollbarOptions>?).");
2425
}
2526

2627
if (string.IsNullOrEmpty(payload.Data.Environment))
2728
{
28-
throw new InvalidOperationException("Configuration variable Rollbar:Environment must be set.");
29+
throw new InvalidOperationException("Configuration variable for your Rollbar Environment must be set (did you include services.Configure<RollbarOptions>?).");
2930
}
3031
}
3132
}

src/RollbarDotNet/Builder/ExceptionBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System.Collections.Generic;
44
using Payloads;
55

6-
public class ExceptionBuilder
6+
public class ExceptionBuilder : IExceptionBuilder
77
{
88
public void Execute(Payload payload, System.Exception exception)
99
{

src/RollbarDotNet/Builder/IBuilder.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
namespace RollbarDotNet.Builder
22
{
33
using Payloads;
4-
using System.Threading.Tasks;
54

65
public interface IBuilder
76
{
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace RollbarDotNet.Builder
2+
{
3+
using Payloads;
4+
5+
public interface IExceptionBuilder
6+
{
7+
void Execute(Payload payload, System.Exception exception);
8+
}
9+
}

0 commit comments

Comments
 (0)