-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3de2de7
commit cecdfb4
Showing
6 changed files
with
97 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using System.Globalization; | ||
using Microsoft.AppCenter; | ||
using Microsoft.AppCenter.Analytics; | ||
using Microsoft.AppCenter.Crashes; | ||
|
||
namespace OnlyM; | ||
|
||
internal static class AppCenterInit | ||
{ | ||
// Please omit this token (or use your own) if you are building a fork | ||
private static readonly string? TheToken = "78e43751-d0c9-4fc7-8137-0fcc95ebd0fe"; | ||
|
||
public static void Execute() | ||
{ | ||
if (OperatingSystem.IsWindows()) | ||
{ | ||
#pragma warning disable CA1416 | ||
AppCenter.Start(TheToken, typeof(Analytics), typeof(Crashes)); | ||
AppCenter.SetCountryCode(RegionInfo.CurrentRegion.TwoLetterISORegionName); | ||
#pragma warning restore CA1416 | ||
} | ||
} | ||
} |
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,7 @@ | ||
namespace OnlyM.EventTracking; | ||
|
||
internal enum EventName | ||
{ | ||
Unknown, | ||
StartMedia, | ||
} |
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,42 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Microsoft.AppCenter.Analytics; | ||
using Microsoft.AppCenter.Crashes; | ||
using OnlyM.Core.Models; | ||
|
||
namespace OnlyM.EventTracking; | ||
|
||
#pragma warning disable CA1416 // Validate platform compatibility | ||
|
||
internal static class EventTracker | ||
{ | ||
public static void Track(EventName eventName, Dictionary<string, string>? properties = null) | ||
{ | ||
Analytics.TrackEvent(eventName.ToString(), properties); | ||
} | ||
|
||
public static void TrackStartMedia(SupportedMediaType? mediaType) | ||
{ | ||
var properties = new Dictionary<string, string> | ||
{ | ||
{ "type", mediaType?.Classification.ToString() ?? "No Type" }, | ||
}; | ||
|
||
Track(EventName.StartMedia, properties); | ||
} | ||
|
||
public static void Error(Exception ex, string? context = null) | ||
{ | ||
if (string.IsNullOrEmpty(context)) | ||
{ | ||
Crashes.TrackError(ex); | ||
} | ||
else | ||
{ | ||
var properties = new Dictionary<string, string> { { "context", context } }; | ||
Crashes.TrackError(ex, properties); | ||
} | ||
} | ||
} | ||
|
||
#pragma warning restore CA1416 // Validate platform compatibility} |
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