# Activity Stream

Activity Stream is an advanced feature that enables you to receive a real-time stream of all events that happen to people in your Encharge Account. You can store this activity in your data warehouse for further analytics.

### How to get started?

Activity Stream is an add-on that is available for an extra fee. Please get in touch with your account manager or contact <support@encharge.io>.

Please prepare your endpoint where events will be POSTed to. See below for a sample of an activity stream event.

{% hint style="info" %}
You can supply Segment.com [HTTP Tracking API source](https://segment.com/docs/connections/sources/catalog/libraries/server/http-api/#http-tracking-api-source) instead of your own endpoint.
{% endhint %}

The endpoint should return a success response (2XX code) in 2 seconds or less.

Each event will contain information (ID and email) about the person that triggered the event.

The timestamp that indicates when the event occured is attached to each event. The timestamp is UNIX time in milliseconds.

### What activities are streamed?

Below you'll find a list of activities that Encharge will send.&#x20;

{% hint style="info" %}
Please note that curly brackets indicated a value that will be replaced when the event is emitted. For example: `added-tag-{tag}` will become `added-tag-tag1` when the person is tagged with "tag1".
{% endhint %}

Name: `updatedUser` \
Type: `updatedUser`\
Person was updated. See `changedFields` in `properties` for changed fields, and their previous and new values.

Name: `newUser`\
Type: `newUser`\
Person was created.

Name: `unsubscribedUser` \
Type: `unsubscribedUser`\
Person unsubscribed from all emails.

Name: `added-tag-{tag}`\
Type: `tag`\
Person was tagged. The tag is also passed as `tag` in `properties`.

Name: `removed-tag-{tag}`\
Type: `tag`\
Person was untagged. The tag is also passed as `tag` in `properties`.

Name: `page-visited`\
Type: `page`\
Person visited a page on your site (when Site Tracking is installed). URL is available in `url` in `properties`.

Name: `form-submitted`\
Person submitted a from on your site (when Site Tracking is installed). URL is available in `url` in `properties`. Form data is available in `form` in `properties`.

Name: `sms-sent`\
Type: `sms`\
Person was sent an SMS. Message is available as `message` in `properties`.&#x20;

Name: `sms-failed` \
Type: sms\
Person couldn't be sent an SMS. Message is available as `message` in `propertis`.&#x20;

#### Email Events

In `properties` , each of these events will contain:

* Email Id as `emailId`&#x20;
* Flow ID (if applicable) as `flowId`.
* Flow Name (if applicable) as `flowName`.
* Email name as `emailName`.

Name: `email-delivered`\
Type: `email`\
Person received an email.&#x20;

Name: `email-open`\
Type: `email`\
Person opened an email.&#x20;

Name: `email-click`\
Type: `email`\
Person clicked an email. Clicked link URL can be found in `url` in `properties` .

Name: `email-reply`\
Type: `email`\
Person replied to an email.&#x20;

Name: `email-blocked`\
Type: `email`\
Person couldn't receive an email (soft bounce).

Name: `email-bounce`\
Type: `email`\
Person couldn't receive an email (hard bounce).

Name: `email-dropped`\
Type: `email`\
Person couldn't receive an email because they are unsubscribed, have an invalid email address, or if they've received this marketing email before. See `reason` in `properties` .

Name: `email-spamreport`\
Type: `email`\
Person reported this email as spam.

####

#### Flows Events

Name: `performed-step:{stepId}`\
Type: `step`\
Person performed a step. You can find the step and the flow ID as `stepId` and `flowId`  in `properties` .

Name: `errored-step:{stepId}`\
Type: `step`\
An error occured while the person was performing a step. You can find the step and the flow ID as `stepId` and `flowId`  in `properties` .

#### Custom Objects/Companies Events

All object events will include the available object information in the `object` property.

Name: `newObject-{objectName}`\
Type: `object`\
Custom object/company was created. Object data will be available in `properties`.\
For example, event named `newObject-company` will trigger when a new company is created.

Name: `updatedObject-{objectName}`\
Type: `object`\
Custom object/company was updated. See `changedFields` in `properties` for changed fields, and their previous and new values. \
For example, an event named `updatedObject-invoice` will trigger when an invoice is updated.

Name: `deletedObject-{objectName}`\
Type: `object`\
Custom object/company was deleted. The object `id` and `externalId` will be available in `properties`.

#### Object associations

Name: `newAssociation-{associationId}`\
Type: `association`\
Triggers when a new association with a specific ID is created.\
For example, an event named `newAssociation-123` will trigger when a new association of ID 123 is created between objects. \
The following properties are available in `properties`:  `associationId`, `fromId`, `fromObject`, `toId`, `toObject`.

Name: deletedAssociation-{associationId}\
Type: association\
Triggers when a new association with a specific ID is deleted.\
For example, an event named `deletedAssociation-123` will trigger when a new association of ID 123 is deleted. \
The following properties are available in `properties`:  `associationId`, `fromId`, `fromObject`, `toId`, `toObject` .

### Example payloads

#### Tag added

Person was tagged.

```json
{
  "event": "added-tag-test",
  "type": "tag",
  "properties": {
    "tag": "test"
  },
  "user": {
    "id": "c1756f7d-8086-4704-ac73-b242857feb1a",
    "email": "201c3420-2ab1-11ec-ab62-4f0b3dac823e-e2e-test-user@mailsac.com"
  },
  "timestamp": 1562914373005
}
```

#### Email Clicked

Email was delivered to person.

```json
{
  "event": "email-delivered",
  "type": "email",
  "properties": {
    "emailId": 59969,
    "flowId": "48918",
    "flowName": "New Flow",
    "emailName": "Welcome email"
  },
  "user": {
    "id": "1ad75773-a8d9-4676-b2e8-d2beebf3742f",
    "email": "someone@example.com"
  },
  "timestamp": 1562914373005
}
```

#### Person Updated

Field `company` was changed from "Acme" to "Encharge".

```json
{
  "event": "updatedUser",
  "type": "updatedUser",
  "properties": {
    "changedFields": {
      "company": {
        "newValue": "Encharge",
        "oldValue": "Acme"
      },
    },
    "source": "manual"
  },
  "user": {
    "id": "b361b760-f6c9-4b23-80a8-82a968987fb8",
    "email": "someone@example.com"
  },
  "timestamp": 1562914373005
}

```
