Satori Integration #

Satori is LiveOps solution for Heroic, designed from inception to seamlessly integrate and work with Nakama. This guide demonstrates interacting with Satori via the Nakama server framework.

Prerequisites #

Getting started #

Learn how to get started using the Satori Client via the Nakama server runtime.

Satori client #

The Satori Client connects to your Satori Server and is the entry point to access Satori features.

The server connection details are configured in your Nakama configuration, so fetch the Satori client as follows:

Server
1
satori := nk.GetSatori()
Server
1
const satori = nk.getSatori();
Server
1
local satori = nk.get_satori()

Authentication #

Authenticate users with Satori and create a corresponding Satori identity, if one does not exist already. The id used can be the Nakama user ID or any other unique identifier.

Server
1
2
userId := "user-id"
satori.Authenticate(ctx, userId)
Server
1
2
const userId = "user-id";
satori.authenticate(userId);
Server
1
2
local userId = "user-id"
satori.authenticate(userId)

Properties #

Fetch the associated properties of an identity, and update any of these properties as desired.

Get properties #

To fetch the properties of an identity:

Server
1
properties, err := satori.PropertiesGet(ctx, "identityId")
Server
1
const properties = satori.propertiesGet("identityId");
Server
1
local properties = satori.properties_get("identityId")

Update properties #

To update the properties of an identity:

Server
1
2
3
4
5
6
7
8
err := satori.PropertiesUpdate(ctx, "identityId", &runtime.PropertiesUpdate{
  Default: map[string]string{
    "language": "japanese",
  },
  Custom: map[string]string{
    "customProperty": "someValue",
  },
})
Server
1
2
3
4
5
6
7
8
satori.propertiesUpdate("identityId", {
    default: {
        "language": "japanese"
    },
    custom: {
        "customProperty": "someValue"
    }
});
Server
1
2
3
4
5
6
7
8
satori.properties_update("identityId", {
    ["default"] = {
        ["language"] = "japanese"
    },
    ["custom"] = {
        ["customProperty"] = "someValue"
    }
})

Events #

Publish one or more events to Satori for a given identity.

Server
1
2
3
4
5
6
7
8
9
satori.EventsPublish(ctx, "identityId", []*runtime.Event{{
  Name: "eventName",
  Id: "optionalEventId",
  Metadata: map[string]string{
    "someProperty": "someValue",
  },
  Value: "someValue",
  Timestamp: time.Now().Unix(),
}})
Server
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
satori.eventsPublish("identityId", [
    {
        name: "eventName",
        id: "optionalEventId",
        metadata: {
            "someProperty": "someValue"
        },
        value: "someValue",
        timestamp: Date.now()
    }
]);
Server
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
satori.events_publish("identityId", {
    {
        ["name"] = "eventName",
        ["id"] = "optionalEventId",
        ["metadata"] = {
            ["someProperty"] = "someValue"
        },
        ["value"] = "someValue",
        ["timestamp"] = os.time()
    }
})

Experiments #

You can list all experiments for a given identity, or optionally filter by a specific experiment.

Server
1
experimentList, err := satori.ExperimentsList(ctx, "identityId", "experimentName1", "experimentName2")
Server
1
const experiments = satori.experimentsList("identityId", ["experimentName1", "experimentName2"]);
Server
1
local experiments = satori.experiments_list("identityId", { "experimentName1", "experimentName2" })

Feature Flags #

You can list all flags for a given identity, or optionally filter by a specific feature flag.

Server
1
flagList, err := satori.FlagsList(ctx, "identityId", "flagName1", "flagName2")
Server
1
const flags = satori.flagsList("identityId", ["flagName1", "flagName2"]);
Server
1
local flags = satori.flags_list("identityId", { "flagName1", "flagName2" })

Live Events #

You can list all Live Events for a given identity, or optionally filter by a specific live event.

Server
1
liveEventList, err := satori.LiveEventsList(ctx, "identityId", "liveEventName1", "liveEventName2")
Server
1
const liveEvents = satori.liveEventsList("identityId", ["liveEventName1", "liveEventName2"])
Server
1
local liveEvents = satori.live_events_list("identityId", { "liveEventName1", "liveEventName2" })