Skip to content

Commit 79ea456

Browse files
♻️ clarify and document js-core transport public API
Rename ambiguous types with their context prefix (`ApiType` → `TransportApiType`, `RetryInfo` → `TransportRetryInfo`, `EffectiveType` → `NetworkEffectiveType`), convert `EndpointBuilder` from an inferred return type to an explicit interface, and add JSDoc to all public exports in `@datadog/js-core`.
1 parent 7b583b9 commit 79ea456

15 files changed

Lines changed: 485 additions & 120 deletions

File tree

packages/browser-core/src/browser/cookie.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ONE_SECOND } from '@datadog/js-core/time'
2-
import { buildUrl, globalObject } from '@datadog/js-core/util'
2+
import { buildUrl, globalObject } from '@datadog/js-core/util'
33
import {
44
findAllCommaSeparatedValues,
55
findCommaSeparatedValue,

packages/browser-core/src/browser/fetchObservable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { ClocksState } from '@datadog/js-core/time'
22
import { clocksNow } from '@datadog/js-core/time'
3-
import { normalizeUrl, globalObject } from '@datadog/js-core/util'
3+
import { normalizeUrl, globalObject } from '@datadog/js-core/util'
44
import type { GlobalObject } from '@datadog/js-core/util'
55
import type { InstrumentedMethodCall } from '../tools/instrumentMethod'
66
import { instrumentMethod } from '../tools/instrumentMethod'

packages/browser-core/src/browser/xhrObservable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { elapsed, timeStampNow, clocksNow } from '@datadog/js-core/time'
22
import type { Duration, ClocksState } from '@datadog/js-core/time'
3-
import { normalizeUrl, globalObject } from '@datadog/js-core/util'
3+
import { normalizeUrl, globalObject } from '@datadog/js-core/util'
44
import type { InstrumentedMethodCall } from '../tools/instrumentMethod'
55
import { instrumentMethod } from '../tools/instrumentMethod'
66
import { Observable } from '../tools/observable'

packages/browser-core/src/domain/connectivity/connectivity.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import type { EffectiveType, NetworkInterface } from '@datadog/js-core/util'
1+
import type { NetworkEffectiveType, NetworkInterface } from '@datadog/js-core/util'
22
import { globalObject } from '@datadog/js-core/util'
33

44
export interface Connectivity {
55
status: 'connected' | 'not_connected'
66
interfaces?: NetworkInterface[]
7-
effective_type?: EffectiveType
7+
effective_type?: NetworkEffectiveType
88
[key: string]: unknown
99
}
1010

packages/browser-core/src/domain/telemetry/telemetry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { clocksNow } from '@datadog/js-core/time'
2-
import { getDebugMode, combine, globalObject, isWorkerEnvironment } from '@datadog/js-core/util'
2+
import { getDebugMode, combine, globalObject, isWorkerEnvironment } from '@datadog/js-core/util'
33
import type { Hook } from '@datadog/js-core/assembly'
44
import type { RecursivePartial } from '@datadog/js-core/util'
55
import { DISCARDED } from '@datadog/js-core/assembly'

packages/browser-core/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export type {
108108
NetworkInformation,
109109
Navigator,
110110
NetworkInterface,
111-
EffectiveType,
111+
NetworkEffectiveType,
112112
Profiler,
113113
ProfilerConstructor,
114114
ProfilerTrace,

packages/browser-core/src/transport/httpRequest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { EndpointBuilder, RetryInfo } from '@datadog/js-core/transport'
1+
import type { EndpointBuilder, TransportRetryInfo } from '@datadog/js-core/transport'
22
import type { Context } from '../tools/serialisation/context'
33
import { fetch } from '../browser/fetch'
44
import { monitor, monitorError } from '../tools/monitor'
@@ -60,7 +60,7 @@ export type HttpRequestEvent<Body extends Payload = Payload> =
6060
export interface Payload {
6161
data: string | FormData | Blob
6262
bytesCount: number
63-
retry?: RetryInfo
63+
retry?: TransportRetryInfo
6464
encoding?: 'deflate'
6565
}
6666

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
## API Report File for "@datadog/js-core"
2+
3+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4+
5+
```ts
6+
7+
// @public
8+
export function buildEndpointUrl(input: BuildEndpointUrlOptions): string;
9+
10+
// @public
11+
export interface BuildEndpointUrlOptions {
12+
parameters?: string;
13+
path: string;
14+
proxy?: string | ProxyFn;
15+
site: Site | undefined;
16+
subdomain?: string;
17+
}
18+
19+
// @public
20+
export function createEndpointBuilder(configuration: EndpointBuilderConfiguration, trackType: TrackType, extraParameters?: string[]): EndpointBuilder;
21+
22+
// @public
23+
export function createReplicaEndpointBuilder(input: ConfigurationWithReplica, trackType: TrackType): EndpointBuilder | undefined;
24+
25+
// @public
26+
export interface EndpointBuilder {
27+
build(api: TransportApiType, payload: EndpointPayload): string;
28+
trackType: TrackType;
29+
}
30+
31+
// @public
32+
export interface EndpointPayload {
33+
encoding?: 'deflate';
34+
retry?: TransportRetryInfo;
35+
}
36+
37+
// @public
38+
export const INTAKE_SITE_EU1: Site;
39+
40+
// @public
41+
export const INTAKE_SITE_STAGING: Site;
42+
43+
// @public
44+
export const INTAKE_SITE_US1: Site;
45+
46+
// @public
47+
export const INTAKE_SITE_US1_FED: Site;
48+
49+
// @public
50+
export const INTAKE_SITE_US2_FED: Site;
51+
52+
// @public
53+
export const INTAKE_URL_PARAMETERS: string[];
54+
55+
// @public
56+
export function isIntakeUrl(url: string): boolean;
57+
58+
// @public
59+
export type ProxyFn = (options: {
60+
path: string;
61+
parameters: string;
62+
subdomain?: string;
63+
}) => string;
64+
65+
// @public
66+
export type Site = 'datadoghq.com' | 'us3.datadoghq.com' | 'us5.datadoghq.com' | 'datadoghq.eu' | 'ddog-gov.com' | 'us2.ddog-gov.com' | 'ap1.datadoghq.com' | 'ap2.datadoghq.com' | (string & {});
67+
68+
// @public
69+
export type TrackType = 'logs' | 'rum' | 'replay' | 'profile' | 'exposures' | 'flagevaluation' | 'debugger';
70+
71+
// @public
72+
export type TransportApiType = 'fetch' | 'beacon' | 'manual';
73+
74+
// @public
75+
export interface TransportRetryInfo {
76+
count: number;
77+
lastFailureStatus: number;
78+
}
79+
80+
// @public
81+
export type TransportSource = 'browser' | 'flutter' | 'unity' | 'dd_debugger';
82+
83+
// (No @packageDocumentation comment for this package)
84+
85+
```

0 commit comments

Comments
 (0)