new EventPublisher(productName, token, options)
Builds Endpoint Analytics (EA) event payloads and sends them to
the EA server.
Parameters:
| Name | Type | Description |
|---|---|---|
productName |
String | Name of the product publishing events. |
token |
String | The JWT token to use to authenticate with the EA server. |
options |
EventPublisher.Options |
Properties:
| Name | Type | Description |
|---|---|---|
isEnabled |
Boolean | Whether or not this publisher is publishing to the server. Currently ignores the request altogether, in the future this may store them in case publishing is re-enabled later. Defaults to true. |
- Source:
Methods
debug(group, name, payloadopt, nullable, connectionopt, nullable) → {Promise}
Post a debug-level event to the EA server.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
group |
String | The name of the group the event belongs to. | ||
name |
String | The designated event name. | ||
payload |
Object |
<optional> <nullable> |
null | The payload to pass. This will be extended onto the default payload object, if one exists. |
connection |
Connection |
<optional> <nullable> |
null | The Connection which is posting this payload. |
- Source:
Returns:
Fulfilled if the HTTP response is 20x.
- Type
- Promise
disable()
Disable the publishing of events.
- Source:
enable()
Enable the publishing of events.
- Source:
error(group, name, payloadopt, nullable, connectionopt, nullable) → {Promise}
Post an error-level event to the EA server.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
group |
String | The name of the group the event belongs to. | ||
name |
String | The designated event name. | ||
payload |
Object |
<optional> <nullable> |
null | The payload to pass. This will be extended onto the default payload object, if one exists. |
connection |
Connection |
<optional> <nullable> |
null | The Connection which is posting this payload. |
- Source:
Returns:
Fulfilled if the HTTP response is 20x.
- Type
- Promise
info(group, name, payloadopt, nullable, connectionopt, nullable) → {Promise}
Post an info-level event to the EA server.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
group |
String | The name of the group the event belongs to. | ||
name |
String | The designated event name. | ||
payload |
Object |
<optional> <nullable> |
null | The payload to pass. This will be extended onto the default payload object, if one exists. |
connection |
Connection |
<optional> <nullable> |
null | The Connection which is posting this payload. |
- Source:
Returns:
Fulfilled if the HTTP response is 20x.
- Type
- Promise
post(level, group, name, payloadopt, nullable, connectionopt, nullable) → {Promise}
Post an event to the EA server. Use this method when the level
is dynamic. Otherwise, it's better practice to use the sugar
methods named for the specific level.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
level |
String | ['debug', 'info', 'warning', 'error'] | ||
group |
String | The name of the group the event belongs to. | ||
name |
String | The designated event name. | ||
payload |
Object |
<optional> <nullable> |
null | The payload to pass. This will be extended onto the default payload object, if one exists. |
connection |
Connection |
<optional> <nullable> |
null | The Connection which is posting this payload. |
- Source:
Returns:
Fulfilled if the HTTP response is 20x.
- Type
- Promise
postMetrics(group, name, metrics, customFieldsopt, nullable) → {Promise}
Post a metrics event to the EA server.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
group |
String | The name of the group the event belongs to. | |
name |
String | The designated event name. | |
metrics |
Array.<Object> | The metrics to post. | |
customFields |
Object |
<optional> <nullable> |
Custom fields to append to each payload. |
- Source:
Returns:
Fulfilled if the HTTP response is 20x.
- Type
- Promise
setToken(token) → {void}
Update the token to use to authenticate requests.
Parameters:
| Name | Type | Description |
|---|---|---|
token |
string |
- Source:
Returns:
- Type
- void
warn(group, name, payloadopt, nullable, connectionopt, nullable) → {Promise}
Post a warning-level event to the EA server.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
group |
String | The name of the group the event belongs to. | ||
name |
String | The designated event name. | ||
payload |
Object |
<optional> <nullable> |
null | The payload to pass. This will be extended onto the default payload object, if one exists. |
connection |
Connection |
<optional> <nullable> |
null | The Connection which is posting this payload. |
- Source:
Returns:
Fulfilled if the HTTP response is 20x.
- Type
- Promise
Type Definitions
Options
Type:
- Object
Properties:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
host |
String |
<optional> |
'eventgw.twilio.com' | The host address of the EA server to publish to. |
defaultPayload |
Object | function |
<optional> |
A default payload to extend when creating and sending event payloads. Also takes a function that should return an object representing the default payload. This is useful for fields that should always be present when they are available, but are not always available. |
- Source: