question

Jack Stephenson avatar image
Jack Stephenson asked

writeTelemetryEvents

I am trying to call WriteTelemetryEvents from Unity

to log information before a player has logged in.

Am having trouble understanding the proper aruguments

and where I get them from.

        WriteEventsRequest writeEventsRequest = new WriteEventsRequest();
        List<EventContents> contentList = new List<EventContents>();
        EventContents content = new EventContents();
        PlayFabAuthenticationContext context = new PlayFabAuthenticationContext();


        context.EntityToken = "???????????";
        context.EntityType = "??????????";
        context.EntityId = "??????????????";
        context.ClientSessionTicket = "??????????????";
        content.Name = "my_custom_event";
        content.EventNamespace = "custom";
        content.Entity = new PlayFab.EventsModels.EntityKey();
        content.Entity.Id = "???????????";
        content.Entity.Type = "????????????????";
        content.PayloadJSON = "{'Name'='jack'}";


        contentList.Add(content);


        writeEventsRequest.Events = contentList;
        writeEventsRequest.AuthenticationContext = context;


        PlayFabEventsAPI.WriteTelemetryEvents(writeEventsRequest, TResult, TError);


apis
10 |1200

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

Rick Chen avatar image
Rick Chen answered

Entities are the most basic addressable "things" that PlayFab APIs operate on. Each entity has a Type and an Id which together uniquely identify it. For more information about entity, you can refer to this document: Entity Programming Model. You can get an Entity Token when you call one of the login method or GetEntityToken API. The Authentication Context as well as the Entity in the request of the WriteTelemetryEvents API have been taken care by the SDK. In other words, as long as you have logged in as a player (called one of the login APIs), the EntityToken, EntityType, EntityId and ClientSessionTicket will be there when you call an API. You don’t need to define a new PlayFabAuthenticationContext or EntityKey when you call the API.

10 |1200

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

Jack Stephenson avatar image
Jack Stephenson answered

So then this should work?

         //Assume I am logged in
        WriteEventsRequest writeEventsRequest = new WriteEventsRequest();
        List<EventContents> contentList = new List<EventContents>();
        EventContents content = new EventContents();
        ////PlayFabAuthenticationContext context = new PlayFabAuthenticationContext();


        ////context.EntityToken = "???????????";
        ////context.EntityType = "??????????";
        ////context.EntityId = "??????????????";
        ////context.ClientSessionTicket = "??????????????";
        content.Name = "my_custom_event";
        content.EventNamespace = "custom";
        //content.Entity = "??????????????";
        //content.Entity.Id = "??????????????";
        //content.Entity.Type = "??????????????";
        content.PayloadJSON = "{'Name':'jack'}";


        contentList.Add(content);


        writeEventsRequest.Events = contentList;
        ////writeEventsRequest.AuthenticationContext = context;


        PlayFabEventsAPI.WriteTelemetryEvents(writeEventsRequest, TResult, TError);


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.

Rick Chen avatar image Rick Chen ♦ commented ·

Yes, assume you have logged in, it should work. If you encounter any issue with that, please let us know.

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.