Last active
June 12, 2017 16:43
-
-
Save cdesch/e08275e85a3f27a7b1b481430e12f308 to your computer and use it in GitHub Desktop.
Rollbar.NET WPF Sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Configuration; | |
using System.Data; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using System.Windows; | |
using RollbarDotNet; | |
namespace Sample | |
{ | |
/// <summary> | |
/// Interaction logic for App.xaml | |
/// </summary> | |
public partial class App : Application | |
{ | |
protected override void OnStartup(StartupEventArgs e) | |
{ | |
base.OnStartup(e); | |
System.Diagnostics.Debug.WriteLine("App Start Up"); | |
//Initialize Rollbar | |
Rollbar.Init(new RollbarConfig | |
{ | |
AccessToken = "<your rollbar token>", | |
#if DEBUG | |
Environment = "development" | |
#else | |
Environment = "production" | |
#endif | |
}); | |
// Setup Exception Handler | |
AppDomain.CurrentDomain.UnhandledException += (sender, args) => | |
{ | |
Rollbar.Report(args.ExceptionObject as System.Exception); | |
}; | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO.Ports; | |
using System.Linq; | |
using System.Text; | |
using System.Text.RegularExpressions; | |
using System.Threading.Tasks; | |
using System.Windows; | |
using RollbarDotNet; | |
namespace Sample | |
{ | |
/// <summary> | |
/// Interaction logic for MainWindow.xaml | |
/// </summary> | |
public partial class MainWindow : Window | |
{ | |
public MainWindow() | |
{ | |
System.Diagnostics.Debug.Write("Starting MainWindow"); | |
InitializeComponent(); | |
//Set Default User for RollbarReporting | |
// -- Reset if user logins in or wait to call SetRollbarReportingUser until user logins in | |
SetRollbarReportingUser("id", "[email protected]", "default"); | |
} | |
private void SetRollbarReportingUser(string id, string email, string userName) | |
{ | |
Person person = new Person(id); | |
person.Email = email; | |
person.UserName = userName; | |
Rollbar.PersonData(() => person); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment