Skip to content

Commit 5440807

Browse files
authored
fix(core): Return checkin id from client (#8116)
1 parent 9a267eb commit 5440807

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

packages/browser/test/unit/sdk.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* eslint-disable @typescript-eslint/unbound-method */
22
import { createTransport, Scope } from '@sentry/core';
3-
import { MockIntegration } from '@sentry/core/test/lib/sdk.test';
43
import type { Client, Integration } from '@sentry/types';
54
import { resolvedSyncPromise } from '@sentry/utils';
65

@@ -18,6 +17,14 @@ function getDefaultBrowserOptions(options: Partial<BrowserOptions> = {}): Browse
1817
};
1918
}
2019

20+
export class MockIntegration implements Integration {
21+
public name: string;
22+
public setupOnce: () => void = jest.fn();
23+
public constructor(name: string) {
24+
this.name = name;
25+
}
26+
}
27+
2128
jest.mock('@sentry/core', () => {
2229
const original = jest.requireActual('@sentry/core');
2330
return {

packages/core/src/exports.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,17 +196,14 @@ export function startTransaction(
196196
* to create a monitor automatically when sending a check in.
197197
*/
198198
export function captureCheckIn(checkIn: CheckIn, upsertMonitorConfig?: MonitorConfig): string {
199-
const capturedCheckIn =
200-
checkIn.status !== 'in_progress' && checkIn.checkInId ? checkIn : { ...checkIn, checkInId: uuid4() };
201-
202199
const client = getCurrentHub().getClient();
203200
if (!client) {
204201
__DEBUG_BUILD__ && logger.warn('Cannot capture check-in. No client defined.');
205202
} else if (!client.captureCheckIn) {
206203
__DEBUG_BUILD__ && logger.warn('Cannot capture check-in. Client does not support sending check-ins.');
207204
} else {
208-
client.captureCheckIn(capturedCheckIn, upsertMonitorConfig);
205+
return client.captureCheckIn(checkIn, upsertMonitorConfig);
209206
}
210207

211-
return capturedCheckIn.checkInId;
208+
return uuid4();
212209
}

packages/core/test/lib/sdk.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe('captureCheckIn', () => {
4747
} as unknown as Client;
4848
});
4949

50-
expect(captureCheckIn({ monitorSlug: 'gogogo', status: 'in_progress' })).toStrictEqual(expect.any(String));
50+
expect(captureCheckIn({ monitorSlug: 'gogogo', status: 'in_progress' })).toStrictEqual('some-id-wasd-1234');
5151
});
5252

5353
it('returns an id when client is undefined', () => {

0 commit comments

Comments
 (0)