Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Quality Script #21

Open
subsoap opened this issue Aug 13, 2019 · 1 comment
Open

Code Quality Script #21

subsoap opened this issue Aug 13, 2019 · 1 comment

Comments

@subsoap
Copy link
Contributor

subsoap commented Aug 13, 2019

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
@the1schwartz
Copy link
Contributor

Ok thanks for sharing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants