Skip to content

Commit

Permalink
Merge pull request #7 from bnotech/feature/net8.0
Browse files Browse the repository at this point in the history
Feature/net8.0
  • Loading branch information
bnoffer authored Jan 14, 2025
2 parents a6a2108 + 29c2af8 commit 6f8f6e4
Show file tree
Hide file tree
Showing 24 changed files with 505 additions and 289 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

#- name: Setup nuget
# uses: nuget/setup-nuget@v1
- name: Restore packages for solution
run: dotnet restore Matomo.Maui.csproj
run: dotnet restore

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.0.3
- name: Build
run: msbuild Matomo.Maui.csproj
run: dotnet build
20 changes: 6 additions & 14 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,19 @@ jobs:
script: |
return context.payload.ref.replace(/\/refs\/tags\//, '');
- name: Setup nuget
uses: nuget/setup-nuget@v1
- name: Restore nuget packages for solution
run: dotnet restore Matomo.Maui.csproj

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.0.3
- name: Build
run: msbuild Matomo.Maui.csproj /property:Configuration=Release
run: dotnet restore

- name: Pack
run: |
$version=${{ steps.tag.outputs.result }}
$version=$version.replace("refs/tags/v", "")
nuget pack Matomo.Maui.nuspec -Prop Configuration=Release -verbosity detailed -basepath ./ -OutputDirectory ./package -Version $version
- name: Setup Nuget Push
run: nuget setApiKey "$env:NUGET_ORG_TOKEN"
env:
NUGET_ORG_TOKEN: ${{ secrets.NUGET_ORG_TOKEN }}
dotnet pack --configuration Release --verbosity detailed --output ../package -p:PackageVersion=$version
- name: Push
run: |
$version=${{ steps.tag.outputs.result }}
$version=$version.replace("refs/tags/v", "")
$package="package/Matomo.Maui." + $version + ".nupkg"
nuget push $package -Source https://api.nuget.org/v3/index.json
dotnet nuget push $package -k "$env:NUGET_ORG_TOKEN" -Source https://api.nuget.org/v3/index.json
env:
NUGET_ORG_TOKEN: ${{ secrets.NUGET_ORG_TOKEN }}
23 changes: 8 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,21 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
return context.payload.ref.replace(/\/refs\/tags\//, '');
- name: Setup nuget
uses: nuget/setup-nuget@v1
- name: Restore nuget packages for solution
run: nuget restore Matomo.Maui.csproj

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.0.3
- name: Build
run: msbuild Matomo.Maui.csproj /property:Configuration=Release
run: nuget restore

- name: Pack
run: |
$version=${{ steps.tag.outputs.result }}
$version=$version.replace("refs/tags/v", "")
nuget pack Matomo.Maui.nuspec -Prop Configuration=Release -verbosity detailed -basepath ./ -OutputDirectory ./package -Version $version
- name: Setup Nuget Push
run: nuget setApiKey "$env:NUGET_ORG_TOKEN"
env:
NUGET_ORG_TOKEN: ${{ secrets.NUGET_ORG_TOKEN }}
dotnet pack --configuration Release --verbosity detailed --output ../package -p:PackageVersion=$version
- name: Push
run: |
$version=${{ steps.tag.outputs.result }}
$version=$version.replace("refs/tags/v", "")
$package="package/Matomo.Maui." + $version + ".nupkg"
nuget push $package -Source https://api.nuget.org/v3/index.json
dotnet nuget push $package -k "$env:NUGET_ORG_TOKEN" -Source https://api.nuget.org/v3/index.json
env:
NUGET_ORG_TOKEN: ${{ secrets.NUGET_ORG_TOKEN }}
7 changes: 2 additions & 5 deletions Matomo.Maui.sln
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ Global
SolutionGuid = {99E4CA5A-ABE0-4F3F-8376-D15689601C67}
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{F98A6817-2895-47D3-9FC3-E93BB5747555} = {199F81EB-3FE7-451F-BD77-41E680A31F0B}
{EBD1EEA9-0CB1-42E1-B01E-17FEB3B1E2C0} = {F98A6817-2895-47D3-9FC3-E93BB5747555}
{C7882A5C-EE2F-4B30-AE11-530F33F4CF2A} = {F98A6817-2895-47D3-9FC3-E93BB5747555}
{F33C9D2B-FDF0-469A-9704-0154B9B87E3B} = {84FA4430-CA33-4436-98E6-E421058A0973}
EndGlobalSection
{F33C9D2B-FDF0-469A-9704-0154B9B87E3B} = {84FA4430-CA33-4436-98E6-E421058A0973}
EndGlobalSection
EndGlobal
84 changes: 0 additions & 84 deletions Matomo.Maui/ActionBuffer.cs

This file was deleted.

27 changes: 27 additions & 0 deletions Matomo.Maui/AppBuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Matomo.Maui.Services.Core;
using Matomo.Maui.Services.Shell;
using Matomo.Maui.Services.Storage;

namespace Matomo.Maui;

/// <summary>
/// <see cref="MauiAppBuilder"/> Extensions
/// </summary>
public static class AppBuilderExtensions
{
/// <summary>
/// Initializes the Matomo Analytics Client
/// </summary>
/// <param name="builder"><see cref="MauiAppBuilder"/> generated by <see cref="MauiApp"/> </param>
/// <returns><see cref="MauiAppBuilder"/> initialized for <see cref="Matomo.Maui"/></returns>
public static MauiAppBuilder UseMatomo(this MauiAppBuilder builder)
{
builder
.Services
.AddTransient<IShellHelper, ShellHelper>()
.AddSingleton<ISimpleStorage, SimpleStorage>()
.AddSingleton<IMatomoAnalytics, MatomoAnalytics>();

return builder;
}
}
90 changes: 90 additions & 0 deletions Matomo.Maui/Buffers/ActionBuffer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using System.Collections.Specialized;
using Newtonsoft.Json;
using Matomo.Maui.Services.Storage;

namespace Matomo.Maui.Buffers;

public class ActionBuffer
{
private readonly string _baseParameters;
private readonly List<string> _inbox;
private readonly List<string> _outbox;
private readonly ISimpleStorage _storage;

public ActionBuffer(NameValueCollection baseParameters, ISimpleStorage storage)
{
_baseParameters = $"?rec=1&apiv=1&{baseParameters}&";
_inbox = [];
_outbox = [];
_storage = storage;

_inbox = storage.Get("actions_inbox", new List<string>());
_outbox = storage.Get("actions_outbox", new List<string>());
}

public int Count
{
get
{
if (_inbox != null && _outbox != null) return _inbox.Count + _outbox.Count;
return 0;
}
}

public void Add(NameValueCollection parameters)
{
if (OptOut)
return;

lock (_inbox)
{
_inbox.Add(_baseParameters + parameters);
_storage.Put("actions_inbox", _inbox);
}
}

public string CreateOutbox()
{
lock (_outbox) lock (_inbox)
{
_outbox.AddRange(_inbox);
if (_outbox.Count == 0)
return "";

_inbox.Clear();
_storage.Put("actions_inbox", _inbox);
_storage.Put("actions_outbox", _outbox);
}

var data = new Dictionary<string, object>();
data["requests"] = _outbox;
return JsonConvert.SerializeObject(data);
}

public void ClearOutbox()
{
lock (_outbox)
{
_outbox.Clear();
_storage.Put("actions_outbox", _outbox);
}
}

public void Clear()
{
lock (_outbox) // NOTE we atain a lock for both objects before clearing.
lock (_inbox)
{
_inbox.Clear();
_outbox.Clear();
_storage.Put("actions_inbox", _inbox);
_storage.Put("actions_outbox", _outbox);
}
}

public bool OptOut
{
get => _storage.Get("opt_out", false);
set => _storage.Put("opt_out", value);
}
}
35 changes: 24 additions & 11 deletions Matomo.Maui/Matomo.Maui.csproj
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net7.0-android;net7.0-ios16.2;net7.0-maccatalyst16.2</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> -->
<TargetFrameworks>net8.0;net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows</TargetFrameworks>
<RootNamespace>Matomo.Maui</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<MauiVersion>8.0.91</MauiVersion>

<!-- NuGet configuration -->
<PackageId>Matomo.Maui</PackageId>
<Version>8.0.0</Version>
<Authors>bnoffer</Authors>
<Owners>bnotech</Owners>
<Company>BNO Technology Solutions e.K.</Company>
<Description>This library provides Matomo Tracking for .NET MAUI Apps</Description>
<Copyright>©Copyright 2025, BNO Technology Solutions e.K.</Copyright>
<Tags>Matomo Piwik MAUI Analytics</Tags>
<PackageReadmeFile>README.md</PackageReadmeFile>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-ios|AnyCPU'">
Expand All @@ -24,6 +29,14 @@
<None Remove="Newtonsoft.Json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" />
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Essentials" Version="$(MauiVersion)" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
<ItemGroup>
<None Include="..\readme.md" Pack="true" PackagePath="\"/>
</ItemGroup>
</Project>
24 changes: 0 additions & 24 deletions Matomo.Maui/Matomo.Maui.nuspec

This file was deleted.

3 changes: 1 addition & 2 deletions Matomo.Maui/Dimension.cs → Matomo.Maui/Models/Dimension.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
namespace Matomo.Maui;
namespace Matomo.Maui.Models;

public class Dimension
{
Expand Down
Loading

0 comments on commit 6f8f6e4

Please sign in to comment.