segmentio / analytics-node

The hassle-free way to integrate analytics into any node application.

Home Page:https://segment.com/libraries/node

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`Analytics` intialization doesn't catch invalid/non-existent write key

chasebish opened this issue · comments

commented

With the following code:

const segmentAnalytics = new Analytics("unusable_write_key");

no error is thrown by the constructor.

When using analytics-next, this error is sufficiently caught, as seen here:

const segmentAnalytics = new AnalyticsBrowser();
segmentAnalytics
  .load({
    "unusable_write_key",
  })
  .catch(() => {
    doSomething();
  });

Is there plan to add support to the analytics-node client that will enable catching a bad write key?

@chasebish Thank you for realizing this issue with analytics-node, unfortunately this package has been deprecated and it is recommended that everyone begin to use the analytics-next/node package:

https://github.com/segmentio/analytics-node#-this-package-is-deprecated

https://github.com/segmentio/analytics-next/tree/master/packages/node#readme

Sorry for any inconvenience this may cause you and your team.

Thank you for your patronage.

Just a heads up, this isn't in any of our node libraries. We do not do WriteKey validation beyond their existence either at instantiation time or or on our generic ingestion APIs -- this would require a separate API call for validation, and it's not clear that it's worth the cost.

We only validate on the browser as biproduct of the call to fetch source settings before instantiation. Server libraries never fetch settings.