//Find Form submission events and map them to Identify calls.
_.map(_.filter(events, { event: 'Demo Form Submitted' }), event => {
//Build a payload with the properties we're interested in.
const payload = _.pick(
event.properties,
'lang',
'country',
'company',
);
//Save them as a property in the Traits group
hull.traits(payload);
//Save them as a property in the `demo` group
hull.traits(payload, { source: "demo" });
});
// ======= OR =======
// If you don't want to overwrite certain values and keep the first ones submitted.
_.map(_.filter(events, { event: 'Demo Form Submitted' }), event => {
const { properties } = event;
hull.traits({
email: { operation: "setIfNull", value: properties.email },
lang: { operation: "setIfNull", value: properties.lang }
//...
});
});