Here is it:
export function transformEvent(event, metadata) {
const EVENT_NAME = event.properties.event.name;
const productID = event.properties.event.properties.product_id;
const userId = event.properties.user.devices[0].device_id;
const VALUE = event.properties.event.properties.usd_price;
var VALUE_round = Math.round(VALUE * 100) / 100
if (isNaN(VALUE_round)) VALUE_round = 0;
const isoTimestamp = event.properties.event.created_at;
const timestampDate = new Date(isoTimestamp);
const timestampSeconds = Math.round(timestampDate.getTime()/1000);
var platform = “”;
if (event.properties.user.subscriptions[0].store == “play_store”) {
platform = “Android”;
}
else {
platform = “iOS”;
}
var result = {
“a”: “key”,
“p”: platform,
“n”: “apphud_“+EVENT_NAME,
“i”: event.properties.app.bundle_id,
“custom_user_id”: userId,
// “value”: String(VALUE_round),
“value”: String(0.1),
“purchase_product_id”: productID,
// “amt”: String(VALUE_round),
“amt”: String(0.1),
“cur”: “USD”,
“is_revenue_event”: true,
“utime”: timestampSeconds,
“ip”: “85.253.16.7”
};
if (platform == “iOS”) {
if (event.properties.user.devices[0].idfa) {
result.idfa = event.properties.user.devices[0].idfa;
}
if (event.properties.user.devices[0].idfv) {
result.idfv = event.properties.user.devices[0].idfv;
}
}
else {
if (event.properties.user.devices[0].idfa) {
result.aifa = event.properties.user.devices[0].idfa;
}
}
return result;
}