Skip to content

Commit 3cee041

Browse files
committed
fix(js-client-sdk): better undefined handling
1 parent f4bd636 commit 3cee041

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

packages/sdk/browser/src/BrowserApi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ export function addWindowEventListener(
5050
listener: (this: Document, ev: Event) => any,
5151
options?: boolean | AddEventListenerOptions,
5252
): () => void {
53-
if (isDocument()) {
53+
if (isWindow()) {
5454
window.addEventListener(type, listener, options);
5555
return () => {
5656
window.removeEventListener(type, listener, options);
5757
};
5858
}
59-
// No document, so no need to unregister anything.
59+
// No window, so no need to unregister anything.
6060
return () => {};
6161
}
6262

packages/sdk/browser/src/platform/randomUuidV4.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const nodes = {
3636
};
3737

3838
function getRandom128bit(): number[] {
39-
if (crypto && crypto.getRandomValues) {
39+
if (typeof crypto !== 'undefined' && crypto.getRandomValues) {
4040
const typedArray = new Uint8Array(16);
4141
crypto.getRandomValues(typedArray);
4242
return [...typedArray.values()];

packages/telemetry/browser-telemetry/src/randomUuidV4.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const nodes = {
3939
};
4040

4141
function getRandom128bit(): number[] {
42-
if (crypto && crypto.getRandomValues) {
42+
if (typeof crypto !== 'undefined' && crypto.getRandomValues) {
4343
const typedArray = new Uint8Array(16);
4444
crypto.getRandomValues(typedArray);
4545
return [...typedArray.values()];

0 commit comments

Comments
 (0)