Jump to content

Analytics Bug?


Recommended Posts

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

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

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

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");
	}
}

 

  • Upvote 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

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

  • Josh locked this topic
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...