Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: check-ins configuration api #1241

Merged
merged 15 commits into from
Nov 14, 2023
Merged

feat: check-ins configuration api #1241

merged 15 commits into from
Nov 14, 2023

Conversation

subzero10
Copy link
Member

@subzero10 subzero10 commented Nov 3, 2023

Status

READY

Description

Check-Ins configuration through the SDK, similar to the Laravel/PHP implementation.
Closes #1208.

Related PRs

Todos

  • Tests
  • Manual Tests
  • Create checkins <- can throw errors
  • Update checkins <- can throw errors
  • Remove checkins <- can throw errors
  • Honeybadger.checkin(checkinName) <- should not throw errors
  • Bin command to execute sync - make sure CheckinsManager errors are caught and logged
  • Example project
  • Documentation - #374

Bonus:

  • Allow reading config from honeybadger.config.js (only for js on the server) - adds dependency to cosmicconfig
  • Tests for reading config from file
  • Tests for configuration precedence: config file, constructor parameters, default values
  • Documentation for configuration file - #375

@subzero10 subzero10 self-assigned this Nov 9, 2023
@subzero10 subzero10 added enhancement js @honeybadger-io/js labels Nov 10, 2023
@subzero10
Copy link
Member Author

I moved the last 3 TODO points to #1243 because this PR is already too big and a review will be difficult.

@@ -290,7 +289,7 @@ export function sanitize(obj, maxDepth = 8) {
return safeSerialize(obj)
}

export function logger(client: Client): Logger {
export function logger(client: { config: { debug: boolean; logger: Logger; } }): Logger {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Support more than one client (CheckinsClient and HoneybadgerClient)

defaultHeaders(): Record<string, string> {
return {};
}
send<T>(_options: TransportOptions, _payload: T): Promise<{ statusCode: number; body: string }> {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the payload to be generic because I didn't want to define the payload for check-ins here (check-ins are not part of the core package)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Project that demonstrates npx honeybadger-checkins-sync.

@@ -127,6 +164,7 @@ const singleton = new Honeybadger({
uncaughtException(),
unhandledRejection()
],
...(readConfigFromFileSystem() ?? {})
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line allows loading configuration from a file.

'util',
'domain',
'async_hooks',
'cosmiconfig',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure about this.
My reasoning is:

  • this is the server bundle, we want to transform to multiple targets (formats),
  • but it can require external modules (i.e. from node_modules)

However, we want the browser bundles to be single files so they can be loaded from the CDN.

@subzero10 subzero10 requested a review from halfbyte November 12, 2023 13:36
Copy link

@halfbyte halfbyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@subzero10 subzero10 merged commit 866bb8d into master Nov 14, 2023
9 checks passed
@subzero10 subzero10 deleted the checkins-v2 branch November 14, 2023 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement js @honeybadger-io/js
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Checkins V2
2 participants