Skip to content

Instantly share code, notes, and snippets.

@cdesch
Last active June 12, 2017 16:43
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save cdesch/e08275e85a3f27a7b1b481430e12f308 to your computer and use it in GitHub Desktop.
Rollbar.NET WPF Sample
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);
};
}
}
}
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", "myEmail@example.com", "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