Giter Club home page Giter Club logo

customerio-node's People

Contributors

alexgeb avatar alvincrespo avatar antoncazalet avatar chance-schultz avatar clabland avatar cmunozgar avatar daimenworrall-cinch avatar dependabot[bot] avatar djanhjo avatar glosier avatar hownowstephen avatar jescalan avatar joepurdy avatar jordanhailey avatar jpvalery avatar karngyan avatar katt avatar kevinkucharczyk avatar lisaah avatar mike-engel avatar nunofgs avatar pavanmachavolu avatar pfadel avatar pierreavizou avatar pkvince avatar prafful1234 avatar swastik avatar xanderberkein avatar zaf avatar zamoore avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

customerio-node's Issues

Add missing triggered broadcast params

Is there a timeline for adding the missing parameters for a triggered broadcast?

ids
id_ignore_missing
emails
email_ignore_missing
email_add_duplicates

Thanks!

[ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type Function. Received type object

I'm following your documentation for tracking events in Node.js. I'm running into an issue where I keep getting

[ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type Function. Received type object

Here's my sample code:

	const userId = 'adajkdaAS7aAS';
	
	const customerioTrackClient = new TrackClient(
      'mySiteId',
      'myApiKey',
      { region: RegionUS }
    );

      await customerioTrackClient.track(userId, {
        name: 'ExampleName',
        data: {
          sku: 'blahlah',
        },
      });

Any ideas?

Removal of manual segments APIs

Hi there, I observed that the manual segment APIs addToSegment and removeFromSegment were removed in this commit and no longer exists in the v1.0.0 release: e487c3c

Is there any reason why these APIs were removed? We currently make use of these APIs.

Allow additional options for different types of Broadcast recipients

When triggering a broadcast with per_user_data or data_file_url, we should be able to pass in additional options like we currently do for ids & emails:

const BROADCASTS_ALLOWED_RECIPIENT_FIELDS = {
ids: ['ids', 'id_ignore_missing'],
emails: ['emails', 'email_ignore_missing', 'email_add_duplicates'],
per_user_data: ['per_user_data'],
data_file_url: ['data_file_url']
}

I think this should become

const BROADCASTS_ALLOWED_RECIPIENT_FIELDS = { 
   ids: ['ids', 'id_ignore_missing'], 
   emails: ['emails', 'email_ignore_missing', 'email_add_duplicates'], 
   per_user_data: ['per_user_data', 'id_ignore_missing', 'email_ignore_missing', 'email_add_duplicates'], 
   data_file_url: ['data_file_url',  'id_ignore_missing', 'email_ignore_missing', 'email_add_duplicates'] 
 } 

relevant customer.io docs: https://customer.io/docs/api/#apicorecampaignscampaigns_trigger

Question

Is there any way to get the Subscription Center topics?

301 Unknown error

    const client = new APIClient("********************************");
    try {
        const customers = await client.getCustomersByEmail(data.to);
    } catch (err: any) {
        console.log(err.statusCode, err.message)
    }

This code logs: 301 Unknown error

I'm using "customerio-node": "3.4.1",

I don't know what to do

Issue with broadcast after identify users

@kevinkucharczyk @mike-engel

We are experiencing errors when sending emails in broadcast mode after identifying a user, the identify endpoint responds 200 but when we send broadcast emails with ids option the recipients remain at 0, there must be a data synchronization issue between their 2 services (broadcast / identity.... you recently moved this endpoint).

As a workaround we have to fail with the flag ({id_ignore_missing:false} RECIPIENTS_ERROR_CODE (422)) if any of our recipients are missing in your side and we've built a cron job server to retry the failed broadcasts

Bulk API Support

Is there or will there be support for the bulk api/api v2? Thanks!

Is this production ready?

Hi, I've been meaning to send data from my Node.js app to Customer.io, and stumbled upon this official package. The API looks complete, but it lacks traction compared to other unofficial libraries (such as node-customerio or node-customer.io).

Will this library be supported in the long run if I decided to use this in production or should I use the other libraries?

Typings

Hi!
How to use typings of customerio-node?

thanks!

Suggestion: Add email field in Readme

As subject states, this is about email sending. Would be great to indicate how to pass the email to cio, and not leave it to our guessing :)
thanks

Cannot override message template when sending transactional emails

We are using transactional_message_id in SendEmailRequest to specify a message template, but we need to be able to override the subject.

Per the Customer.io docs,

If you include both a transactional_message_id and a subject, the subject in your request overwrites the values in your message template.

However this does not work with this library; this code is the culprit:

    if ('from' in opts) {
      this.message.from = opts.from;
      this.message.subject = opts.subject;
      this.message.body = opts.body;
    }

Can you please set subject regardless?

This is a showstopper for us; we need to be able to set the email subject line to different values (but still use a template).

Incrementing the value of an attribute

Great work on the library. How do I increment the value of a property on a person? For example:

cio.identify(1, {
  email: '[email protected]',
  created_at: 1361205308,
  first_name: 'Bob',
  plan: 'basic',
  number_of_purchases: 0
});

Each time a user makes a purchase, I want to increment number_of_purchases by 1, so I don't have to write a database query to count all the purchases a user has made. Thank you.

cc: @mike-engel

Is this library supported?

A lot of endpoints are missing, hence the question.

Could you archive the repository if that's not the case?

Add support of Bearer Auth for TrackClient.

Hi there,

We got a message from CustomerIO to use Bearer Auth instead of Basic Auth when using API.

Hi there,

We've noticed that you've used basic authentication to access the App API in the last 30 days. You will need to change the authentication method within the next 2 weeks, or calls to send triggered broadcasts or transactional messages will fail.

Beginning April 14th at 00:00 UTC we will no longer allow access to our App API through basic authentication. Instead, bearer authentication is required to utilize the API. You can find more details on this authentication scheme in our API documentation.

If you have any questions, simply reply to this email and we'll be happy to help!

Thanks!

CIO Engineering Team

Can you please make TrackClient to support Bearer Auth as well? Currently it supports only Basic Auth.

add promise reject

if i use cio.identify in a wrong way (cio.identify(object)) it have to reject the promise

Frontend SDK?

Hi folks,
We have a use case where we want to send events from the front-end instead of the backend, and this node SDK doesn't work because it uses some node-specific libraries such as fs.

So I've copied this repo and made it compatible with frontends: https://github.com/stefanoeb/react-native-customerio
It probably works with web as well, but I've just tested on react-native for now.

This is just an FYI for anyone trying to send stuff from the frontend as well in the future.

Add support for interacting with Customer.io objects

Hi there!
I'm a user of the customer.io-node library and I've been really impressed with how easy it is to send targeted emails and messages to my customers. However, I've noticed that the library doesn't currently support interacting with Customer.io's objects feature, which was recently added to the platform (https://customer.io/docs/objects/#).

I believe that adding support for objects would be a valuable addition to the customer.io-node library because it would allow users to take advantage of this powerful new feature. By using objects, we can associate data with our customers and create more personalized messaging experiences based on their attributes.

Specifically, I'd like to request that the customer.io-node library add methods for creating, updating, and deleting objects. Ideally, these methods would be easy to use and would integrate seamlessly with the existing functionality of the library.

I think that adding support for objects would make customer.io-node an even more valuable tool for marketers and businesses looking to connect with their customers in more meaningful ways.

Thanks for considering my request!

Display the real error message instead of "Unknown error"

When calling the identify method (I'm using the last version "0.7.0" of your lib), and in the case where a 400 error happened because of a too long attribute value, here is what I get :

message: 'Unknown error',
statusCode: 400,
...
body: '{\n' +
      '  "meta": {\n' +
      '    "errors": [\n' +
      `      "value for attribute 'myAttribute' cannot be longer than 1000 bytes"\n` +
      '    ]\n' +
      '  }\n' +
      '}\n',

After a look into your code, I noticed that this specific line :

message: (json && json.meta && json.meta.error) || 'Unknown error',
suggests that the body should actually be formatted like this :

meta {
    error // string
}

Whereas I'm getting this :

meta {
    errors // array of string
}

Is it something that you are planning to deal with at some point ? For now, I handled it myself but it would be nice to include it in the lib I guess :)

json TS2345: Argument of type 'null' is not assignable to parameter of type 'Record<string, any> | PromiseLike<Record<string, any>>'

I am getting the following error, while trying to use the package:

error TS2345: Argument of type 'null' is not assignable to parameter of type 'Record<string, any> | PromiseLike<Record<string, any>>'

It happens when the project is compiled as part of NestJs applciation.
Basically, it says that json has a wrong type, which was deducted from value assigned to it (an it is only null). While function response never expects null as return type.

image

image

Can you modify it to something like: resolve(json ?? {});?

Reading package.json doesn't work when bundled

We're bundling our backend with Rollup before uploading to Lambda, and this line of code inside lib/request.ts just made our Lambda hang, because of some infinite loop caused by Rollup + this particular piece of code. It happens when it can't find a package.json (and because everything is bundled, there is no package.json uploaded to AWS Lambda.)

const PACKAGE_JSON = findPackageJson(resolve(__dirname, '..'));

Could this be turned into something that also works inside bundled files?
e.g.:

let PACKAGE_JSON: any;
try {
  PACKAGE_JSON = require('../package.json');
} catch (e) {}

Error(400) When trying to set fake_bcc options on transaction API

Found this issue on transaction API where by default the value for fake_bcc is true and due to this, it leads to parent recipient's name + email is appended to the subject.

When trying to disable this option and following the error encountered with the library, whereas it works fine on the API side.

CustomerIORequestError: Request entity must be JSON encoded and not exceed 3024 KB.

fake_bcc should be a boolean as on the API and seem to be the cause of this issue, when types are overwritten and we pass a boolean value for fake_bcc things work fine on API as well as with CURL.

Please suggest if any additional updates would be required, adding an issue for tracking.

Will send a fix soon.

Minor documentation error

In the README, it has this sample code:

let cio = new TrackClient(siteId, apiKey, { region: RegionUS }, [defaults]);

The [defaults] argument is incorrect; the signature is (siteid: string, apikey: string, defaults?: Partial<TrackDefaults> | undefined).

This example is also incorrect in TypeScript:

const cio = new TrackClient(123, 'abc', {
  timeout: 5000
});

siteId (123) should be a string.

Add beta methods

The API should have Beta methods, specially GET /customers.

Is it OK to create a PR for it?

Transactional Mails with Umlauts

I think it's an API issue but when I send special characters as message data it returns "Request entity must be JSON encoded and not exceed 2548 KB.". When I replace the special characters with ä everything works. Now have to write a helper function to parse the json object for those characters and replace them.

To reproduce:

  const request = new SendEmailRequest({
    to: <your email>,
    transactional_message_id: <message id>,
    message_data: {
      name: "Stämpfli", // "St&auml;mpfli" works here..
    },
    identifiers: {
      id: <customer id>,
    },
  });

  const apiClient = new APIClient(<api key>);

  return apiClient.sendEmail(request);

Unhandled 'Unauthorized request' error

I am using version 3.0.1
When using customer-io in development we don't pass a correct key.
So the calls return an Unauthorized request
But request.js tries to parse the string like this JSON.parse(body) and throws this error:

(node:34878) UnhandledPromiseRejectionWarning: Error: Unable to parse JSON. Error: SyntaxError: Unexpected token U in JSON at position 0 
Body:
 Unauthorized request
    at IncomingMessage.<anonymous> (/xxx/node_modules/customerio-node/dist/lib/request.js:48:39)
    at IncomingMessage.emit (events.js:326:22)
    at IncomingMessage.EventEmitter.emit (domain.js:483:12)
    at endReadableNT (_stream_readable.js:1241:12)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)

Support Edge environments

This project relies on the native "http" / "https" modules from Node.js which are not compatible on Edge environments such as Cloudflare Workers, Next.js Edge Routes / middleware nor AWS Lambda Edge.

I would recommend a version built on top of "fetch" witch is getting a native Node.js implementation.

Support for /api/v2/batch

Hi, I was wondering if there's support for the Track V2 API, more specifically https://track.customer.io/api/v2/batch. If not, is there any workaround that we could use to send data through batch calls for identify and destroy functions?

Exports API support

Feature request: Download a customer export. I'd like to automate a report that joins CIO customer table with an external system and the exports API looks to be helpful. It'd be great if this SDK supported this as a single method (and I imagine a similar method for exporting deliveries would be welcome too).

Escaping quotes in requests

We have come across an issue where the customer.io client fails to send notifications when quotes are included in the payload.

For example, when sending a payload like this:

const trackClient = new TrackClient(
  process.env.CUSTOMERIO_SITE_ID,
  process.env.CUSTOMERIO_API_KEY
);

trackClient.track('some_user_id', {
  name: 'notify',
  data: {
    'title': 'My Title "Just Will Not Work" With Quotes Included',
  },
});

The notification will result in an "attempted" status with reason:

Custom payload is invalid JSON: invalid character 'J' after object key:value pair

I believe this is due to the quotes not being escaped by the client before the request is sent.

We are applying a fix for this prior to client use by escaping the quotes before the track call. But I wanted to flag this as a potential feature to add so others aren't caught by the same issue.

API docs detail missing

Hi, not sure where is the best place to post this.

There is an important detail missing from the transactional messages docs for one parameter.
https://customer.io/docs/api/#operation/sendEmail

send_at
A unix timestamp determining when the message will be sent. The timestamp can be up to 90 days in the future. If this value is in the past your message is sent immediately.

The timestamp should be in seconds!
Not milliseconds (which new Date().getTime() or Date.now() returns)

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.