Code Destination
A destination does not need a package. Pass an object with a push function
as code, and the collector calls it for every event, like any other
destination. Use it to run a few lines of your own code on events.
Where this fits
Code is a destination in the walkerOS flow:
Runs your own push function on each event, without a package.
Integrated
import { startFlow } from '@walkeros/collector';
const { elb } = await startFlow({
destinations: {
console: {
code: {
type: 'console',
config: {},
push: (event) => {
console.log('Event:', event.name, event.data);
},
},
},
},
});Bundled
In a flow.json, write the function as a $code: string:
"destinations": {
"console": {
"code": {
"type": "console",
"push": "$code:(event) => { console.log('Event:', event.name, event.data); }"
}
}
}The rules for code in a flow file are in
Inline code.
Set consent, mapping and the other destination options in config beside
code, as for any destination. In integrated mode the object can implement the
whole destination interface. batch
needs a pushBatch function, which only the integrated form can provide: a
flow file's code takes only type, init and push.
💡 Need implementation support?
elbwalker offers hands-on support: setup review, measurement planning, destination mapping, and live troubleshooting. Book a 2-hour session (€399)