Skip to content

Commit b19b373

Browse files
authored
feat: Update JavaScript SDKs to v9.40.0 (#1191)
1 parent 93b3de1 commit b19b373

22 files changed

+164
-159
lines changed

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,16 @@
6060
"e2e": "xvfb-maybe vitest run --root=./test/e2e --silent=false --disable-console-intercept"
6161
},
6262
"dependencies": {
63-
"@sentry/browser": "9.36.0",
64-
"@sentry/core": "9.36.0",
65-
"@sentry/node": "9.36.0",
63+
"@sentry/browser": "9.40.0",
64+
"@sentry/core": "9.40.0",
65+
"@sentry/node": "9.40.0",
6666
"deepmerge": "4.3.1"
6767
},
6868
"devDependencies": {
6969
"@rollup/plugin-node-resolve": "^15.2.3",
7070
"@rollup/plugin-typescript": "^11.1.6",
71-
"@sentry-internal/eslint-config-sdk": "9.36.0",
72-
"@sentry-internal/typescript": "9.36.0",
71+
"@sentry-internal/eslint-config-sdk": "9.40.0",
72+
"@sentry-internal/typescript": "9.40.0",
7373
"@types/busboy": "^1.5.4",
7474
"@types/form-data": "^2.5.0",
7575
"@types/koa": "^2.0.52",

src/main/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export {
9191
NodeClient,
9292
nodeContextIntegration,
9393
onUnhandledRejectionIntegration,
94+
openAIIntegration,
9495
OpenFeatureIntegrationHook,
9596
openFeatureIntegration,
9697
parameterize,
@@ -164,6 +165,7 @@ export { rendererProfileFromIpc } from './integrations/renderer-profiling';
164165
export { normalizePathsIntegration } from './integrations/normalize-paths';
165166
export { electronContextIntegration } from './integrations/electron-context';
166167
export { gpuContextIntegration } from './integrations/gpu-context';
168+
// eslint-disable-next-line deprecation/deprecation
167169
export { anrIntegration } from './integrations/anr';
168170
export { rendererAnrIntegration } from './integrations/renderer-anr';
169171

src/main/integrations/electron-minidump.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { applyScopeDataToEvent, defineIntegration, Event, logger, makeDsn, ScopeData, uuid4 } from '@sentry/core';
1+
import { applyScopeDataToEvent, debug, defineIntegration, Event, makeDsn, ScopeData, uuid4 } from '@sentry/core';
22
import { NodeClient, NodeOptions } from '@sentry/node';
33
import { app, crashReporter } from 'electron';
44
import { addScopeListener, getScopeData } from '../../common/scope';
@@ -127,21 +127,21 @@ export const electronMinidumpIntegration = defineIntegration(() => {
127127
crashReporter.addExtraParameter(key, value);
128128
}
129129
})
130-
.catch((error) => logger.error(error));
130+
.catch((error) => debug.error(error));
131131
}
132132

133133
function startCrashReporter(options: NodeOptions): void {
134134
const submitURL = minidumpUrlFromDsn(options.dsn || '');
135135
if (!submitURL) {
136-
logger.log('Invalid DSN. Cannot start Electron crashReporter');
136+
debug.log('Invalid DSN. Cannot start Electron crashReporter');
137137
return;
138138
}
139139

140140
// We don't add globalExtra when Breakpad is in use because it doesn't support JSON like strings:
141141
// https://github.com/electron/electron/issues/29711
142142
const globalExtra = { sentry___initialScope: JSON.stringify(getScope(options)) };
143143

144-
logger.log('Starting Electron crashReporter');
144+
debug.log('Starting Electron crashReporter');
145145

146146
crashReporter.start({
147147
companyName: '',
@@ -192,7 +192,7 @@ export const electronMinidumpIntegration = defineIntegration(() => {
192192
unreportedDuringLastSession(crashReporter.getLastCrashReport()?.date).then((crashed) => {
193193
// Check if a previous session was not closed
194194
return checkPreviousSession(crashed);
195-
}, logger.error);
195+
}, debug.error);
196196
},
197197
};
198198
});

src/main/integrations/net-breadcrumbs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import {
22
addBreadcrumb,
3+
debug,
34
defineIntegration,
45
fill,
56
getBreadcrumbLogLevelFromHttpStatusCode,
67
getClient,
78
getTraceData,
8-
logger,
99
LRUMap,
1010
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
1111
SentryNonRecordingSpan,
@@ -161,7 +161,7 @@ function createWrappedRequestFactory(
161161

162162
if (shouldAttachTraceData(method, url)) {
163163
for (const [key, value] of Object.entries(getTraceData({ span }))) {
164-
logger.log(`[Tracing] Adding ${key} header ${value} to outgoing request to "${url}": `);
164+
debug.log(`[Tracing] Adding ${key} header ${value} to outgoing request to "${url}": `);
165165
request.setHeader(key, value);
166166
}
167167
}

src/main/integrations/preload-injection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineIntegration, logger } from '@sentry/core';
1+
import { debug, defineIntegration } from '@sentry/core';
22
import { app } from 'electron';
33
import { existsSync } from 'fs';
44
import { isAbsolute, resolve } from 'path';
@@ -51,7 +51,7 @@ export const preloadInjectionIntegration = defineIntegration(() => {
5151
setPreload(sesh, path);
5252
}
5353
} else {
54-
logger.log(
54+
debug.log(
5555
'The preload script could not be injected automatically. This is most likely caused by bundling of the main process',
5656
);
5757
}

src/main/integrations/renderer-anr.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import {
22
callFrameToStackFrame,
33
captureEvent,
44
Client,
5+
debug,
56
defineIntegration,
67
Event,
78
Integration,
8-
logger,
99
StackFrame,
1010
stripSentryFramesAndReverse,
1111
watchdogTimer,
@@ -20,7 +20,7 @@ import { sessionAnr } from '../sessions';
2020
import { captureRendererStackFrames } from '../stack-parse';
2121

2222
function log(message: string, ...args: unknown[]): void {
23-
logger.log(`[Renderer ANR] ${message}`, ...args);
23+
debug.log(`[Renderer ANR] ${message}`, ...args);
2424
}
2525

2626
interface ScriptParsedEventDataType {

src/main/integrations/screenshots.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { defineIntegration, logger } from '@sentry/core';
1+
import { debug, defineIntegration } from '@sentry/core';
22
import { BrowserWindow } from 'electron';
33
import { ElectronMainOptions } from '../sdk';
44

@@ -35,7 +35,7 @@ export const screenshotsIntegration = defineIntegration(() => {
3535
}
3636
} catch (e) {
3737
// Catch all errors so we don't break event submission if something goes wrong
38-
logger.error('Error capturing screenshot', e);
38+
debug.error('Error capturing screenshot', e);
3939
}
4040
}
4141
}

src/main/integrations/sentry-minidump/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import {
22
applyScopeDataToEvent,
33
captureEvent,
4+
debug,
45
defineIntegration,
56
Event,
6-
logger,
77
Scope,
88
ScopeData,
99
Session,
@@ -47,7 +47,7 @@ export const sentryMinidumpIntegration = defineIntegration((options: Options = {
4747
let minidumpLoader: MinidumpLoader | undefined;
4848

4949
function startCrashReporter(): void {
50-
logger.log('Starting Electron crashReporter');
50+
debug.log('Starting Electron crashReporter');
5151

5252
crashReporter.start({
5353
companyName: '',
@@ -96,7 +96,7 @@ export const sentryMinidumpIntegration = defineIntegration((options: Options = {
9696
// right now and hope that the delay was not too long.
9797

9898
if (minidumpsRemaining <= 0) {
99-
logger.log('Not sending minidumps because the limit has been reached');
99+
debug.log('Not sending minidumps because the limit has been reached');
100100
}
101101

102102
// If the SDK is not enabled, or we've already reached the minidump limit, tell the loader to delete all minidumps
@@ -156,7 +156,7 @@ export const sentryMinidumpIntegration = defineIntegration((options: Options = {
156156
const crashedProcess =
157157
(minidumpProcess === 'renderer' && getRendererName ? getRendererName(contents) : minidumpProcess) || 'unknown';
158158

159-
logger.log(`'${crashedProcess}' process '${details.reason}'`);
159+
debug.log(`'${crashedProcess}' process '${details.reason}'`);
160160

161161
return {
162162
contexts: {
@@ -178,7 +178,7 @@ export const sentryMinidumpIntegration = defineIntegration((options: Options = {
178178
}
179179

180180
async function sendChildProcessCrash(client: NodeClient, details: Omit<Electron.Details, 'exitCode'>): Promise<void> {
181-
logger.log(`${details.type} process has ${details.reason}`);
181+
debug.log(`${details.type} process has ${details.reason}`);
182182

183183
await sendNativeCrashes(client, (minidumpProcess) => ({
184184
contexts: {
@@ -218,7 +218,7 @@ export const sentryMinidumpIntegration = defineIntegration((options: Options = {
218218
} catch (error) {
219219
// This is rare but we've seen reports:
220220
// https://github.com/getsentry/sentry-electron/issues/1102
221-
logger.error('Failed to create minidump loader', error);
221+
debug.error('Failed to create minidump loader', error);
222222
}
223223

224224
const options = client.getOptions();
@@ -288,7 +288,7 @@ export const sentryMinidumpIntegration = defineIntegration((options: Options = {
288288
restorePreviousSession(sessionToRestore);
289289
}
290290
})
291-
.catch((error) => logger.error(error));
291+
.catch((error) => debug.error(error));
292292
},
293293
};
294294
});

src/main/integrations/sentry-minidump/minidump-loader.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Attachment, logger } from '@sentry/core';
1+
import { Attachment, debug } from '@sentry/core';
22
import { app } from 'electron';
33
import { promises as fs } from 'fs';
44
import { basename, join } from 'path';
@@ -47,14 +47,14 @@ export function createMinidumpLoader(getMinidumpPaths: () => Promise<string[]>):
4747
continue;
4848
}
4949

50-
logger.log('Found minidump', path);
50+
debug.log('Found minidump', path);
5151

5252
let stats = await fs.stat(path);
5353

5454
const thirtyDaysAgo = new Date().getTime() - MAX_AGE_DAYS * MS_PER_DAY;
5555

5656
if (stats.mtimeMs < thirtyDaysAgo) {
57-
logger.log(`Ignoring minidump as it is over ${MAX_AGE_DAYS} days old`);
57+
debug.log(`Ignoring minidump as it is over ${MAX_AGE_DAYS} days old`);
5858
continue;
5959
}
6060

@@ -68,7 +68,7 @@ export function createMinidumpLoader(getMinidumpPaths: () => Promise<string[]>):
6868
try {
6969
const parsedMinidump = parseMinidump(data);
7070

71-
logger.log('Sending minidump');
71+
debug.log('Sending minidump');
7272

7373
await callback(parsedMinidump, {
7474
attachmentType: 'event.minidump',
@@ -77,31 +77,31 @@ export function createMinidumpLoader(getMinidumpPaths: () => Promise<string[]>):
7777
});
7878
} catch (e) {
7979
const message = e instanceof Error ? e.toString() : 'Unknown error';
80-
logger.warn(`Dropping minidump:\n${message}`);
80+
debug.warn(`Dropping minidump:\n${message}`);
8181
break;
8282
}
8383

8484
break;
8585
}
8686

87-
logger.log(`Waiting. Minidump has been modified in the last ${NOT_MODIFIED_MS} milliseconds.`);
87+
debug.log(`Waiting. Minidump has been modified in the last ${NOT_MODIFIED_MS} milliseconds.`);
8888
retries += 1;
8989
await delay(RETRY_DELAY_MS);
9090
// update the stats
9191
stats = await fs.stat(path);
9292
}
9393

9494
if (retries >= MAX_RETRIES) {
95-
logger.warn('Timed out waiting for minidump to stop being modified');
95+
debug.warn('Timed out waiting for minidump to stop being modified');
9696
}
9797
} catch (e) {
98-
logger.error('Failed to load minidump', e);
98+
debug.error('Failed to load minidump', e);
9999
} finally {
100100
// We always attempt to delete the minidump
101101
try {
102102
await fs.unlink(path);
103103
} catch (e) {
104-
logger.warn('Could not delete minidump', path);
104+
debug.warn('Could not delete minidump', path);
105105
}
106106
}
107107
}
@@ -118,7 +118,7 @@ async function deleteCrashpadMetadataFile(crashesDirectory: string, waitMs: numb
118118
const metadataPath = join(crashesDirectory, 'metadata');
119119
try {
120120
await fs.unlink(metadataPath);
121-
logger.log('Deleted Crashpad metadata file', metadataPath);
121+
debug.log('Deleted Crashpad metadata file', metadataPath);
122122
} catch (e: any) {
123123
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
124124
if (e.code && e.code == 'EBUSY') {
@@ -158,7 +158,7 @@ export function getMinidumpLoader(): MinidumpLoader {
158158
}
159159

160160
return createMinidumpLoader(async () => {
161-
await deleteCrashpadMetadataFile(crashesDirectory).catch((error) => logger.error(error));
161+
await deleteCrashpadMetadataFile(crashesDirectory).catch((error) => debug.error(error));
162162
const files = await readDirsAsync(dumpDirectories);
163163
return files.filter((file) => file.endsWith('.dmp'));
164164
});

src/main/ipc.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import {
22
_INTERNAL_captureSerializedLog,
33
Attachment,
44
Client,
5+
debug,
56
DynamicSamplingContext,
67
Event,
7-
logger,
88
parseEnvelope,
99
ScopeData,
1010
SerializedLog,
@@ -50,7 +50,7 @@ function newProtocolRenderer(): void {
5050
WINDOW_ID_TO_WEB_CONTENTS?.delete(windowId);
5151
});
5252
}
53-
}, logger.error);
53+
}, debug.error);
5454
}
5555
}
5656
}
@@ -137,7 +137,7 @@ function handleScope(options: ElectronMainOptionsInternal, jsonScope: string): v
137137
try {
138138
sentScope = JSON.parse(jsonScope) as ScopeData;
139139
} catch {
140-
logger.warn('sentry-electron received an invalid scope message');
140+
debug.warn('sentry-electron received an invalid scope message');
141141
return;
142142
}
143143

@@ -233,7 +233,7 @@ function configureProtocol(client: Client, options: ElectronMainOptionsInternal)
233233
});
234234
}
235235
})
236-
.catch((error) => logger.error(error));
236+
.catch((error) => debug.error(error));
237237
}
238238

239239
/**

0 commit comments

Comments
 (0)