8000 fix: Typedocs and public exposed functions · DanielGibbsNZ/sentry-javascript@8ea2ec7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8ea2ec7

Browse files
committed
fix: Typedocs and public exposed functions
1 parent df0c3d7 commit 8ea2ec7

File tree

23 files changed

+145
-48
lines changed

23 files changed

+145
-48
lines changed

packages/browser/src/backend.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ export interface BrowserOptions extends Options {
2828
whitelistUrls?: Array<string | RegExp>;
2929
}
3030

31-
/** The Sentry Browser SDK Backend. */
31+
/**
32+
* The Sentry Browser SDK Backend.
33+
* @hidden
34+
*/
3235
export class BrowserBackend extends BaseBackend<BrowserOptions> {
3336
/**
3437
* @inheritDoc

packages/browser/src/integrations/breadcrumbs.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ import { breadcrumbEventHandler, keypressEventHandler, wrap } from './helpers';
1212
const global = getGlobalObject() as Window;
1313
let lastHref: string | undefined;
1414

15-
/** JSDoc */
15+
/**
16+
* @hidden
17+
*/
1618
export interface SentryWrappedXMLHttpRequest extends XMLHttpRequest {
1719
[key: string]: any;
1820
__sentry_xhr__?: {

packages/browser/src/integrations/helpers.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@ let keypressTimeout: number | undefined;
99
let lastCapturedEvent: Event | undefined;
1010
let ignoreOnError: number = 0;
1111

12-
/** JSDoc */
12+
/**
13+
* @hidden
14+
*/
1315
export function shouldIgnoreOnError(): boolean {
1416
return ignoreOnError > 0;
1517
}
16-
/** JSDoc */
18+
19+
/**
20+
* @hidden
21+
*/
1722
export function ignoreNextOnError(): void {
1823
// onerror should trigger before setTimeout
1924
ignoreOnError += 1;
@@ -28,6 +33,7 @@ export function ignoreNextOnError(): void {
2833
*
2934
* @param fn A function to wrap.
3035
* @returns The wrapped function.
36+
* @hidden
3137
*/
3238
export function wrap(
3339
fn: SentryWrappedFunction,
@@ -141,6 +147,7 @@ export function wrap(
141147
* Wraps addEventListener to capture UI breadcrumbs
142148
* @param eventName the event name (e.g. "click")
143149
* @returns wrapped breadcrumb events handler
150+
* @hidden
144151
*/
145152
export function breadcrumbEventHandler(eventName: string): (event: Event) => void {
146153
return (event: Event) => {
@@ -185,6 +192,7 @@ export function breadcrumbEventHandler(eventName: string): (event: Event) => voi
185192
/**
186193
* Wraps addEventListener to capture keypress UI events
187194
* @returns wrapped keypress events handler
195+
* @hidden
188196
*/
189197
export function keypressEventHandler(): (event: Event) => void {
190198
// TODO: if somehow user switches keypress target before

packages/browser/src/parsers.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const STACKTRACE_LIMIT = 50;
99
/**
1010
* This function creates an exception from an TraceKitStackTrace
1111
* @param stacktrace TraceKitStackTrace that will be converted to an exception
12+
* @hidden
1213
*/
1314
export function exceptionFromStacktrace(stacktrace: TraceKitStackTrace): SentryException {
1415
const frames = prepareFramesForEvent(stacktrace.stack);
@@ -30,7 +31,9 @@ export function exceptionFromStacktrace(stacktrace: TraceKitStackTrace): SentryE
3031
return exception;
3132
}
3233

33-
/** JSDoc */
34+
/**
35+
* @hidden
36+
*/
3437
export function eventFromPlainObject(exception: {}, syntheticException: Error | null): SentryEvent {
3538
const exceptionKeys = Object.keys(exception).sort();
3639
const event: SentryEvent = {
@@ -52,7 +55,9 @@ export function eventFromPlainObject(exception: {}, syntheticException: Error |
5255
return event;
5356
}
5457

55-
/** JSDoc */
58+
/**
59+
* @hidden
60+
*/
5661
export function eventFromStacktrace(stacktrace: TraceKitStackTrace): SentryEvent {
5762
const exception = exceptionFromStacktrace(stacktrace);
5863

@@ -63,7 +68,9 @@ export function eventFromStacktrace(stacktrace: TraceKitStackTrace): SentryEvent
6368
};
6469
}
6570

66-
/** JSDoc */
71+
/**
72+
* @hidden
73+
*/
6774
export function prepareFramesForEvent(stack: TraceKitStackFrame[]): StackFrame[] {
6875
if (!stack || !stack.length) {
6976
return [];
@@ -104,6 +111,7 @@ export function prepareFramesForEvent(stack: TraceKitStackFrame[]): StackFrame[]
104111
* @param event The event to modify.
105112
* @param value Value of the exception.
106113
* @param type Type of the exception.
114+
* @hidden
107115
*/
108116
export function addExceptionTypeValue(event: SentryEvent, value?: string, type?: string): void {
109117
event.exception = event.exception || {};

packages/browser/src/sdk.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@ import { BrowserClient, ReportDialogOptions } from './client';
44
import { Breadcrumbs, GlobalHandlers, LinkedErrors, TryCatch, UserAgent } from './integrations';
55

66
export const defaultIntegrations = [
7-
// Common
87
new CoreIntegrations.Dedupe(),
98
new CoreIntegrations.InboundFilters(),
109
new CoreIntegrations.FunctionToString(),
1110
new CoreIntegrations.ExtraErrorData(),
12-
// Native Wrappers
1311
new TryCatch(),
1412
new Breadcrumbs(),
15-
// Global Handlers
1613
new GlobalHandlers(),
17-
// Misc
1814
new LinkedErrors(),
1915
new UserAgent(),
2016
];
@@ -27,29 +23,42 @@ export const defaultIntegrations = [
2723
* the provided methods.
2824
*
2925
* @example
26+
*
27+
* ```
28+
*
3029
* import { init } from '@sentry/browser';
3130
*
3231
* init({
3332
* dsn: '__DSN__',
3433
* // ...
3534
* });
35+
* ```
3636
*
3737
* @example
38+
* ```
39+
*
3840
* import { configureScope } from '@sentry/browser';
3941
* configureScope((scope: Scope) => {
4042
* scope.setExtra({ battery: 0.7 });
4143
* scope.setTag({ user_mode: 'admin' });
4244
* scope.setUser({ id: '4711' });
4345
* });
46+
* ```
4447
*
4548
* @example
49+
* ```
50+
*
4651
* import { addBreadcrumb } from '@sentry/browser';
4752
* addBreadcrumb({
4853
* message: 'My Breadcrumb',
4954
* // ...
5055
* });
56+
* ```
5157
*
5258
* @example
59+
*
60+
* ```
61+
*
5362
* import * as Sentry from '@sentry/browser';
5463
* Sentry.captureMessage('Hello, world!');
5564
* Sentry.captureException(new Error('Good bye'));
@@ -59,8 +68,9 @@ export const defaultIntegrations = [
5968
* // ...
6069
* ],
6170
* });
71+
* ```
6272
*
63-
* @see BrowserOptions for documentation on configuration options.
73+
* @see {@link BrowserOptions} for documentation on configuration options.
6474
*/
6575
export function init(options: BrowserOptions = {}): void {
6676
if (options.defaultIntegrations === undefined) {
@@ -91,14 +101,16 @@ export function lastEventId(): string | undefined {
91101
}
92102

93103
/**
94-
* This function is here to be API compatible with the loader
104+
* This function is here to be API compatible with the loader.
105+
* @hidden
95106
*/
96107
export function forceLoad(): void {
97108
// Noop
98109
}
99110

100111
/**
101-
* This function is here to be API compatible with the loader
112+
* This function is here to be API compatible with the loader.
113+
* @hidden
102114
*/
103115
export function onLoad(callback: () => void): void {
104116
callback();

packages/browser/src/tracekit.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import { isUndefined, isError, isErrorEvent } from '@sentry/utils/is';
44
import { getGlobalObject } from '@sentry/utils/misc';
55

6+
/**
7+
* @hidden
8+
*/
69
export interface StackFrame {
710
url: string;
811
func: string;
@@ -12,6 +15,9 @@ export interface StackFrame {
1215
context: string[];
1316
}
1417

18+
/**
19+
* @hidden
20+
*/
1521
export interface StackTrace {
1622
/**
1723
* Known modes: callers, failed, multiline, onerror, stack, stacktrace

packages/core/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@
2121

2222
This package contains interface definitions, base classes and utilities for building Sentry JavaScript SDKs, like
2323
`@sentry/node` or `@sentry/browser`.
24+
25+
Please consider all classes and exported functions and interfaces `internal`.

packages/core/src/integrations/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export { Dedupe } from './dedupe';
22
export { FunctionToString } from './functiontostring';
3-
export { SDKInformation } from './sdkinformation';
43
export { InboundFilters } from './inboundfilters';
54
export { ExtraErrorData } from './extraerrordata';
65

packages/hub/src/hub.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ declare module 'domain' {
2727
*
2828
* WARNING: This number should only be incresed when the global interface
2929
* changes a and new methods are introduced.
30+
*
31+
* @hidden
3032
*/
3133
export const API_VERSION = 3;
3234

@@ -71,6 +73,8 @@ export class Hub {
7173
*
7274
* @param version A version number to compare to.
7375
* @return True if the given version is newer; otherwise false.
76+
*
77+
* @hidden
7478
*/
7579
public isOlderThan(version: number): boolean {
7680
return this.version < version;
@@ -347,7 +351,7 @@ export function getCurrentHub(): Hub {
347351
* This will tell whether a carrier has a hub on it or not
348352
* @param carrier object
349353
*/
350-
export function hasHubOnCarrier(carrier: any): boolean {
354+
function hasHubOnCarrier(carrier: any): boolean {
351355
if (carrier && carrier.__SENTRY__ && carrier.__SENTRY__.hub) {
352356
return true;
353357
} else {
@@ -359,6 +363,7 @@ export function hasHubOnCarrier(carrier: any): boolean {
359363
* This will create a new {@link Hub} and add to the passed object on
360364
* __SENTRY__.hub.
361365
* @param carrier object
366+
* @hidden
362367
*/
363368
export function getHubFromCarrier(carrier: any): Hub {
364369
if (carrier && carrier.__SENTRY__ && carrier.__SENTRY__.hub) {

packages/hub/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export { Carrier, Layer } from './interfaces';
22
export { addGlobalEventProcessor, Scope } from './scope';
3-
export { getCurrentHub, getHubFromCarrier, getMainCarrier, Hub, setHubOnCarrier } from './hub';
3+
export { getCurrentHub, getHubFromCarrier, getMainCarrier, Hub, makeMain, setHubOnCarrier } from './hub';

packages/hub/src/interfaces.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
import { Hub } from './hub';
22
import { Scope } from './scope';
33

4-
/** A layer in the process stack. */
4+
/**
5+
* A layer in the process stack.
6+
* @hidden
7+
*/
58
export interface Layer {
69
client?: any;
710
scope?: Scope;
811
}
912

10-
/** An object that contains a hub and maintains a scope stack. */
13+
/**
14+
* An object that contains a hub and maintains a scope stack.
15+
* @hidden
16+
*/
1117
export interface Carrier {
1218
__SENTRY__?: {
1319
hub?: Hub;

packages/hub/src/scope.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ import { getGlobalObject } from '@sentry/utils/misc';
44
import { assign, safeNormalize } from '@sentry/utils/object';
55
import { SyncPromise } from '@sentry/utils/syncpromise';
66

7+
/**
8+
* Event processors are used to change the event before it will be send.
9+
* We strongly advise to make this function sync.
10+
* Returning a Promise<SentryEvent | null> works just fine, just be sure what you are doing.
11+
* Eventprosccing will be stopped until your Promise is resolved.
12+
*/
713
export type EventProcessor = (
814
event: SentryEvent,
915
hint?: SentryEventHint,
@@ -228,6 +234,7 @@ export class Scope {
228234
* @param event SentryEvent
229235
* @param hint May contain additional informartion about the original exception.
230236
* @param maxBreadcrumbs number of max breadcrumbs to merged into event.
237+
* @hidden
231238
*/
232239
public applyToEvent(
233240
event: SentryEvent,

packages/node/src/backend.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ export interface NodeOptions extends Options {
3636
frameContextLines?: number;
3737
}
3838

39-
/** The Sentry Node SDK Backend. */
39+
/**
40+
* The Sentry Node SDK Backend.
41+
* @hidden
42+
*/
4043
export class NodeBackend extends BaseBackend<NodeOptions> {
4144
/**
4245
* @inheritdoc

packages/node/src/handlers.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ function extractUserData(req: { [key: string]: any }, keys: boolean | string[]):
152152
* @param event Will be mutated and enriched with req data
153153
* @param req Request object
154154
* @param options object containing flags to enable functionality
155+
* @hidden
155156
*/
156157
export function parseRequest(
157158
event: SentryEvent,
@@ -211,7 +212,10 @@ export function parseRequest(
211212
return event;
212213
}
213214

21 F438 4-
/** JSDoc */
215+
/**
216+
* Express compatible request handler.
217+
* @see Exposed as `Handlers.requestHandler`
218+
*/
215219
export function requestHandler(options?: {
216220
request?: boolean;
217221
serverName?: boolean;
@@ -253,7 +257,10 @@ function getStatusCodeFromResponse(error: MiddlewareError): number {
253257
return statusCode ? parseInt(statusCode as string, 10) : 500;
254258
}
255259

256-
/** JSDoc */
260+
/**
261+
* Express compatible error handler.
262+
* @see Exposed as `Handlers.errorHandler`
263+
*/
257264
export function errorHandler(): (
258265
error: MiddlewareError,
259266
req: http.IncomingMessage,
@@ -276,7 +283,9 @@ export function errorHandler(): (
276283
};
277284
}
278285

279-
/** JSDoc */
286+
/**
287+
* @hidden
288+
*/
280289
export function defaultOnFatalError(error: Error): void {
281290
console.error(error && error.stack ? error.stack : error);
282291
const options = (getCurrentHub().getClient() as NodeClient).getOptions();

packages/node/src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,11 @@ export { SDK_NAME, SDK_VERSION } from './version';
3535
import { Integrations as CoreIntegrations } from '@sentry/core';
3636
import * as Handlers from './handlers';
3737
import * as NodeIntegrations from './integrations';
38-
import * as Parsers from './parsers';
3938
import * as Transports from './transports';
4039

4140
const INTEGRATIONS = {
4241
...CoreIntegrations,
4342
...NodeIntegrations,
4443
};
4544

46-
export { INTEGRATIONS as Integrations, Transports, Parsers, Handlers };
45+
export { INTEGRATIONS as Integrations, Transports, Handlers };

0 commit comments

Comments
 (0)
0