question

brendan avatar image
brendan asked

Writing custom events with custom data

Question from a developer:

We're attempting to get useful data out of custom events, in a format something like this:

{
    "EventName": "customEvent",
    "EventNamespace": "title.123A",
    "Source": "123A",
    "EntityType": "player",
    "TitleId": "123A",
    "EventId": "b10a823068c24f9f83ea74cb8e5f369d",
    "EntityId": "6D37623BCB1AAA74",
    "SourceType": "GameClient",
    "Timestamp": "2017-06-06T20:19:52.801178Z",
    "History": null,
    "CustomTags": null,
    "Reserved": null,
    "customInfo1": 1234,
    "customInfo2": "foo"
}

How can we best accomplish this?

PlayStream
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 WritePlayerEvent API call is specifically designed to allow you to create custom events with custom data. For example, using this example:

POST /Client/WritePlayerEvent HTTP/1.1
Host: 5F4.playfabapi.com
Content-Type: application/json
X-Authentication: {SessionTicket}
{
  "EventName": "player_defeated_enemy",
  "Body": {
    "Enemy": "guardian",
    "Damage": 5,
    "Coordinates": {
      "X": 123.4,
      "Y": 543.2
    }
  }
}

You would get an event like this in PlayStream:

{
    "EventName": "player_defeated_enemy",
    "EventNamespace": "title.5F4",
    "Source": "5F4",
    "EntityType": "player",
    "TitleId": "5F4",
    "EventId": "3519be9914bb49259a99a883c925d448",
    "EntityId": "D1D23770317461C6",
    "SourceType": "GameClient",
    "Timestamp": "2017-06-06T20:33:40.8235998Z",
    "History": null,
    "CustomTags": null,
    "Reserved": null,
    "Enemy": "guardian",
    "Damage": 5,
    "Coordinates": {
        "X": 123.4,
        "Y": 543.2
    }
}
10 |1200

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

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.