Anonymous Sign up / in does not Trigger event in Cloud Code?

I’m attempting to create a Trigger for new users to initialize default values. Setting up the C# module and the trigger itself was not a problem at all. But the game client using the following code doesn’t cause the authentication event to trigger:

await UnityServices.InitializeAsync();
await AuthenticationService.Instance.SignInAnonymouslyAsync();

Calling my own CloudCode functions after the sign in process is working just fine… it just seems that the event isn’t firing?

To test further, I followed this sample exactly (except using sign-in instead of sign-up) :
Use case sample: Initialize newly signed-up players with default configuration values

And the game client would still not work. The only way I was actually able to get the event to work is through a cloud code script described in the same sample.

I’m not 100% sure if this is a bug or just a limitation of anonymous users?

Hi @TimHeijden2, do you have a a sample of your trigger configuration for me to take a look at?

Here is the trigger I created from the dashboard:

And the C# module looks like this: (and the logs do not show up)

public interface ICloudCodeEvents
{
    Task OnUserSignIn(IExecutionContext context, IGameApiClient gameApiClient, string playerId);
    Task OnUserSignUp(IExecutionContext context, IGameApiClient gameApiClient, string playerId);
}

public class ICloudCodeEventsHandler : ICloudCodeEvents
{
    private readonly ILogger<ICloudCodeEventsHandler> logger;
    public ICloudCodeEventsHandler(ILogger<ICloudCodeEventsHandler> logger)
    {
        this.logger = logger;
    }

    [CloudCodeFunction("OnUserSignIn")]
    public async Task OnUserSignIn(IExecutionContext context, IGameApiClient gameApiClient, string playerId)
    {
        logger.LogDebug("Triggered OnUserSignIn!");
    }

    [CloudCodeFunction("OnUserSignUp")]
    public async Task OnUserSignUp(IExecutionContext context, IGameApiClient gameApiClient, string playerId)
    {
        logger.LogDebug("Triggered OnUserSignUp!");
    }
}


public class ModuleConfig : ICloudCodeSetup
{
    public void Setup(ICloudCodeConfig config)
    {
        config.Dependencies.AddSingleton(GameApiClient.Create());
    }
}

Hi there! Thanks for that, your trigger and module look fine to me. Just to confirm, I’ve had a look at your project and do see the logs being printed in the logging page. If you’re using the button link to the triggers logs in the triggers page, be sure to remove the filter that is added by default to the log query, as it will only log information tagged with the trigger attribute.

If that wasn’t the issue, could you also help me by confirming the editor environment is setup correctly. You can check this in edit > project settings > Services > Environments, and ensure the environment is set to the environment your module is deployed to. Let me know how this goes. :slightly_smiling_face:

Thanks for your response! I’m not sure what I did wrong when doing this before but indeed I’m seeing the logs now as you’ve described.

No worries at all, glad it’s working now. Feel free to jump back on the forum if you have any other queries :slightly_smiling_face: