Skip to content

Commit 86badae

Browse files
authored
Merge pull request #8958 from getsentry/prepare-release/7.68.0
2 parents 546aed4 + 5dd16de commit 86badae

File tree

21 files changed

+817
-17
lines changed

21 files changed

+817
-17
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
!/cjs/**/*
77
!/esm/**/*
88
!/types/**/*
9+
!/types-ts3.8/**/*

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44

55
- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott
66

7+
## 7.68.0
8+
9+
- feat(browser): Add `BroadcastChannel` and `SharedWorker` to TryCatch EventTargets (#8943)
10+
- feat(core): Add `name` to `Span` (#8949)
11+
- feat(core): Add `ServerRuntimeClient` (#8930)
12+
- fix(node-experimental): Ensure `span.finish()` works as expected (#8947)
13+
- fix(remix): Add new sourcemap-upload script files to prepack assets. (#8948)
14+
- fix(publish): Publish downleveled TS3.8 types and fix types path (#8954)
15+
716
## 7.67.0
817

918
### Important Changes

MIGRATION.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Deprecations in 7.x
22

3+
You can use [@sentry/migr8](https://www.npmjs.com/package/@sentry/migr8) to automatically update your SDK usage and fix most deprecations:
4+
5+
```bash
6+
npx @sentry/migr8@latest
7+
```
8+
9+
This will let you select which updates to run, and automatically update your code. Make sure to still review all code changes!
10+
311
## Deprecate `timestampWithMs` export - #7878
412

513
The `timestampWithMs` util is deprecated in favor of using `timestampInSeconds`.

packages/browser/src/integrations/trycatch.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const DEFAULT_EVENT_TARGET = [
99
'Node',
1010
'ApplicationCache',
1111
'AudioTrackList',
12+
'BroadcastChannel',
1213
'ChannelMergerNode',
1314
'CryptoOperation',
1415
'EventSource',
@@ -24,6 +25,7 @@ const DEFAULT_EVENT_TARGET = [
2425
'Notification',
2526
'SVGElementInstance',
2627
'Screen',
28+
'SharedWorker',
2729
'TextTrack',
2830
'TextTrackCue',
2931
'TextTrackList',

packages/core/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export type { ClientClass } from './sdk';
22
export type { AsyncContextStrategy, Carrier, Layer, RunWithAsyncContextOptions } from './hub';
33
export type { OfflineStore, OfflineTransportOptions } from './transports/offline';
4+
export type { ServerRuntimeClientOptions } from './server-runtime-client';
45

56
export * from './tracing';
67
export {
@@ -38,6 +39,7 @@ export { SessionFlusher } from './sessionflusher';
3839
export { addGlobalEventProcessor, Scope } from './scope';
3940
export { getEnvelopeEndpointWithUrlEncodedAuth, getReportDialogEndpoint } from './api';
4041
export { BaseClient } from './baseclient';
42+
export { ServerRuntimeClient } from './server-runtime-client';
4143
export { initAndBind } from './sdk';
4244
export { createTransport } from './transports/base';
4345
export { makeOfflineTransport } from './transports/offline';
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
import type {
2+
BaseTransportOptions,
3+
CheckIn,
4+
ClientOptions,
5+
DynamicSamplingContext,
6+
Event,
7+
EventHint,
8+
MonitorConfig,
9+
SerializedCheckIn,
10+
Severity,
11+
SeverityLevel,
12+
TraceContext,
13+
} from '@sentry/types';
14+
import { eventFromMessage, eventFromUnknownInput, logger, uuid4 } from '@sentry/utils';
15+
16+
import { BaseClient } from './baseclient';
17+
import { createCheckInEnvelope } from './checkin';
18+
import { getCurrentHub } from './hub';
19+
import type { Scope } from './scope';
20+
import { addTracingExtensions, getDynamicSamplingContextFromClient } from './tracing';
21+
22+
export interface ServerRuntimeClientOptions extends ClientOptions<BaseTransportOptions> {
23+
platform?: string;
24+
runtime?: { name: string; version?: string };
25+
serverName?: string;
26+
}
27+
28+
/**
29+
* The Sentry Server Runtime Client SDK.
30+
*/
31+
export class ServerRuntimeClient<
32+
O extends ClientOptions & ServerRuntimeClientOptions = ServerRuntimeClientOptions,
33+
> extends BaseClient<O> {
34+
/**
35+
* Creates a new Edge SDK instance.
36+
* @param options Configuration options for this SDK.
37+
*/
38+
public constructor(options: O) {
39+
// Server clients always support tracing
40+
addTracingExtensions();
41+
42+
super(options);
43+
}
44+
45+
/**
46+
* @inheritDoc
47+
*/
48+
public eventFromException(exception: unknown, hint?: EventHint): PromiseLike<Event> {
49+
return Promise.resolve(eventFromUnknownInput(getCurrentHub, this._options.stackParser, exception, hint));
50+
}
51+
52+
/**
53+
* @inheritDoc
54+
*/
55+
public eventFromMessage(
56+
message: string,
57+
// eslint-disable-next-line deprecation/deprecation
58+
level: Severity | SeverityLevel = 'info',
59+
hint?: EventHint,
60+
): PromiseLike<Event> {
61+
return Promise.resolve(
62+
eventFromMessage(this._options.stackParser, message, level, hint, this._options.attachStacktrace),
63+
);
64+
}
65+
66+
/**
67+
* Create a cron monitor check in and send it to Sentry.
68+
*
69+
* @param checkIn An object that describes a check in.
70+
* @param upsertMonitorConfig An optional object that describes a monitor config. Use this if you want
71+
* to create a monitor automatically when sending a check in.
72+
*/
73+
public captureCheckIn(checkIn: CheckIn, monitorConfig?: MonitorConfig, scope?: Scope): string {
74+
const id = checkIn.status !== 'in_progress' && checkIn.checkInId ? checkIn.checkInId : uuid4();
75+
if (!this._isEnabled()) {
76+
__DEBUG_BUILD__ && logger.warn('SDK not enabled, will not capture checkin.');
77+
return id;
78+
}
79+
80+
const options = this.getOptions();
81+
const { release, environment, tunnel } = options;
82+
83+
const serializedCheckIn: SerializedCheckIn = {
84+
check_in_id: id,
85+
monitor_slug: checkIn.monitorSlug,
86+
status: checkIn.status,
87+
release,
88+
environment,
89+
};
90+
91+
if (checkIn.status !== 'in_progress') {
92+
serializedCheckIn.duration = checkIn.duration;
93+
}
94+
95+
if (monitorConfig) {
96+
serializedCheckIn.monitor_config = {
97+
schedule: monitorConfig.schedule,
98+
checkin_margin: monitorConfig.checkinMargin,
99+
max_runtime: monitorConfig.maxRuntime,
100+
timezone: monitorConfig.timezone,
101+
};
102+
}
103+
104+
const [dynamicSamplingContext, traceContext] = this._getTraceInfoFromScope(scope);
105+
if (traceContext) {
106+
serializedCheckIn.contexts = {
107+
trace: traceContext,
108+
};
109+
}
110+
111+
const envelope = createCheckInEnvelope(
112+
serializedCheckIn,
113+
dynamicSamplingContext,
114+
this.getSdkMetadata(),
115+
tunnel,
116+
this.getDsn(),
117+
);
118+
119+
__DEBUG_BUILD__ && logger.info('Sending checkin:', checkIn.monitorSlug, checkIn.status);
120+
void this._sendEnvelope(envelope);
121+
return id;
122+
}
123+
124+
/**
125+
* @inheritDoc
126+
*/
127+
protected _prepareEvent(event: Event, hint: EventHint, scope?: Scope): PromiseLike<Event | null> {
128+
if (this._options.platform) {
129+
event.platform = event.platform || this._options.platform;
130+
}
131+
132+
if (this._options.runtime) {
133+
event.contexts = {
134+
...event.contexts,
135+
runtime: (event.contexts || {}).runtime || this._options.runtime,
136+
};
137+
}
138+
139+
if (this._options.serverName) {
140+
event.server_name = event.server_name || this._options.serverName;
141+
}
142+
143+
return super._prepareEvent(event, hint, scope);
144+
}
145+
146+
/** Extract trace information from scope */
147+
private _getTraceInfoFromScope(
148+
scope: Scope | undefined,
149+
): [dynamicSamplingContext: Partial<DynamicSamplingContext> | undefined, traceContext: TraceContext | undefined] {
150+
if (!scope) {
151+
return [undefined, undefined];
152+
}
153+
154+
const span = scope.getSpan();
155+
if (span) {
156+
const samplingContext = span.transaction ? span.transaction.getDynamicSamplingContext() : undefined;
157+
return [samplingContext, span.getTraceContext()];
158+
}
159+
160+
const { traceId, spanId, parentSpanId, dsc } = scope.getPropagationContext();
161+
const traceContext: TraceContext = {
162+
trace_id: traceId,
163+
span_id: spanId,
164+
parent_span_id: parentSpanId,
165+
};
166+
if (dsc) {
167+
return [dsc, traceContext];
168+
}
169+
170+
return [getDynamicSamplingContextFromClient(traceId, this, scope), traceContext];
171+
}
172+
}

packages/core/src/tracing/span.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,15 @@ export class Span implements SpanInterface {
161161
}
162162
}
163163

164+
/** An alias for `description` of the Span. */
165+
public get name(): string {
166+
return this.description || '';
167+
}
168+
/** Update the name of the span. */
169+
public set name(name: string) {
170+
this.setName(name);
171+
}
172+
164173
/**
165174
* @inheritDoc
166175
*/

0 commit comments

Comments
 (0)