update api.js to track every sale