drip-nodejs icon indicating copy to clipboard operation
drip-nodejs copied to clipboard

Documentation is incorrect for "Record an event"

Open victorcarvalhosp opened this issue 4 years ago • 0 comments

Hi guys,

Looking into the Javascript tab in the "Record an event" section in the documentation we can see the following code:

const client = require('drip-nodejs')({ token: YOUR_API_KEY, accountId: YOUR_ACCOUNT_ID });
const payload = {
  events: [{
    email: "[email protected]",
    action: "Logged in",
    properties: {
      affiliate_code: "XYZ"
    }
  }]
};

client.recordEvent(payload)
  .then((response) => {
    // Handle `response.body`
  })
  .catch((error) => {
    // Handle errors
  });

But this payload is wrong and returns an error: "JSON parsing error: The property '#/' of type object did not match one or more of the required schemas\"

The correct code should be:

const client = require('drip-nodejs')({ token: YOUR_API_KEY, accountId: YOUR_ACCOUNT_ID });
const payload = {
    email: "[email protected]",
    action: "Logged in",
    properties: {
      affiliate_code: "XYZ"
    }
};

client.recordEvent(payload)
  .then((response) => {
    // Handle `response.body`
  })
  .catch((error) => {
    // Handle errors
  });

Please update the documentation.

Thanks!

victorcarvalhosp avatar Oct 15 '21 13:10 victorcarvalhosp