braintrust 3.4.0 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dev/dist/index.d.mts +45 -5
  2. package/dev/dist/index.d.ts +45 -5
  3. package/dev/dist/index.js +992 -245
  4. package/dev/dist/index.mjs +914 -167
  5. package/dist/auto-instrumentations/bundler/esbuild.cjs +208 -10
  6. package/dist/auto-instrumentations/bundler/esbuild.d.mts +2 -2
  7. package/dist/auto-instrumentations/bundler/esbuild.d.ts +2 -2
  8. package/dist/auto-instrumentations/bundler/esbuild.mjs +2 -2
  9. package/dist/auto-instrumentations/bundler/rollup.cjs +208 -10
  10. package/dist/auto-instrumentations/bundler/rollup.mjs +2 -2
  11. package/dist/auto-instrumentations/bundler/vite.cjs +208 -10
  12. package/dist/auto-instrumentations/bundler/vite.d.mts +2 -2
  13. package/dist/auto-instrumentations/bundler/vite.d.ts +2 -2
  14. package/dist/auto-instrumentations/bundler/vite.mjs +2 -2
  15. package/dist/auto-instrumentations/bundler/webpack.cjs +208 -10
  16. package/dist/auto-instrumentations/bundler/webpack.d.mts +2 -2
  17. package/dist/auto-instrumentations/bundler/webpack.d.ts +2 -2
  18. package/dist/auto-instrumentations/bundler/webpack.mjs +2 -2
  19. package/dist/auto-instrumentations/{chunk-LVWWLUMN.mjs → chunk-DQTPSXJB.mjs} +208 -10
  20. package/dist/auto-instrumentations/chunk-EVUKFMHG.mjs +41 -0
  21. package/dist/auto-instrumentations/{chunk-D5ZPIUEL.mjs → chunk-F3TJZ3Z2.mjs} +1 -1
  22. package/dist/auto-instrumentations/chunk-VLEJ5AEK.mjs +41 -0
  23. package/dist/auto-instrumentations/hook.mjs +238 -18
  24. package/dist/auto-instrumentations/index.cjs +208 -10
  25. package/dist/auto-instrumentations/index.mjs +1 -1
  26. package/dist/auto-instrumentations/loader/cjs-patch.cjs +32 -10
  27. package/dist/auto-instrumentations/loader/cjs-patch.mjs +10 -5
  28. package/dist/auto-instrumentations/loader/esm-hook.mjs +4 -4
  29. package/dist/auto-instrumentations/loader/get-package-version.cjs +28 -8
  30. package/dist/auto-instrumentations/loader/get-package-version.d.mts +2 -1
  31. package/dist/auto-instrumentations/loader/get-package-version.d.ts +2 -1
  32. package/dist/auto-instrumentations/loader/get-package-version.mjs +3 -1
  33. package/dist/browser.d.mts +342 -269
  34. package/dist/browser.d.ts +342 -269
  35. package/dist/browser.js +996 -241
  36. package/dist/browser.mjs +996 -241
  37. package/dist/cli.js +1029 -289
  38. package/dist/edge-light.js +1007 -220
  39. package/dist/edge-light.mjs +1007 -220
  40. package/dist/index.d.mts +342 -269
  41. package/dist/index.d.ts +342 -269
  42. package/dist/index.js +1182 -427
  43. package/dist/index.mjs +996 -241
  44. package/dist/instrumentation/index.js +781 -107
  45. package/dist/instrumentation/index.mjs +781 -107
  46. package/dist/workerd.js +1007 -220
  47. package/dist/workerd.mjs +1007 -220
  48. package/package.json +22 -6
  49. package/dist/auto-instrumentations/chunk-XDBPUTVE.mjs +0 -22
  50. package/dist/auto-instrumentations/chunk-ZEC7BCL4.mjs +0 -22
@@ -42,19 +42,37 @@ var import_module_details_from_path = __toESM(require("module-details-from-path"
42
42
  var import_node_fs = require("fs");
43
43
  var import_node_path = require("path");
44
44
  var packageVersions = /* @__PURE__ */ new Map();
45
- function getPackageVersion(baseDir) {
46
- if (packageVersions.has(baseDir)) {
47
- return packageVersions.get(baseDir);
48
- }
45
+ var packageNames = /* @__PURE__ */ new Map();
46
+ function readPackageJson(baseDir) {
49
47
  try {
50
48
  const packageJsonPath = (0, import_node_path.join)(baseDir, "package.json");
51
49
  const jsonFile = (0, import_node_fs.readFileSync)(packageJsonPath, "utf8");
52
- const { version } = JSON.parse(jsonFile);
53
- packageVersions.set(baseDir, version);
54
- return version;
50
+ return JSON.parse(jsonFile);
55
51
  } catch {
56
- return process.version.slice(1);
52
+ return void 0;
53
+ }
54
+ }
55
+ function getPackageVersion(baseDir) {
56
+ if (packageVersions.has(baseDir)) {
57
+ return packageVersions.get(baseDir);
57
58
  }
59
+ const packageJson = readPackageJson(baseDir);
60
+ if (typeof packageJson?.version === "string") {
61
+ packageVersions.set(baseDir, packageJson.version);
62
+ return packageJson.version;
63
+ }
64
+ return process.version.slice(1);
65
+ }
66
+ function getPackageName(baseDir) {
67
+ if (packageNames.has(baseDir)) {
68
+ return packageNames.get(baseDir);
69
+ }
70
+ const packageJson = readPackageJson(baseDir);
71
+ if (typeof packageJson?.name === "string") {
72
+ packageNames.set(baseDir, packageJson.name);
73
+ return packageJson.name;
74
+ }
75
+ return void 0;
58
76
  }
59
77
 
60
78
  // src/auto-instrumentations/loader/cjs-patch.ts
@@ -80,11 +98,15 @@ var ModulePatch = class {
80
98
  const [content, filename] = args;
81
99
  const normalizedForPlatform = filename.split("/").join(import_node_path2.sep);
82
100
  const resolvedModule = (0, import_module_details_from_path.default)(normalizedForPlatform);
83
- if (resolvedModule && self.packages.has(resolvedModule.name)) {
101
+ if (resolvedModule) {
102
+ const packageName = getPackageName(resolvedModule.basedir) ?? resolvedModule.name;
103
+ if (!self.packages.has(packageName)) {
104
+ return self.originalCompile.apply(this, args);
105
+ }
84
106
  const version = getPackageVersion(resolvedModule.basedir);
85
107
  const normalizedModulePath = resolvedModule.path.replace(/\\/g, "/");
86
108
  const transformer = self.instrumentator.getTransformer(
87
- resolvedModule.name,
109
+ packageName,
88
110
  version,
89
111
  normalizedModulePath
90
112
  );
@@ -1,13 +1,14 @@
1
1
  import {
2
+ getPackageName,
2
3
  getPackageVersion
3
- } from "../chunk-XDBPUTVE.mjs";
4
+ } from "../chunk-VLEJ5AEK.mjs";
4
5
 
5
6
  // src/auto-instrumentations/loader/cjs-patch.ts
6
7
  import {
7
8
  create
8
9
  } from "@apm-js-collab/code-transformer";
9
- import * as Module from "node:module";
10
- import { sep } from "node:path";
10
+ import * as Module from "module";
11
+ import { sep } from "path";
11
12
  import moduleDetailsFromPath from "module-details-from-path";
12
13
  var ModulePatch = class {
13
14
  packages;
@@ -31,11 +32,15 @@ var ModulePatch = class {
31
32
  const [content, filename] = args;
32
33
  const normalizedForPlatform = filename.split("/").join(sep);
33
34
  const resolvedModule = moduleDetailsFromPath(normalizedForPlatform);
34
- if (resolvedModule && self.packages.has(resolvedModule.name)) {
35
+ if (resolvedModule) {
36
+ const packageName = getPackageName(resolvedModule.basedir) ?? resolvedModule.name;
37
+ if (!self.packages.has(packageName)) {
38
+ return self.originalCompile.apply(this, args);
39
+ }
35
40
  const version = getPackageVersion(resolvedModule.basedir);
36
41
  const normalizedModulePath = resolvedModule.path.replace(/\\/g, "/");
37
42
  const transformer = self.instrumentator.getTransformer(
38
- resolvedModule.name,
43
+ packageName,
39
44
  version,
40
45
  normalizedModulePath
41
46
  );
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  getPackageVersion
3
- } from "../chunk-ZEC7BCL4.mjs";
3
+ } from "../chunk-EVUKFMHG.mjs";
4
4
 
5
5
  // src/auto-instrumentations/loader/esm-hook.mts
6
- import { readFile } from "node:fs/promises";
7
- import { fileURLToPath } from "node:url";
8
- import { sep } from "node:path";
6
+ import { readFile } from "fs/promises";
7
+ import { fileURLToPath } from "url";
8
+ import { sep } from "path";
9
9
  import {
10
10
  create
11
11
  } from "@apm-js-collab/code-transformer";
@@ -20,27 +20,47 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/auto-instrumentations/loader/get-package-version.ts
21
21
  var get_package_version_exports = {};
22
22
  __export(get_package_version_exports, {
23
+ getPackageName: () => getPackageName,
23
24
  getPackageVersion: () => getPackageVersion
24
25
  });
25
26
  module.exports = __toCommonJS(get_package_version_exports);
26
27
  var import_node_fs = require("fs");
27
28
  var import_node_path = require("path");
28
29
  var packageVersions = /* @__PURE__ */ new Map();
29
- function getPackageVersion(baseDir) {
30
- if (packageVersions.has(baseDir)) {
31
- return packageVersions.get(baseDir);
32
- }
30
+ var packageNames = /* @__PURE__ */ new Map();
31
+ function readPackageJson(baseDir) {
33
32
  try {
34
33
  const packageJsonPath = (0, import_node_path.join)(baseDir, "package.json");
35
34
  const jsonFile = (0, import_node_fs.readFileSync)(packageJsonPath, "utf8");
36
- const { version } = JSON.parse(jsonFile);
37
- packageVersions.set(baseDir, version);
38
- return version;
35
+ return JSON.parse(jsonFile);
39
36
  } catch {
40
- return process.version.slice(1);
37
+ return void 0;
38
+ }
39
+ }
40
+ function getPackageVersion(baseDir) {
41
+ if (packageVersions.has(baseDir)) {
42
+ return packageVersions.get(baseDir);
43
+ }
44
+ const packageJson = readPackageJson(baseDir);
45
+ if (typeof packageJson?.version === "string") {
46
+ packageVersions.set(baseDir, packageJson.version);
47
+ return packageJson.version;
48
+ }
49
+ return process.version.slice(1);
50
+ }
51
+ function getPackageName(baseDir) {
52
+ if (packageNames.has(baseDir)) {
53
+ return packageNames.get(baseDir);
54
+ }
55
+ const packageJson = readPackageJson(baseDir);
56
+ if (typeof packageJson?.name === "string") {
57
+ packageNames.set(baseDir, packageJson.name);
58
+ return packageJson.name;
41
59
  }
60
+ return void 0;
42
61
  }
43
62
  // Annotate the CommonJS export names for ESM import in node:
44
63
  0 && (module.exports = {
64
+ getPackageName,
45
65
  getPackageVersion
46
66
  });
@@ -3,5 +3,6 @@
3
3
  * If the package.json file cannot be read, it defaults to the Node.js version.
4
4
  */
5
5
  declare function getPackageVersion(baseDir: string): string;
6
+ declare function getPackageName(baseDir: string): string | undefined;
6
7
 
7
- export { getPackageVersion };
8
+ export { getPackageName, getPackageVersion };
@@ -3,5 +3,6 @@
3
3
  * If the package.json file cannot be read, it defaults to the Node.js version.
4
4
  */
5
5
  declare function getPackageVersion(baseDir: string): string;
6
+ declare function getPackageName(baseDir: string): string | undefined;
6
7
 
7
- export { getPackageVersion };
8
+ export { getPackageName, getPackageVersion };
@@ -1,6 +1,8 @@
1
1
  import {
2
+ getPackageName,
2
3
  getPackageVersion
3
- } from "../chunk-XDBPUTVE.mjs";
4
+ } from "../chunk-VLEJ5AEK.mjs";
4
5
  export {
6
+ getPackageName,
5
7
  getPackageVersion
6
8
  };