gamecreator Posted March 24, 2019 Share Posted March 24, 2019 The following code resulted in me not getting data to Analytics. There was an acknowledgement of some connection (I forget the details but the game project went from pending to waiting or something) but then not a single data piece went through. // Get date & time for GameAnalytics info time_t t = time(NULL); struct tm tm = *localtime(&t); // printf("now: %d-%d-%d %d:%d:%d\n", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); string gameanalyticsinfo = "game_start - "+std::string(SteamFriends()->GetFriendPersonaName(SteamUser()->GetSteamID()))+" - "+String(tm.tm_year+1900)+"-"+String(tm.tm_mon + 1)+"-"+String(tm.tm_mday)+" "; gameanalyticsinfo=gameanalyticsinfo+String(tm.tm_hour)+":"+String(tm.tm_min)+"-"+String(tm.tm_sec); cout << endl << endl << gameanalyticsinfo << endl << endl; // GAME ANALYTICS - send start information Analytics::SetKeys("mygamekeywenthere","mysecretcodewashere"); bool analyts=analyts=Analytics::Enable(); if(!analyts) { MessageBoxA(0, "Could not initialize game analytics.", "Error", 0); exit(1); } if(Analytics::SendGenericEvent(gameanalyticsinfo)) printf("gameanalytics successfully sent?\n"); else printf("gameanalytics send failed\n"); I've also just tried to send a very basic string, per Josh's suggestion in the past, and that didn't work either. I should also note that I've successfully received data in the past for another Leadwerks project and I copied and pasted the analytics code from that project (except for the changed keys). There's a chance that I'm doing something wrong but I don't see it. Edit: this is what the console showed: Quote [{"event":{"category":"user","device":"unknown","v":2,"user_id":"3904621100649993201","client_ts":1542914629,"sdk_version":"rest api v2","os_version":"windows 10.0","manufacturer":"unknown","platform":"windows","session_id":"18cb7098-2ff9-4030-9c94-82a7c4018dd4","session_num":0},"errors":[{"error_type":"not_in_range","path":"/session_num"}]}] [{"event":{"category":"design","device":"unknown","v":2,"user_id":"3904621100649993201","client_ts":1542914629,"sdk_version":"rest api v2","os_version":"windows 10.0","manufacturer":"unknown","platform":"windows","session_id":"18cb7098-2ff9-4030-9c94-82a7c4018dd4","session_num":0,"event_id":"simplestringtest"},"errors":[{"error_type":"not_in_range","path":"/session_num"}]}] [{"event":{"category":"session_end","device":"unknown","v":2,"user_id":"3904621100649993201","client_ts":1542915698,"sdk_version":"rest api v2","os_version":"windows 10.0","manufacturer":"unknown","platform":"windows","session_id":"18cb7098-2ff9-4030-9c94-82a7c4018dd4","session_num":0,"length":1},"errors":[{"error_type":"not_in_range","path":"/session_num"}]}] Link to comment Share on other sites More sharing options...
Josh Posted March 24, 2019 Share Posted March 24, 2019 Does it say "gameanalytics successfully sent" or "gameanalytics send failure" when you run the program? My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
gamecreator Posted March 24, 2019 Author Share Posted March 24, 2019 It did say success. I have a little time; I'll try again from scratch now too. Link to comment Share on other sites More sharing options...
Josh Posted March 24, 2019 Share Posted March 24, 2019 Okay, here is my test code. I sent an event and I am waiting to see if it shows up in the web data. I think there is a delay. #include "Leadwerks.h" using namespace Leadwerks; int main(int argc,const char *argv[]) { std::string publickey = "xxx"; std::string privatekey = "xxx"; // GAME ANALYTICS - send start information Analytics::SetKeys(publickey, privatekey); bool analyts = Analytics::Enable(); if (!analyts) { MessageBoxA(0, "Could not initialize game analytics.", "Error", 0); exit(1); } printf("gameanalytics successfully initialized\n"); std::string gameanalyticsinfo = "Test Event"; if (Analytics::SendGenericEvent(gameanalyticsinfo)) { printf("gameanalytics successfully sent\n"); } else { printf("gameanalytics send failed\n"); } } My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
gamecreator Posted March 24, 2019 Author Share Posted March 24, 2019 Thanks. I think they say that sometimes it can take up to a day for the data to get into your dashboard or whatever. Link to comment Share on other sites More sharing options...
Josh Posted March 24, 2019 Share Posted March 24, 2019 I notice there is an error with session_num. This starts at zero and gets pulled from the config file. Maybe it isn't being incremented, and zero is considered invalid... My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Josh Posted March 24, 2019 Share Posted March 24, 2019 This code will prevent that error: #include "Leadwerks.h" using namespace Leadwerks; int main(int argc,const char *argv[]) { std::string publickey = "xxx"; std::string privatekey = "xxx"; // GAME ANALYTICS - send start information Analytics::SetKeys(publickey, privatekey); System::SetProperty("session_number", "1"); bool analyts = Analytics::Enable(); if (!analyts) { printf("Could not initialize game analytics."); return 1; } printf("gameanalytics successfully initialized\n"); std::string gameanalyticsinfo = "Test Event"; if (Analytics::SendGenericEvent(gameanalyticsinfo)) { printf("gameanalytics successfully sent\n"); } else { printf("gameanalytics send failed\n"); } } 1 My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
gamecreator Posted March 24, 2019 Author Share Posted March 24, 2019 Is all the data sent together when the program ends? I notice the above errors I mentioned pop up as I close the program. Or is it sent live and that's something else? Link to comment Share on other sites More sharing options...
Josh Posted March 24, 2019 Share Posted March 24, 2019 Events are added to a list and all sent when the program ends. My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
gamecreator Posted March 24, 2019 Author Share Posted March 24, 2019 Interesting. I mostly copied and pasted your code (with my keys) and I didn't get the error either. This is good; something to work from. Link to comment Share on other sites More sharing options...
Josh Posted March 24, 2019 Share Posted March 24, 2019 I am setting the default session number to 1 and adding some code that automatically increments it. I think maybe originally a session number of zero was considered valid, and then maybe they changed that. My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
gamecreator Posted March 24, 2019 Author Share Posted March 24, 2019 Ah ok, yes. Without that System::SetProperty("session_number", "1"), I do get the error too. Glad you have a lead though. I'll keep an eye on if my data ends up in my analytics too. Link to comment Share on other sites More sharing options...
Josh Posted March 24, 2019 Share Posted March 24, 2019 I will assume this is fixed unless you tell me otherwise. 1 My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts