@use-tusk/drift-node-sdk 0.1.10 → 0.1.11
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.
- package/dist/index.cjs +40 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +40 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -230,17 +230,9 @@ function withTuskDrift(nextConfig = {}, options = {}) {
|
|
|
230
230
|
const originalExternals = webpackConfig.externals;
|
|
231
231
|
const coreExternals = ["require-in-the-middle", "jsonpath"];
|
|
232
232
|
const externalsMapping = {};
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
for (const pkg of coreExternals) {
|
|
237
|
-
const pkgPath = require("path").join(sdkNodeModules, pkg);
|
|
238
|
-
externalsMapping[pkg] = `commonjs ${pkgPath}`;
|
|
239
|
-
debugLog(debug, `Mapped external ${pkg} -> ${pkgPath}`);
|
|
240
|
-
}
|
|
241
|
-
} catch (e) {
|
|
242
|
-
warn(suppressAllWarnings || false, `Could not resolve SDK path, falling back to regular externals: ${e instanceof Error ? e.message : String(e)}`);
|
|
243
|
-
for (const pkg of coreExternals) externalsMapping[pkg] = `commonjs ${pkg}`;
|
|
233
|
+
for (const pkg of coreExternals) {
|
|
234
|
+
externalsMapping[pkg] = `commonjs ${pkg}`;
|
|
235
|
+
debugLog(debug, `Mapped external ${pkg} -> commonjs ${pkg}`);
|
|
244
236
|
}
|
|
245
237
|
if (!originalExternals) {
|
|
246
238
|
webpackConfig.externals = [externalsMapping];
|
|
@@ -286,7 +278,7 @@ var TdInstrumentationAbstract = class {
|
|
|
286
278
|
|
|
287
279
|
//#endregion
|
|
288
280
|
//#region package.json
|
|
289
|
-
var version = "0.1.
|
|
281
|
+
var version = "0.1.11";
|
|
290
282
|
|
|
291
283
|
//#endregion
|
|
292
284
|
//#region src/version.ts
|
|
@@ -12978,6 +12970,41 @@ var TuskDriftCore = class TuskDriftCore {
|
|
|
12978
12970
|
default: return TuskDriftMode.DISABLED;
|
|
12979
12971
|
}
|
|
12980
12972
|
}
|
|
12973
|
+
validateSamplingRate(value, source) {
|
|
12974
|
+
if (typeof value !== "number" || isNaN(value)) {
|
|
12975
|
+
logger.warn(`Invalid sampling rate from ${source}: not a number. Ignoring.`);
|
|
12976
|
+
return false;
|
|
12977
|
+
}
|
|
12978
|
+
if (value < 0 || value > 1) {
|
|
12979
|
+
logger.warn(`Invalid sampling rate from ${source}: ${value}. Must be between 0.0 and 1.0. Ignoring.`);
|
|
12980
|
+
return false;
|
|
12981
|
+
}
|
|
12982
|
+
return true;
|
|
12983
|
+
}
|
|
12984
|
+
determineSamplingRate(initParams) {
|
|
12985
|
+
if (initParams.samplingRate !== void 0) {
|
|
12986
|
+
if (this.validateSamplingRate(initParams.samplingRate, "init params")) {
|
|
12987
|
+
logger.debug(`Using sampling rate from init params: ${initParams.samplingRate}`);
|
|
12988
|
+
return initParams.samplingRate;
|
|
12989
|
+
}
|
|
12990
|
+
}
|
|
12991
|
+
const envSamplingRate = OriginalGlobalUtils.getOriginalProcessEnvVar("TUSK_SAMPLING_RATE");
|
|
12992
|
+
if (envSamplingRate !== void 0) {
|
|
12993
|
+
const parsed = parseFloat(envSamplingRate);
|
|
12994
|
+
if (this.validateSamplingRate(parsed, "TUSK_SAMPLING_RATE env var")) {
|
|
12995
|
+
logger.debug(`Using sampling rate from TUSK_SAMPLING_RATE env var: ${parsed}`);
|
|
12996
|
+
return parsed;
|
|
12997
|
+
}
|
|
12998
|
+
}
|
|
12999
|
+
if (this.config.recording?.sampling_rate !== void 0) {
|
|
13000
|
+
if (this.validateSamplingRate(this.config.recording.sampling_rate, "config.yaml")) {
|
|
13001
|
+
logger.debug(`Using sampling rate from config.yaml: ${this.config.recording.sampling_rate}`);
|
|
13002
|
+
return this.config.recording.sampling_rate;
|
|
13003
|
+
}
|
|
13004
|
+
}
|
|
13005
|
+
logger.debug("Using default sampling rate: 1.0");
|
|
13006
|
+
return 1;
|
|
13007
|
+
}
|
|
12981
13008
|
registerDefaultInstrumentations() {
|
|
12982
13009
|
const transforms = this.config.transforms ?? this.initParams.transforms;
|
|
12983
13010
|
new HttpInstrumentation({
|
|
@@ -13076,7 +13103,7 @@ var TuskDriftCore = class TuskDriftCore {
|
|
|
13076
13103
|
logLevel: initParams.logLevel || "info",
|
|
13077
13104
|
prefix: "TuskDrift"
|
|
13078
13105
|
});
|
|
13079
|
-
this.samplingRate = this.
|
|
13106
|
+
this.samplingRate = this.determineSamplingRate(initParams);
|
|
13080
13107
|
this.initParams = initParams;
|
|
13081
13108
|
if (!this.initParams.env) {
|
|
13082
13109
|
const nodeEnv = OriginalGlobalUtils.getOriginalProcessEnvVar("NODE_ENV") || "development";
|