ResearchCave Technology

ResearchCave.Achievements.Client (1.0.0)

Published 2026-10-12 19:37:17 +03:00 by admin

Installation

dotnet nuget add source --name ResearchCave --username your_username --password your_token https://git.researchcave.com/api/packages/ResearchCave/nuget/index.json
dotnet add package --source ResearchCave --version 1.0.0 ResearchCave.Achievements.Client

About this package

Typed metric publishing and profile badge client for ResearchCave Achievements.

ResearchCave.Achievements.Client

Register the client and the metric route alongside the normal ResearchCave messaging setup:

builder.Services.AddResearchCaveAchievementsClient(builder.Configuration);
builder.AddResearchCaveMessaging(
    configureWolverine: options => options.PublishResearchCaveAchievementMetrics());

Publish typed absolute values or increments without hand-writing source and metric strings:

await achievements.ReportAbsoluteAsync(userId, AchievementMetric.ForumPosts, postCount, cancellationToken: ct);
await achievements.ReportIncrementAsync(userId, AchievementMetric.LoginCount, cancellationToken: ct);
await achievements.ReportIncrementOnceAsync(
    liveSessionId,
    broadcasterUserId,
    AchievementMetric.LiveBroadcastWatchSeconds,
    audienceWatchSeconds,
    cancellationToken: ct);

Normal reports receive a new idempotency key. Use ReportIncrementOnceAsync with a stable domain-event ID when a retry must not apply the same increment twice. Prefer absolute values whenever a service can calculate the current total.

Profile pages can retrieve a user's public badge awards by their OIDC subject ID:

public sealed class ProfileService(IAchievementProfileClient achievements)
{
    public Task<IReadOnlyList<AchievementBadge>> GetBadgesAsync(
        Guid subjectId,
        CancellationToken cancellationToken) =>
        achievements.GetUserBadgesAsync(subjectId, cancellationToken);
}

The result includes the badge code, name, description, absolute image URL, typed rarity, achievement name, award time and whether the award was granted manually. Configuration uses the existing Services:Achievements section:

{
  "Services": {
    "Achievements": {
      "BaseUrl": "https+http://achievements",
      "PublicBaseUrl": "https://achievements.researchcave.com"
    }
  }
}

Dependencies

ID Version Target Framework
Microsoft.Extensions.Http 10.0.12 net10.0
Microsoft.Extensions.Options.ConfigurationExtensions 10.0.12 net10.0
ResearchCave.Messaging 1.1.68 net10.0
Details
NuGet
2026-10-12 19:37:17 +03:00
2
ResearchCave.Achievements.Client
36 KiB
Assets (2)
Versions (1) View all
1.0.0 2026-10-12