-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(node): Add ability to send cron monitor check ins #8039
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import type { CheckIn } from '@sentry/types'; | ||
import type { SerializedCheckIn } from '@sentry/types'; | ||
|
||
import { createCheckInEnvelope } from '../src/checkin'; | ||
|
||
|
@@ -44,7 +44,7 @@ describe('CheckIn', () => { | |
duration: 10.0, | ||
release: '1.0.0', | ||
environment: 'production', | ||
} as CheckIn, | ||
} as SerializedCheckIn, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. giga l: you can simply do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gonna keep this anyway because I prefer the explicitness of the type. |
||
{ | ||
check_in_id: '83a7c03ed0a04e1b97e2e3b18d38f244', | ||
monitor_slug: 'b7645b8e-b47d-4398-be9a-d16b0dac31cb', | ||
|
@@ -69,7 +69,7 @@ describe('CheckIn', () => { | |
max_runtime: 30, | ||
timezone: 'America/Los_Angeles', | ||
}, | ||
} as CheckIn, | ||
} as SerializedCheckIn, | ||
{ | ||
check_in_id: '83a7c03ed0a04e1b97e2e3b18d38f244', | ||
monitor_slug: 'b7645b8e-b47d-4398-be9a-d16b0dac31cb', | ||
|
@@ -98,7 +98,7 @@ describe('CheckIn', () => { | |
unit: 'minute', | ||
}, | ||
}, | ||
} as CheckIn, | ||
} as SerializedCheckIn, | ||
{ | ||
check_in_id: '83a7c03ed0a04e1b97e2e3b18d38f244', | ||
monitor_slug: 'b7645b8e-b47d-4398-be9a-d16b0dac31cb', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -280,6 +280,66 @@ describe('NodeClient', () => { | |
expect(event.server_name).not.toEqual('bar'); | ||
}); | ||
}); | ||
|
||
describe('captureCheckIn', () => { | ||
it('sends a checkIn envelope', () => { | ||
const options = getDefaultNodeClientOptions({ dsn: PUBLIC_DSN, serverName: 'bar' }); | ||
client = new NodeClient(options); | ||
|
||
// @ts-ignore accessing private method | ||
const sendEnvelopeSpy = jest.spyOn(client, '_sendEnvelope'); | ||
|
||
client.captureCheckIn( | ||
{ monitorSlug: 'foo', status: 'ok', duration: 1222 }, | ||
{ | ||
schedule: { | ||
type: 'crontab', | ||
value: '0 * * * *', | ||
}, | ||
checkinMargin: 2, | ||
maxRuntime: 12333, | ||
timezone: 'Canada/Eastern', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🫡 |
||
}, | ||
); | ||
|
||
expect(sendEnvelopeSpy).toHaveBeenCalledTimes(1); | ||
expect(sendEnvelopeSpy).toHaveBeenCalledWith([ | ||
expect.any(Object), | ||
[ | ||
[ | ||
expect.any(Object), | ||
{ | ||
check_in_id: expect.any(String), | ||
duration: 1222, | ||
monitor_slug: 'foo', | ||
status: 'ok', | ||
monitor_config: { | ||
schedule: { | ||
type: 'crontab', | ||
value: '0 * * * *', | ||
}, | ||
checkin_margin: 2, | ||
max_runtime: 12333, | ||
timezone: 'Canada/Eastern', | ||
}, | ||
}, | ||
], | ||
], | ||
]); | ||
}); | ||
|
||
it('does not send a checkIn envelope if disabled', () => { | ||
const options = getDefaultNodeClientOptions({ dsn: PUBLIC_DSN, serverName: 'bar', enabled: false }); | ||
client = new NodeClient(options); | ||
|
||
// @ts-ignore accessing private method | ||
const sendEnvelopeSpy = jest.spyOn(client, '_sendEnvelope'); | ||
|
||
client.captureCheckIn({ monitorSlug: 'foo', status: 'ok', duration: 1222 }); | ||
|
||
expect(sendEnvelopeSpy).toHaveBeenCalledTimes(0); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('flush/close', () => { | ||
|
Uh oh!
There was an error while loading. Please reload this page.