Skip to content

Commit cdded3d

Browse files
committed
Update Sample App
Update sample app to provide exmaples for all use cases.
1 parent 6f1b313 commit cdded3d

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

IO.TrakerrClient/TrakerrClient.cs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static void SendToTrakerr(this Exception e, string classification = "issu
2929
{
3030
var client = new TrakerrClient();
3131

32-
client.SendEventAsync(client.CreateAppEvent(e, classification));
32+
client.SendEventAsync(client.CreateAppEvent(e, AppEvent.LogLevelEnum.Error, classification));
3333
}
3434
}
3535

@@ -121,14 +121,14 @@ public TrakerrClient(string apiKey = null, string contextAppVersion = null, stri
121121
{
122122
if (apiKey == null) apiKey = ConfigurationManager.AppSettings["trakerr.apiKey"];
123123
if (contextAppVersion == null) contextAppVersion = ConfigurationManager.AppSettings["trakerr.contextAppVersion"];
124-
if (contextDeploymentStage == null) contextDeploymentStage = ConfigurationManager.AppSettings["trakerr.eploymentStage"];
124+
if (contextDeploymentStage == null) contextDeploymentStage = ConfigurationManager.AppSettings["trakerr.deploymentStage"];
125125

126126
this.apiKey = apiKey;
127127
this.contextAppVersion = contextAppVersion;
128128
this.contextDeploymentStage = contextDeploymentStage;
129129

130130
this.contextEnvLanguage = contextEnvLanguage;
131-
this.contextEnvName = Type.GetType("Mono.Runtime") != null ? "Mono" : "Microsoft CLI";
131+
this.contextEnvName = Type.GetType("Mono.Runtime") != null ? "Mono" : "Microsoft CLR";
132132

133133
this.contextEnvVersion = null;
134134
Type type = Type.GetType("Mono.Runtime");
@@ -180,7 +180,7 @@ public TrakerrClient(string apiKey = null, string contextAppVersion = null, stri
180180
/// <summary>
181181
/// Use this to bootstrap a new AppEvent object with the supplied logLevel, classification, event type and message.
182182
/// </summary>
183-
/// <param name="logLevel">String representation of the level (Error/Warning/Info/Debug) of the error, defaults to "Error" if null or passed in something else.</param>
183+
/// <param name="logLevel">Level (Error/Warning/Info/Debug) of the error, defaults to "Error" if null or passed in something else.</param>
184184
/// <param name="classification">Optional extra string descriptor. Defaults to issue.</param>
185185
/// <param name="eventType">Type of event (eg. System.Exception), defaults to "unknonwn"</param>
186186
/// <param name="eventMessage">Message, defaults to "unknown"</param>
@@ -196,9 +196,9 @@ public AppEvent CreateAppEvent(AppEvent.LogLevelEnum logLevel = AppEvent.LogLeve
196196
/// <param name="exception">The Exception to use to create the new AppEvent</param>
197197
/// <param name="classification">Optional extra string descriptor. Defaults to issue.</param>
198198
/// <returns>Newly created AppEvent</returns>
199-
public AppEvent CreateAppEvent(Exception exception, string classification = "issue")
199+
public AppEvent CreateAppEvent(Exception exception, AppEvent.LogLevelEnum logLevel = AppEvent.LogLevelEnum.Error, string classification = "issue")
200200
{
201-
var exceptionEvent = CreateAppEvent(classification: classification, eventType: exception.GetType().ToString(), eventMessage: exception.Message);
201+
var exceptionEvent = CreateAppEvent(logLevel, classification, exception.GetType().ToString(), exception.Message);
202202

203203
exceptionEvent.EventStacktrace = EventTraceBuilder.GetEventTraces(exception);
204204

@@ -215,8 +215,8 @@ public void SendEvent(AppEvent appEvent)
215215
FillDefaults(appEvent);
216216

217217
var response = eventsApi.EventsPostWithHttpInfo(appEvent);
218-
Console.Error.WriteLine("Status Code:" + response.StatusCode);
219-
Console.Error.WriteLine(response.Data);
218+
/*Console.Error.WriteLine("Status Code:" + response.StatusCode);
219+
Console.Error.WriteLine(response.Data);Debug statements*/
220220
}
221221

222222
/// <summary>
@@ -229,10 +229,20 @@ public async void SendEventAsync(AppEvent appEvent)
229229
FillDefaults(appEvent);
230230

231231
var response = await eventsApi.EventsPostAsyncWithHttpInfo(appEvent);
232-
await Console.Error.WriteLineAsync("Status Code:" + response.StatusCode);
233-
await Console.Error.WriteLineAsync(response.Data.ToString());
232+
/*await Console.Error.WriteLineAsync("Status Code:" + response.StatusCode);
233+
await Console.Error.WriteLineAsync(response.Data.ToString());Debug statements*/
234234
}
235235

236+
/// <summary>
237+
/// Creates and sends an AppEvent to Trakerr with the provided Exception and other parameters
238+
/// </summary>
239+
/// <param name="e">Exception to send to Trakerr</param>
240+
/// <param name="logLevel">Level of the exception that you want to be registered to trakerr (Error/Warning/Info/Debug).</param>
241+
/// <param name="classification">Optional extra string descriptor. Defaults to issue.</param>
242+
public void SendException(Exception e, AppEvent.LogLevelEnum logLevel = AppEvent.LogLevelEnum.Error, string classification = "issue")
243+
{
244+
SendEventAsync(CreateAppEvent(e, logLevel, classification));
245+
}
236246

237247
/// <summary>
238248
/// Fills the default values for the properties.

TrakerrSampleApp/App.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
55
</startup>
66
<appSettings>
7-
<add key="trakerr.apiKey" value="b224233d1398d73d068f10a3a485060719967512097450" />
7+
<add key="trakerr.apiKey" value="YourAPIkeyhere" />
88
<add key="trakerr.url" value="https://www.trakerr.io/api/v1" />
99
<add key="trakerr.contextAppVersion" value="1.0" />
1010
<add key="trakerr.deploymentStage" value="development"/>

TrakerrSampleApp/TrakerrSampleApp.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
</None>
5656
</ItemGroup>
5757
<ItemGroup>
58+
<ProjectReference Include="..\generated\src\IO.Trakerr\IO.Trakerr.csproj">
59+
<Project>{BB542020-52A0-4488-862D-9232D4777DF4}</Project>
60+
<Name>IO.Trakerr</Name>
61+
</ProjectReference>
5862
<ProjectReference Include="..\IO.TrakerrClient\IO.TrakerrClient.csproj">
5963
<Project>{a0ee88dc-7890-453b-b0cd-0c5d92487188}</Project>
6064
<Name>IO.TrakerrClient</Name>

0 commit comments

Comments
 (0)