Skip to content

UrsKroell/UserLogNET

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UserLogNET

a UserLog SDK for dotnet

NuGet Version


Website: https://getuserlog.com/

Docs: https://docs.getuserlog.com/

Installation

dotnet add package UserLogNET

Usage

Add client to dependency injection

using UserLogNET.Extensions;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddUserLog("api-key", "project-name");

The project name will be auto-injected in all requests.

Log

using UserLogNET;
using UserLogNET.Client;

// Inject UserLogClient into service
public GenericController(IUserLogClient userLogClient)
{
    _userLogClient = userLogClient;
}

public async Task<bool> Get()
{
    // Create a new UserLogEvent
    var newLogEvent = new UserLogEvent()
    {
        Channel = "payments",                           // Required
        Event = "New Subscription",                     // Required
        Notify = true,                                  // Required
        
        Description = "A new subscription was created", // optional
        UserId = "[email protected]",                  // optional
        Icon = "💰"                                     // optional (needs to be an emoji)
    };
    
    // Add Tags (optional)
    newLogEvent.AddTags(
        ("plan", "hello"),       // supports string
        ("cycle", "monthly"),    
        ("mrr", 19.95),          // numbers
        ("trial", true)          // and bool
    );
    
    // push the LogEvent to be tracked
    return await _userLogClient.Track(newLogEvent);
}

Releases

No releases published

Packages

No packages published

Languages