amplitude / Amplitude-TypeScript

TypeScript Amplitude Analytics SDK
https://amplitude.github.io/Amplitude-TypeScript/
MIT License
142 stars 40 forks source link

Revenue Duplicated #231

Closed renatotr closed 2 years ago

renatotr commented 2 years ago

Hello, I have implemented the beta node sdk, but I'm facing a problem while registering a new Revenue.. When I register it, and check it on the User Look-up, I see it duplicated.

The first one, in the Event Type (again, looking at the User Look-Up Table) is called [Amplitude] Revenue (with the properties correct and everything just fine)

The second one, that appears almost immediately after the first one, is with the [Amplitude] Revenue (Unverified). I'm supposing this should not be the behavior expected.

The events work just fine with a very similar code.

My function below (all the parameters where checked beforehand by other function)

async function trackRevenue(user_id, product_id, price, eventProperties, env) {
    require('@amplitude/analytics-node').init('MY_KEY_HERE')

    const event = new Revenue()
        .setProductId(product_id)
        .setPrice(price)
        .setQuantity(1)
        .setRevenueType((price > 0) ? `incoming` : `refund`)
        .setEventProperties(eventProperties)

    try {
        const result = await revenue(event, {
            user_id: user_id
        }).promise

        if (result.code !== 200) {
            console.log(`Error: : ${result.code}
            Received message: ${result.message}
            Created Event Server Side ${JSON.stringify(result.event)}`)
            return ({ error: true, message: result.message })

        }
        console.log(`Everything worked just fine. Success Message: ${result.message}`)
        return ({ error: false, message: result.message })
    } catch (err) {
        console.log(`Error on trackRevenue. Error received: ${err}`)
        return ({ error: true, message: err })
    }

}

PS: I receive a success message from amplitude

Environment

Print: image

Thanks for the support!

liuyang1520 commented 2 years ago

Hi, @renatotr ,

Thanks for asking here!

I think this is expected behavior, here is the reason of "Revenue (Unverified)":

If a revenue event is unverified, that does not mean it failed verification. It means Amplitude did not attempt to verify it since it came through the HTTP API, Javascript SDK, or because your project did not include any revenue verification keys. If verification is not on, this event will be logged for all revenue events.

If you want to learn more, we have a doc mentioning how to enable the revenue verification.

Thanks!