Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update JavaScript SDKs to v7.90.0 #800

Merged
merged 12 commits into from
Jan 2, 2024
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@
"e2e": "cross-env TS_NODE_PROJECT=tsconfig.test.json xvfb-maybe mocha --require ts-node/register/transpile-only --retries 3 ./test/e2e/*.ts"
},
"dependencies": {
"@sentry/browser": "7.84.0",
"@sentry/core": "7.84.0",
"@sentry/node": "7.84.0",
"@sentry/types": "7.84.0",
"@sentry/utils": "7.84.0",
"@sentry/browser": "7.90.0",
"@sentry/core": "7.90.0",
"@sentry/node": "7.90.0",
"@sentry/types": "7.90.0",
"@sentry/utils": "7.90.0",
"deepmerge": "4.3.0",
"tslib": "^2.5.0"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.2.1",
"@rollup/plugin-typescript": "^11.1.4",
"@sentry-internal/eslint-config-sdk": "7.84.0",
"@sentry-internal/typescript": "7.84.0",
"@sentry-internal/eslint-config-sdk": "7.90.0",
"@sentry-internal/typescript": "7.90.0",
"@types/busboy": "^0.2.3",
"@types/chai": "^4.2.10",
"@types/chai-as-promised": "^7.1.5",
Expand Down
32 changes: 24 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { BrowserOptions } from './renderer';
export type {
Breadcrumb,
BreadcrumbHint,
PolymorphicRequest,
Request,
SdkInfo,
Event,
Expand All @@ -16,6 +17,7 @@ export type {
// eslint-disable-next-line deprecation/deprecation
Severity,
SeverityLevel,
Span,
StackFrame,
Stacktrace,
Thread,
Expand All @@ -24,36 +26,50 @@ export type {
} from '@sentry/types';

export {
// eslint-disable-next-line deprecation/deprecation
addGlobalEventProcessor,
addEventProcessor,
addBreadcrumb,
addIntegration,
captureException,
captureEvent,
captureMessage,
// eslint-disable-next-line deprecation/deprecation
configureScope,
createTransport,
// eslint-disable-next-line deprecation/deprecation
extractTraceparentData,
getActiveTransaction,
getHubFromCarrier,
getCurrentHub,
getClient,
getCurrentScope,
Hub,
lastEventId,
makeMain,
runWithAsyncContext,
Scope,
startTransaction,
getActiveSpan,
startSpan,
startInactiveSpan,
startSpanManual,
continueTrace,
SDK_VERSION,
setContext,
setExtra,
setExtras,
setTag,
setTags,
setUser,
spanStatusfromHttpCode,
trace,
withScope,
FunctionToString,
InboundFilters,
captureCheckIn,
withMonitor,
setMeasurement,
getActiveSpan,
startSpan,
// eslint-disable-next-line deprecation/deprecation
startActiveSpan,
startInactiveSpan,
startSpanManual,
continueTrace,
metrics,
} from '@sentry/core';
export type { SpanStatusType } from '@sentry/core';

Expand Down
4 changes: 3 additions & 1 deletion src/main/anr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ function rendererDebugger(contents: WebContents, pausedStack: (frames: StackFram
});

// In node, we enable just before pausing but for Chrome, the debugger must be enabled before he ANR event occurs
void contents.debugger.sendCommand('Debugger.enable');
contents.debugger.sendCommand('Debugger.enable').catch(() => {
// ignore
});

return () => {
return contents.debugger.sendCommand('Debugger.pause');
Expand Down
32 changes: 25 additions & 7 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as ElectronMainIntegrations from './integrations';
export type {
Breadcrumb,
BreadcrumbHint,
PolymorphicRequest,
Request,
SdkInfo,
Event,
Expand All @@ -17,41 +18,58 @@ export type {
// eslint-disable-next-line deprecation/deprecation
Severity,
SeverityLevel,
Span,
StackFrame,
Stacktrace,
Thread,
Transaction,
User,
} from '@sentry/types';

export {
// eslint-disable-next-line deprecation/deprecation
addGlobalEventProcessor,
addEventProcessor,
addBreadcrumb,
addIntegration,
captureException,
captureEvent,
captureMessage,
// eslint-disable-next-line deprecation/deprecation
configureScope,
createTransport,
// eslint-disable-next-line deprecation/deprecation
extractTraceparentData,
getActiveTransaction,
getHubFromCarrier,
getCurrentHub,
getClient,
getCurrentScope,
Hub,
makeMain,
runWithAsyncContext,
Scope,
startTransaction,
getActiveSpan,
startSpan,
startInactiveSpan,
startSpanManual,
continueTrace,
setContext,
setExtra,
setExtras,
setTag,
setTags,
setUser,
spanStatusfromHttpCode,
trace,
withScope,
FunctionToString,
InboundFilters,
captureCheckIn,
withMonitor,
setMeasurement,
getActiveSpan,
startSpan,
// eslint-disable-next-line deprecation/deprecation
startActiveSpan,
startInactiveSpan,
startSpanManual,
continueTrace,
metrics,
} from '@sentry/core';
export type { SpanStatusType } from '@sentry/core';

Expand Down
29 changes: 17 additions & 12 deletions src/main/integrations/additional-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,26 @@ export class AdditionalContext implements Integration {
addGlobalEventProcessor(async (event: Event) => this._addAdditionalContext(event));

// Some metrics are only available after app ready so we lazily load them
void whenAppReady.then(() => {
const { language, screen } = this._options;
whenAppReady.then(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just fyi, when you're 100% certain that a promise cannot reject it is also fine to just ignore the lint rule!

() => {
const { language, screen } = this._options;

if (language) {
this._lazyDeviceContext.language = app.getLocale();
}

if (screen) {
this._setPrimaryDisplayInfo();
if (language) {
this._lazyDeviceContext.language = app.getLocale();
}

electronScreen.on('display-metrics-changed', () => {
if (screen) {
this._setPrimaryDisplayInfo();
});
}
});

electronScreen.on('display-metrics-changed', () => {
this._setPrimaryDisplayInfo();
});
}
},
() => {
// ignore
},
);
}

/** Adds additional context to event */
Expand Down
6 changes: 4 additions & 2 deletions src/main/integrations/browser-window-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class BrowserWindowSession implements Integration {
// We are now active
if (this._state.name === 'inactive') {
// If we were inactive, start a new session
void startSession(true);
startSession(true);
} else if (this._state.name === 'timeout') {
// Clear the timeout since the app has become active again
clearTimeout(this._state.timer);
Expand All @@ -96,7 +96,9 @@ export class BrowserWindowSession implements Integration {
// if the state says we're still waiting for the timeout, end the session
if (this._state.name === 'timeout') {
this._state = { name: 'inactive' };
void endSession();
endSession().catch(() => {
// ignore
});
}
}, timeout)
// unref so this timer doesn't block app exit
Expand Down
23 changes: 14 additions & 9 deletions src/main/integrations/electron-breadcrumbs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,21 @@ export class ElectronBreadcrumbs implements Integration {

trackRendererProperties();

void whenAppReady.then(() => {
// We can't access these until app 'ready'
if (this._options.screen) {
this._patchEventEmitter(screen, 'screen', this._options.screen);
}
whenAppReady.then(
() => {
// We can't access these until app 'ready'
if (this._options.screen) {
this._patchEventEmitter(screen, 'screen', this._options.screen);
}

if (this._options.powerMonitor) {
this._patchEventEmitter(powerMonitor, 'powerMonitor', this._options.powerMonitor);
}
});
if (this._options.powerMonitor) {
this._patchEventEmitter(powerMonitor, 'powerMonitor', this._options.powerMonitor);
}
},
() => {
// ignore
},
);

if (this._options.app) {
this._patchEventEmitter(app, 'app', this._options.app);
Expand Down
25 changes: 10 additions & 15 deletions src/main/integrations/electron-minidump.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getCurrentHub, Scope } from '@sentry/core';
import { applyScopeDataToEvent, getCurrentHub } from '@sentry/core';
import { NodeClient, NodeOptions } from '@sentry/node';
import { Event, Integration } from '@sentry/types';
import { Event, Integration, ScopeData } from '@sentry/types';
import { logger, makeDsn, SentryError } from '@sentry/utils';
import { app, crashReporter } from 'electron';

Expand Down Expand Up @@ -105,10 +105,10 @@ export class ElectronMinidump implements Integration {
}

// Check if last crash report was likely to have been unreported in the last session
void unreportedDuringLastSession(crashReporter.getLastCrashReport()?.date).then((crashed) => {
unreportedDuringLastSession(crashReporter.getLastCrashReport()?.date).then((crashed) => {
// Check if a previous session was not closed
checkPreviousSession(crashed).catch((error) => logger.error(error));
});
return checkPreviousSession(crashed);
}, logger.error);
}

/**
Expand Down Expand Up @@ -145,19 +145,15 @@ export class ElectronMinidump implements Integration {
const hubScope = getCurrentHub().getScope();
if (hubScope) {
hubScope.addScopeListener((updatedScope) => {
const scope = Scope.clone(updatedScope);
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
(scope as any)._eventProcessors = [];
(scope as any)._scopeListeners = [];
/* eslint-enable @typescript-eslint/no-unsafe-member-access */

const scope = updatedScope.getScopeData();
scope.eventProcessors = [];
this._updateExtraParams(scope);
});
}
}

/** Updates Electron uploader extra params */
private _updateExtraParams(scope: Scope): void {
private _updateExtraParams(scope: ScopeData): void {
this._updateEpoch += 1;
const currentEpoch = this._updateEpoch;

Expand All @@ -175,15 +171,14 @@ export class ElectronMinidump implements Integration {
}

/** Builds up an event to send with the native Electron uploader */
private async _getNativeUploaderEvent(scope: Scope): Promise<Event> {
private async _getNativeUploaderEvent(scope: ScopeData): Promise<Event> {
const event = mergeEvents(await getEventDefaults(this._customRelease), {
level: 'fatal',
platform: 'native',
tags: { 'event.environment': 'native', event_type: 'native' },
});

// Apply the scope to the event
await scope.applyToEvent(event);
applyScopeDataToEvent(event, scope);

delete event.sdkProcessingMetadata;

Expand Down
2 changes: 1 addition & 1 deletion src/main/integrations/main-process-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class MainProcessSession implements Integration {

/** @inheritDoc */
public setupOnce(): void {
void startSession(!!this._options.sendOnCreate);
startSession(!!this._options.sendOnCreate);

endSessionOnExit();
}
Expand Down
Loading
Loading