Skip to content

Commit 63de374

Browse files
authored
feat(js): make check-ins client public (#1456)
1 parent 0b82825 commit 63de374

File tree

5 files changed

+42
-6
lines changed

5 files changed

+42
-6
lines changed

packages/js/scripts/copy-typedefs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function copyFileSync( source, target ) {
1313
}
1414
}
1515

16-
fs.writeFileSync(targetFile, fs.readFileSync(source, 'utf8').replace(/'\.\//g, '\'./types/'));
16+
fs.writeFileSync(targetFile, fs.readFileSync(source, 'utf8'));
1717
}
1818

1919
function copyFolderRecursiveSync( source, target ) {

packages/js/src/server.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,7 @@ singleton.setNotifier(NOTIFIER)
186186

187187
export { Types } from '@honeybadger-io/core'
188188

189+
export { CheckInsClient, CheckIn } from './server/check-ins-manager'
190+
export { ServerTransport } from './server/transport'
191+
189192
export default singleton

packages/js/src/server/check-ins-manager/index.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import { Util, Types, Defaults } from '@honeybadger-io/core'
22
import { CheckInsClient } from './client'
33
import { CheckInsConfig } from './types'
4-
import { ServerTransport } from '../transport';
5-
import { CheckIn } from './check-in';
4+
import { ServerTransport } from '../transport'
5+
import { CheckIn } from './check-in'
6+
7+
export { CheckInsClient } from './client'
8+
export { CheckIn } from './check-in'
69

710
export class CheckInsManager {
811

packages/js/src/server/check-ins-manager/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export type CheckInDto = {
3131

3232
/**
3333
* The amount of time to allow a job to not report before it's reported as missing.
34-
* Valid values are the same as the report_report field.
34+
* Valid values are the same as the reportPeriod field.
3535
*/
3636
gracePeriod?: string
3737

packages/js/test-d/server.test-d.tsx

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import Honeybadger from '../dist/server/honeybadger'
1+
import { Defaults } from '@honeybadger-io/core'
2+
import Honeybadger, { CheckInsClient, CheckIn, ServerTransport } from '../dist/server/honeybadger'
23

34
Honeybadger.configure({
45
debug: false,
@@ -40,4 +41,33 @@ const client2 = Honeybadger.factory()
4041
client2.beforeNotify(() => {
4142
console.log('Notifying')
4243
})
43-
client2.notify('test')
44+
client2.notify('test');
45+
46+
(async function () {
47+
const checkInsClient = new CheckInsClient({
48+
apiKey: 'project api key',
49+
appEndpoint: Defaults.CONFIG.appEndpoint,
50+
personalAuthToken: 'personal auth token',
51+
logger: console
52+
}, new ServerTransport())
53+
54+
await checkInsClient.get('project id', 'check-in id')
55+
56+
await checkInsClient.create('project id', new CheckIn({
57+
name: 'a simple check-in',
58+
slug: 'simple-check-in',
59+
scheduleType: 'simple',
60+
reportPeriod: '1 day',
61+
gracePeriod: '5 minutes',
62+
}))
63+
64+
await checkInsClient.create('project id', new CheckIn({
65+
name: 'a cron check-in',
66+
slug: 'cron-check-in',
67+
scheduleType: 'cron',
68+
cronSchedule: '* * * * 5',
69+
cronTimezone: 'UTC',
70+
gracePeriod: '5 minutes',
71+
}))
72+
})()
73+

0 commit comments

Comments
 (0)