Relay Reference
Relay Reference
|
The Event Protocol and Relay library are currently in early access. If you’re interested in using the Event Protocol and Relay library, reach out to your Customer Success Manager (CSM). |
Interfaces
EventConfig
The EventConfig
object provides additional information for the configuration associated with the event.
Properties
-
trackingId:
string
The unique identifier of a web property. See What’s a tracking ID?.
Meta
The Meta
object provides a structured representation of metadata associated with an emitted event.
This object is auto-populated by Relay.
Properties
-
clientId:
string
Persistent unique identifier of a device.
-
config:
EventConfig
Configuration associated with the event.
-
location:
nil
|string
Browser Location’s
href
property if set. -
referrer:
nil
|string
Browser Document’s
referrer
property if set. -
source:
string[]
Names and versions of the client side libraries which built and emitted this event.
-
ts:
number
Timestamp when the event was emitted.
-
type:
string
Event’s type that was emitted.
-
userAgent:
nil
|string
Browser Navigator’s
user agent
property if set.
Relay
Relay instance. This object provides a comprehensive set of variables and methods for interacting with the Event API.
Functions
-
clearStorage
Removes the visitorId cookie and localStorage key.
-
Returns
void
-
-
emit
Sends an event to the Event API.
-
Parameters
-
type:
string
Event’s type to be emitted.
-
payload:
Record<string>
|Record<any>
Payload to include within the event.
-
-
Returns
void
-
-
getMeta
Gets the client-side generated meta object.
-
Parameters
-
type:
string
Event’s type that will be included in the meta object.
-
-
Returns
Meta
-
-
off
Detach callback(s) from events. If only the "type" parameter is set, all callbacks for the specified type will be removed.
-
Parameters
-
type:
string
Event’s type.
-
callback:
EventCallback
Callback that should be removed.
-
-
Returns
void
-
-
on
Attaches an event callback to either all event types or a specific one. The callback set will be called when an event with the specified type is emitted. It’s not possible to modify the payload of the event sent to Coveo using this listener. Setting type as "*" will trigger the callback for all event types. Returns the "off" function to detach the event callback.
-
Parameters
-
type:
string
Event’s type.
-
callback:
EventCallback
Callback that should be called when the event is emitted.
-
-
Returns
Off
-
-
updateConfig
Updates Relay’s configuration after its initialization.
-
Parameters
-
config:
Partial<RelayConfig>
Configuration that should be updated.
-
-
Returns
void
-
Properties
-
version:
string
Current version of the Relay library.
RelayConfig
The RelayConfig
object defines the configuration options for initializing a Relay instance.
Properties
-
mode:
emit
|disabled
Defines the library mode. The available modes are
emit
anddisabled
.emit
sends analytics events to Coveo to be stored.disabled
prevents the emission of events and does not trigger callbacks.Default:
emit
-
source:
string[]
Optionally allows a Relay integration to specify the name(s) of software package(s) relay is being called from. These names will be transmitted with each event, along with Relay’s own version. The recommendation is to specify them using a 'softwarename@softwareversion' string.
-
token:
string
Token to authorize the access to the Event API endpoint.
-
trackingId:
string
The unique identifier of a web property. See What’s a tracking ID?.
-
url:
string
Endpoint defined to communicate with the Event API.
RelayEvent
Defines the structure of a RelayEvent, extending the RelayPayload.
Extends RelayPayload
Properties
-
meta:
Readonly
Read-only
meta
property of Meta type.
Functions
createRelay
Initializes the Relay library object.
-
Parameters
-
initialConfig:
RelayConfig
-
-
Returns
Relay
Type Aliases
EventCallback
Callback to perform an action when a specified event is emitted.
-
Parameters
-
event:
RelayEvent
The Relay event payload that triggered the callback.
-
-
Returns
void
Off
Function that detaches an event callback.
-
Returns
void
RelayPayload
Represents the payload sent with Relay. It is a object with string keys and values of any type.