GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ref(core): Keep log and metric capture helpers as deprecated aliases · getsentry/sentry-javascript@0a6ff37

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/core
    • src
      • index.ts
      • logs
        • internal.ts
      • metrics
        • internal.ts
        • public-api.ts
    • test/lib
      • client.test.ts
      • metrics
        • internal.test.ts
      • server-runtime-client.test.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/core/src/index.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/index.ts
+16-2Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,24 @@ export { profiler } from './profiling';
186186
export { instrumentFetchRequest, _INTERNAL_getTracingHeadersForFetchRequest } from './fetch';
187187
export { captureFeedback } from './feedback';
188188
export type { ReportDialogOptions } from './report-dialog';
189-
export { _INTERNAL_captureLog, _INTERNAL_flushLogsBuffer } from './logs/internal';
189+
export {
190+
_INTERNAL_captureLog,
191+
_INTERNAL_flushLogsBuffer,
192+
captureSerializedLog,
193+
// oxlint-disable-next-line typescript/no-deprecated
194+
_INTERNAL_captureSerializedLog,
195+
} from './logs/internal';
190196
export { logger } from './logs/public-api';
191197
export { consoleLoggingIntegration } from './logs/console-integration';
192-
export { _INTERNAL_flushMetricsBuffer } from './metrics/internal';
198+
export {
199+
_INTERNAL_flushMetricsBuffer,
200+
captureMetric,
201+
captureSerializedMetric,
202+
// oxlint-disable-next-line typescript/no-deprecated
203+
_INTERNAL_captureMetric,
204+
// oxlint-disable-next-line typescript/no-deprecated
205+
_INTERNAL_captureSerializedMetric,
206+
} from './metrics/internal';
193207
export { metrics } from './metrics/public-api';
194208
export type { MetricOptions } from './metrics/public-api';
195209
export { createConsolaReporter } from './integrations/consola';
Collapse file

‎packages/core/src/logs/internal.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/logs/internal.ts
+10-4Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function setLogAttribute(
6060
* @experimental This method will experience breaking changes. This is not yet part of
6161
* the stable Sentry SDK API and can be changed or removed without warning.
6262
*/
63-
export function _INTERNAL_captureSerializedLog(client: Client, serializedLog: SerializedLog): void {
63+
export function captureSerializedLog(client: Client, serializedLog: SerializedLog): void {
6464
const bufferMap = _getBufferMap();
6565
const logBuffer = _INTERNAL_getLogBuffer(client);
6666

@@ -78,21 +78,27 @@ export function _INTERNAL_captureSerializedLog(client: Client, serializedLog: Se
7878
}
7979
}
8080

81+
/**
82+
* @deprecated Use `captureSerializedLog` instead.
83+
*/
84+
// TODO(v12): Remove once the Electron SDK no longer uses it.
85+
export const _INTERNAL_captureSerializedLog = captureSerializedLog;
86+
8187
/**
8288
* Captures a log event and sends it to Sentry.
8389
*
8490
* @param log - The log event to capture.
8591
* @param scope - A scope. Uses the current scope if not provided.
8692
* @param client - A client. Uses the current client if not provided.
87-
* @param captureSerializedLog - A function to capture the serialized log.
93+
* @param captureSerialized - A function to capture the serialized log.
8894
*
8995
* @experimental This method will experience breaking changes. This is not yet part of
9096
* the stable Sentry SDK API and can be changed or removed without warning.
9197
*/
9298
export function _INTERNAL_captureLog(
9399
beforeLog: Log,
94100
currentScope = getCurrentScope(),
95-
captureSerializedLog: (client: Client, log: SerializedLog) => void = _INTERNAL_captureSerializedLog,
101+
captureSerialized: (client: Client, log: SerializedLog) => void = captureSerializedLog,
96102
): void {
97103
const client = currentScope?.getClient() ?? getClient();
98104
if (!client) {
@@ -195,7 +201,7 @@ export function _INTERNAL_captureLog(
195201
}),
196202
};
197203

198-
captureSerializedLog(client, serializedLog);
204+
captureSerialized(client, serializedLog);
199205

200206
client.emit('afterCaptureLog', log);
201207
}
Collapse file

‎packages/core/src/metrics/internal.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/metrics/internal.ts
+16-4Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function setMetricAttribute(
5757
* @experimental This method will experience breaking changes. This is not yet part of
5858
* the stable Sentry SDK API and can be changed or removed without warning.
5959
*/
60-
export function _INTERNAL_captureSerializedMetric(client: Client, serializedMetric: SerializedMetric): void {
60+
export function captureSerializedMetric(client: Client, serializedMetric: SerializedMetric): void {
6161
const bufferMap = _getBufferMap();
6262
const metricBuffer = _INTERNAL_getMetricBuffer(client);
6363

@@ -81,6 +81,12 @@ export function _INTERNAL_captureSerializedMetric(client: Client, serializedMetr
8181
}
8282
}
8383

84+
/**
85+
* @deprecated Use `captureSerializedMetric` instead.
86+
*/
87+
// TODO(v12): Remove once the Electron SDK no longer uses it.
88+
export const _INTERNAL_captureSerializedMetric = captureSerializedMetric;
89+
8490
/**
8591
* Options for capturing a metric internally.
8692
*/
@@ -184,9 +190,9 @@ function _buildSerializedMetric(
184190
* @experimental This method will experience breaking changes. This is not yet part of
185191
* the stable Sentry SDK API and can be changed or removed without warning.
186192
*/
187-
export function _INTERNAL_captureMetric(beforeMetric: Metric, options?: InternalCaptureMetricOptions): void {
193+
export function captureMetric(beforeMetric: Metric, options?: InternalCaptureMetricOptions): void {
188194
const currentScope = options?.scope ?? getCurrentScope();
189-
const captureSerializedMetric = options?.captureSerializedMetric ?? _INTERNAL_captureSerializedMetric;
195+
const captureSerialized = options?.captureSerializedMetric ?? captureSerializedMetric;
190196
const client = currentScope?.getClient() ?? getClient();
191197
if (!client) {
192198
DEBUG_BUILD && debug.warn('No client available to capture metric.');
@@ -224,11 +230,17 @@ export function _INTERNAL_captureMetric(beforeMetric: Metric, options?: Internal
224230

225231
DEBUG_BUILD && debug.log('[Metric]', serializedMetric);
226232

227-
captureSerializedMetric(client, serializedMetric);
233+
captureSerialized(client, serializedMetric);
228234

229235
client.emit('afterCaptureMetric', processedMetric);
230236
}
231237

238+
/**
239+
* @deprecated Use `captureMetric` instead.
240+
*/
241+
// TODO(v12): Remove once the Electron SDK no longer uses it.
242+
export const _INTERNAL_captureMetric = captureMetric;
243+
232244
/**
233245
* Flushes the metrics buffer to Sentry.
234246
*
Collapse file

‎packages/core/src/metrics/public-api.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/metrics/public-api.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Scope } from '../scope';
22
import type { MetricUnit } from '../types/measurement';
33
import type { Metric, MetricType } from '../types/metric';
4-
import { _INTERNAL_captureMetric } from './internal';
4+
import { captureMetric as captureMetricEvent } from './internal';
55

66
/**
77
* Options for capturing a metric.
@@ -32,7 +32,7 @@ export interface MetricOptions {
3232
* @param options - Options for capturing the metric.
3333
*/
3434
function captureMetric(type: MetricType, name: string, value: number, options?: MetricOptions): void {
35-
_INTERNAL_captureMetric(
35+
captureMetricEvent(
3636
{ type, name, value, unit: options?.unit, attributes: options?.attributes },
3737
{ scope: options?.scope },
3838
);
Collapse file

‎packages/core/test/lib/client.test.ts‎

Copy file name to clipboardExpand all lines: packages/core/test/lib/client.test.ts
+12-12Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
import * as integrationModule from '../../src/integration';
2020
import * as logsInternalModule from '../../src/logs/internal';
2121
import { _INTERNAL_captureLog } from '../../src/logs/internal';
22-
import { _INTERNAL_captureMetric } from '../../src/metrics/internal';
22+
import { captureMetric } from '../../src/metrics/internal';
2323
import * as traceModule from '../../src/tracing/trace';
2424
import { DEFAULT_TRANSPORT_BUFFER_SIZE } from '../../src/transports/base';
2525
import type { Envelope } from '../../src/types/envelope';
@@ -4425,11 +4425,11 @@ describe('Client', () => {
44254425

44264426
expect(onSpy).not.toHaveBeenCalledWith('afterCaptureMetric', expect.any(Function));
44274427

4428-
_INTERNAL_captureMetric({ name: 'metric1', value: 1, type: 'counter', attributes: {} }, { scope });
4428+
captureMetric({ name: 'metric1', value: 1, type: 'counter', attributes: {} }, { scope });
44294429
expect(onSpy).toHaveBeenCalledWith('afterCaptureMetric', expect.any(Function));
44304430

44314431
onSpy.mockClear();
4432-
_INTERNAL_captureMetric({ name: 'metric2', value: 2, type: 'counter', attributes: {} }, { scope });
4432+
captureMetric({ name: 'metric2', value: 2, type: 'counter', attributes: {} }, { scope });
44334433
expect(onSpy).not.toHaveBeenCalledWith('afterCaptureMetric', expect.any(Function));
44344434

44354435
onSpy.mockRestore();
@@ -4447,7 +4447,7 @@ describe('Client', () => {
44474447

44484448
// Create large metrics that will exceed the 800KB threshold
44494449
const largeValue = 'x'.repeat(400_000); // 400KB string
4450-
_INTERNAL_captureMetric(
4450+
captureMetric(
44514451
{ name: 'large_metric', value: 1, type: 'counter', attributes: { large_value: largeValue } },
44524452
{ scope },
44534453
);
@@ -4466,7 +4466,7 @@ describe('Client', () => {
44664466
const sendEnvelopeSpy = vi.spyOn(client, 'sendEnvelope');
44674467

44684468
// Create metrics that won't exceed the threshold
4469-
_INTERNAL_captureMetric({ name: 'test_metric', value: 42, type: 'counter', attributes: {} }, { scope });
4469+
captureMetric({ name: 'test_metric', value: 42, type: 'counter', attributes: {} }, { scope });
44704470

44714471
expect(sendEnvelopeSpy).not.toHaveBeenCalled();
44724472
});
@@ -4482,8 +4482,8 @@ describe('Client', () => {
44824482
const sendEnvelopeSpy = vi.spyOn(client, 'sendEnvelope');
44834483

44844484
// Add some metrics
4485-
_INTERNAL_captureMetric({ name: 'metric1', value: 1, type: 'counter', attributes: {} }, { scope });
4486-
_INTERNAL_captureMetric({ name: 'metric2', value: 2, type: 'counter', attributes: {} }, { scope });
4485+
captureMetric({ name: 'metric1', value: 1, type: 'counter', attributes: {} }, { scope });
4486+
captureMetric({ name: 'metric2', value: 2, type: 'counter', attributes: {} }, { scope });
44874487

44884488
// Trigger flush event
44894489
client.emit('flush');
@@ -4502,7 +4502,7 @@ describe('Client', () => {
45024502
scope.setClient(client);
45034503

45044504
// Capture a metric which will start the flush timer
4505-
_INTERNAL_captureMetric({ name: 'test_metric', value: 42, type: 'counter', attributes: {} }, { scope });
4505+
captureMetric({ name: 'test_metric', value: 42, type: 'counter', attributes: {} }, { scope });
45064506

45074507
// Verify safeUnref was called on the timer
45084508
expect(safeUnrefSpy).toHaveBeenCalledTimes(1);
@@ -4522,7 +4522,7 @@ describe('Client', () => {
45224522
client.on('flushMetrics', flushMetricsHandler);
45234523

45244524
// Capture a metric which starts the weight-based flush timer
4525-
_INTERNAL_captureMetric({ name: 'test_metric', value: 42, type: 'counter', attributes: {} }, { scope });
4525+
captureMetric({ name: 'test_metric', value: 42, type: 'counter', attributes: {} }, { scope });
45264526

45274527
expect(flushMetricsHandler).not.toHaveBeenCalled();
45284528

@@ -4543,7 +4543,7 @@ describe('Client', () => {
45434543
const scope = new Scope();
45444544
scope.setClient(client);
45454545

4546-
_INTERNAL_captureMetric({ name: 'test_metric', value: 42, type: 'counter', attributes: {} }, { scope });
4546+
captureMetric({ name: 'test_metric', value: 42, type: 'counter', attributes: {} }, { scope });
45474547

45484548
expect(safeUnrefSpy).not.toHaveBeenCalled();
45494549

@@ -4561,7 +4561,7 @@ describe('Client', () => {
45614561

45624562
const sendEnvelopeSpy = vi.spyOn(client, 'sendEnvelope');
45634563

4564-
_INTERNAL_captureMetric({ name: 'metric1', value: 1, type: 'counter', attributes: {} }, { scope });
4564+
captureMetric({ name: 'metric1', value: 1, type: 'counter', attributes: {} }, { scope });
45654565

45664566
expect(sendEnvelopeSpy).not.toHaveBeenCalled();
45674567

@@ -4582,7 +4582,7 @@ describe('Client', () => {
45824582
const sendEnvelopeSpy = vi.spyOn(client, 'sendEnvelope');
45834583

45844584
const largeValue = 'x'.repeat(400_000);
4585-
_INTERNAL_captureMetric(
4585+
captureMetric(
45864586
{ name: 'large_metric', value: 1, type: 'counter', attributes: { large_value: largeValue } },
45874587
{ scope },
45884588
);

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.