question

larissa avatar image
larissa asked

Location - Latitude and Langitude missing in context

Hey there! :)

----

When running a task on a player segment, which executes a Cloudscript functions, the playerProfile in the context parameter looks like this:

{
    "playerProfile": {
        "PlayerId": "3AD2...",
        "DisplayName": "lissi",


	...

        "Locations": {
            "LastLogin": {
                "ContinentCode": "EU",
                "CountryCode": "DE",
                "City": "Frankfurt am Main",
                "Latitude": null,
                "Longitude": null
            }
        },

	...

}

I have several questions regarding this.

1.) Why are Latitude and Longitude missing here - even though when the Last Login happened, they were included in the event, and they also show up, when manually requesting the Profile via GetPlayerProfile?

2.) What keys can be expected to be available within the "Locations"-dictionary? Only "LastLogin", or any others as well? Is "LastLogin" guaranteed to be there? The documentation ( https://api.playfab.com/playstream/profile/PlayerProfile ) does not seem to mention this.

3.) Somewhat unrelated: When manually requesting the Players Locations via GetPlayerProfile, which Locations can be expected to be in the list (is there for example a certain timeframe or a certain amount of locations that are stored on the server?). Is the list ordered? Is there a guarantee, that at least the most recent location will be included?

---

Thanks!

apistasksPlayStream
10 |1200

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

1 Answer

·
brendan avatar image
brendan answered

The profile only contains the last location (last login). If the lat/long are null, that would normally be due to them having been null in the associated event. In my own testing, they show up in the profile the same way they do in the event. If you can give me the Title ID you're testing, the PlayFab ID of your player, and the ID of the Task, I can have a look at your title to see why you're getting different results.

5 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.

larissa avatar image larissa commented ·

Thanks! I checked the previous login-events (player_logged_in) of this player (as well as other players) and they always had non-null lat/long values. Here's the details:

TitleID: 6131

TaskID: 6234B1911A6F188E

PlayFabID: 3AD264F1DD7F6299 (but it happened for *every* player I tested)

Cloudscript Revision: 1018

(The cloudscript function I execute is logging the context, that's how I got the above result. The result can be seen in the playstream as well)

0 Likes 0 ·
brendan avatar image brendan larissa commented ·

I just tested querying that player's profile in your title, and it had the lat/long data:

{
    "code": 200,
    "status": "OK",
    "data": {
        "PlayerProfile": {
            "PublisherId": "9FC655C648B8DA29",
            "TitleId": "6131",
            "PlayerId": "3AD264F1DD7F6299",
            "Locations": [
                {
                    "ContinentCode": "EU",
                    "CountryCode": "DE",
                    "Latitude": 51.{removed - potential PII},
                    "Longitude": 9.{removed - potential PII}
                }
            ]
        }
    }
}

What is the specific handler in your Cloud Script you're using for this?

0 Likes 0 ·
larissa avatar image larissa brendan commented ·

"EnqueueNotificationTask" - as of now it does nothing but check the args for a password and log the context:

handlers.EnqueueNotificationTask = function (args, context)
{
    let notificationTaskArgs = getJsonObjectFromArgs(args);

    if (!notificationTaskArgs.hasOwnProperty(kPasswordKey) || notificationTaskArgs[kPasswordKey] !== kPassword)
    {
        logd("Error: EnqueueNotificationTask missing password");
        return false;
    }

    logd("The Context:");
    logd(JSON.stringify(context));
}

Please note this happens specifically when running the scheduled task, it might not happen when running the handler manually. Maybe you can try it with the task as well

TaskID: 6234B1911A6F188E
0 Likes 0 ·
Show more comments

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.