# Fullstory

## Overview

> **Info:** **API INFO**: The Base URL used for the Fullstory connector is **<https://api.fullstory.com/>**. More information can be found on their main [API documentation (v1)](https://developer.fullstory.com/introduction) site.

FullStory enables users to track and monitor each customer activity. From clicks to page transitions, everything is indexed automatically.

## Authentication

Within the builder, click on the Fullstory connector to display the connector properties panel. Select the 'Authentication' tab and click on the 'New authentication' button.
![add-new-auth](https://tray.ai/documentation/images/connectors/service/fullstory/32e26275-ae476988_add-new-auth.png)
In the Tray.io authentication pop-up modal, name the authentication in a way that will easily identify it within a potentially large list. For example, whether it is a Sandbox or Production auth, etc.
Consider who/ how many people will need access to this authentication when choosing where to create this authentication ('Personal' or 'Organisational').
The second page asks you for your 'API Key'.
![auth-api-key](https://tray.ai/documentation/images/connectors/service/fullstory/32e26275-505c4bcc_auth-api-key.png)
In order to get these fields, head to the Fullstory dashboard. Click on the vertical hamburger icon on the top right corner and select 'Settings'.
Navigate to 'Integrations' > 'API Keys'.
Here you can create an API Key using the 'Create key' button.

> **Info:** **PLEASE NOTE**: Make sure to copy the API token as it will only be displayed once.

![auth-create-api-key](https://tray.ai/documentation/images/connectors/service/fullstory/32e26275-a27a9564_auth-create-api-key.png)
Once you have added these fields to your Tray.io authentication pop-up window, click the 'Create authentication' button.
Your connector authentication setup should now be complete.

## Available Operations

The examples below show one or two of the available connector operations in use.
Please see the [Full Operations Reference](#operationsFull) at the end of this page for details on all available operations for this connector.

## Notes on using Fullstory

### Get user

> **Warning:** **PLEASE NOTE**: The 'UserId' received in the output of the 'List Sessions from Email' operation cannot be used as an input to the 'User ID' field of the 'Get user' operation.

The Get user operation provides the data about users who have been identified in the browser. It uses 'User ID' to fetch the user details from Fullstory.
![get-user-operation](https://tray.ai/documentation/images/connectors/service/fullstory/32e26275-4e038225_get-user-operation.png)
User ID is a six-digit number found in the User's profile on your Fullstory dashboard.
![user-profile](https://tray.ai/documentation/images/connectors/service/fullstory/32e26275-256ec640_user-profile.png)

## Example Usage

> **Info:** **TRAY POTENTIAL:** Tray.io is extremely flexible. By design there is no fixed way of working with it - you can pull whatever data you need from other services and work with it using our core and helper connectors. This demo which follows shows only one possible way of working with Tray.io and the Fullstory connector. Once you've finished working through this example please see our [Introduction to working with data and jsonpaths](https://tray.ai/documentation/platform/automation-integration/building-workflows/mapping-data/basic-data-concepts/) page and [Data Guide](https://tray.ai/documentation/platform/automation-integration/building-workflows/mapping-data/mapping-data-between-steps/) for more details.

Below is an example of a way in which you could potentially use the Fullstory connector to list session details for a given email address.
These sessions are then counted and a daily notification of the total session count is sent to [Slack](https://tray.ai/documentation/connectors/service/slack/), to keep track of daily browser activities.
Note that you could also send this information to a [Google Sheet](https://tray.ai/documentation/connectors/service/google-sheets) or a SQL database.
The overall logic of the workflow is:

1. The workflow is triggered by a **scheduled trigger** that runs daily.
2. It **gets the List of all the sessions** based on the specified email address.
3. Loops through the **Session Dates** and compares each with the **Last Run Date** to see if there are any new sessions.
4. **Is new Session?** is a boolean step which checks if each session **occurred after the last run date**. If so, the **Session count is incremented**.
5. Then the **Total Session Count is fetched** and sent as a **Slack notification**.
6. Finally, the **Last Run Date** is set, which will be used in the next run of the workflow

> **Warning:** The efficiency of this workflow may slightly reduce over time if after say, a year, a user has thousands of sessions to be looped through. In which case you may find it will take a minuteor so to run

Your completed workflow should look similar to this:
![fullstory-complete-wf-1](https://tray.ai/documentation/images/connectors/service/fullstory/32e26275-fb45e94b_fullstory-complete-wf-1.png)

### Step-by-step Explanation

### 1 - Scheduled Trigger

The [Scheduled Trigger](https://tray.ai/documentation/connectors/trigger/scheduled-trigger/) runs Daily at Midnight. This can be tuned to run more or less often.
![scheduled-trigger](https://tray.ai/documentation/images/connectors/service/fullstory/32e26275-68c94cd3_scheduled-trigger.png)

### 2 - Remove 7 Days

This step backdates the workflow 7 days before.
The output from the **Remove 7 Days** step will **only be used the first time this workflow runs**.
On the first run, there will be **no last run date** in data storage, so we need to **set a date in recent history to make the first check**.
The **Remove 7 Days** step uses the [Date time helpers](https://tray.ai/documentation/connectors/helper/date-time-helper/) **Minus from date** operation. It takes the workflow's **execution start time ($.env.execution\_start\_time)** and removes seven days from it.
If you wish to **change how far back** the first check goes, you can highlight the **Remove 7 Days** step, and in the properties panel to the right, change the number of 'Days' based on your requirements.
After the first run, the workflow will keep track of its previous run in the **Set Last Run Date** step and use this value every time the workflow runs henceforth.
![remove-seven-days](https://tray.ai/documentation/images/connectors/service/fullstory/32e26275-113c8114_remove-seven-days.png)

### 3 - Get Last Run Date

This step **gets the last Run date from** the key set in the **Set Last Run Date** step. Usually, this value will be the previous day.
If it's the **first run**, this step will pull this date from the **Remove 7 Days** step.

> **Info:** **JSONPATHS:** For more information on what jsonpaths are and how to use jsonpaths with Tray, please see our pages on [Basic data concepts](https://tray.ai/documentation/platform/automation-integration/building-workflows/mapping-data/basic-data-concepts) and [Mapping data between steps](https://tray.ai/documentation/platform/automation-integration/building-workflows/mapping-data/mapping-data-between-steps)

> **Info:** \*\*CONNECTOR-SNAKE: \*\*The simplest and easiest way to generate your jsonpaths is to use our feature called the [Connector-snake](https://tray.ai/documentation/platform/automation-integration/building-workflows/mapping-data/mapping-data-between-steps/#the-connector-snake). Please see the main page for more details.

![get-last-run-date](https://tray.ai/documentation/images/connectors/service/fullstory/32e26275-cd9ea7e6_get-last-run-date.png)

### 4 - List Sessions from Email

It is a Fullstory connector step that, using the 'List Sessions from Email' operation, fetches all the sessions for the specified 'Email' address.
![list-session-from-email](https://tray.ai/documentation/images/connectors/service/fullstory/32e26275-b3c5bf88_list-session-from-email.png)

### 5 - Loop Fullstory Sessions

Loops through the records received from the previous step.
![loop-fullstory-sessions](https://tray.ai/documentation/images/connectors/service/fullstory/32e26275-6b411622_loop-fullstory-sessions.png)

### 5a - Format Session Date

Formats the CreatedTime value received through the loop into the `YYYY-MM-DDTHH:mm:ssZ (2006-01-22T23:04:05-0000)` date format.
This is done to match the CreatedTime date format with the workflows Last Run Date format, as they will be later compared in the **Compare Dates** step.
![format-session-date](https://tray.ai/documentation/images/connectors/service/fullstory/32e26275-ff236314_format-session-date.png)

### 5b - Compare Dates

A comparison between the Sessions CreatedTime and workflows Last Run Date. Where the CreatedTime Date (`$.steps.date-time-helpers-1.result`) should be **AFTER** the Last Run Date (`$.steps.storage-1.value`).
This will ensure the session received from the **List Sessions from Email** step is a new session.
If the check passes, the step will return the `true` value.
![compare-dates](https://tray.ai/documentation/images/connectors/service/fullstory/32e26275-0e20d245_compare-dates.png)

### 5c - Is New Session?

A boolean check to verify if the value received through the previous step is **Not equal to** `false`.
![boolean-check](https://tray.ai/documentation/images/connectors/service/fullstory/32e26275-42d55b46_boolean-check.png)

### True Branch

### 1 - Increment Session Count

If the **boolean check passes**, i.e. the session received through the loop is a new session **, the session count will increment by one**.
This step uses the [Data storage's](https://tray.ai/documentation/connectors/core/data-storage/) **Atomic Increment** operation, which increases the counter based on the value specified in the 'Value to add' field.
![increment-session-count](https://tray.ai/documentation/images/connectors/service/fullstory/32e26275-c8f26600_increment-session-count.png)

### False Branch

### 1 - No action is taken

If the **boolean check fails**, i.e. the session received through the loop is not a new session, then **no action is taken**.

### 6 - Get Total Session Count

This step **gets the total session count** from under the `count` key set in the **Increment Session Count** step.
![get-total-session-count](https://tray.ai/documentation/images/connectors/service/fullstory/32e26275-5f035872_get-total-session-count.png)

### 7 - Send Session Count

This step uses Slack's **Send message** operation to send the total session count to a selected Slack 'Channel'.
The value for the total session count is fetched from the previous step (`$.steps.storage-2.value`).
![send-session-count](https://tray.ai/documentation/images/connectors/service/fullstory/32e26275-b2d30e6a_send-session-count.png)
The session count sent on the Slack message should look something like this:
![slack-message-op](https://tray.ai/documentation/images/connectors/service/fullstory/32e26275-db6c4a49_slack-message-op.png)

### 8 - Set Last Run Date

In this step, we are using an environment variable ($.env.execution\_start\_time) that is the workflow's execution start date and time.
This value keeps track of the workflow's previous run and uses this value every time the workflow runs.
![set-last-run-date](https://tray.ai/documentation/images/connectors/service/fullstory/32e26275-baaa4808_set-last-run-date.png)

> **Info:** \*\*BEST PRACTICES: \*\*Whenever you do decide to create your own workflow, be sure to check out some of our key articles such as:- [Using callable workflows](https://tray.ai/documentation/platform/automation-integration/building-workflows/composable-workflows/calling-other-workflows)
> - [Pagination](https://tray.ai/documentation/platform/automation-integration/advanced-use-cases/batching-queueing/pagination)
> - [Data transformation guide](https://tray.ai/documentation/platform/automation-integration/building-workflows/mapping-data/data-transformation-guide)
