Skip to content

Commit 624f980

Browse files
committed
flesh out docstrings
1 parent db8fa1a commit 624f980

File tree

4 files changed

+35
-20
lines changed

4 files changed

+35
-20
lines changed

packages/browser/src/sdk.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,12 @@ export function onLoad(callback: () => void): void {
146146
}
147147

148148
/**
149-
* A promise that resolves when all current events have been sent.
150-
* If you provide a timeout and the queue takes longer to drain the promise returns false.
149+
* Call `flush()` on the current client, if there is one. See {@link Client.flush}.
151150
*
152-
* @param timeout Maximum time in ms the client should wait.
151+
* @param timeout Maximum time in ms the client should wait to flush its event queue. Omitting this parameter will cause
152+
* the client to wait until all events are sent before resolving the promise.
153+
* @returns A promise which resolves to `true` if the queue successfully drains before the timeout, or `false` if it
154+
* doesn't (or if there's no client defined).
153155
*/
154156
export function flush(timeout?: number): PromiseLike<boolean> {
155157
const client = getCurrentHub().getClient<BrowserClient>();
@@ -161,10 +163,12 @@ export function flush(timeout?: number): PromiseLike<boolean> {
161163
}
162164

163165
/**
164-
* A promise that resolves when all current events have been sent.
165-
* If you provide a timeout and the queue takes longer to drain the promise returns false.
166+
* Call `close()` on the current client, if there is one. See {@link Client.close}.
166167
*
167-
* @param timeout Maximum time in ms the client should wait.
168+
* @param timeout Maximum time in ms the client should wait to flush its event queue before shutting down. Omitting this
169+
* parameter will cause the client to wait until all events are sent before disabling itself.
170+
* @returns A promise which resolves to `true` if the queue successfully drains before the timeout, or `false` if it
171+
* doesn't (or if there's no client defined).
168172
*/
169173
export function close(timeout?: number): PromiseLike<boolean> {
170174
const client = getCurrentHub().getClient<BrowserClient>();

packages/node/src/sdk.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,12 @@ export function lastEventId(): string | undefined {
140140
}
141141

142142
/**
143-
* A promise that resolves when all current events have been sent.
144-
* If you provide a timeout and the queue takes longer to drain the promise returns false.
143+
* Call `flush()` on the current client, if there is one. See {@link Client.flush}.
145144
*
146-
* @param timeout Maximum time in ms the client should wait.
145+
* @param timeout Maximum time in ms the client should wait to flush its event queue. Omitting this parameter will cause
146+
* the client to wait until all events are sent before resolving the promise.
147+
* @returns A promise which resolves to `true` if the queue successfully drains before the timeout, or `false` if it
148+
* doesn't (or if there's no client defined).
147149
*/
148150
export async function flush(timeout?: number): Promise<boolean> {
149151
const client = getCurrentHub().getClient<NodeClient>();
@@ -155,10 +157,12 @@ export async function flush(timeout?: number): Promise<boolean> {
155157
}
156158

157159
/**
158-
* A promise that resolves when all current events have been sent.
159-
* If you provide a timeout and the queue takes longer to drain the promise returns false.
160+
* Call `close()` on the current client, if there is one. See {@link Client.close}.
160161
*
161-
* @param timeout Maximum time in ms the client should wait.
162+
* @param timeout Maximum time in ms the client should wait to flush its event queue before shutting down. Omitting this
163+
* parameter will cause the client to wait until all events are sent before disabling itself.
164+
* @returns A promise which resolves to `true` if the queue successfully drains before the timeout, or `false` if it
165+
* doesn't (or if there's no client defined).
162166
*/
163167
export async function close(timeout?: number): Promise<boolean> {
164168
const client = getCurrentHub().getClient<NodeClient>();

packages/types/src/client.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,22 @@ export interface Client<O extends Options = Options> {
6060
getOptions(): O;
6161

6262
/**
63-
* A promise that resolves when all current events have been sent.
64-
* If you provide a timeout and the queue takes longer to drain the promise returns false.
63+
* Flush the event queue and set the client to `enabled = false`. See {@link Client.flush}.
6564
*
66-
* @param timeout Maximum time in ms the client should wait.
65+
* @param timeout Maximum time in ms the client should wait before shutting down. Omitting this parameter will cause
66+
* the client to wait until all events are sent before disabling itself.
67+
* @returns A promise which resolves to `true` if the flush completes successfully before the timeout, or `false` if
68+
* it doesn't.
6769
*/
6870
close(timeout?: number): PromiseLike<boolean>;
6971

7072
/**
71-
* A promise that resolves when all current events have been sent.
72-
* If you provide a timeout and the queue takes longer to drain the promise returns false.
73+
* Wait for all events to be sent or the timeout to expire, whichever comes first.
7374
*
74-
* @param timeout Maximum time in ms the client should wait.
75+
* @param timeout Maximum time in ms the client should wait for events to be flushed. Omitting this parameter will
76+
* cause the client to wait until all events are sent before resolving the promise.
77+
* @returns A promise that will resolve with `true` if all events are sent before the timeout, or `false` if there are
78+
* still events in the queue when the timeout is reached.
7579
*/
7680
flush(timeout?: number): PromiseLike<boolean>;
7781

packages/types/src/transport.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ export interface Transport {
2121
sendSession?(session: Session | SessionAggregates): PromiseLike<Response>;
2222

2323
/**
24-
* Call this function to wait until all pending requests have been sent.
24+
* Wait for all events to be sent or the timeout to expire, whichever comes first.
2525
*
26-
* @param timeout Number time in ms to wait until the buffer is drained.
26+
* @param timeout Maximum time in ms the transport should wait for events to be flushed. Omitting this parameter will
27+
* cause the transport to wait until all events are sent before resolving the promise.
28+
* @returns A promise that will resolve with `true` if all events are sent before the timeout, or `false` if there are
29+
* still events in the queue when the timeout is reached.
2730
*/
2831
close(timeout?: number): PromiseLike<boolean>;
2932
}

0 commit comments

Comments
 (0)