Eventvisor

Concepts

Transports

Transports send governed events to destinations. Core owns pipeline decisions. Transport modules own delivery reliability.

track() starts selected destinations in parallel and waits for every transport attempt. This is not a durable-delivery guarantee. A transport decides whether an attempt means sending immediately or accepting the event into its own queue.

Use module-http for bounded batching and retries, or module-beacon for browser navigation and shutdown delivery.

Module setup

We can install the module module-console in our application to give a demo:

Command
$ npm install --save @eventvisor/module-console

And then set it up when initializing the SDK:

import { createEventvisor } from "@eventvisor/sdk";
import { createConsoleModule } from "@eventvisor/module-console";
const eventvisor = createEventvisor({
modules: [
createConsoleModule(),
],
});

Usage example

Now that we know our application is set up with the module, we can use console as our transport in our desired destination:

destinations/browser.yml
description: Print to browser console
tags:
- web
transport: console

When we start tracking an event in our application using the SDK, it will be printed to the browser's console.

Creating custom transports

To create a custom transport, you can create a new custom module with at least the transport method implemented:

Defining module

your-app/custom.ts
export function createCustomModule() {
return {
name: "custom",
transport: async ({
payload,
eventName,
eventLevel,
error,
destinationName,
}, api) => {
// send the payload somewhere here...
// metadata also includes the datafile revision and optional validation details
// if tracked event is an error, then `error` will be the error object
},
};
};

Transport options include revision. When deliverWithWarning is active they also include validation.valid: false and validation errors. Quarantine transport calls receive a stable envelope as their payload.

SDK setup

And then set it up when initializing the SDK:

your-app/index.js
import { createEventvisor } from "@eventvisor/sdk";
import { createCustomModule } from "./custom";
const eventvisor = createEventvisor({
modules: [
createCustomModule(),
],
});

Transport usage

Later in your destination definition, you can use the custom transport like this:

destinations/browser.yml
# ...
transport: custom
Previous
Handlers