lio Plugin
A framework for authoring JSTag integrations with pull and push patterns
`lio` plugin
A framework for authoring JSTag integrations.
| LIO |
|---|
| namespace lio |
| framework |
Concepts
"Pull integrations"
A "pull integration" is an extension of the JSTag which runs immediately when the tag is initialized. Pull integrations are about reading some data from the current web page to include in the initial entity request. For instance, a pull integration might read the value of a global variable in order to include that information with the entity request.
"Push integrations"
A "push integration" is an extension of the JSTag which runs after the Lytics entity is retrieved. Push integrations are about reading some information from the entity (or reading the entity itself in its entirety) and forwarding that information into another service.
"The blank"
The blank is a concept germane to pull integrations. When each pull integration runs, it receives as its argument "the blank", which is an object guaranteed to be freshly instantiated for each pull cycle. Each pull integration can mutate this object, usually by installing properties to it. The blank will be sent along with the entity request. Lytics will merge the blank with the user's entity for the purposes of computing the entity's current segment membership.
Configuration
lio: {
global: "liosetup",
polling: {
"lio.push": {
retries: 600,
interval: 100 // milliseconds
},
"lio.pull": {
retries: 0
}
},
performPullAndSend: true
}Interfaces
IntegrationOptions
properties
integrationName
- Type string
The name of the integration.
globalVariableName
- Type string
- Optional
The name of a property of the global object to pull into the entity request.
success
- Type () => void
- Optional
A callback to invoke upon success.
failure
- Type () => void
- Optional
A callback to invoke upon failure.
polling
- Type PollOptions
- Optional
Overrides for the default polling options
LioTask
Properties
channel
- Type "lio.pull" | "lio.push"
options
- Type IntegrationOptions
succeed
- Type Sink
fail
- Type Sink
LioStatus
- Type "lio.registered" | "lio.success" | "lio.failure"
Registry
- Type { [key: string]: LioStatus };
Sink
- Type (...rest: any[]) => void;
API
getIntegrationsRegistry(): Registry
Returns the registry of integrations.
isIntegrationLoaded(integrationName: string): boolean
Returns true if an integration is "loaded"
TODO terminology: should we be more consistent with terminology? I prefer the term "registered" to the term "loaded")
pull(sink: Sink): void
Run the pull integrations.
Plugin API
integration(channel: LioChannel, options: IntegrationOptions)
Register an integration on a channel. When an event fires on that channel, run the associated code. This is the primary mechanism for extending JSTag. Using the slightly friendlier entrypoints pullIntegration and pushIntegration is recommended.
pullIntegration(options: IntegrationOptions)
A convenience over integration("lio.pull", options)
pushIntegration(options: IntegrationOptions)
A convenience over integration("lio.push", options)
pullGlobalVariable(options: IntegrationOptions)
A convenience over integration("lio.pull", options) that streamlines the use-case of reading a global variable to include in the entity request.
Events
| Event | Fires when | Payload |
|---|---|---|
| lio.pull | Pull stage begins | "the blank" to install properties into |
| lio.push | Push stage begins | the entity |
| lio.pulled | Pull stage completes | none |
| lio.pushed | Push stage completes | none |
| lio.registered | After a task is registered | the LioTask |
| lio.started | Before each task | the LioTask |
| lio.succeeded | After a task completes successfully | the LioTask |
| lio.failed | After a task fails | the LioTask |
| lio.finished | After each task finishes | the LioTask |
| lio.flush | Before a stage begins | either "lio.pull" or "lio.push" |
| lio.flushed | After a stage completes | either "lio.pull" or "lio.push" |
| lio.done | After both pull and push stages complete | none |