Eventvisor

Concepts

Transports

Transports are the means how tracked events are sent to different destinations. They are made available as modules to your application.

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 { createInstance } from "@eventvisor/sdk";
import { createConsoleModule } from "@eventvisor/module-console";
const eventvisor = createInstance({
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, destinationName }) => {
// send the payload somewhere here...
},
};
};

SDK setup

And then set it up when initializing the SDK:

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

Transport usage

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

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