Skip to content

Instantly share code, notes, and snippets.

@TheEpicFace007
Last active April 11, 2020 21:58
Show Gist options
  • Save TheEpicFace007/64794239cf026a9c21f55311f3151323 to your computer and use it in GitHub Desktop.
Save TheEpicFace007/64794239cf026a9c21f55311f3151323 to your computer and use it in GitHub Desktop.
Google analytics for roblox exploits
-- google analytics api --
local GA = {}
-- google analytic stracking id. Example : UA-000000000-0 - info on getting it: https://support.google.com/analytics/thread/5348459
local id = "UA-000000000-0"
-- wether it will print to the console the reported event without sending them to google analytics
local debugMode = false
local googleUserTrackingId = game:GetService("HttpService"):GenerateGUID()
local lastTimeGeneratedGoogleUserId = os.time()
local HttpRequest = syn.request or request or http_request
function HttpPost(url,body)
HttpRequest({
Url = url;
Method = "POST";
Headers = {["Content-Type"] = "Application/x-www-form-urlencoded";};
Body = body
})
end
function stringifyEvent(category, action, label, value)
return "GA EVENT: " ..
"Category: [" .. tostring(category) .. "] " ..
"Action: [" .. tostring(action) .. "] " ..
"Label: [" .. tostring(label) .. "] " ..
"Value: [" .. tostring(value) .. "]"
end
function printEventInsteadOfActuallySendingIt(category, action, label, value)
print(stringifyEvent(category, action, label, value))
end
function GA.ReportEvent(category, action, label, value)
local numberValue = tonumber(value)
if numberValue == nil or numberValue ~= math.floor(numberValue) then
warn("WARNING: not reporting event because value is not an integer. ", stringifyEvent(category, action, label, value))
return
end
value = numberValue
if not debugMode then
if id == nil then
warn("WARNING: not reporting event because ID has not been defined")
return
end
-- Try to detect studio start server + player
if game.CreatorId <= 0 then
printEventInsteadOfActuallySendingIt(category, action, label, value)
return
end
if os.time() - lastTimeGeneratedGoogleUserId > 7200 then
googleUserTrackingId = game:GetService("HttpService"):GenerateGUID()
lastTimeGeneratedGoogleUserId = os.time()
end
local hs = game:GetService("HttpService")
HttpPost(
"http://www.google-analytics.com/collect",
"v=1&t=event&sc=start" ..
"&tid=" .. id ..
"&cid=" .. googleUserTrackingId ..
"&ec=" .. hs:UrlEncode(category) ..
"&ea=" .. hs:UrlEncode(action) ..
"&el=" .. hs:UrlEncode(label) ..
"&ev=" .. hs:UrlEncode(value)
)
else
printEventInsteadOfActuallySendingIt(category, action, label, value)
end
end
-- google analytics api end --
-- google analytics api end --
function getExploit()
if secure_load then
return "Sentinel"
elseif pebc_execute then
return "ProtoSmasher"
elseif is_sirhurt_closure then
return "Sirhurt"
elseif syn then
return "Synapse X"
end;
end
GA.ReportEvent("User exploit","Exploit",getExploit(),1)
-- google analytics api --
local GA = {}
-- google analytic stracking id. Example : UA-000000000-0 - info on getting it: https://support.google.com/analytics/thread/5348459
local id = "UA-000000000-0"
-- wether it will print to the console the reported event without sending them to google analytics
local debugMode = false
local googleUserTrackingId = game:GetService("HttpService"):GenerateGUID()
local lastTimeGeneratedGoogleUserId = os.time()
local HttpRequest = syn.request or request or http_request
function HttpPost(url,body)
HttpRequest({
Url = url;
Method = "POST";
Headers = {["Content-Type"] = "Application/x-www-form-urlencoded";};
Body = body
})
end
function stringifyEvent(category, action, label, value)
return "GA EVENT: " ..
"Category: [" .. tostring(category) .. "] " ..
"Action: [" .. tostring(action) .. "] " ..
"Label: [" .. tostring(label) .. "] " ..
"Value: [" .. tostring(value) .. "]"
end
function printEventInsteadOfActuallySendingIt(category, action, label, value)
print(stringifyEvent(category, action, label, value))
end
function GA.ReportEvent(category, action, label, value)
local numberValue = tonumber(value)
if numberValue == nil or numberValue ~= math.floor(numberValue) then
warn("WARNING: not reporting event because value is not an integer. ", stringifyEvent(category, action, label, value))
return
end
value = numberValue
if not debugMode then
if id == nil then
warn("WARNING: not reporting event because ID has not been defined")
return
end
-- Try to detect studio start server + player
if game.CreatorId <= 0 then
printEventInsteadOfActuallySendingIt(category, action, label, value)
return
end
if os.time() - lastTimeGeneratedGoogleUserId > 7200 then
googleUserTrackingId = game:GetService("HttpService"):GenerateGUID()
lastTimeGeneratedGoogleUserId = os.time()
end
local hs = game:GetService("HttpService")
HttpPost(
"http://www.google-analytics.com/collect",
"v=1&t=event&sc=start" ..
"&tid=" .. id ..
"&cid=" .. googleUserTrackingId ..
"&ec=" .. hs:UrlEncode(category) ..
"&ea=" .. hs:UrlEncode(action) ..
"&el=" .. hs:UrlEncode(label) ..
"&ev=" .. hs:UrlEncode(value)
)
else
printEventInsteadOfActuallySendingIt(category, action, label, value)
end
end
-- google analytics api end --
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment