-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from MindscapeHQ/sean/maui-offline-store
Add offline crash report storage for MAUI
- Loading branch information
Showing
6 changed files
with
144 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Mindscape.Raygun4Net.Offline; | ||
using Mindscape.Raygun4Net.Storage; | ||
|
||
namespace Raygun4Maui; | ||
|
||
/// <summary> | ||
/// Represents a crash report store specifically for Raygun in a MAUI application, | ||
/// utilizing the file system to store crash reports offline. | ||
/// </summary> | ||
public sealed class RaygunMauiOfflineStore : FileSystemCrashReportStore | ||
{ | ||
private const string OfflineStoreId = "raygun.offline-store-id"; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="RaygunMauiOfflineStore"/> class. | ||
/// </summary> | ||
/// <param name="backgroundSendStrategy">The strategy used to send crash reports in the background.</param> | ||
/// <param name="maxOfflineFiles">The maximum number of offline files to store. Default is 50.</param> | ||
public RaygunMauiOfflineStore(IBackgroundSendStrategy backgroundSendStrategy, int maxOfflineFiles = 50) | ||
: base(backgroundSendStrategy, GetLocalAppDirectory(), maxOfflineFiles) | ||
{ | ||
} | ||
|
||
private static string GetLocalAppDirectory() | ||
{ | ||
return Path.Combine(FileSystem.AppDataDirectory, GetOrCreateStoreId()); | ||
} | ||
|
||
private static string GetOrCreateStoreId() | ||
{ | ||
var storeId = Preferences.Get(OfflineStoreId, null); | ||
if (string.IsNullOrEmpty(storeId)) | ||
{ | ||
storeId = Guid.NewGuid().ToString("N"); | ||
Preferences.Set(OfflineStoreId, storeId); | ||
} | ||
return storeId; | ||
} | ||
} |