0.2.4 • Published 4 years ago

iris-agent v0.2.4

Weekly downloads
23
License
SEE LICENSE IN LI...
Repository
github
Last release
4 years ago

Iris agent

This JavaScript library sends events data to agent-backend to then be stored in ClickHouse. You can define events as you wish (not only page loads) and send a custom payload with each of them.

Install

npm install iris-agent

or

yarn add iris-agent

Usage

Once the library is loaded (@todo info about how to load it using different include methods, in the meanwhile check ./example folder you must init the library this way:

<script>
    Iris.init('ACCOUNT_ID', CONFIG);
</script>

Where:

  • ACCOUNT_ID is a string to help you group all events happening for a given user defined domain. This can be a domain, a group of domains, a TLD, etc.
  • CONFIG is a configuration object that contains the following settings:
    • cookiePrefix (optional, string): this library stores cookies to identify user and sessions. You can costumize the string prepended to the name of these cookies.
    • targetUrl (optional, string): The uri of iris-backend (or any proxy you might have in between)
    • useBeacon (optional, bool): this library will try to send data using beacons by default. If this functionality is not available, it will fall back to transparent hidden pixel. Setting this value to false it will always use the fallback (pixel) method.

Example:

  <script>
    Iris.init(
        'XXX-ACCOUNT',
        {
            targetUrl: "http://iris-backend/recordevent.gif", cookiePrefix: "_foo",
            useBeacon: true
        });
  </script>

Once the library has been loaded and initted, you can use them using the fire method:

<script>
    Iris.fire('EVENT_NAME', EVENT_DATA);
</script>

Where:

  • EVENT_NAME (string): is the name of your event, such as pageload, button_clicked, etc.
  • EVENT_DATA (optional, misc): is the data you can attach to any event, like {"customer_id":123} or {"AB_TEST_FOO_VERSION":"A"}, it's up to you. However, it is a good idea to send JavaScript objects since these will be serialized as JSON. Once in ClickHouse it's easy to do queries that read JSON values.

Example:

<script>
    Iris.fire('pageview');
    Iris.fire('button_clicked', {text: "apply now!"});
</script>

Extend it

This assumes you have yarn installed.

yarn install
yarn development

Build it

yarn build

Example React Application

yarn example

Example HTML

yarn example:html
0.2.4

4 years ago

0.2.3

4 years ago

0.2.1

4 years ago

0.2.2

4 years ago

0.2.0

4 years ago

0.1.1

4 years ago