question

Amar avatar image
Amar asked

Deleting a custom event from the history once it is consumed by cloud script?

@Brendan, we have a use case in a secure application where no personal date is persisted or saved, including in the event history on the PlayStream as user on the application is anonymous. But we have a need to send some personal information to 3rd party servers when certain conditions are met, and for that we would like to capture that information from the user in a popup, and pass it as payload via a custom event, which we capture on the Play Stream and invoke a "web hook API" call and pass this data to the 3rd party server..

We do not want this kind of custom event to be persisted in the event history, because it has payload with personal data. We would like to delete this event from the event history, as soon as it is consumed.

How can we achieve this? Is there a way to consume a custom event and delete the event from the event history/queue?

datawebhooksPlayStream
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

·
Sarah Zhang avatar image
Sarah Zhang answered

PlayFab event history is designed for data analysis. So PlayFab doesn’t provide a “deleting specific history records” feature to title developers. For your situation, we would suggest you do the API requests directly on CloudScript or on CloudScript using Azure Functions. For example, you can write a CloudScript function like the following one to make a web request to an external HTTP API.

Besides, using Azure Functions to run cloud code that is bound to a PlayFab title gives you the power of C# and strongly typed code. It also gives you the ability to leverage any number of Azure features such as CosmosDB. If you want more details about this feature, please check the doc -- https://docs.microsoft.com/en-us/gaming/playfab/features/automation/cloudscript-af/.

ExecuteCloudScript and ExecuteFunction can be used in clients, the custom servers or be used as the actions in the PlayFab Rules. When you execute the functions, you can disable the “GeneratePlayStreamEvent” option to prevent the generation of event history.

// This is a simple example of making a web request to an external HTTP API.
handlers.makeHTTPRequest = function (args, context) {
    var headers = {
        "X-MyCustomHeader": "Some Value"
    };
    
    var body = {
        input: args,
        userId: currentPlayerId,
        mode: "foobar"
    };

    var url = "http://httpbin.org/status/200";
    var content = JSON.stringify(body);
    var httpMethod = "post";
    var contentType = "application/json";

    // The pre-defined http object makes synchronous HTTP requests
    var response = http.request(url, httpMethod, content, contentType, headers);
    return { responseContent: response };
};

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.