send Plugin

Send data into Lytics with support for blocking and mock modes

send plugin

Send data into Lytics.

Send
namespace send
data collection utility

Concepts

"mock"

"blocked"

We have the capability of buffering calls to jstag.send() until we "unblock" the instance. This can be useful for working around load order issues and other causes of asynchrony.

Interfaces

SendParams

All parameters are optional, and they can be passed in any order. They are disambiguated using the JavaScript typeof operator.

The parameters are:

  • payload Record<string, unknown> the key value pairs to send into Lytics
  • stream string the name of the Lytics stream to send this message.
  • isMock boolean when true, this is a mock send
  • callback AckCallback A callback which will be invoked when the message is acknowledged.

AckCallback

Message

properties

  • data Record<string, unknown>;
  • dataMsg string The serialized data message
  • sendurl string[]
  • callback AckCallback Optional
  • stream string Optional
  • channelName "Form" | "Gif" The transport used to send the message

API

send(...rest: SendParams[]): void;

parameters

SendParams

examples

jstag.send({ skyColor: 'blue' });

Exhibit: sending an arbitrary message without notification

jstag.send({ skyColor: 'blue' }, () => {
  console.log('message was sent');
});

Exhibit: sending an arbitrary message with notification

identify(...rest: SendParams[]): void;

An alias of send.

parameters

SendParams

example

jstag.identify();

Exhibit: A perhaps more semantic way of sending a user's identity into Lytics

page(...rest: SendParams[]): void;

Like send, but with the results of page analysis merged into the payload.

parameters

SendParams

examples

jstag.page();

Exhibit: Recording a page view in Lytics

MyApp.onRouterChange(() => jstag.page());

Exhibit: A setup for a hypothetical single page app.

pageView(...rest: SendParams[]): void;

An alias of page

parameters

SendParams

example

jstag.pageView();

Exhibit: A perhaps more semantic way of calling jstag.page()

mock(...rest: SendParams[]): void;

Like send, but with mock always true

parameters

SendParams

examples

jstag.mock({ cartContents: MyApp.getCartContents() });

Exhibit: collecting some data that will be included when the entity request is made, and will get sent into Lytics eventually

unblock(): JSTag;

Send all the blocked messages. Note that there is no method to block again once unblocked.

Events

EventFires whenPayload
send.unblockedThe initial "block" has been removed.the number of buffered messages which were merged when unblock was called

Learn more about events