send Plugin
Send data into Lytics with support for blocking and mock modes
send plugin
send pluginSend 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
SendParamsAll 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
stringthe name of the Lytics stream to send this message. - isMock
booleanwhen true, this is a mock send - callback
AckCallbackA callback which will be invoked when the message is acknowledged.
AckCallback
AckCallbackMessage
Messageproperties
- data
Record<string, unknown>; - dataMsg
stringThe serialized data message - sendurl
string[] - callback
AckCallbackOptional - stream
stringOptional - channelName
"Form" | "Gif"The transport used to send the message
API
send(...rest: SendParams[]): void;
send(...rest: SendParams[]): void;parameters
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;
identify(...rest: SendParams[]): void;An alias of send.
parameters
example
jstag.identify();Exhibit: A perhaps more semantic way of sending a user's identity into Lytics
page(...rest: SendParams[]): void;
page(...rest: SendParams[]): void;Like send, but with the results of page analysis merged into the payload.
parameters
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;
pageView(...rest: SendParams[]): void;An alias of page
parameters
example
jstag.pageView();Exhibit: A perhaps more semantic way of calling jstag.page()
mock(...rest: SendParams[]): void;
mock(...rest: SendParams[]): void;Like send, but with mock always true
parameters
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;
unblock(): JSTag;Send all the blocked messages. Note that there is no method to block again once unblocked.
Events
| Event | Fires when | Payload |
|---|---|---|
send.unblocked | The initial "block" has been removed. | the number of buffered messages which were merged when unblock was called |
Updated 13 days ago
