-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathTrackingManager.cs
More file actions
78 lines (68 loc) · 1.65 KB
/
TrackingManager.cs
File metadata and controls
78 lines (68 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
#if !DEBUG && WINDOWS_UWP && !HAS_UNO
// See https://learn.microsoft.com/windows/uwp/monetize/log-custom-events-for-dev-center
using Microsoft.Services.Store.Engagement;
#endif
namespace CommunityToolkit.App.Shared.Helpers;
#if DEBUG || !WINDOWS_UWP || HAS_UNO
// Stub for non-UWP platforms and DEBUG mode
internal class StoreServicesCustomEventLogger
{
public static StoreServicesCustomEventLogger GetDefault() => new();
public void Log(string message)
{
Debug.WriteLine($"Log - {message}");
}
}
#endif
public static class TrackingManager
{
private static StoreServicesCustomEventLogger? logger;
static TrackingManager()
{
try
{
logger = StoreServicesCustomEventLogger.GetDefault();
}
catch
{
// Ignoring error
}
}
public static void TrackException(Exception ex)
{
try
{
logger?.Log($"exception - {ex.Message} - {ex.StackTrace}");
}
catch
{
// Ignore error
}
}
public static void TrackSample(string name)
{
try
{
logger?.Log($"sample - {name}");
}
catch
{
// Ignore error
}
}
public static void TrackPage(string pageName)
{
try
{
logger?.Log($"openpage - {pageName}");
}
catch
{
// Ignore error
}
}
}