ResearchCave.Achievements.Client (1.0.0)
Installation
dotnet nuget add source --name ResearchCave --username your_username --password your_token https://git.researchcave.com/api/packages/ResearchCave/nuget/index.jsondotnet add package --source ResearchCave --version 1.0.0 ResearchCave.Achievements.ClientAbout 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"
}
}
}