GameAnalytics / GA-SDK-ROBLOX

Repository for GameAnalytics Roblox SDK
MIT License
68 stars 45 forks source link

Simplify the Initialization process #71

Closed brinkokevin closed 4 years ago

brinkokevin commented 4 years ago

It would be great if you could move code from GameAnalyticsServer to the main module. I don't see why we would have to use two server scripts to setup game analytics. The Settings table should also be moved to GameAnalyticsServerInitUsingSettings instead of being a table inside of the GameAnalytics module. At the moment every time I want to update GameAnalytics to the latest version I have to save my Settings module, replace all files with the new ones and add my settings back to the module. Ideally, there should be only 1 server script where we modify the settings which we can send to the "initialize" method. Initialization should accept all arguments which the Settings module has at the moment.

My server script should look something like this

local ServerStorage = game:GetService("ServerStorage")
local GameAnalytics = require(ServerStorage.GameAnalytics)

GameAnalytics:Initialize({
    Build = "0.1";

    GameKey = "";
    SecretKey = "";

    EnableInfoLog = true;
    EnableVerboseLog = false;
    AutomaticSendBusinessEvents = true;
    ReportErrors = true;

    AvailableCustomDimensions01 = {};
    AvailableCustomDimensions02 = {};
    AvailableCustomDimensions03 = {};
    AvailableResourceCurrencies = {};
    AvailableResourceItemTypes = {};
    AvailableGamepasses = {};
})
the1schwartz commented 4 years ago

Everything in the GameAnalyticsServer script is code that needs to run once on the server when the server has started. I am no Roblox export so you are welcome to suggest a solution if you have one.

Regarding the settings it can be done in two ways as described here: https://gameanalytics.com/docs/item/roblox-sdk#initializing

because of the issues you just mentioned.

brinkokevin commented 4 years ago

Modules also execute code one time when required. Take a look at some changes that I made here https://github.com/brinkokevin/GA-SDK-ROBLOX/commits/master

the1schwartz commented 4 years ago

You are welcome to make a PR if you feel it will improve the SDK

brinkokevin commented 4 years ago

https://github.com/GameAnalytics/GA-SDK-ROBLOX/pull/72