question

Julius Hipolito avatar image
Julius Hipolito asked

Unreal - Event data displaying bool values instead of int values

Is it possible to force json field types while using the Unreal SDK?

When stepping through the `bool UPlayFabClientAPI::WritePlayerEvent(...)` function, I do _not_ hit the boolean switch case below.

    case EJson::Boolean:
    {
        writer->WriteValue(JsonValue->AsBool());
        break;
    }

But when viewing the event logs raw data, the JSON is displaying false/true values for fields populated with 0/1 number types.

Fields In Question: team0PlayerCount & team1PlayerCount & teamId

{
    "EventName": "player_started_match",
    "EventNamespace": "title.AF0A",
    "Source": "AF0A",
    "EntityType": "player",
    "TitleId": "AF0A",
    "EntityId": "1848B07180DA0CAA",
    "EventId": "4420729caf2c49c5baede1cf7108c671",
    "SourceType": "GameClient",
    "clientSessionId": "78C563354140CFD957A5D69FB20D5E54",
    "platformName": "WindowsEditor",
    "tsUtc": "2019-04-22T19:29:25.9200000Z",
    "tsLocal": "2019-04-22T12:29:25.9200000Z",
    "team0PlayerCount": true,
    "team1PlayerCount": false,
    "teamId": false,
    "gameModeName": 2
}

Some cases, some values are displayed as their intended type. `team0Score`

{
    "EventName": "player_ended_match",
    "EventNamespace": "title.AF0A",
    "EntityType": "player",
    "EntityId": "1848B07180DA0CAA",
    "EventId": "d6d55bc42812415698555893372bb530",
    "clientSessionId": "EE1B474D4FBDEF3F304949A2DCE32D28",
    "platformName": "WindowsEditor",
    "tsUtc": "2019-04-22T18:52:06.5130000Z",
    "tsLocal": "2019-04-22T11:52:06.5130000Z",
    "teamId": false,
    "team0Score": 2,
    "team1Score": 0
}

NOTE: I do recall that at some point these fields were populated with boolean values during implementation.

Could there be some type of field mapping on the PlayStream end that we are not aware of?

apisPlayStream
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Marcus Nixon avatar image
Marcus Nixon answered

Hi Julius,

I tried to reproduce the issue in Postman using the json you posted. My results are the following:

"teamId": 1,
"gameModeType": 2

I will report this issue to the development team and let them investigate.

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Julius Hipolito avatar image Julius Hipolito commented ·

Thank you for the support @Marcus Nixon!

I look forward to their findings. For the mean time, I hope changing the field name and creating a new event title will resolve the issue in the immediate future.

I want to link this issue as it also has data mutation present in PlayStream event output:

https://community.playfab.com/questions/29025/analytics-event-history-display-changes.html

0 Likes 0 ·
Marcus Nixon avatar image Marcus Nixon Julius Hipolito commented ·

Thanks Julius. I will also add that forum post to the bug report.

1 Like 1 ·
Marcus Nixon avatar image
Marcus Nixon answered

Hi Julius,

Can you please add your code here so that I can see the data you are passing in when you make your PlayFab api call?

3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Julius Hipolito avatar image Julius Hipolito commented ·

Sure thing. Here is an example of the code I used to generate the first payload. For clarity sake, I made the code explicit.

void USMPlayFabManager::LogEvent() const
{
	FDateTime dtUtc = FDateTime::UtcNow();
	FDateTime dtNow = FDateTime::Now();
	PlayFab::ClientModels::FWriteClientPlayerEventRequest request;
	request.EventName = FString(TEXT("player_started_match"));
	// Common Data
	request.Body.Add(FString(TEXT("tsUtc")), PlayFab::FJsonKeeper(dtUtc.ToIso8601()));
	request.Body.Add(FString(TEXT("tsLocal")), PlayFab::FJsonKeeper(dtNow.ToIso8601()));
	request.Body.Add(FString(TEXT("clientSessionId")), PlayFab::FJsonKeeper(FString(TEXT("78C563354140CFD957A5D69FB20D5E54"))));
	request.Body.Add(FString(TEXT("buildNumber")), PlayFab::FJsonKeeper(FString(TEXT("0.0.1.0"))));
	request.Body.Add(FString(TEXT("team0PlayerCount")), PlayFab::FJsonKeeper(int(1)));
	request.Body.Add(FString(TEXT("team1PlayerCount")), PlayFab::FJsonKeeper(int(0)));
	request.Body.Add(FString(TEXT("teamId")), PlayFab::FJsonKeeper(int(0)));
	request.Body.Add(FString(TEXT("gameModeName")), PlayFab::FJsonKeeper(int(2)));

0 Likes 0 ·
Julius Hipolito avatar image Julius Hipolito commented ·

Part 2...

#if WITH_EDITOR
	request.Body.Add(FString(TEXT("platformName")), PlayFab::FJsonKeeper(UGameplayStatics::GetPlatformName().Append(TEXT("Editor"))));
#else
	request.Body.Add(FString(TEXT("platformName")), PlayFab::FJsonKeeper(UGameplayStatics::GetPlatformName()));
#endif
	// End Common Data
	PlayFabClientPtr clientAPI = IPlayFabModuleInterface::Get().GetClientAPI();
	clientAPI->WritePlayerEvent(request); 

}
0 Likes 0 ·
Julius Hipolito avatar image Julius Hipolito commented ·

After setting the int values for team0PlayerCount and team1PlayerCount to larger numbers, PlayStream still displays the raw data as 'true/false'.

0 Likes 0 ·
Marcus Nixon avatar image
Marcus Nixon answered

Hi Julius,

I am attempting to reproduce your issue. I will let you know my results.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Marcus Nixon avatar image
Marcus Nixon answered

Hi Julius,

I was unable to reproduce your issue. My values are always written as integers as shown below:

"team0PlayerCount": 1,
"team1PlayerCount": 0,

Can you confirm that you are using the latest PlayFab plugin version 1.14.190329 and Unreal Engine 4.21?

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Julius Hipolito avatar image Julius Hipolito commented ·

We are using an older version of both the PF and UE4.

"VersionName": "1.5.181002",
"EngineVersion": "4.20.0",
0 Likes 0 ·
Julius Hipolito avatar image Julius Hipolito commented ·

Can you try creating an Custom Event with a payload:

"teamCount": true, 
"teamId": true

Then after reviewing the PlayStream event raw data, push to the same custom event with payload:

"teamCount": 1, 
"teamId": 0
0 Likes 0 ·
Marcus Nixon avatar image
Marcus Nixon answered

Using PlayFab::FJsonKeeper(bool(true)) and PlayFab::FJsonKeeper(int(1)) and PlayFab::FJsonKeeper(int(0)), I was able to produce your pasted results. The only problem I ran into was when I would make a change and attempt to run the code in Unreal before I actually recompiled.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Julius Hipolito avatar image Julius Hipolito commented ·

We updated our PlayFab SDK to 1.15.190410 and recompiled. Still receiving the same results where `int` values are being captured and displayed as `bool` in PlayStream raw event data.. Do we know what the cause of this is on PlayStreams side?

0 Likes 0 ·
Marcus Nixon avatar image
Marcus Nixon answered

I made some attempts today, but I am still unable to reproduce your issue. I even downloaded Unreal Engine 4.20.3 and tried to reproduce it with that version. Can you provide your title id so that we can investigate on our side? Also, to isolate the problem to the client side, you can try grabbing a fiddler trace to determine whether the values are leaving the client as Booleans or Ints. Another good troubleshooting step could be for you to download the PlayFab Postman collection and attempt to make the WritePlayerEvent request from Postman and compare the results.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Julius Hipolito avatar image Julius Hipolito commented ·
TitleID: AF08
EventID: 5977f45cb9524298a88e12bdf70be11b


Log Property: 'TeamId' should be 0 or 1.

I'll grab the Fiddler logs and I'll make a quick API call with our C# web tool we created as soon as I am able.

Thanks for the follow up!

0 Likes 0 ·
Marcus Nixon avatar image
Marcus Nixon answered
@Julius Hipolito

Hi Julius,

Were you able to provide a fiddler trace and test the API call with Postman or some other external API calling tool?

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Julius Hipolito avatar image Julius Hipolito commented ·

Sorry @Marcus Nixon - Got busy with tasks that derailed my investigations.

I have not had the time to try out Fiddler, but I did a quick Postman API call:

POST https://AF0A.playfabapi.com/Server/WritePlayerEvent
Content-Type: application/json
X-SecretKey: xxxSecretKeyxxx

{
    "PlayFabId": "1848B07180DA0CAA",
    "EntityType": "player",
    "EntityId": "1848B07180DA0CAA",
    "EventName": "player_started_match",
    "EventNamespace": "title.AF0A",
    "Source": "AF0A",
    "EntityType": "player",
    "Body": 
        {
    	"character": "Sumo",
    	"buildNumber": "0.1.0.21628",
    	"clientSessionId": "E50D00B4400A63938BF81EA7E7BB3788",
    	"platformName": "Windows",
    	"tsUtc": "2019-05-07T16:57:09.5160000Z",
    	"tsLocal": "2019-05-07T09:57:09.5160000Z",
    	"teamId": 1,
    	"gameModeType": 2
	}
}

This call resulted in the following response body:

{
    "code": 200,
    "status": "OK",
    "data": {
        "EventId": "efeb9e3ec77c41e3b002cd29cf7ec7ee"
    }

0 Likes 0 ·
Julius Hipolito avatar image Julius Hipolito commented ·

When reviewing event id 'efeb9e3ec77c41e3b002cd29cf7ec7ee' in PlayStream, we see the following output:

{
    "PlayFabEnvironment": {
        "Cloud": "main",
        "Vertical": "master",
        "Application": "mainserver",
        "Commit": "00114e6"
    },
    "EventName": "player_started_match",
    "EventNamespace": "title.AF0A",
    "Source": "AF0A",
    "EntityType": "player",
    "TitleId": "AF0A",
    "EntityId": "1848B07180DA0CAA",
    "EventId": "efeb9e3ec77c41e3b002cd29cf7ec7ee",
    "SourceType": "GameServer",
    "character": "Resistor",
    "Timestamp": "2019-05-07T17:24:53.7296756Z",
    "buildNumber": "0.1.0.21628",
    "clientSessionId": "E50D00B4400A63938BF81EA7E7BB3788",
    "platformName": "Windows",
    "tsUtc": "2019-05-07T16:57:09.5160000Z",
    "tsLocal": "2019-05-07T09:57:09.5160000Z",
    "teamId": {
        "bool": true
    },
    "gameModeType": 2
}

Team ID is reverted to a nested bool object?

Also, when posting to a completely new and different 'event name', such as 'player_started_match_four' we get:

{
    .,
    .,
    .,
    "teamId": {
        "long": 1
    },
    "gameModeType": 2
}
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.