Skip to content

Commit 23438ff

Browse files
📝 improve API documentation (#3894)
Co-authored-by: Benoit Zugmeyer <[email protected]>
1 parent 76e3b5a commit 23438ff

File tree

23 files changed

+319
-62
lines changed

23 files changed

+319
-62
lines changed

packages/logs/src/boot/logsPublicApi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export interface LoggerConfiguration {
3333
*
3434
* See [Browser Log Collection](https://docs.datadoghq.com/logs/log_collection/javascript) for further information.
3535
*
36-
* @category API
36+
* @category Main
3737
*/
3838
export interface LogsPublicApi extends PublicApi {
3939
/**

packages/logs/src/domain/configuration.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,23 @@ import type { LogsEventDomainContext } from '../domainContext.types'
1515
/**
1616
* Init Configuration for the Logs browser SDK.
1717
*
18-
* @category Configuration
19-
* @example
18+
* @category Main
19+
* @example NPM
20+
* ```ts
21+
* import { datadogLogs } from '@datadog/browser-logs'
22+
*
23+
* datadogLogs.init({
24+
* clientToken: '<DATADOG_CLIENT_TOKEN>',
25+
* site: '<DATADOG_SITE>',
26+
* // ...
27+
* })
28+
* ```
29+
* @example CDN
2030
* ```ts
2131
* DD_LOGS.init({
22-
* applicationId: '<DATADOG_APPLICATION_ID>',
2332
* clientToken: '<DATADOG_CLIENT_TOKEN>',
2433
* site: '<DATADOG_SITE>',
25-
* ...
34+
* // ...
2635
* })
2736
* ```
2837
*/

packages/logs/src/entries/main.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export type { InternalContext } from '../domain/contexts/internalContext'
1616
export type { LogsMessage } from '../domain/logger'
1717
export { Logger, HandlerType } from '../domain/logger'
1818
export { StatusType } from '../domain/logger/isAuthorized'
19-
export type { LoggerConfiguration, LogsPublicApi as LogsGlobal } from '../boot/logsPublicApi'
19+
export type { LoggerConfiguration, LogsPublicApi as DatadogLogs } from '../boot/logsPublicApi'
2020
export type { LogsInitConfiguration } from '../domain/configuration'
2121
export type { LogsEvent } from '../logsEvent.types'
2222
export type {
@@ -26,6 +26,11 @@ export type {
2626
LoggerLogsEventDomainContext,
2727
} from '../domainContext.types'
2828

29+
/**
30+
* @deprecated Use {@link DatadogLogs} instead
31+
*/
32+
export type LogsGlobal = LogsPublicApi
33+
2934
export type {
3035
InitConfiguration,
3136
PublicApi,
@@ -48,6 +53,8 @@ export type {
4853
/**
4954
* The global Logs instance. Use this to call Logs methods.
5055
*
56+
* @category Main
57+
* @see {@link DatadogLogs}
5158
* @see [Browser Log Collection](https://docs.datadoghq.com/logs/log_collection/javascript/)
5259
*/
5360
export const datadogLogs = makeLogsPublicApi(startLogs)

packages/rum-core/src/boot/rumPublicApi.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export interface StartRecordingOptions {
6363
*
6464
* See [RUM Browser Monitoring Setup](https://docs.datadoghq.com/real_user_monitoring/browser) for further information.
6565
*
66-
* @category API
66+
* @category Main
6767
*/
6868
export interface RumPublicApi extends PublicApi {
6969
/**
@@ -73,20 +73,13 @@ export interface RumPublicApi extends PublicApi {
7373
*
7474
* @category Init
7575
* @param initConfiguration - Configuration options of the SDK
76-
* @example Init RUM Browser SDK example
76+
* @example
7777
* ```ts
7878
* datadogRum.init({
7979
* applicationId: '<DATADOG_APPLICATION_ID>',
8080
* clientToken: '<DATADOG_CLIENT_TOKEN>',
8181
* site: '<DATADOG_SITE>',
82-
* // service: 'my-web-application',
83-
* // env: 'production',
84-
* // version: '1.0.0',
85-
* sessionSampleRate: 100,
86-
* sessionReplaySampleRate: 100,
87-
* trackResources: true,
88-
* trackLongTasks: true,
89-
* trackUserInteractions: true,
82+
* // ...
9083
* })
9184
* ```
9285
*/
@@ -158,6 +151,7 @@ export interface RumPublicApi extends PublicApi {
158151
* Get the init configuration
159152
*
160153
* @category Init
154+
* @returns RumInitConfiguration | undefined
161155
*/
162156
getInitConfiguration: () => RumInitConfiguration | undefined
163157

@@ -434,30 +428,33 @@ export interface RumPublicApi extends PublicApi {
434428
stopDurationVital: (nameOrRef: string | DurationVitalReference, options?: DurationVitalOptions) => void
435429

436430
/**
437-
* [Experimental] start a feature operation
431+
* start a feature operation
438432
*
439433
* @category Vital - Feature Operation
440434
* @param name - Name of the operation step
441435
* @param options - Options for the operation step (operationKey, context, description)
436+
* @hidden // TODO: replace by @since when GA
442437
*/
443438
startFeatureOperation: (name: string, options?: FeatureOperationOptions) => void
444439

445440
/**
446-
* [Experimental] succeed a feature operation
441+
* succeed a feature operation
447442
*
448443
* @category Vital - Feature Operation
449444
* @param name - Name of the operation step
450445
* @param options - Options for the operation step (operationKey, context, description)
446+
* @hidden // TODO: replace by @since when GA
451447
*/
452448
succeedFeatureOperation: (name: string, options?: FeatureOperationOptions) => void
453449

454450
/**
455-
* [Experimental] fail a feature operation
451+
* fail a feature operation
456452
*
457453
* @category Vital - Feature Operation
458454
* @param name - Name of the operation step
459455
* @param failureReason
460456
* @param options - Options for the operation step (operationKey, context, description)
457+
* @hidden // TODO: replace by @since when GA
461458
*/
462459
failFeatureOperation: (name: string, failureReaon: FailureReason, options?: FeatureOperationOptions) => void
463460
}

packages/rum-core/src/domain/configuration/configuration.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,19 @@ export const DEFAULT_PROPAGATOR_TYPES: PropagatorType[] = ['tracecontext', 'data
2323
/**
2424
* Init Configuration for the RUM browser SDK.
2525
*
26-
* @category Configuration
27-
* @example
26+
* @category Main
27+
* @example NPM
28+
* ```ts
29+
* import { datadogRum } from '@datadog/browser-rum'
30+
*
31+
* datadogRum.init({
32+
* applicationId: '<DATADOG_APPLICATION_ID>',
33+
* clientToken: '<DATADOG_CLIENT_TOKEN>',
34+
* site: '<DATADOG_SITE>',
35+
* // ...
36+
* })
37+
* ```
38+
* @example CDN
2839
* ```ts
2940
* DD_RUM.init({
3041
* applicationId: '<DATADOG_APPLICATION_ID>',

packages/rum-react/react-router-v6/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"name": "@datadog/browser-rum-react/react-router-v6",
23
"private": true,
34
"main": "../cjs/entries/reactRouterV6.js",
45
"module": "../esm/entries/reactRouterV6.js",
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "https://typedoc.org/schema.json",
3+
"entryPoints": ["../src/entries/reactRouterV6.ts"]
4+
}

packages/rum-react/react-router-v7/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"name": "@datadog/browser-rum-react/react-router-v7",
23
"private": true,
34
"main": "../cjs/entries/reactRouterV7.js",
45
"module": "../esm/entries/reactRouterV7.js",
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "https://typedoc.org/schema.json",
3+
"entryPoints": ["../src/entries/reactRouterV7.ts"]
4+
}

packages/rum-react/src/domain/error/addReactError.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,26 @@ import {
1212
import { RumEventType } from '@datadog/browser-rum-core'
1313
import { onRumStart } from '../reactPlugin'
1414

15+
/**
16+
* Add a React error to the RUM session.
17+
*
18+
* @category Error
19+
* @example
20+
* ```ts
21+
* import { createRoot } from 'react-dom/client'
22+
* import { datadogRum } from '@datadog/browser-rum'
23+
* import { addReactError } from '@datadog/browser-rum-react'
24+
*
25+
* const container = document.getElementById('root')
26+
* const root = createRoot(container, {
27+
* onUncaughtError: (error, errorInfo) => {
28+
* // Report uncaught errors to Datadog
29+
* addReactError(error, errorInfo)
30+
* }
31+
* })
32+
* // ...
33+
* ```
34+
*/
1535
export function addReactError(error: Error, info: ErrorInfo) {
1636
const handlingStack = createHandlingStack('react error')
1737
const startClocks = clocksNow()

0 commit comments

Comments
 (0)