Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
caa59df
fix: replace Node.js pipe() with Web Streams pipeThrough() in createR…
yoannmoinet May 12, 2026
8e67521
refactor: replace zlib.unzipSync with DecompressionStream in sender test
yoannmoinet May 12, 2026
11f6dc4
chore: format sender.test.ts
yoannmoinet May 13, 2026
5b21983
Replace rollup-plugin-dts with dts-bundle-generator for type bundling
yoannmoinet May 15, 2026
880dcce
Clean RUM Browser SDK types
yoannmoinet May 15, 2026
d9244f8
Move dts bundle artifacts to tmpdir and configure libraries
yoannmoinet May 15, 2026
62f0ec2
Simplify dts bundle plugin
yoannmoinet May 15, 2026
44ab2c3
Trim dts bundle plugin
yoannmoinet May 15, 2026
20d39ea
Stop exporting inlined internal types
yoannmoinet May 15, 2026
c88b966
Declare workspace paths in root tsconfig
yoannmoinet May 15, 2026
b0b262b
Add integrity check for tsconfig @dd/* paths
yoannmoinet May 15, 2026
0757359
Enforce sort order in tsconfig paths check
yoannmoinet May 15, 2026
d7dea8c
Move plugin build config under buildPlugin
yoannmoinet May 15, 2026
8bdf01c
Fix typing
yoannmoinet May 15, 2026
a49c8fc
Extract dts bundle plugin to its own module
yoannmoinet May 15, 2026
7ecc8d3
Merge branch 'master' into yoann/fix-notreadableerror-blob-race-condi…
yoannmoinet May 19, 2026
9e24b9f
Merge branch 'master' into yoann/dts-bundle-generator
yoannmoinet May 19, 2026
e8d409a
Merge branch 'master' into yoann/fix-notreadableerror-blob-race-condi…
yoannmoinet May 20, 2026
5cbd3f6
Batch metrics submission to avoid HTTP 413 on large builds
yoannmoinet May 20, 2026
0edfbb2
Merge remote-tracking branch 'origin/yoann/fix-notreadableerror-blob-…
yoannmoinet May 22, 2026
66aef51
Merge remote-tracking branch 'origin/yoann/dts-bundle-generator' into…
yoannmoinet May 22, 2026
e109cc0
Merge remote-tracking branch 'origin/yoann/batch-metrics-submission' …
yoannmoinet May 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ yarn-error.log
node_modules/
dist/
dist-basic/
.dts-tmp-*/

.vitrine/*
!.vitrine/project.json
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
14 changes: 14 additions & 0 deletions .yarn/patches/dts-bundle-generator-npm-9.5.1-0927b6826f.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/dist/types-usage-evaluator.js b/dist/types-usage-evaluator.js
index a09f141f087b152c34ad9c88e66ed516f8294865..b3eb7f6a799992fe6c15b7caaa17a7eecde24478 100644
--- a/dist/types-usage-evaluator.js
+++ b/dist/types-usage-evaluator.js
@@ -111,6 +111,9 @@ class TypesUsageEvaluator {
if (ts.isExportDeclaration(node) && node.exportClause !== undefined && ts.isNamedExports(node.exportClause)) {
for (const exportElement of node.exportClause.elements) {
const exportElementSymbol = (0, typescript_1.getImportExportReferencedSymbol)(exportElement, this.typeChecker);
+ if (exportElementSymbol === undefined) {
+ continue;
+ }
// i.e. `import * as NS from './local-module'`
const namespaceImportForElement = (0, typescript_1.getDeclarationsForSymbol)(exportElementSymbol).find(ts.isNamespaceImport);
if (namespaceImportForElement !== undefined) {
2 changes: 1 addition & 1 deletion LICENSES-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ diff,npm,BSD-3-Clause,(https://www.npmjs.com/package/diff)
diff-sequences,npm,MIT,(https://www.npmjs.com/package/diff-sequences)
dir-glob,npm,MIT,Kevin Mårtensson (github.com/kevva)
doctrine,npm,Apache-2.0,(https://github.com/eslint/doctrine)
dts-bundle-generator,patch,MIT,Evgeniy Timokhov (https://github.com/timocov/dts-bundle-generator)
eastasianwidth,npm,MIT,Masaki Komagata (https://www.npmjs.com/package/eastasianwidth)
ecc-jsbn,npm,MIT,Jeremie Miller (https://github.com/quartzjer/ecc-jsbn)
ejs,npm,Apache-2.0,Matthew Eernisse (https://github.com/mde/ejs)
Expand Down Expand Up @@ -700,7 +701,6 @@ retry,npm,MIT,Tim Koschützki (https://github.com/tim-kos/node-retry)
reusify,npm,MIT,Matteo Collina (https://github.com/mcollina/reusify#readme)
rimraf,npm,ISC,Isaac Z. Schlueter (http://blog.izs.me/)
rollup,npm,MIT,Rich Harris (https://rollupjs.org/)
rollup-plugin-dts,virtual,LGPL-3.0-only,Arpad Borsos (https://github.com/Swatinem/rollup-plugin-dts#readme)
rollup-plugin-esbuild,virtual,MIT,EGOIST (https://www.npmjs.com/package/rollup-plugin-esbuild)
rollup-plugin-import-css,virtual,MIT,Jacob Leeson (https://github.com/jleeson/rollup-plugin-import-css#readme)
run-parallel,npm,MIT,Feross Aboukhadijeh (https://github.com/feross/run-parallel)
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@
"typescript": "5.4.3"
},
"resolutions": {
"rollup": "4.45.1"
"rollup": "4.45.1",
"dts-bundle-generator/typescript": "5.4.3",
"dts-bundle-generator@npm:9.5.1": "patch:dts-bundle-generator@npm%3A9.5.1#~/.yarn/patches/dts-bundle-generator-npm-9.5.1-0927b6826f.patch"
},
"packageManager": "yarn@4.10.3"
}
13 changes: 7 additions & 6 deletions packages/core/src/helpers/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
// Copyright 2019-Present Datadog, Inc.

import retry from 'async-retry';
import { Readable } from 'stream';
import type { RequestInit } from 'undici-types';
import type { Gzip } from 'zlib';
import { createGzip } from 'zlib';

import type { RequestOpts } from '../types';

Expand Down Expand Up @@ -61,7 +58,7 @@ export const getOriginHeaders = (opts: { bundler: string; plugin: string; versio
};

export type RequestData = {
data: Gzip | Readable;
data: ReadableStream;
headers: Record<string, string>;
};

Expand All @@ -78,8 +75,12 @@ export const createRequestData = async (options: {
// Serialize FormData through Request to get a streaming body
// and auto-generated headers (boundary) that we can forward while piping through gzip.
const req = new Request('fake://url', { method: 'POST', body: form });
const formStream = Readable.fromWeb(req.body!);
const data = zip ? formStream.pipe(createGzip()) : formStream;

// Use Web Streams pipeThrough instead of Node.js pipe() to keep the pipeline lazy.
// Node.js pipe() immediately puts the source into flowing mode (starts reading blobs
// via process.nextTick), which races with cleanup of file-backed blobs after the
// request completes. Web Streams only start reading when the output is consumed.
const data = zip ? req.body!.pipeThrough(new CompressionStream('gzip')) : req.body!;

const headers = {
'Content-Encoding': zip ? 'gzip' : 'multipart/form-data',
Expand Down
16 changes: 8 additions & 8 deletions packages/plugins/apps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
"directory": "packages/plugins/apps"
},
"buildPlugin": {
"hideFromRootReadme": true
},
"toBuild": {
"apps-runtime": {
"entry": "./src/built/apps-runtime.ts",
"format": [
"esm"
]
"hideFromRootReadme": true,
"toBuild": {
"apps-runtime": {
"entry": "./src/built/apps-runtime.ts",
"format": [
"esm"
]
}
}
},
"exports": {
Expand Down
20 changes: 3 additions & 17 deletions packages/plugins/error-tracking/src/sourcemaps/sender.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import {
getSourcemapsConfiguration,
addFixtureFiles,
} from '@dd/tests/_jest/helpers/mocks';
import { type Stream } from 'stream';
import { unzipSync } from 'zlib';

jest.mock('@dd/core/helpers/fs', () => {
const original = jest.requireActual('@dd/core/helpers/fs');
Expand All @@ -42,19 +40,6 @@ jest.mock('@dd/core/helpers/request', () => {

const doRequestMock = jest.mocked(doRequest);

function readFully(stream: Stream): Promise<Buffer> {
const chunks: any[] = [];
return new Promise((resolve, reject) => {
stream.on('data', (chunk) => chunks.push(chunk));

stream.on('end', () => {
resolve(Buffer.concat(chunks));
});

stream.on('error', reject);
});
}

const contextMock = getContextMock();
const uploadContextMock = {
apiKey: contextMock.auth.apiKey,
Expand Down Expand Up @@ -106,8 +91,9 @@ describe('Error Tracking Plugin Sourcemaps', () => {
const payload = getPayloadMock();

const { data, headers } = await getData(payload)();
const zippedData = await readFully(data);
const unzippedData = unzipSync(zippedData).toString('utf-8');
const unzippedData = await new Response(
data.pipeThrough(new DecompressionStream('gzip')),
).text();
const dataLines = unzippedData.split(/[\r\n]/g).filter(Boolean);
const boundary = headers['content-type']
.split('boundary=')
Expand Down
30 changes: 22 additions & 8 deletions packages/plugins/metrics/src/common/sender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { Logger, Metric, MetricToSend } from '@dd/core/types';
import chalk from 'chalk';

export const METRICS_API_PATH = 'api/v1/series';
const METRICS_BATCH_SIZE = 500;

const green = chalk.bold.green;

Expand Down Expand Up @@ -54,15 +55,28 @@ Sending ${metricsToSend.length} metrics with configuration:
Metrics:
- ${metricsNames.join('\n - ')}`);

return doRequest({
method: 'POST',
url: `https://api.${auth.site}/${METRICS_API_PATH}?api_key=${auth.apiKey}`,
getData: () => ({
data: JSON.stringify({ series: metricsToSend } satisfies {
series: Metric[];
const batches: Metric[][] = [];
for (let i = 0; i < metricsToSend.length; i += METRICS_BATCH_SIZE) {
batches.push(metricsToSend.slice(i, i + METRICS_BATCH_SIZE));
}

if (batches.length > 1) {
log.debug(`Sending metrics in ${batches.length} batches of up to ${METRICS_BATCH_SIZE}.`);
}

return Promise.all(
batches.map((batch) =>
doRequest({
method: 'POST',
url: `https://api.${auth.site}/${METRICS_API_PATH}?api_key=${auth.apiKey}`,
getData: () => ({
data: JSON.stringify({ series: batch } satisfies {
series: Metric[];
}),
}),
}),
}),
}).catch((e) => {
),
).catch((e) => {
log.error(`Error sending metrics ${e}`);
});
};
29 changes: 17 additions & 12 deletions packages/plugins/rum/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,22 @@
"directory": "packages/plugins/rum"
},
"buildPlugin": {
"hideFromRootReadme": true
},
"toBuild": {
"rum-browser-sdk": {
"entry": "./src/built/rum-browser-sdk.ts"
},
"privacy-helpers": {
"format": [
"cjs",
"esm"
],
"entry": "./src/built/privacy-helpers.ts"
"hideFromRootReadme": true,
"inlinedLibraries": [
"@datadog/browser-core",
"@datadog/browser-rum-core"
],
"toBuild": {
"rum-browser-sdk": {
"entry": "./src/built/rum-browser-sdk.ts"
},
"privacy-helpers": {
"format": [
"cjs",
"esm"
],
"entry": "./src/built/privacy-helpers.ts"
}
}
},
"exports": {
Expand All @@ -40,6 +44,7 @@
},
"devDependencies": {
"@datadog/browser-rum": "6.26.0",
"@datadog/browser-rum-core": "6.26.0",
"typescript": "5.4.3"
}
}
5 changes: 5 additions & 0 deletions packages/plugins/rum/src/browserSdkTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Unless explicitly stated otherwise all files in this repository are licensed under the MIT License.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2019-Present Datadog, Inc.

export type { RumPublicApi, RumInitConfiguration } from '@datadog/browser-rum-core';
3 changes: 2 additions & 1 deletion packages/plugins/rum/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import type { PluginOptions, GetPlugins } from '@dd/core/types';
import { InjectPosition } from '@dd/core/types';
import path from 'path';

import type { RumInitConfiguration, RumPublicApi } from './browserSdkTypes';
import { CONFIG_KEY, PLUGIN_NAME } from './constants';
import { getSourceCodeContextSnippet } from './getSourceCodeContextSnippet';
import { getPrivacyPlugin } from './privacy';
import { getInjectionValue } from './sdk';
import type { RumOptions, RumOptionsWithSdk, RumPublicApi, RumInitConfiguration } from './types';
import type { RumOptions, RumOptionsWithSdk } from './types';
import { validateOptions } from './validate';

export { CONFIG_KEY, PLUGIN_NAME };
Expand Down
8 changes: 1 addition & 7 deletions packages/plugins/rum/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2019-Present Datadog, Inc.

import type {
datadogRum,
RumInitConfiguration as ExpRumInitConfiguration,
} from '@datadog/browser-rum';
import type { Assign } from '@dd/core/types';

import type { RumInitConfiguration } from './browserSdkTypes';
import type { PrivacyOptions, PrivacyOptionsWithDefaults } from './privacy/types';

export type SourceCodeContextOptions = {
Expand All @@ -22,9 +19,6 @@ export type RumOptions = {
sourceCodeContext?: SourceCodeContextOptions;
};

export type RumPublicApi = typeof datadogRum;
export type RumInitConfiguration = ExpRumInitConfiguration;

export type SDKOptions = Assign<
RumInitConfiguration,
{
Expand Down
2 changes: 1 addition & 1 deletion packages/published/esbuild-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@
"@rollup/plugin-terser": "0.4.4",
"@types/babel__core": "^7",
"@types/babel__preset-env": "^7",
"dts-bundle-generator": "patch:dts-bundle-generator@npm%3A9.5.1#~/.yarn/patches/dts-bundle-generator-npm-9.5.1-0927b6826f.patch",
"esbuild": "0.25.8",
"rollup": "4.45.1",
"rollup-plugin-dts": "6.1.1",
"rollup-plugin-esbuild": "6.1.1",
"typescript": "5.4.3"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/published/rollup-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@
"@rollup/plugin-terser": "0.4.4",
"@types/babel__core": "^7",
"@types/babel__preset-env": "^7",
"dts-bundle-generator": "patch:dts-bundle-generator@npm%3A9.5.1#~/.yarn/patches/dts-bundle-generator-npm-9.5.1-0927b6826f.patch",
"esbuild": "0.25.8",
"rollup": "4.45.1",
"rollup-plugin-dts": "6.1.1",
"rollup-plugin-esbuild": "6.1.1",
"typescript": "5.4.3"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/published/rspack-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@
"@rollup/plugin-terser": "0.4.4",
"@types/babel__core": "^7",
"@types/babel__preset-env": "^7",
"dts-bundle-generator": "patch:dts-bundle-generator@npm%3A9.5.1#~/.yarn/patches/dts-bundle-generator-npm-9.5.1-0927b6826f.patch",
"esbuild": "0.25.8",
"rollup": "4.45.1",
"rollup-plugin-dts": "6.1.1",
"rollup-plugin-esbuild": "6.1.1",
"typescript": "5.4.3"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/published/vite-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@
"@rollup/plugin-terser": "0.4.4",
"@types/babel__core": "^7",
"@types/babel__preset-env": "^7",
"dts-bundle-generator": "patch:dts-bundle-generator@npm%3A9.5.1#~/.yarn/patches/dts-bundle-generator-npm-9.5.1-0927b6826f.patch",
"esbuild": "0.25.8",
"rollup": "4.45.1",
"rollup-plugin-dts": "6.1.1",
"rollup-plugin-esbuild": "6.1.1",
"typescript": "5.4.3"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/published/webpack-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@
"@rollup/plugin-terser": "0.4.4",
"@types/babel__core": "^7",
"@types/babel__preset-env": "^7",
"dts-bundle-generator": "patch:dts-bundle-generator@npm%3A9.5.1#~/.yarn/patches/dts-bundle-generator-npm-9.5.1-0927b6826f.patch",
"esbuild": "0.25.8",
"rollup": "4.45.1",
"rollup-plugin-dts": "6.1.1",
"rollup-plugin-esbuild": "6.1.1",
"typescript": "5.4.3"
},
Expand Down
3 changes: 3 additions & 0 deletions packages/tools/src/commands/integrity/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Integrity extends Command {
const { updateDependencies } = await import('./dependencies');
const { updateFiles } = await import('./files');
const { updateReadmes, injectTocsInAllReadmes, verifyLinks } = await import('./readme');
const { updateTsconfigPaths } = await import('./tsconfig');
const { getWorkspaces } = await import('@dd/tools/helpers');

const workspaces = await getWorkspaces();
Expand All @@ -51,6 +52,8 @@ class Integrity extends Command {
errors.push(...(await verifyLinks()));
// Update the files that need to be updated.
errors.push(...(await updateFiles(plugins)));
// Sync @dd/* paths in the root tsconfig with each workspace's package.json exports.
updateTsconfigPaths(workspaces);
// Run auto-fixes to ensure the code is correct.
errors.push(...(await runAutoFixes()));

Expand Down
Loading
Loading