I have multi product_context
and want add it to an event (my app is react app, and i using Browser Tracker in Javascipt Tracker). My code below:
const contextArray = [];
cart.map(async (element, index) => {
var category = await this.props.productActions.getNameCategoryByID(element.id_category)
var publisher = await this.props.productActions.getNamePubliserByID(element.id_nsx)
var author = await this.props.productActions.getNameAuthorByID(element.id_author)
const product_context = {
schema: "iglu:com.bookshop/product_context/jsonschema/1-0-0",
data: {
product_id: element._id,
product_name: element.name,
quantity: parseInt(element.count),
price: element.price,
category: category.data.name,
publisher: publisher.data.name,
author: author.data.name
}
}
contextArray.push(product_context)
})
trackSelfDescribingEvent({
event: {
schema: 'iglu:com.bookshop/product_action/jsonschema/1-0-0',
data: {
action: "purchase"
}
},
context: contextArray
})
But it not working. I can help me!!