API Reference of GS2-Log SDK for Game Engine

Model

EzInGameLog

In-game log

TypeRequireDefaultLimitationDescription
timestamplongTimestamp (Unix time unit:milliseconds)
userIdstring~ 128 charsUser Id
tagsList<EzInGameLogTag>~ 20 itemsTags
payloadstring~ 10485760 charsPayload in JSON format

EzInGameLogTag

In-game log tag

TypeRequireDefaultLimitationDescription
keystring~ 64 charsTag Key
valuestring~ 128 charsTag Value

Methods

sendInGameLog

Send in-game logs

Request

TypeRequireDefaultLimitationDescription
namespaceNamestring~ 128 charsNamespace name
tagsList<EzInGameLogTag>~ 20 itemsTags
payloadstring~ 10485760 charsPayload in JSON format
accessTokenstring~ 128 charsUser Id

Result

TypeDescription
itemEzInGameLogIn-game log

Implementation Example

    var domain = gs2.Log.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    );
    var result = await domain.SendInGameLogAsync(
        payload: "{\"category\": \"use-item\", \"count\": 1, \"itemId\": \"item-0001\"}",
        tags: new List<Gs2.Unity.Gs2Log.Model.EzInGameLogTag> {
            new Gs2.Unity.Gs2Log.Model.EzInGameLogTag() {
                Key = "tag1",
                Value = "value1",
            },
            new Gs2.Unity.Gs2Log.Model.EzInGameLogTag() {
                Key = "tag2",
                Value = "value2",
            },
        }
    );
    var item = await result.ModelAsync();
    var domain = gs2.Log.Namespace(
        namespaceName: "namespace-0001"
    ).Me(
        gameSession: GameSession
    );
    var future = domain.SendInGameLogFuture(
        payload: "{\"category\": \"use-item\", \"count\": 1, \"itemId\": \"item-0001\"}",
        tags: new List<Gs2.Unity.Gs2Log.Model.EzInGameLogTag> {
            new Gs2.Unity.Gs2Log.Model.EzInGameLogTag() {
                Key = "tag1",
                Value = "value1",
            },
            new Gs2.Unity.Gs2Log.Model.EzInGameLogTag() {
                Key = "tag2",
                Value = "value2",
            },
        }
    );
    yield return future;
    if (future.Error != null)
    {
        onError.Invoke(future.Error, null);
        yield break;
    }
    var future2 = future.Result.ModelFuture();
    yield return future2;
    if (future2.Error != null)
    {
        onError.Invoke(future2.Error, null);
        yield break;
    }
    var result = future2.Result;
    const auto Domain = Gs2->Log->Namespace(
        "namespace-0001" // namespaceName
    )->Me(
        GameSession
    );
    const auto Future = Domain->SendInGameLog(
        "{\"category\": \"use-item\", \"count\": 1, \"itemId\": \"item-0001\"}", // payload
        []
        {
            auto v = MakeShared<TArray<TSharedPtr<Gs2::UE5::Log::Model::FEzInGameLogTag>>>();
            v->Add(
                MakeShared<Gs2::UE5::Log::Model::FEzInGameLogTag>()
                ->WithKey(TOptional<FString>("tag1"))
                ->WithValue(TOptional<FString>("value1"))
            );
            v->Add(
                MakeShared<Gs2::UE5::Log::Model::FEzInGameLogTag>()
                ->WithKey(TOptional<FString>("tag2"))
                ->WithValue(TOptional<FString>("value2"))
            );
            return v;
        }() // tags
    );
    Future->StartSynchronousTask();
    if (Future->GetTask().IsError())
    {
        return false;
    }

    // obtain changed values / result values
    const auto Future2 = Future->GetTask().Result()->Model();
    Future2->StartSynchronousTask();
    if (Future2->GetTask().IsError())
    {
        return Future2->GetTask().Error();
    }
    const auto Result = Future2->GetTask().Result();