File tree Expand file tree Collapse file tree 3 files changed +19
-7
lines changed Expand file tree Collapse file tree 3 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -164,17 +164,20 @@ export class NodeClient extends BaseClient<NodeClientOptions> {
164
164
const options = this . getOptions ( ) ;
165
165
const { release, environment, tunnel } = options ;
166
166
167
- const id = checkIn . checkInId || uuid4 ( ) ;
167
+ const id = checkIn . status === 'in_progress' ? uuid4 ( ) : checkIn . checkInId ;
168
168
169
169
const serializedCheckIn : SerializedCheckIn = {
170
170
check_in_id : id ,
171
171
monitor_slug : checkIn . monitorSlug ,
172
172
status : checkIn . status ,
173
- duration : checkIn . duration ,
174
173
release,
175
174
environment,
176
175
} ;
177
176
177
+ if ( checkIn . status !== 'in_progress' ) {
178
+ serializedCheckIn . duration = checkIn . duration ;
179
+ }
180
+
178
181
if ( monitorConfig ) {
179
182
serializedCheckIn . monitor_config = {
180
183
schedule : monitorConfig . schedule ,
Original file line number Diff line number Diff line change @@ -361,7 +361,7 @@ describe('NodeClient', () => {
361
361
// @ts -ignore accessing private method
362
362
const sendEnvelopeSpy = jest . spyOn ( client , '_sendEnvelope' ) ;
363
363
364
- client . captureCheckIn ( { monitorSlug : 'foo' , status : 'ok' , duration : 1222 } ) ;
364
+ client . captureCheckIn ( { monitorSlug : 'foo' , status : 'in_progress' } ) ;
365
365
366
366
expect ( sendEnvelopeSpy ) . toHaveBeenCalledTimes ( 0 ) ;
367
367
} ) ;
Original file line number Diff line number Diff line change @@ -38,16 +38,25 @@ export interface SerializedCheckIn {
38
38
} ;
39
39
}
40
40
41
- export type CheckIn = {
41
+ interface InProgressCheckIn {
42
+ // The distinct slug of the monitor.
43
+ monitorSlug : SerializedCheckIn [ 'monitor_slug' ] ;
44
+ // The status of the check-in.
45
+ status : 'in_progress' ;
46
+ }
47
+
48
+ interface FinishedCheckIn {
42
49
// The distinct slug of the monitor.
43
50
monitorSlug : SerializedCheckIn [ 'monitor_slug' ] ;
44
51
// Check-In ID (unique and client generated).
45
- checkInId ? : SerializedCheckIn [ 'check_in_id' ] ;
52
+ checkInId : SerializedCheckIn [ 'check_in_id' ] ;
46
53
// The status of the check-in.
47
- status : SerializedCheckIn [ 'status' ] ;
54
+ status : 'ok' | 'error' ;
48
55
// The duration of the check-in in seconds. Will only take effect if the status is ok or error.
49
56
duration ?: SerializedCheckIn [ 'duration' ] ;
50
- } ;
57
+ }
58
+
59
+ export type CheckIn = InProgressCheckIn | FinishedCheckIn ;
51
60
52
61
type SerializedMonitorConfig = NonNullable < SerializedCheckIn [ 'monitor_config' ] > ;
53
62
You can’t perform that action at this time.
0 commit comments