Skip to content

Commit

Permalink
Add an optional email field to the bug report view
Browse files Browse the repository at this point in the history
Fixes #28
  • Loading branch information
flagbug committed Mar 12, 2014
1 parent 7a2ec8d commit e7b6059
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
20 changes: 18 additions & 2 deletions Espera/Espera.Core/Analytics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,18 @@ public async Task InitializeAsync(CoreSettings settings)
}
}

public async Task<bool> RecordBugReportAsync(string message)
public async Task<bool> RecordBugReportAsync(string message, string email)
{
await this.AwaitAuthenticationAsync();

if (!this.isAuthenticated)
return false;

if (!String.IsNullOrWhiteSpace(email))
{
await UpdateUserEmailAsync(this.user, email);
}

string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();

string logId = await this.SendLogFileAsync();
Expand All @@ -94,13 +99,18 @@ public async Task<bool> RecordBugReportAsync(string message)
return true;
}

public async Task<bool> RecordCrashAsync(Exception exception)
public async Task<bool> RecordCrashAsync(Exception exception, string email)
{
await this.AwaitAuthenticationAsync();

if (!this.isAuthenticated)
return false;

if (!String.IsNullOrWhiteSpace(email))
{
await UpdateUserEmailAsync(this.user, email);
}

string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();

string logId = await this.SendLogFileAsync();
Expand Down Expand Up @@ -147,6 +157,12 @@ public async Task RecordMobileUsage()
}
}

private static async Task UpdateUserEmailAsync(AuthenticatedUser user, string email)
{
await user.UpdateAsync(user.Email, String.Empty, user.Gender, user.Age, email, // email is the only field we change here
user.Status, user.LocationFuzzing, user.CelebrityMode, user.ApplicationTag);
}

private async Task AwaitAuthenticationAsync()
{
if (this.isAuthenticated)
Expand Down
4 changes: 3 additions & 1 deletion Espera/Espera.View/ViewModels/BugReportViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ public BugReportViewModel()
.ToCommand();

this.sendingSucceeded = this.SubmitBugReport
.RegisterAsyncTask(x => Analytics.Instance.RecordBugReportAsync(this.Message))
.RegisterAsyncTask(x => Analytics.Instance.RecordBugReportAsync(this.Message, this.Email))
.Select(x => new bool?(x))
.ToProperty(this, x => x.SendingSucceeded);
}

public string Email { get; set; }

public string Message
{
get { return this.message; }
Expand Down
8 changes: 6 additions & 2 deletions Espera/Espera.View/Views/BugReportView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
Title="Bug report"
Width="600"
Height="400"
Height="430"
ResizeMode="NoResize">
<Window.Resources>
<ResourceDictionary>
Expand All @@ -27,10 +27,14 @@
<StackPanel Margin="10" Orientation="Vertical">
<TextBlock Style="{StaticResource DescriptionHeaderStyle}" Text="Report a bug" />
<TextBlock Style="{StaticResource DescriptionHeaderStyle2}" Text="You can send a bug report to help improving Espera" />
<DockPanel Margin="0, 10, 0, 0">
<TextBlock Text="Email (optional)" VerticalAlignment="Center" DockPanel.Dock="Left" />
<TextBox Margin="10, 0, 0, 0" Text="{Binding Path=Email}" DockPanel.Dock="Right" />
</DockPanel>
<TextBox Height="225"
TextWrapping="Wrap"
AcceptsReturn="True"
Margin="0, 15, 0, 0"
Margin="0, 10, 0, 0"
Controls:TextboxHelper.Watermark="Please enter a detailed description of the bug you encountered."
Text="{Binding Path=Message,
UpdateSourceTrigger=PropertyChanged}" />
Expand Down

0 comments on commit e7b6059

Please sign in to comment.