Api Initialization

To get started using the Scala library, instantiate the ReplayApi object. By default, it tries to locate a Typesafe config file for its parameters. A sample file looks like the following:

{ "replay-scala":
 {
     "api-key"    : "xxx-xxx-xxx-xxx-xxx"
     "ssl"        : true
     "server"     : "api.replay.io"
     "eventUri"   : "/events"
     "traitUri"   : "/traits"
 }
}

A manually constructed configuration object may also be passed in as an argument.

Api Methods

Both Events and Traits can be sent to the Replay service through the notify method. Its has the following signature:

def notify(message: ReplayMessage): Future[HttpResponse]

We use Spray.io for our networking. The HttpResponse from the server may be handled at your discretion.

Replay Messages

Replay messages can be constructed using the specific case class constructors.

Event

The event messages allow you to send events that happen on your site to Replay. They are constructed with a distinctId indicating a unique user and an eventName specific to the event type. Additional information can be added to a propertes map in the form of String - JsValue pairs.

case class Event(
    distinctId: String,
    eventName: String,
    properties: Map[String, JsValue]
)
Property Type Description
distinct_id String A distinct string that identifies the user (required)
event_name String A name for the event (e.g. “Signed Up”)
properties Object A dictionary of extra properties about an event

Trait

The trait messages allow you to send user information to Replay. They are constructed with a distinctId indicating a unique user. Additional information can be added to a propertes map in the form of String - JsValue pairs.

case class Trait(
    distinctId: String,
    properties: Map[String, JsValue]
)
Property Type Description
distinct_id String A distinct string that identifies the user (required)
properties Object A dictionary of extra traits of a user

Calling notify with a trait message will submit that event to our server.