Giter VIP home page Giter VIP logo

drip-nodejs's People

Contributors

blangenfeld avatar mnadel avatar pieterjandesmedt avatar samudary avatar shradhdha03 avatar wwalser avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

drip-nodejs's Issues

Preview mode not supported

In a local/testing environment, there seems to be no way to support the Drip API's Preview/Test mode.

I think this would be a great API to have, easily configured with an ENV variable:

const drip = Drip({
  token: API_KEY,
  accountId: ACCOUNT_ID,
  preview: true,
})

tagSubscriber not working

Everything you put in the payload results in these errors:

[ { code: 'email_error',
              attribute: 'email',
              message: 'Email must be a valid email address' },
            { code: 'presence_error',
              attribute: 'email',
              message: 'Email can\'t be blank' },
            { code: 'length_error',
              attribute: 'tag',
              message: 'Tag is too short (minimum is 1 character)' } ]

Turns out the payload shoudn't be put in an array.
Fixed by #12

Cannot create tags with a subscriber

Two issues here. If you try to post an array of tags when creating/updating a subscriber as per the docs:

req.body [Object: null prototype] {
  email: '[email protected]',
  tags: '["tag1", "tag2"]'
}

then it passes an array of an array:

"tags": [
   "[\"tag1\", \"tag2\"]"
],

however, even if I fix this and just pass just a comma string:

"tags": [
    "\"tag1\",\"tag2\""
 ],

Drip still stores it like this:

Screen Shot 2020-05-01 at 9 04 44 AM

404 on createUpdateSubscribers POST(Options)

Hi.
I'm using drip-nodejs package in my Reactjs project recently.
I follow the example code

const client = require('drip-nodejs')({
  token: API KEY,
  accountId: ACCOUNT ID,
});
const payload = {
      subscribers: [{
        email: "[email protected]",
        time_zone: "America/Los_Angeles",
        custom_fields: {
          shirt_size: "Medium"
        }
      }]
    };
    
    client.createUpdateSubscriber(payload)
      .then((response: any) => {
        // Handle `response.body`
        console.log(response, ' ------ dri - ---')
      })
      .catch((error: any) => {
        // Handle errors
      });

An error is reported in the browser

OPTIONS https://api.getdrip.com/v2/1151297/subscribers 404
Access to fetch at 'https://api.getdrip.com/v2/1151297/subscribers' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

How can I fix this?

Documentation is incorrect for "Record an event"

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!

Failed to `Subscribe someone to a campaign` and `Create or update a batch of subscribers`

Hello, please advise:

1) Subscribe someone to a campaign

{
  "email": "[email protected]",
  "time_zone": "Asia/Kuala_Lumpur",
  "custom_fields": {
    "name": "Jane Doe"
  }
}
  • response:
{
    "errors": [
        {
            "code": "parsing_error",
            "message": "JSON parsing error: The property '#/' of type Hash did not match one or more of the required schemas"
        }
    ]
}

2) Create or update a batch of subscribers

"batches": [{
    "subscribers": [
      {
        "email": "[email protected]",
        "tags": "early-access"
      },
      {
        "email": "[email protected]",
        "tags": "early-access"
      }
    ]
  }]
  • response:
{
    "status": 400,
    "error": "There was a problem in the JSON you submitted: 822: unexpected token at ': [{\n    \"subscribers\": [\n      {\n        \"email\": \"[email protected]\",\n        \"tags\": \"early-access\"\n      },\n      {\n        \"email\": \"[email protected]\",\n        \"tags\": \"early-access\"\n      }\n    ]\n  }]'"
}

Fetching batch results with `request_id`

The documentation mentions:

Responds with a 202 Accepted if successful. That means the server accepted the request and queued it for processing. The response includes a list of unique request_ids that can be used to check the status of the request later on.

However, there doesn't appear to be an exposed endpoint to lookup a result on the request_id. Am I missing something?

The URL generated by createUpdateOrder is incorrect

Here is the response object. This is with the latest version of the library

    "statusCode": 202,
    "body": {},
    "headers": {
        "content-type": "application/json; charset=utf-8",
        "content-length": "2",
        "connection": "close",
        "date": "Sun, 27 Jun 2021 02:26:04 GMT",
        "x-amzn-requestid": "5dca6177-1b40-4248-8355-0c44c9d47527",
        "referrer-policy": "strict-origin-when-cross-origin",
        "x-permitted-cross-domain-policies": "none",
        "x-xss-protection": "1; mode=block",
        "x-runtime": "0.033977",
        "strict-transport-security": "max-age=31536000; includeSubDomains",
        "x-amzn-remapped-content-length": "2",
        "x-frame-options": "SAMEORIGIN",
        "x-amzn-remapped-connection": "keep-alive",
        "x-download-options": "noopen",
        "x-request-id": "0077775e-2668-4377-bfbd-881d81ada366",
        "x-ratelimit-remaining": "3596",
        "x-amz-apigw-id": "BkA1hFlpoAMFvPw=",
        "cache-control": "no-cache",
        "x-amzn-remapped-server": "nginx",
        "x-ratelimit-limit": "3600",
        "x-content-type-options": "nosniff",
        "x-amzn-remapped-date": "Sun, 27 Jun 2021 02:26:04 GMT",
        "x-cache": "Miss from cloudfront",
        "via": "1.1 fc2f37d7003b9d84c9f65e09b5236c1e.cloudfront.net (CloudFront)",
        "x-amz-cf-pop": "YTO50-C3",
        "x-amz-cf-id": "YqoHuRhQ1BxAlwK3Qnae3CxdIO6ml-RMEevTMH8UJfd4EnA4hBfiuw=="
    },
    "request": {
        "uri": {
            "protocol": "https:",
            "slashes": true,
            "auth": null,
            "host": "api.getdrip.com",
            "port": 443,
            "hostname": "api.getdrip.com",
            "hash": null,
            "search": null,
            "query": null,
            "pathname": "/v2/XXXXXXX/orders",
            "path": "/v2/XXXXXXX/orders",
            "href": "https://api.getdrip.com/v2/XXXXXXX/orders"
        },
        "method": "POST",
        "headers": {
            "Content-Type": "application/json",
            "authorization": "Basic XXXXXXXXX",
            "User-Agent": "Drip NodeJS Wrapper 3.1.0",
            "accept": "application/json",
            "content-length": 765
        }
    }
}```

Orders endpoints

I'm having problems with the Orders methods and endpoints. I've tried both methods:

  let data = [{
    email: '[email protected]',
    amount: 10,
  }]
  let response = await dripClient.createUpdateBatchOrders(data)
  /* 202 Accepted, as in docs. But the order doesn't appear in the Drip web UI, there is
  nothing in the Activity feed and the subscriber `lifetime_value` attribute isn't updated. */

  data = {
    email: '[email protected]',
    amount: 10,
  }
  response = await dripClient.createUpdateOrder(data)
  // 404. Have tried sending an object wrapped in an array, as above, too.

The above uses the minimal payload as per the docs, and I've also tried populating all optional fields in the payload too.

I've also tried the endpoints without the drip-nodejs wrapper, with similar results.

Incorrect documentation for subscribeToCampaign

On https://developer.drip.com/?javascript#subscribe-someone-to-a-campaign it shows that client.subscribeToCampaign takes in an array of subscribers. Unfortunately, it only takes one subscriber.

❗️ Wrong

image

✅ Right

image

More Notes

If you use what the documentation describes, you'll get an HTTP 402 error stating:

{
            errors: [
                {
                    code: 'parsing_error',
                    message:
                        "JSON parsing error: The property '#/' of type object did not match one or more of the required schemas",
                },
            ],
 }

CreateUpdateSubscriber occasionally fails without an error

Hello,

I'm currently using the drip-nodejs package inside AWS Lambda functions. However, the problem I'm running into is that when I use createUpdateSubscriber, the API call will occasionally fail, and not update a subscriber's custom field values in Drip. For some reason, it seems the call is more likely to succeed if there had been recent previous invocations of the API.

This is an example of how I'm implementing the API call, using this as a reference for the payload structure, #30 :

const payload = {
  email: username,
  custom_fields: {
    question_sets_made: qSetsMade.toString(),
    last_question_set_made: date.toString()
  }
};

console.log("Invoking Drip API");
client.createUpdateSubscriber(payload)
  .then((response) => {
    console.log("success");
    console.log(response);
})
  .catch((error) => {
    console.log("failure");
    console.log(error);
});

For some reason, the API call doesn't even seem to receive a response or error message from the invocation, as Cloudwatch only shows this in the lambda function's log:

START RequestId: 3e89eac7-3ab0-4e77-94a6-d9231500d587 Version: $LATEST

2021-08-27T19:40:30.903Z 3e89eac7-3ab0-4e77-94a6-d9231500d587 INFO Invoking Drip API
END RequestId: 3e89eac7-3ab0-4e77-94a6-d9231500d587
REPORT RequestId: 3e89eac7-3ab0-4e77-94a6-d9231500d587 Duration: 1116.99 ms Billed Duration: 1117 ms Memory Size: 128 MB Max Memory Used: 109 MB Init Duration: 919.35 ms

Drip's docs link to their fork, NPM copy is from your repo (which has a different API)

Was just looking to use this and noticed that following links from Drip's documentation leads to https://github.com/DripEmail/drip-nodejs but using npm install gives a more up-to-date version from your repo.

This means that the documentation's API does not match the code that's been installed. For example, the subscribers api no longer takes both email and payload.

Edit: In practice, it's clear that there are several other issues with the library. If I put together well-written pull requests are you/the Drip team willing to accept them?

Documentation incorrect for createUpdateSubscriber

Hello,

Just had to spend about an hour debugging this, which was frustrating so hopefully this can be resolved or someone else having the same issue can find this in the future.

The documentation at https://developer.drip.com/?javascript#create-or-update-a-subscriber states the payload for createUpdateUser should look like this:

const payload = {
  subscribers: [{
    email: "[email protected]",
    time_zone: "America/Los_Angeles",
    custom_fields: {
      shirt_size: "Medium"
    }
  }]
};

However, I was continuously getting this, very unhelpful error:
{"errors":[{"code":"parsing_error","message":"JSON parsing error: The property '#/' of type object did not match one or more of the required schemas"}]}

After triple checking all of my custom field identifiers and racking my brain, I logged the actual entire error response and noticed the body of the request was this:
body: '{"subscribers":[{"subscribers":[{"email":"[email protected]"}]}]}',

So while the documentation is telling you to have your subscriber wrapped in an array under subscribers, you are actually just supposed to send only the subscriber object, like this:

const payload = {
    email: "[email protected]",
    time_zone: "America/Los_Angeles",
    custom_fields: {
      shirt_size: "Medium"
    }
};

Hopefully you guys can make that small change in the documentation, and maybe this issue will help others before that happens. Thanks!

How to keep API token secret on React Native apps?

So I'm looking into using drip-nodejs on React Native.

Normally for an analytics provider (e.g. Google Analytics) all I need is the app id, which is a public id.

However, drip-nodejs needs

const client = require('drip-nodejs')(
  {
    token: YOUR_API_KEY,
    accountId: YOUR_ACCOUNT_ID
  }
);

And API token is supposed to be kept private. I'm assuming drip-nodejs is only supposed to be used on the server-side. So not sure how I would be sending events from the mobile app. Is there a similar interface on React Native like the Drip script on web that only requires the public app id?

404 on Order POST

I'm using this library to call the createUpdateOrder method, which always returns a 404.
Is the Orders API not supposed to work for a nodejs server? I can do stuff with subscribers fine...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.