strings within limits.
You cannot set values of types:
object or array, but you can serialize as strings.exports.onExecutePostLogin = async (event, api) => {
const serialized_object_value = JSON.stringify({
string_value: 'Auth0',
boolean_value: true,
number_value: 12
});
api.transaction.setMetadata('serialized_object_value', serialized_object_value);
const serialized_array_value = JSON.stringify([
'Auth0',
true,
12
]);
api.transaction.setMetadata('serialized_array_value', serialized_array_value);
console.log('serialized_object_value',
JSON.parse(event.transaction?.metadata?.serialized_object_value)
);
/* Outputs "serialized_object_value { string_value: 'Auth0', boolean_value: true, number_value: 12 }" */
console.log('serialized_array_value',
JSON.parse(event.transaction?.metadata?.serialized_array_value)
);
/* Outputs "serialized_array_value [ 'Auth0', true, 12 ]" */
};