posthog-node
Advanced tools
Comparing version 1.1.5 to 1.1.6
@@ -8,2 +8,13 @@ const axios = require('axios') | ||
class ClientError extends Error { | ||
constructor(message, extra) { | ||
super() | ||
Error.captureStackTrace(this, this.constructor) | ||
this.name = 'ClientError' | ||
this.message = message | ||
if (extra) { | ||
this.extra = extra | ||
} | ||
} | ||
} | ||
@@ -76,12 +87,20 @@ class FeatureFlagsPoller { | ||
const res = await this._request({ path: 'api/feature_flag', usePersonalApiKey: true }) | ||
try { | ||
const res = await this._request({ path: 'api/feature_flag', usePersonalApiKey: true }) | ||
if (res && res.status === 401) { | ||
throw new ClientError( | ||
`Your personalApiKey is invalid. Are you sure you're not using your Project API key? More information: https://posthog.com/docs/api/overview` | ||
) | ||
} | ||
if (res && res.status === 401) { | ||
throw new Error( | ||
`Your personalApiKey is invalid. Are you sure you're not using your Project API key? More information: https://posthog.com/docs/api/overview` | ||
) | ||
this.featureFlags = res.data.results.filter(flag => flag.active) | ||
this.loadedSuccessfullyOnce = true | ||
} catch (err) { | ||
// if an error that is not an instance of ClientError is thrown | ||
// we silently ignore the error when reloading feature flags | ||
if (err instanceof ClientError) { | ||
throw err | ||
} | ||
} | ||
this.featureFlags = res.data.results.filter(flag => flag.active) | ||
this.loadedSuccessfullyOnce = true | ||
} | ||
@@ -130,2 +149,3 @@ | ||
let res | ||
@@ -132,0 +152,0 @@ try { |
{ | ||
"name": "posthog-node", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"description": "PostHog Node.js integration", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -25,1 +25,2 @@ # PostHog Node.js Library | ||
### [Join our Slack community.](https://posthog.com/slack) | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26380
624
26