Here is the helper script we use to send script error to GA
local error_table = {}
TOTAL_ERRORS = 0
local VERSION = sys.get_config("project.version")
-- https://gameanalytics.com/docs/item/ga-data
-- https://gameanalytics.com/docs/item/resource-events
local function error_handler(source, message, traceback)
TOTAL_ERRORS = TOTAL_ERRORS + 1
-- don't flood the same unique message more than once
local traceback_hash = hash(traceback)
if error_table[traceback_hash] ~= nil then
return false
else
error_table[traceback_hash] = true
end
local severity_rating = "Critical"
if sys.get_engine_info().is_debug then
severity_rating = "Debug"
end
local error_message = VERSION .. " - " .. source .. " - " .. message .. " - " .. traceback
if gameanalytics then
gameanalytics.addErrorEvent {
severity = severity_rating,
message = error_message
}
end
end
function init(self)
sys.set_error_handler(error_handler)
end
Here is the helper script we use to send script error to GA