Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Services
- local ServerStorage = game:GetService("ServerStorage")
- -- Folders
- local configurations = ServerStorage:WaitForChild("Configurations")
- local classes = ServerStorage:WaitForChild("Classes")
- -- Classes
- local DSInterface = require(classes:WaitForChild("DSInterface"))
- -- DSInterfaces
- local analyticsInterface = DSInterface.new("GameAnalytics")
- -- Function cache
- local osDate = os.date
- -- Tables
- local module = {}
- -- Private functions
- local function joinValues(...)
- local str = "%g" .. string.rep(" : %g", #{...} - 1)
- return str:format(...)
- end
- -- Functions
- function module:IncrementAnalytics(generalAnalytics)
- local currentDate = osDate("*t")
- local currentDay = tostring(currentDate.day)
- local currentMonth = currentDate.month
- local currentYear = currentDate.year
- local dateKey = joinValues(currentMonth, currentYear)
- local monthData = analyticsInterface:Get(dateKey) or {}
- local allTimeData = analyticsInterface:Get("AllTime")
- if monthData then
- local activeUsers = generalAnalytics.ActiveUsers
- local dayUsers = activeUsers.Day
- local monthUsers = activeUsers.Month
- local DAU = monthData.DAU or {}
- local TodayDAU = DAU[currentDay]
- print(monthData)
- if not TodayDAU then
- print("Assigning")
- DAU[currentDay] = dayUsers
- else
- print("Adding")
- DAU[currentDay] += dayUsers
- end
- monthData.DAU = DAU
- monthData.MAU = monthData.MAU or 0
- monthData.MAU += monthUsers
- print(monthData)
- analyticsInterface:Set(dateKey, monthData)
- end
- if allTimeData then
- allTimeData.UniqueUsers += generalAnalytics.UniqueUsers
- print(allTimeData)
- analyticsInterface:Set("AllTime", allTimeData)
- end
- end
- return module
Advertisement
Add Comment
Please, Sign In to add comment