GameAnalytics SDK: Could not add error event SDK is disabled?

I’ve been trying to use the GameAnalytics SDK for a project i’m working on to move away from discord webhooks. I’ve tried submitting this sample error through a Server Script:

GameAnalytics:addErrorEvent('AbnormalActivity', {
         severity = GameAnalytics.EGAErrorSeverity.Info,
         message = "This is a test info message for GameAnalytics"
})

However I get this response in the server output:
Warning/GameAnalytics: Could not add error event SDK is disabled

Why is this happening? I have the game + secret key in the settings module.

Make sure HTTP requests are enabled for your game. Since I’m pretty sure it uses the HttpService.

HTTPService is enabled, as it shows it successfully sending POST requests to their API

After looking at the code and documentation, it seems like the first parameter should be a player ID. (player.UserId) you put ‘AbnormalActivity’.

function ga:addErrorEvent(playerId, options)
    threading:performTaskOnGAThread(function()
        if not state:isEventSubmissionEnabled() then
            return
        end
        if not isSdkReady({playerId=playerId, needsInitialized=true, shouldWarn=true, message="Could not add error event"}) then
            return
        end

        -- Send to events
        local severity = options["severity"] or 0
        local message = options["message"] or ""

        events:addErrorEvent(playerId, severity, message)
    end)
end

This code returns the error, so it seems to be that you’re forwarding the wrong parameter.

-- Is SDK enabled
    if needsInitialized and playerId and not state:isEnabled(playerId) then
        if shouldWarn then
            logger:w(message .. " SDK is disabled")
        end
        return false
    end
2 Likes

Thanks for clearing this up! Managed to get two incomimg evenrs registered on the site, now I just gotta wait for them to come through and appear on the log

So we’re all good? If so, then awesome, if not then feel free to come back to this. :smiley:

Almost all good, the 2 incoming events seem to be stuck there and are not appearing, unsure if this is to do with their api or not

Could be that it takes time, or you may have to close the session (game/studio run session) before it posts if it has a shutdown hook. Or if the player leaves and ends their session.

Edit:
Seems like there’s session events for starting/ending so it may only log things after the session of said player ends.