Skip to content

Commit 2365014

Browse files
committed
version 0.0.7
1 parent 5199dad commit 2365014

File tree

8 files changed

+39
-14
lines changed

8 files changed

+39
-14
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.0.7
2+
3+
* Use a more reliable method for Debug/Release mode detection
4+
* Update docs
5+
16
## 0.0.6
27

38
* Fix automatic Debug/Release mode detection

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Instrument your apps with Aptabase, an Open Source, Privacy-First and, Simple An
99
Start by adding the Aptabase NuGet package to your .csproj:
1010

1111
```xml
12-
<PackageReference Include="Aptabase.Maui" Version="0.0.6" />
12+
<PackageReference Include="Aptabase.Maui" Version="0.0.7" />
1313
```
1414

1515
## Usage
@@ -31,7 +31,13 @@ public static MauiApp CreateMauiApp()
3131

3232
The `UseAptabase` method will add the `IAptabaseClient` to your dependency injection container, allowing you to use it in your pages and view models.
3333

34-
As an example, you can add the following code to your `MainPage.xaml.cs`:
34+
As an example, to track events in your `MainPage`, you first need to add it to the DI Container in `MauiProgram.cs`:
35+
36+
```csharp
37+
builder.Services.AddSingleton<MainPage>();
38+
```
39+
40+
And then inject and use it on your `MainPage.xaml.cs`:
3541

3642
```csharp
3743
public partial class MainPage : ContentPage

etc/logo.png

4.41 KB
Loading

package/Aptabase.Maui.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<PackageId>Aptabase.Maui</PackageId>
5-
<Version>0.0.6</Version>
5+
<Version>0.0.7</Version>
66
<TargetFrameworks>net7.0;net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
77
<Description>Maui SDK for Aptabase: Open Source, Privacy-First and Simple Analytics for Mobile, Desktop and Web Apps</Description>
88
<Authors>Aptabase Team</Authors>

package/AptabaseClient.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.Net.Http.Json;
1+
using System.Diagnostics;
2+
using System.Net.Http.Json;
3+
using System.Reflection;
24
using Microsoft.Extensions.Logging;
35

46
namespace Aptabase.Maui;
@@ -18,7 +20,7 @@ public interface IAptabaseClient
1820
public class AptabaseClient : IAptabaseClient
1921
{
2022
private static TimeSpan SESSION_TIMEOUT = TimeSpan.FromMinutes(60);
21-
private static SystemInfo _sysInfo = new();
23+
private static SystemInfo _sysInfo = new(Assembly.GetEntryAssembly());
2224

2325
private readonly ILogger<AptabaseClient>? _logger;
2426
private readonly HttpClient? _http;

package/AptabaseExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using Aptabase.Maui;
22
using Microsoft.Extensions.Logging;
3+
using System.Diagnostics;
4+
using System.Reflection;
35

46
namespace Microsoft.Maui.Hosting;
57

package/InitOptions.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
/// </summary>
77
public class InitOptions
88
{
9-
109
/// <summary>
1110
/// Custom host for Self-Hosted instances
1211
/// </summary>

package/SystemInfo.cs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,41 @@ internal class SystemInfo
88
private static string _pkgVersion = typeof(AptabaseClient).Assembly
99
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()!.InformationalVersion;
1010

11-
public bool IsDebug { get; private set; }
11+
public bool IsDebug { get; }
1212
public string OsName { get; }
1313
public string OsVersion { get; }
1414
public string SdkVersion { get; }
1515
public string Locale { get; }
1616
public string AppVersion { get; }
1717
public string AppBuildNumber { get; }
1818

19-
public SystemInfo()
19+
public SystemInfo(Assembly? assembly)
2020
{
21-
this.MaybeSetDebugMode();
22-
21+
this.IsDebug = IsInDebugMode(assembly);
2322
this.OsName = GetOsName();
2423
this.OsVersion = GetOsVersion();
2524
this.SdkVersion = $"Aptabase.Maui@{_pkgVersion}";
2625
this.Locale = Thread.CurrentThread.CurrentCulture.Name;
2726
this.AppVersion = AppInfo.Current.VersionString;
2827
this.AppBuildNumber = AppInfo.Current.BuildString;
2928
}
30-
31-
[Conditional("DEBUG")]
32-
public void MaybeSetDebugMode()
29+
30+
private static bool IsInDebugMode(Assembly? assembly)
3331
{
34-
this.IsDebug = true;
32+
if (assembly == null)
33+
return false;
34+
35+
var attributes = assembly.GetCustomAttributes(typeof(DebuggableAttribute), false);
36+
if (attributes.Length > 0)
37+
{
38+
var debuggable = attributes[0] as DebuggableAttribute;
39+
if (debuggable != null)
40+
return (debuggable.DebuggingFlags & DebuggableAttribute.DebuggingModes.Default) == DebuggableAttribute.DebuggingModes.Default;
41+
else
42+
return false;
43+
}
44+
else
45+
return false;
3546
}
3647

3748
private string GetOsName()

0 commit comments

Comments
 (0)