raindrop-ai 0.0.92 → 0.1.0-otelv2
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/{chunk-PURTSYKG.mjs → chunk-S6UIW5C4.mjs} +150 -34
- package/dist/index.d.mts +22 -1
- package/dist/index.d.ts +22 -1
- package/dist/index.js +196 -50
- package/dist/index.mjs +49 -17
- package/dist/tracing/index.d.mts +12 -0
- package/dist/tracing/index.d.ts +12 -0
- package/dist/tracing/index.js +149 -34
- package/dist/tracing/index.mjs +1 -1
- package/package.json +6 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// ../core/dist/chunk-
|
|
1
|
+
// ../core/dist/chunk-LMIWKHOH.js
|
|
2
2
|
function wait(ms) {
|
|
3
3
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
4
4
|
}
|
|
@@ -89,10 +89,66 @@ async function postJson(url, body, headers, opts) {
|
|
|
89
89
|
);
|
|
90
90
|
}
|
|
91
91
|
var LOCAL_DEBUGGER_ENV_VAR = "RAINDROP_LOCAL_DEBUGGER";
|
|
92
|
+
var WORKSHOP_ENV_VAR = "RAINDROP_WORKSHOP";
|
|
93
|
+
var DEFAULT_LOCAL_WORKSHOP_URL = "http://localhost:5899/v1/";
|
|
94
|
+
function readEnvVar(name) {
|
|
95
|
+
var _a;
|
|
96
|
+
try {
|
|
97
|
+
const env = (_a = globalThis == null ? void 0 : globalThis.process) == null ? void 0 : _a.env;
|
|
98
|
+
if (env && typeof env[name] === "string" && env[name].length > 0) {
|
|
99
|
+
return env[name];
|
|
100
|
+
}
|
|
101
|
+
} catch (e) {
|
|
102
|
+
}
|
|
103
|
+
return void 0;
|
|
104
|
+
}
|
|
105
|
+
function readWorkshopEnv() {
|
|
106
|
+
const raw = readEnvVar(WORKSHOP_ENV_VAR);
|
|
107
|
+
if (raw === void 0) return void 0;
|
|
108
|
+
const trimmed = raw.trim();
|
|
109
|
+
if (trimmed.length === 0) return void 0;
|
|
110
|
+
if (/^https?:\/\//i.test(trimmed)) return { url: trimmed };
|
|
111
|
+
if (/^(1|true|yes|on)$/i.test(trimmed)) return "enable";
|
|
112
|
+
if (/^(0|false|no|off)$/i.test(trimmed)) return "disable";
|
|
113
|
+
return void 0;
|
|
114
|
+
}
|
|
115
|
+
function isLocalDevHost(hostname) {
|
|
116
|
+
if (!hostname) return false;
|
|
117
|
+
if (hostname === "localhost" || hostname === "127.0.0.1" || hostname === "0.0.0.0" || hostname === "::1") {
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
if (hostname.endsWith(".localhost")) return true;
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
function readRuntimeHostname() {
|
|
124
|
+
try {
|
|
125
|
+
const loc = globalThis == null ? void 0 : globalThis.location;
|
|
126
|
+
if (loc && typeof loc.hostname === "string" && loc.hostname.length > 0) {
|
|
127
|
+
return loc.hostname;
|
|
128
|
+
}
|
|
129
|
+
} catch (e) {
|
|
130
|
+
}
|
|
131
|
+
return void 0;
|
|
132
|
+
}
|
|
133
|
+
function shouldAutoEnableLocalWorkshop() {
|
|
134
|
+
if (isLocalDevHost(readRuntimeHostname())) return true;
|
|
135
|
+
if (readEnvVar("NODE_ENV") === "development") return true;
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
92
138
|
function resolveLocalDebuggerBaseUrl(baseUrl) {
|
|
93
139
|
var _a, _b, _c;
|
|
94
|
-
|
|
95
|
-
|
|
140
|
+
if (baseUrl === null) return null;
|
|
141
|
+
if (typeof baseUrl === "string" && baseUrl.length > 0) {
|
|
142
|
+
return (_a = formatEndpoint(baseUrl)) != null ? _a : null;
|
|
143
|
+
}
|
|
144
|
+
const explicitUrlEnv = readEnvVar(LOCAL_DEBUGGER_ENV_VAR);
|
|
145
|
+
if (explicitUrlEnv) return (_b = formatEndpoint(explicitUrlEnv)) != null ? _b : null;
|
|
146
|
+
const workshopEnv = readWorkshopEnv();
|
|
147
|
+
if (workshopEnv === "disable") return null;
|
|
148
|
+
if (workshopEnv === "enable") return DEFAULT_LOCAL_WORKSHOP_URL;
|
|
149
|
+
if (workshopEnv && "url" in workshopEnv) return (_c = formatEndpoint(workshopEnv.url)) != null ? _c : null;
|
|
150
|
+
if (shouldAutoEnableLocalWorkshop()) return DEFAULT_LOCAL_WORKSHOP_URL;
|
|
151
|
+
return null;
|
|
96
152
|
}
|
|
97
153
|
function localDebuggerEnabled(baseUrl) {
|
|
98
154
|
return resolveLocalDebuggerBaseUrl(baseUrl) !== null;
|
|
@@ -148,7 +204,7 @@ globalThis.RAINDROP_ASYNC_LOCAL_STORAGE = AsyncLocalStorage;
|
|
|
148
204
|
// package.json
|
|
149
205
|
var package_default = {
|
|
150
206
|
name: "raindrop-ai",
|
|
151
|
-
version: "0.0
|
|
207
|
+
version: "0.1.0",
|
|
152
208
|
main: "dist/index.js",
|
|
153
209
|
module: "dist/index.mjs",
|
|
154
210
|
types: "dist/index.d.ts",
|
|
@@ -510,19 +566,18 @@ var DirectTraceShipper = class {
|
|
|
510
566
|
constructor(opts) {
|
|
511
567
|
this.queue = [];
|
|
512
568
|
this.inFlight = /* @__PURE__ */ new Set();
|
|
513
|
-
var _a, _b, _c, _d, _e;
|
|
569
|
+
var _a, _b, _c, _d, _e, _f;
|
|
514
570
|
this.writeKey = opts.writeKey;
|
|
515
571
|
this.baseUrl = (_a = formatEndpoint2(opts.endpoint)) != null ? _a : "https://api.raindrop.ai/v1/";
|
|
516
572
|
this.enabled = (_b = opts.enabled) != null ? _b : true;
|
|
573
|
+
this.cloudEnabled = (_c = opts.cloudEnabled) != null ? _c : true;
|
|
517
574
|
this.debug = opts.debug;
|
|
518
|
-
this.flushIntervalMs = (
|
|
519
|
-
this.maxBatchSize = (
|
|
520
|
-
this.maxQueueSize = (
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
this.localDebuggerUrl = resolved;
|
|
525
|
-
}
|
|
575
|
+
this.flushIntervalMs = (_d = opts.flushIntervalMs) != null ? _d : 1e3;
|
|
576
|
+
this.maxBatchSize = (_e = opts.maxBatchSize) != null ? _e : 50;
|
|
577
|
+
this.maxQueueSize = (_f = opts.maxQueueSize) != null ? _f : 5e3;
|
|
578
|
+
const resolved = resolveLocalDebuggerBaseUrl(opts.localDebuggerUrl);
|
|
579
|
+
if (resolved && resolved !== this.baseUrl) {
|
|
580
|
+
this.localDebuggerUrl = resolved;
|
|
526
581
|
}
|
|
527
582
|
}
|
|
528
583
|
/**
|
|
@@ -631,6 +686,10 @@ var DirectTraceShipper = class {
|
|
|
631
686
|
}
|
|
632
687
|
while (this.queue.length > 0) {
|
|
633
688
|
const batch = this.queue.splice(0, this.maxBatchSize);
|
|
689
|
+
if (!this.cloudEnabled) {
|
|
690
|
+
if (this.debug) console.log(`[raindrop] direct: dropped ${batch.length} cloud spans (local-only)`);
|
|
691
|
+
continue;
|
|
692
|
+
}
|
|
634
693
|
const body = buildExportTraceServiceRequest2(batch);
|
|
635
694
|
const url = `${this.baseUrl}traces`;
|
|
636
695
|
const p = postJson2(
|
|
@@ -1567,8 +1626,8 @@ function isLocalDebuggerUrl(baseUrl) {
|
|
|
1567
1626
|
return false;
|
|
1568
1627
|
}
|
|
1569
1628
|
}
|
|
1570
|
-
function resolveLocalDebuggerExporterBaseUrl() {
|
|
1571
|
-
const localDebuggerUrl = resolveLocalDebuggerBaseUrl();
|
|
1629
|
+
function resolveLocalDebuggerExporterBaseUrl(baseUrlOpt) {
|
|
1630
|
+
const localDebuggerUrl = resolveLocalDebuggerBaseUrl(baseUrlOpt);
|
|
1572
1631
|
if (!localDebuggerUrl || !isLocalDebuggerUrl(localDebuggerUrl)) {
|
|
1573
1632
|
return null;
|
|
1574
1633
|
}
|
|
@@ -1578,7 +1637,7 @@ function createLocalDebuggerOtlpExporter(config) {
|
|
|
1578
1637
|
return new OTLPHttpTraceExporter(config);
|
|
1579
1638
|
}
|
|
1580
1639
|
function createLocalDebuggerSpanProcessor(options) {
|
|
1581
|
-
const localDebuggerUrl = resolveLocalDebuggerExporterBaseUrl();
|
|
1640
|
+
const localDebuggerUrl = resolveLocalDebuggerExporterBaseUrl(options.localDebuggerUrlOpt);
|
|
1582
1641
|
if (!localDebuggerUrl) {
|
|
1583
1642
|
return void 0;
|
|
1584
1643
|
}
|
|
@@ -1868,7 +1927,18 @@ function getCurrentTraceId() {
|
|
|
1868
1927
|
return (_a = trace4.getSpan(context4.active())) == null ? void 0 : _a.spanContext().traceId;
|
|
1869
1928
|
}
|
|
1870
1929
|
var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
|
|
1871
|
-
const {
|
|
1930
|
+
const {
|
|
1931
|
+
logLevel,
|
|
1932
|
+
useExternalOtel,
|
|
1933
|
+
tracingEnabled,
|
|
1934
|
+
disableBatching,
|
|
1935
|
+
bypassOtelForTools,
|
|
1936
|
+
directEndpoint,
|
|
1937
|
+
localDebuggerUrl,
|
|
1938
|
+
cloudEnabled,
|
|
1939
|
+
...otherOptions
|
|
1940
|
+
} = options;
|
|
1941
|
+
const cloudEnabledResolved = cloudEnabled != null ? cloudEnabled : true;
|
|
1872
1942
|
if (isDebug) {
|
|
1873
1943
|
const mode = useExternalOtel ? "(external OTEL mode)" : tracingEnabled === false ? "(tracing disabled)" : "";
|
|
1874
1944
|
console.log("[raindrop] Initializing tracing", mode);
|
|
@@ -1880,7 +1950,9 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
|
|
|
1880
1950
|
writeKey,
|
|
1881
1951
|
endpoint: directEndpoint != null ? directEndpoint : apiUrl,
|
|
1882
1952
|
debug: isDebug,
|
|
1883
|
-
enabled: tracingEnabled !== false
|
|
1953
|
+
enabled: tracingEnabled !== false,
|
|
1954
|
+
localDebuggerUrl,
|
|
1955
|
+
cloudEnabled: cloudEnabledResolved
|
|
1884
1956
|
}) : void 0;
|
|
1885
1957
|
let traceloopInitialized = false;
|
|
1886
1958
|
try {
|
|
@@ -1909,22 +1981,46 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
|
|
|
1909
1981
|
const localDebuggerProcessor = createLocalDebuggerSpanProcessor({
|
|
1910
1982
|
writeKey,
|
|
1911
1983
|
disableBatching,
|
|
1912
|
-
allowedInstrumentationLibraries: traceloop3.ALL_INSTRUMENTATION_LIBRARIES
|
|
1984
|
+
allowedInstrumentationLibraries: traceloop3.ALL_INSTRUMENTATION_LIBRARIES,
|
|
1985
|
+
localDebuggerUrlOpt: localDebuggerUrl
|
|
1913
1986
|
});
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1987
|
+
if (!cloudEnabledResolved) {
|
|
1988
|
+
if (localDebuggerProcessor) {
|
|
1989
|
+
traceloop3.initialize({
|
|
1990
|
+
baseUrl: apiUrl,
|
|
1991
|
+
apiKey: writeKey,
|
|
1992
|
+
...otherOptions,
|
|
1993
|
+
logLevel,
|
|
1994
|
+
tracingEnabled: tracingEnabled !== false,
|
|
1995
|
+
disableBatch: disableBatching,
|
|
1996
|
+
processor: localDebuggerProcessor
|
|
1997
|
+
});
|
|
1998
|
+
traceloopInitialized = true;
|
|
1999
|
+
} else {
|
|
2000
|
+
traceloop3.initialize({
|
|
2001
|
+
baseUrl: apiUrl,
|
|
2002
|
+
apiKey: writeKey,
|
|
2003
|
+
logLevel,
|
|
2004
|
+
tracingEnabled: false
|
|
2005
|
+
});
|
|
2006
|
+
traceloopInitialized = true;
|
|
2007
|
+
}
|
|
2008
|
+
} else {
|
|
2009
|
+
const processor = mergeWithBestEffortLocalDebuggerProcessor(
|
|
2010
|
+
otherOptions.processor,
|
|
2011
|
+
localDebuggerProcessor
|
|
2012
|
+
);
|
|
2013
|
+
traceloop3.initialize({
|
|
2014
|
+
baseUrl: apiUrl,
|
|
2015
|
+
apiKey: writeKey,
|
|
2016
|
+
...otherOptions,
|
|
2017
|
+
logLevel,
|
|
2018
|
+
tracingEnabled: tracingEnabled !== false,
|
|
2019
|
+
disableBatch: disableBatching,
|
|
2020
|
+
...processor ? { processor } : {}
|
|
2021
|
+
});
|
|
2022
|
+
traceloopInitialized = true;
|
|
2023
|
+
}
|
|
1928
2024
|
}
|
|
1929
2025
|
} catch (error) {
|
|
1930
2026
|
console.warn(
|
|
@@ -1998,6 +2094,24 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
|
|
|
1998
2094
|
}
|
|
1999
2095
|
};
|
|
2000
2096
|
}
|
|
2097
|
+
if (!cloudEnabledResolved) {
|
|
2098
|
+
const localOnlyProcessor = createLocalDebuggerSpanProcessor({
|
|
2099
|
+
writeKey,
|
|
2100
|
+
disableBatching,
|
|
2101
|
+
allowedInstrumentationLibraries: processorOptions == null ? void 0 : processorOptions.allowedInstrumentationLibraries,
|
|
2102
|
+
localDebuggerUrlOpt: localDebuggerUrl
|
|
2103
|
+
});
|
|
2104
|
+
return localOnlyProcessor != null ? localOnlyProcessor : {
|
|
2105
|
+
forceFlush: async () => {
|
|
2106
|
+
},
|
|
2107
|
+
onStart: () => {
|
|
2108
|
+
},
|
|
2109
|
+
onEnd: () => {
|
|
2110
|
+
},
|
|
2111
|
+
shutdown: async () => {
|
|
2112
|
+
}
|
|
2113
|
+
};
|
|
2114
|
+
}
|
|
2001
2115
|
const productionProcessor = traceloop3.createSpanProcessor({
|
|
2002
2116
|
baseUrl: apiUrl,
|
|
2003
2117
|
apiKey: writeKey,
|
|
@@ -2007,7 +2121,8 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
|
|
|
2007
2121
|
const localDebuggerProcessor = createLocalDebuggerSpanProcessor({
|
|
2008
2122
|
writeKey,
|
|
2009
2123
|
disableBatching,
|
|
2010
|
-
allowedInstrumentationLibraries: processorOptions == null ? void 0 : processorOptions.allowedInstrumentationLibraries
|
|
2124
|
+
allowedInstrumentationLibraries: processorOptions == null ? void 0 : processorOptions.allowedInstrumentationLibraries,
|
|
2125
|
+
localDebuggerUrlOpt: localDebuggerUrl
|
|
2011
2126
|
});
|
|
2012
2127
|
return mergeWithBestEffortLocalDebuggerProcessor(
|
|
2013
2128
|
productionProcessor,
|
|
@@ -2073,6 +2188,7 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
|
|
|
2073
2188
|
};
|
|
2074
2189
|
|
|
2075
2190
|
export {
|
|
2191
|
+
resolveLocalDebuggerBaseUrl,
|
|
2076
2192
|
mirrorPartialEventToLocalDebugger,
|
|
2077
2193
|
package_default,
|
|
2078
2194
|
tracing
|
package/dist/index.d.mts
CHANGED
|
@@ -723,12 +723,30 @@ type Tracer = {
|
|
|
723
723
|
|
|
724
724
|
interface AnalyticsConfig {
|
|
725
725
|
wizardSession?: string;
|
|
726
|
-
|
|
726
|
+
/**
|
|
727
|
+
* Raindrop write key. When omitted (or empty), the SDK runs in local-only mode:
|
|
728
|
+
* cloud requests are skipped and only the Workshop / local-debugger mirror fires
|
|
729
|
+
* (when `localWorkshopUrl` resolves to a URL). Useful for local development where
|
|
730
|
+
* you only want events to land in Workshop without provisioning a write key.
|
|
731
|
+
*/
|
|
732
|
+
writeKey?: string;
|
|
727
733
|
bufferSize?: number;
|
|
728
734
|
bufferTimeout?: number;
|
|
729
735
|
debugLogs?: boolean;
|
|
730
736
|
endpoint?: string;
|
|
731
737
|
redactPii?: boolean;
|
|
738
|
+
/**
|
|
739
|
+
* Force-enable (or opt out of) Workshop / local-debugger mirroring.
|
|
740
|
+
*
|
|
741
|
+
* - `string` — explicit Workshop URL (e.g. `"http://localhost:5899/v1/"`),
|
|
742
|
+
* wins over env vars and runtime auto-detect.
|
|
743
|
+
* - `false` (or `null`) — explicit opt-out, even on localhost / when
|
|
744
|
+
* `NODE_ENV=development` / when `RAINDROP_WORKSHOP` is set.
|
|
745
|
+
* - `undefined` (default) — fall through to `RAINDROP_LOCAL_DEBUGGER`,
|
|
746
|
+
* `RAINDROP_WORKSHOP`, and runtime auto-detect (localhost-ish hostname
|
|
747
|
+
* OR `NODE_ENV=development` enables the default `:5899` daemon).
|
|
748
|
+
*/
|
|
749
|
+
localWorkshopUrl?: string | false | null;
|
|
732
750
|
/**
|
|
733
751
|
* @deprecated Renamed to `useExternalOtel`. Use that instead.
|
|
734
752
|
* This option will be removed in a future version.
|
|
@@ -833,11 +851,13 @@ declare class Raindrop {
|
|
|
833
851
|
private disabled;
|
|
834
852
|
private context;
|
|
835
853
|
private _tracing;
|
|
854
|
+
private localDebuggerUrlOpt;
|
|
836
855
|
private partialEventBuffer;
|
|
837
856
|
private partialEventTimeouts;
|
|
838
857
|
private inFlightRequests;
|
|
839
858
|
debugLogs: boolean;
|
|
840
859
|
constructor(config: AnalyticsConfig);
|
|
860
|
+
private get localOnly();
|
|
841
861
|
private formatEndpoint;
|
|
842
862
|
/**
|
|
843
863
|
* Begins a new interaction.
|
|
@@ -943,6 +963,7 @@ declare class Raindrop {
|
|
|
943
963
|
private getSize;
|
|
944
964
|
private saveToBuffer;
|
|
945
965
|
private flush;
|
|
966
|
+
private mirrorBatchToLocalDebugger;
|
|
946
967
|
private sendBatchToApi;
|
|
947
968
|
private getContext;
|
|
948
969
|
private formatZodError;
|
package/dist/index.d.ts
CHANGED
|
@@ -723,12 +723,30 @@ type Tracer = {
|
|
|
723
723
|
|
|
724
724
|
interface AnalyticsConfig {
|
|
725
725
|
wizardSession?: string;
|
|
726
|
-
|
|
726
|
+
/**
|
|
727
|
+
* Raindrop write key. When omitted (or empty), the SDK runs in local-only mode:
|
|
728
|
+
* cloud requests are skipped and only the Workshop / local-debugger mirror fires
|
|
729
|
+
* (when `localWorkshopUrl` resolves to a URL). Useful for local development where
|
|
730
|
+
* you only want events to land in Workshop without provisioning a write key.
|
|
731
|
+
*/
|
|
732
|
+
writeKey?: string;
|
|
727
733
|
bufferSize?: number;
|
|
728
734
|
bufferTimeout?: number;
|
|
729
735
|
debugLogs?: boolean;
|
|
730
736
|
endpoint?: string;
|
|
731
737
|
redactPii?: boolean;
|
|
738
|
+
/**
|
|
739
|
+
* Force-enable (or opt out of) Workshop / local-debugger mirroring.
|
|
740
|
+
*
|
|
741
|
+
* - `string` — explicit Workshop URL (e.g. `"http://localhost:5899/v1/"`),
|
|
742
|
+
* wins over env vars and runtime auto-detect.
|
|
743
|
+
* - `false` (or `null`) — explicit opt-out, even on localhost / when
|
|
744
|
+
* `NODE_ENV=development` / when `RAINDROP_WORKSHOP` is set.
|
|
745
|
+
* - `undefined` (default) — fall through to `RAINDROP_LOCAL_DEBUGGER`,
|
|
746
|
+
* `RAINDROP_WORKSHOP`, and runtime auto-detect (localhost-ish hostname
|
|
747
|
+
* OR `NODE_ENV=development` enables the default `:5899` daemon).
|
|
748
|
+
*/
|
|
749
|
+
localWorkshopUrl?: string | false | null;
|
|
732
750
|
/**
|
|
733
751
|
* @deprecated Renamed to `useExternalOtel`. Use that instead.
|
|
734
752
|
* This option will be removed in a future version.
|
|
@@ -833,11 +851,13 @@ declare class Raindrop {
|
|
|
833
851
|
private disabled;
|
|
834
852
|
private context;
|
|
835
853
|
private _tracing;
|
|
854
|
+
private localDebuggerUrlOpt;
|
|
836
855
|
private partialEventBuffer;
|
|
837
856
|
private partialEventTimeouts;
|
|
838
857
|
private inFlightRequests;
|
|
839
858
|
debugLogs: boolean;
|
|
840
859
|
constructor(config: AnalyticsConfig);
|
|
860
|
+
private get localOnly();
|
|
841
861
|
private formatEndpoint;
|
|
842
862
|
/**
|
|
843
863
|
* Begins a new interaction.
|
|
@@ -943,6 +963,7 @@ declare class Raindrop {
|
|
|
943
963
|
private getSize;
|
|
944
964
|
private saveToBuffer;
|
|
945
965
|
private flush;
|
|
966
|
+
private mirrorBatchToLocalDebugger;
|
|
946
967
|
private sendBatchToApi;
|
|
947
968
|
private getContext;
|
|
948
969
|
private formatZodError;
|
package/dist/index.js
CHANGED
|
@@ -5771,7 +5771,7 @@ __export(index_exports, {
|
|
|
5771
5771
|
});
|
|
5772
5772
|
module.exports = __toCommonJS(index_exports);
|
|
5773
5773
|
|
|
5774
|
-
// ../core/dist/chunk-
|
|
5774
|
+
// ../core/dist/chunk-LMIWKHOH.js
|
|
5775
5775
|
function wait(ms) {
|
|
5776
5776
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
5777
5777
|
}
|
|
@@ -5862,10 +5862,66 @@ async function postJson(url, body, headers, opts) {
|
|
|
5862
5862
|
);
|
|
5863
5863
|
}
|
|
5864
5864
|
var LOCAL_DEBUGGER_ENV_VAR = "RAINDROP_LOCAL_DEBUGGER";
|
|
5865
|
+
var WORKSHOP_ENV_VAR = "RAINDROP_WORKSHOP";
|
|
5866
|
+
var DEFAULT_LOCAL_WORKSHOP_URL = "http://localhost:5899/v1/";
|
|
5867
|
+
function readEnvVar(name) {
|
|
5868
|
+
var _a;
|
|
5869
|
+
try {
|
|
5870
|
+
const env = (_a = globalThis == null ? void 0 : globalThis.process) == null ? void 0 : _a.env;
|
|
5871
|
+
if (env && typeof env[name] === "string" && env[name].length > 0) {
|
|
5872
|
+
return env[name];
|
|
5873
|
+
}
|
|
5874
|
+
} catch (e) {
|
|
5875
|
+
}
|
|
5876
|
+
return void 0;
|
|
5877
|
+
}
|
|
5878
|
+
function readWorkshopEnv() {
|
|
5879
|
+
const raw = readEnvVar(WORKSHOP_ENV_VAR);
|
|
5880
|
+
if (raw === void 0) return void 0;
|
|
5881
|
+
const trimmed = raw.trim();
|
|
5882
|
+
if (trimmed.length === 0) return void 0;
|
|
5883
|
+
if (/^https?:\/\//i.test(trimmed)) return { url: trimmed };
|
|
5884
|
+
if (/^(1|true|yes|on)$/i.test(trimmed)) return "enable";
|
|
5885
|
+
if (/^(0|false|no|off)$/i.test(trimmed)) return "disable";
|
|
5886
|
+
return void 0;
|
|
5887
|
+
}
|
|
5888
|
+
function isLocalDevHost(hostname) {
|
|
5889
|
+
if (!hostname) return false;
|
|
5890
|
+
if (hostname === "localhost" || hostname === "127.0.0.1" || hostname === "0.0.0.0" || hostname === "::1") {
|
|
5891
|
+
return true;
|
|
5892
|
+
}
|
|
5893
|
+
if (hostname.endsWith(".localhost")) return true;
|
|
5894
|
+
return false;
|
|
5895
|
+
}
|
|
5896
|
+
function readRuntimeHostname() {
|
|
5897
|
+
try {
|
|
5898
|
+
const loc = globalThis == null ? void 0 : globalThis.location;
|
|
5899
|
+
if (loc && typeof loc.hostname === "string" && loc.hostname.length > 0) {
|
|
5900
|
+
return loc.hostname;
|
|
5901
|
+
}
|
|
5902
|
+
} catch (e) {
|
|
5903
|
+
}
|
|
5904
|
+
return void 0;
|
|
5905
|
+
}
|
|
5906
|
+
function shouldAutoEnableLocalWorkshop() {
|
|
5907
|
+
if (isLocalDevHost(readRuntimeHostname())) return true;
|
|
5908
|
+
if (readEnvVar("NODE_ENV") === "development") return true;
|
|
5909
|
+
return false;
|
|
5910
|
+
}
|
|
5865
5911
|
function resolveLocalDebuggerBaseUrl(baseUrl) {
|
|
5866
5912
|
var _a, _b, _c;
|
|
5867
|
-
|
|
5868
|
-
|
|
5913
|
+
if (baseUrl === null) return null;
|
|
5914
|
+
if (typeof baseUrl === "string" && baseUrl.length > 0) {
|
|
5915
|
+
return (_a = formatEndpoint(baseUrl)) != null ? _a : null;
|
|
5916
|
+
}
|
|
5917
|
+
const explicitUrlEnv = readEnvVar(LOCAL_DEBUGGER_ENV_VAR);
|
|
5918
|
+
if (explicitUrlEnv) return (_b = formatEndpoint(explicitUrlEnv)) != null ? _b : null;
|
|
5919
|
+
const workshopEnv = readWorkshopEnv();
|
|
5920
|
+
if (workshopEnv === "disable") return null;
|
|
5921
|
+
if (workshopEnv === "enable") return DEFAULT_LOCAL_WORKSHOP_URL;
|
|
5922
|
+
if (workshopEnv && "url" in workshopEnv) return (_c = formatEndpoint(workshopEnv.url)) != null ? _c : null;
|
|
5923
|
+
if (shouldAutoEnableLocalWorkshop()) return DEFAULT_LOCAL_WORKSHOP_URL;
|
|
5924
|
+
return null;
|
|
5869
5925
|
}
|
|
5870
5926
|
function localDebuggerEnabled(baseUrl) {
|
|
5871
5927
|
return resolveLocalDebuggerBaseUrl(baseUrl) !== null;
|
|
@@ -10026,7 +10082,7 @@ var SignalEventSchema = external_exports.object({
|
|
|
10026
10082
|
// package.json
|
|
10027
10083
|
var package_default = {
|
|
10028
10084
|
name: "raindrop-ai",
|
|
10029
|
-
version: "0.0
|
|
10085
|
+
version: "0.1.0",
|
|
10030
10086
|
main: "dist/index.js",
|
|
10031
10087
|
module: "dist/index.mjs",
|
|
10032
10088
|
types: "dist/index.d.ts",
|
|
@@ -10474,19 +10530,18 @@ var DirectTraceShipper = class {
|
|
|
10474
10530
|
constructor(opts) {
|
|
10475
10531
|
this.queue = [];
|
|
10476
10532
|
this.inFlight = /* @__PURE__ */ new Set();
|
|
10477
|
-
var _a, _b, _c, _d, _e;
|
|
10533
|
+
var _a, _b, _c, _d, _e, _f;
|
|
10478
10534
|
this.writeKey = opts.writeKey;
|
|
10479
10535
|
this.baseUrl = (_a = formatEndpoint2(opts.endpoint)) != null ? _a : "https://api.raindrop.ai/v1/";
|
|
10480
10536
|
this.enabled = (_b = opts.enabled) != null ? _b : true;
|
|
10537
|
+
this.cloudEnabled = (_c = opts.cloudEnabled) != null ? _c : true;
|
|
10481
10538
|
this.debug = opts.debug;
|
|
10482
|
-
this.flushIntervalMs = (
|
|
10483
|
-
this.maxBatchSize = (
|
|
10484
|
-
this.maxQueueSize = (
|
|
10485
|
-
|
|
10486
|
-
|
|
10487
|
-
|
|
10488
|
-
this.localDebuggerUrl = resolved;
|
|
10489
|
-
}
|
|
10539
|
+
this.flushIntervalMs = (_d = opts.flushIntervalMs) != null ? _d : 1e3;
|
|
10540
|
+
this.maxBatchSize = (_e = opts.maxBatchSize) != null ? _e : 50;
|
|
10541
|
+
this.maxQueueSize = (_f = opts.maxQueueSize) != null ? _f : 5e3;
|
|
10542
|
+
const resolved = resolveLocalDebuggerBaseUrl(opts.localDebuggerUrl);
|
|
10543
|
+
if (resolved && resolved !== this.baseUrl) {
|
|
10544
|
+
this.localDebuggerUrl = resolved;
|
|
10490
10545
|
}
|
|
10491
10546
|
}
|
|
10492
10547
|
/**
|
|
@@ -10595,6 +10650,10 @@ var DirectTraceShipper = class {
|
|
|
10595
10650
|
}
|
|
10596
10651
|
while (this.queue.length > 0) {
|
|
10597
10652
|
const batch = this.queue.splice(0, this.maxBatchSize);
|
|
10653
|
+
if (!this.cloudEnabled) {
|
|
10654
|
+
if (this.debug) console.log(`[raindrop] direct: dropped ${batch.length} cloud spans (local-only)`);
|
|
10655
|
+
continue;
|
|
10656
|
+
}
|
|
10598
10657
|
const body = buildExportTraceServiceRequest2(batch);
|
|
10599
10658
|
const url = `${this.baseUrl}traces`;
|
|
10600
10659
|
const p = postJson2(
|
|
@@ -11525,8 +11584,8 @@ function isLocalDebuggerUrl(baseUrl) {
|
|
|
11525
11584
|
return false;
|
|
11526
11585
|
}
|
|
11527
11586
|
}
|
|
11528
|
-
function resolveLocalDebuggerExporterBaseUrl() {
|
|
11529
|
-
const localDebuggerUrl = resolveLocalDebuggerBaseUrl();
|
|
11587
|
+
function resolveLocalDebuggerExporterBaseUrl(baseUrlOpt) {
|
|
11588
|
+
const localDebuggerUrl = resolveLocalDebuggerBaseUrl(baseUrlOpt);
|
|
11530
11589
|
if (!localDebuggerUrl || !isLocalDebuggerUrl(localDebuggerUrl)) {
|
|
11531
11590
|
return null;
|
|
11532
11591
|
}
|
|
@@ -11536,7 +11595,7 @@ function createLocalDebuggerOtlpExporter(config) {
|
|
|
11536
11595
|
return new import_exporter_trace_otlp_http.OTLPTraceExporter(config);
|
|
11537
11596
|
}
|
|
11538
11597
|
function createLocalDebuggerSpanProcessor(options) {
|
|
11539
|
-
const localDebuggerUrl = resolveLocalDebuggerExporterBaseUrl();
|
|
11598
|
+
const localDebuggerUrl = resolveLocalDebuggerExporterBaseUrl(options.localDebuggerUrlOpt);
|
|
11540
11599
|
if (!localDebuggerUrl) {
|
|
11541
11600
|
return void 0;
|
|
11542
11601
|
}
|
|
@@ -11826,7 +11885,18 @@ function getCurrentTraceId() {
|
|
|
11826
11885
|
return (_a = import_api4.trace.getSpan(import_api4.context.active())) == null ? void 0 : _a.spanContext().traceId;
|
|
11827
11886
|
}
|
|
11828
11887
|
var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
|
|
11829
|
-
const {
|
|
11888
|
+
const {
|
|
11889
|
+
logLevel,
|
|
11890
|
+
useExternalOtel,
|
|
11891
|
+
tracingEnabled,
|
|
11892
|
+
disableBatching,
|
|
11893
|
+
bypassOtelForTools,
|
|
11894
|
+
directEndpoint,
|
|
11895
|
+
localDebuggerUrl,
|
|
11896
|
+
cloudEnabled,
|
|
11897
|
+
...otherOptions
|
|
11898
|
+
} = options;
|
|
11899
|
+
const cloudEnabledResolved = cloudEnabled != null ? cloudEnabled : true;
|
|
11830
11900
|
if (isDebug) {
|
|
11831
11901
|
const mode = useExternalOtel ? "(external OTEL mode)" : tracingEnabled === false ? "(tracing disabled)" : "";
|
|
11832
11902
|
console.log("[raindrop] Initializing tracing", mode);
|
|
@@ -11838,7 +11908,9 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
|
|
|
11838
11908
|
writeKey,
|
|
11839
11909
|
endpoint: directEndpoint != null ? directEndpoint : apiUrl,
|
|
11840
11910
|
debug: isDebug,
|
|
11841
|
-
enabled: tracingEnabled !== false
|
|
11911
|
+
enabled: tracingEnabled !== false,
|
|
11912
|
+
localDebuggerUrl,
|
|
11913
|
+
cloudEnabled: cloudEnabledResolved
|
|
11842
11914
|
}) : void 0;
|
|
11843
11915
|
let traceloopInitialized = false;
|
|
11844
11916
|
try {
|
|
@@ -11867,22 +11939,46 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
|
|
|
11867
11939
|
const localDebuggerProcessor = createLocalDebuggerSpanProcessor({
|
|
11868
11940
|
writeKey,
|
|
11869
11941
|
disableBatching,
|
|
11870
|
-
allowedInstrumentationLibraries: traceloop3.ALL_INSTRUMENTATION_LIBRARIES
|
|
11871
|
-
|
|
11872
|
-
const processor = mergeWithBestEffortLocalDebuggerProcessor(
|
|
11873
|
-
otherOptions.processor,
|
|
11874
|
-
localDebuggerProcessor
|
|
11875
|
-
);
|
|
11876
|
-
traceloop3.initialize({
|
|
11877
|
-
baseUrl: apiUrl,
|
|
11878
|
-
apiKey: writeKey,
|
|
11879
|
-
...otherOptions,
|
|
11880
|
-
logLevel,
|
|
11881
|
-
tracingEnabled: tracingEnabled !== false,
|
|
11882
|
-
disableBatch: disableBatching,
|
|
11883
|
-
...processor ? { processor } : {}
|
|
11942
|
+
allowedInstrumentationLibraries: traceloop3.ALL_INSTRUMENTATION_LIBRARIES,
|
|
11943
|
+
localDebuggerUrlOpt: localDebuggerUrl
|
|
11884
11944
|
});
|
|
11885
|
-
|
|
11945
|
+
if (!cloudEnabledResolved) {
|
|
11946
|
+
if (localDebuggerProcessor) {
|
|
11947
|
+
traceloop3.initialize({
|
|
11948
|
+
baseUrl: apiUrl,
|
|
11949
|
+
apiKey: writeKey,
|
|
11950
|
+
...otherOptions,
|
|
11951
|
+
logLevel,
|
|
11952
|
+
tracingEnabled: tracingEnabled !== false,
|
|
11953
|
+
disableBatch: disableBatching,
|
|
11954
|
+
processor: localDebuggerProcessor
|
|
11955
|
+
});
|
|
11956
|
+
traceloopInitialized = true;
|
|
11957
|
+
} else {
|
|
11958
|
+
traceloop3.initialize({
|
|
11959
|
+
baseUrl: apiUrl,
|
|
11960
|
+
apiKey: writeKey,
|
|
11961
|
+
logLevel,
|
|
11962
|
+
tracingEnabled: false
|
|
11963
|
+
});
|
|
11964
|
+
traceloopInitialized = true;
|
|
11965
|
+
}
|
|
11966
|
+
} else {
|
|
11967
|
+
const processor = mergeWithBestEffortLocalDebuggerProcessor(
|
|
11968
|
+
otherOptions.processor,
|
|
11969
|
+
localDebuggerProcessor
|
|
11970
|
+
);
|
|
11971
|
+
traceloop3.initialize({
|
|
11972
|
+
baseUrl: apiUrl,
|
|
11973
|
+
apiKey: writeKey,
|
|
11974
|
+
...otherOptions,
|
|
11975
|
+
logLevel,
|
|
11976
|
+
tracingEnabled: tracingEnabled !== false,
|
|
11977
|
+
disableBatch: disableBatching,
|
|
11978
|
+
...processor ? { processor } : {}
|
|
11979
|
+
});
|
|
11980
|
+
traceloopInitialized = true;
|
|
11981
|
+
}
|
|
11886
11982
|
}
|
|
11887
11983
|
} catch (error) {
|
|
11888
11984
|
console.warn(
|
|
@@ -11956,6 +12052,24 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
|
|
|
11956
12052
|
}
|
|
11957
12053
|
};
|
|
11958
12054
|
}
|
|
12055
|
+
if (!cloudEnabledResolved) {
|
|
12056
|
+
const localOnlyProcessor = createLocalDebuggerSpanProcessor({
|
|
12057
|
+
writeKey,
|
|
12058
|
+
disableBatching,
|
|
12059
|
+
allowedInstrumentationLibraries: processorOptions == null ? void 0 : processorOptions.allowedInstrumentationLibraries,
|
|
12060
|
+
localDebuggerUrlOpt: localDebuggerUrl
|
|
12061
|
+
});
|
|
12062
|
+
return localOnlyProcessor != null ? localOnlyProcessor : {
|
|
12063
|
+
forceFlush: async () => {
|
|
12064
|
+
},
|
|
12065
|
+
onStart: () => {
|
|
12066
|
+
},
|
|
12067
|
+
onEnd: () => {
|
|
12068
|
+
},
|
|
12069
|
+
shutdown: async () => {
|
|
12070
|
+
}
|
|
12071
|
+
};
|
|
12072
|
+
}
|
|
11959
12073
|
const productionProcessor = traceloop3.createSpanProcessor({
|
|
11960
12074
|
baseUrl: apiUrl,
|
|
11961
12075
|
apiKey: writeKey,
|
|
@@ -11965,7 +12079,8 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
|
|
|
11965
12079
|
const localDebuggerProcessor = createLocalDebuggerSpanProcessor({
|
|
11966
12080
|
writeKey,
|
|
11967
12081
|
disableBatching,
|
|
11968
|
-
allowedInstrumentationLibraries: processorOptions == null ? void 0 : processorOptions.allowedInstrumentationLibraries
|
|
12082
|
+
allowedInstrumentationLibraries: processorOptions == null ? void 0 : processorOptions.allowedInstrumentationLibraries,
|
|
12083
|
+
localDebuggerUrlOpt: localDebuggerUrl
|
|
11969
12084
|
});
|
|
11970
12085
|
return mergeWithBestEffortLocalDebuggerProcessor(
|
|
11971
12086
|
productionProcessor,
|
|
@@ -12221,19 +12336,17 @@ var Raindrop = class {
|
|
|
12221
12336
|
this.partialEventBuffer = /* @__PURE__ */ new Map();
|
|
12222
12337
|
this.partialEventTimeouts = /* @__PURE__ */ new Map();
|
|
12223
12338
|
this.inFlightRequests = /* @__PURE__ */ new Set();
|
|
12224
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
12225
|
-
|
|
12226
|
-
|
|
12227
|
-
|
|
12228
|
-
this.
|
|
12229
|
-
this.
|
|
12230
|
-
this.bufferSize = (_b = config.bufferSize) != null ? _b : 50;
|
|
12231
|
-
this.bufferTimeout = (_c = config.bufferTimeout) != null ? _c : 1e3;
|
|
12339
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
12340
|
+
this.writeKey = (_a = config.writeKey) != null ? _a : "";
|
|
12341
|
+
this.localDebuggerUrlOpt = config.localWorkshopUrl === false ? null : config.localWorkshopUrl;
|
|
12342
|
+
this.apiUrl = (_b = this.formatEndpoint(config.endpoint)) != null ? _b : `https://api.raindrop.ai/v1/`;
|
|
12343
|
+
this.bufferSize = (_c = config.bufferSize) != null ? _c : 50;
|
|
12344
|
+
this.bufferTimeout = (_d = config.bufferTimeout) != null ? _d : 1e3;
|
|
12232
12345
|
this.buffer = new Array();
|
|
12233
|
-
this.disabled = (
|
|
12234
|
-
this.wizardSession = (
|
|
12235
|
-
this.debugLogs = (
|
|
12236
|
-
this.redactPii = (
|
|
12346
|
+
this.disabled = (_e = config.disabled) != null ? _e : false;
|
|
12347
|
+
this.wizardSession = (_f = config.wizardSession) != null ? _f : null;
|
|
12348
|
+
this.debugLogs = (_g = config.debugLogs) != null ? _g : false;
|
|
12349
|
+
this.redactPii = (_h = config.redactPii) != null ? _h : false;
|
|
12237
12350
|
this.context = this.getContext();
|
|
12238
12351
|
if (this.debugLogs) {
|
|
12239
12352
|
process.env.RAINDROP_DEBUG = "true";
|
|
@@ -12243,10 +12356,10 @@ var Raindrop = class {
|
|
|
12243
12356
|
"[raindrop] 'disableTracing' is deprecated and renamed to 'useExternalOtel'. Please update your config: { useExternalOtel: true }"
|
|
12244
12357
|
);
|
|
12245
12358
|
}
|
|
12246
|
-
const useExternalOtel = (
|
|
12359
|
+
const useExternalOtel = (_j = (_i = config.useExternalOtel) != null ? _i : config.disableTracing) != null ? _j : false;
|
|
12247
12360
|
const url = new URL(this.apiUrl);
|
|
12248
12361
|
const isProduction = process.env.NODE_ENV === "production";
|
|
12249
|
-
const disableBatching = (
|
|
12362
|
+
const disableBatching = (_k = config.disableBatching) != null ? _k : !isProduction;
|
|
12250
12363
|
this._tracing = tracing(
|
|
12251
12364
|
this,
|
|
12252
12365
|
url.origin,
|
|
@@ -12263,11 +12376,16 @@ var Raindrop = class {
|
|
|
12263
12376
|
// Pass full API URL (with /v1/ path) for DirectTraceShipper.
|
|
12264
12377
|
// url.origin strips the path, which traceloop handles internally,
|
|
12265
12378
|
// but the direct shipper needs the full path to post to /v1/traces.
|
|
12266
|
-
directEndpoint: this.apiUrl
|
|
12379
|
+
directEndpoint: this.apiUrl,
|
|
12380
|
+
localDebuggerUrl: this.localDebuggerUrlOpt,
|
|
12381
|
+
cloudEnabled: !this.localOnly
|
|
12267
12382
|
},
|
|
12268
12383
|
this.debugLogs
|
|
12269
12384
|
);
|
|
12270
12385
|
}
|
|
12386
|
+
get localOnly() {
|
|
12387
|
+
return !this.writeKey;
|
|
12388
|
+
}
|
|
12271
12389
|
formatEndpoint(endpoint) {
|
|
12272
12390
|
if (endpoint) {
|
|
12273
12391
|
return endpoint.endsWith("/") ? endpoint : `${endpoint}/`;
|
|
@@ -12642,8 +12760,32 @@ var Raindrop = class {
|
|
|
12642
12760
|
];
|
|
12643
12761
|
return Promise.all(flushPromises);
|
|
12644
12762
|
}
|
|
12763
|
+
// Symmetric with mirrorPartialEventToLocalDebugger: fan batch posts out to a
|
|
12764
|
+
// resolved Workshop daemon so calls like trackAi() that never go through the
|
|
12765
|
+
// partial-event path still land in the local debugger. Fire-and-forget; cloud
|
|
12766
|
+
// shipping is independent.
|
|
12767
|
+
mirrorBatchToLocalDebugger(endpoint, body) {
|
|
12768
|
+
const localUrl = resolveLocalDebuggerBaseUrl(this.localDebuggerUrlOpt);
|
|
12769
|
+
if (!localUrl) return;
|
|
12770
|
+
const headers = { "Content-Type": "application/json" };
|
|
12771
|
+
if (this.writeKey) headers.Authorization = `Bearer ${this.writeKey}`;
|
|
12772
|
+
try {
|
|
12773
|
+
void fetch(`${localUrl}${endpoint}`, {
|
|
12774
|
+
method: "POST",
|
|
12775
|
+
headers,
|
|
12776
|
+
body: JSON.stringify(body)
|
|
12777
|
+
}).catch(() => {
|
|
12778
|
+
});
|
|
12779
|
+
} catch (e) {
|
|
12780
|
+
}
|
|
12781
|
+
}
|
|
12645
12782
|
async sendBatchToApi(events, endpoint) {
|
|
12646
12783
|
var _a;
|
|
12784
|
+
const body = events.map(({ type, ...event }) => event);
|
|
12785
|
+
this.mirrorBatchToLocalDebugger(endpoint, body);
|
|
12786
|
+
if (this.localOnly) {
|
|
12787
|
+
return;
|
|
12788
|
+
}
|
|
12647
12789
|
const opName = `POST ${endpoint}`;
|
|
12648
12790
|
try {
|
|
12649
12791
|
const response = await withRetry3(
|
|
@@ -12654,7 +12796,7 @@ var Raindrop = class {
|
|
|
12654
12796
|
"Content-Type": "application/json",
|
|
12655
12797
|
Authorization: `Bearer ${this.writeKey}`
|
|
12656
12798
|
},
|
|
12657
|
-
body: JSON.stringify(
|
|
12799
|
+
body: JSON.stringify(body)
|
|
12658
12800
|
});
|
|
12659
12801
|
if (!resp.ok) {
|
|
12660
12802
|
const text = await resp.text().catch(() => "");
|
|
@@ -12880,10 +13022,14 @@ var Raindrop = class {
|
|
|
12880
13022
|
const endpoint = "events/track_partial";
|
|
12881
13023
|
const opName = `POST ${endpoint}`;
|
|
12882
13024
|
mirrorPartialEventToLocalDebugger(event, {
|
|
13025
|
+
baseUrl: this.localDebuggerUrlOpt,
|
|
12883
13026
|
writeKey: this.writeKey,
|
|
12884
13027
|
debug: this.debugLogs,
|
|
12885
13028
|
sdkName: "js-sdk"
|
|
12886
13029
|
});
|
|
13030
|
+
if (this.localOnly) {
|
|
13031
|
+
return;
|
|
13032
|
+
}
|
|
12887
13033
|
try {
|
|
12888
13034
|
const response = await withRetry3(
|
|
12889
13035
|
async () => {
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
mirrorPartialEventToLocalDebugger,
|
|
3
3
|
package_default,
|
|
4
|
+
resolveLocalDebuggerBaseUrl,
|
|
4
5
|
tracing
|
|
5
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-S6UIW5C4.mjs";
|
|
6
7
|
import {
|
|
7
8
|
__commonJS,
|
|
8
9
|
__toESM
|
|
@@ -10125,19 +10126,17 @@ var Raindrop = class {
|
|
|
10125
10126
|
this.partialEventBuffer = /* @__PURE__ */ new Map();
|
|
10126
10127
|
this.partialEventTimeouts = /* @__PURE__ */ new Map();
|
|
10127
10128
|
this.inFlightRequests = /* @__PURE__ */ new Set();
|
|
10128
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
10129
|
-
|
|
10130
|
-
|
|
10131
|
-
|
|
10132
|
-
this.
|
|
10133
|
-
this.
|
|
10134
|
-
this.bufferSize = (_b = config.bufferSize) != null ? _b : 50;
|
|
10135
|
-
this.bufferTimeout = (_c = config.bufferTimeout) != null ? _c : 1e3;
|
|
10129
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
10130
|
+
this.writeKey = (_a = config.writeKey) != null ? _a : "";
|
|
10131
|
+
this.localDebuggerUrlOpt = config.localWorkshopUrl === false ? null : config.localWorkshopUrl;
|
|
10132
|
+
this.apiUrl = (_b = this.formatEndpoint(config.endpoint)) != null ? _b : `https://api.raindrop.ai/v1/`;
|
|
10133
|
+
this.bufferSize = (_c = config.bufferSize) != null ? _c : 50;
|
|
10134
|
+
this.bufferTimeout = (_d = config.bufferTimeout) != null ? _d : 1e3;
|
|
10136
10135
|
this.buffer = new Array();
|
|
10137
|
-
this.disabled = (
|
|
10138
|
-
this.wizardSession = (
|
|
10139
|
-
this.debugLogs = (
|
|
10140
|
-
this.redactPii = (
|
|
10136
|
+
this.disabled = (_e = config.disabled) != null ? _e : false;
|
|
10137
|
+
this.wizardSession = (_f = config.wizardSession) != null ? _f : null;
|
|
10138
|
+
this.debugLogs = (_g = config.debugLogs) != null ? _g : false;
|
|
10139
|
+
this.redactPii = (_h = config.redactPii) != null ? _h : false;
|
|
10141
10140
|
this.context = this.getContext();
|
|
10142
10141
|
if (this.debugLogs) {
|
|
10143
10142
|
process.env.RAINDROP_DEBUG = "true";
|
|
@@ -10147,10 +10146,10 @@ var Raindrop = class {
|
|
|
10147
10146
|
"[raindrop] 'disableTracing' is deprecated and renamed to 'useExternalOtel'. Please update your config: { useExternalOtel: true }"
|
|
10148
10147
|
);
|
|
10149
10148
|
}
|
|
10150
|
-
const useExternalOtel = (
|
|
10149
|
+
const useExternalOtel = (_j = (_i = config.useExternalOtel) != null ? _i : config.disableTracing) != null ? _j : false;
|
|
10151
10150
|
const url = new URL(this.apiUrl);
|
|
10152
10151
|
const isProduction = process.env.NODE_ENV === "production";
|
|
10153
|
-
const disableBatching = (
|
|
10152
|
+
const disableBatching = (_k = config.disableBatching) != null ? _k : !isProduction;
|
|
10154
10153
|
this._tracing = tracing(
|
|
10155
10154
|
this,
|
|
10156
10155
|
url.origin,
|
|
@@ -10167,11 +10166,16 @@ var Raindrop = class {
|
|
|
10167
10166
|
// Pass full API URL (with /v1/ path) for DirectTraceShipper.
|
|
10168
10167
|
// url.origin strips the path, which traceloop handles internally,
|
|
10169
10168
|
// but the direct shipper needs the full path to post to /v1/traces.
|
|
10170
|
-
directEndpoint: this.apiUrl
|
|
10169
|
+
directEndpoint: this.apiUrl,
|
|
10170
|
+
localDebuggerUrl: this.localDebuggerUrlOpt,
|
|
10171
|
+
cloudEnabled: !this.localOnly
|
|
10171
10172
|
},
|
|
10172
10173
|
this.debugLogs
|
|
10173
10174
|
);
|
|
10174
10175
|
}
|
|
10176
|
+
get localOnly() {
|
|
10177
|
+
return !this.writeKey;
|
|
10178
|
+
}
|
|
10175
10179
|
formatEndpoint(endpoint) {
|
|
10176
10180
|
if (endpoint) {
|
|
10177
10181
|
return endpoint.endsWith("/") ? endpoint : `${endpoint}/`;
|
|
@@ -10546,8 +10550,32 @@ var Raindrop = class {
|
|
|
10546
10550
|
];
|
|
10547
10551
|
return Promise.all(flushPromises);
|
|
10548
10552
|
}
|
|
10553
|
+
// Symmetric with mirrorPartialEventToLocalDebugger: fan batch posts out to a
|
|
10554
|
+
// resolved Workshop daemon so calls like trackAi() that never go through the
|
|
10555
|
+
// partial-event path still land in the local debugger. Fire-and-forget; cloud
|
|
10556
|
+
// shipping is independent.
|
|
10557
|
+
mirrorBatchToLocalDebugger(endpoint, body) {
|
|
10558
|
+
const localUrl = resolveLocalDebuggerBaseUrl(this.localDebuggerUrlOpt);
|
|
10559
|
+
if (!localUrl) return;
|
|
10560
|
+
const headers = { "Content-Type": "application/json" };
|
|
10561
|
+
if (this.writeKey) headers.Authorization = `Bearer ${this.writeKey}`;
|
|
10562
|
+
try {
|
|
10563
|
+
void fetch(`${localUrl}${endpoint}`, {
|
|
10564
|
+
method: "POST",
|
|
10565
|
+
headers,
|
|
10566
|
+
body: JSON.stringify(body)
|
|
10567
|
+
}).catch(() => {
|
|
10568
|
+
});
|
|
10569
|
+
} catch (e) {
|
|
10570
|
+
}
|
|
10571
|
+
}
|
|
10549
10572
|
async sendBatchToApi(events, endpoint) {
|
|
10550
10573
|
var _a;
|
|
10574
|
+
const body = events.map(({ type, ...event }) => event);
|
|
10575
|
+
this.mirrorBatchToLocalDebugger(endpoint, body);
|
|
10576
|
+
if (this.localOnly) {
|
|
10577
|
+
return;
|
|
10578
|
+
}
|
|
10551
10579
|
const opName = `POST ${endpoint}`;
|
|
10552
10580
|
try {
|
|
10553
10581
|
const response = await withRetry(
|
|
@@ -10558,7 +10586,7 @@ var Raindrop = class {
|
|
|
10558
10586
|
"Content-Type": "application/json",
|
|
10559
10587
|
Authorization: `Bearer ${this.writeKey}`
|
|
10560
10588
|
},
|
|
10561
|
-
body: JSON.stringify(
|
|
10589
|
+
body: JSON.stringify(body)
|
|
10562
10590
|
});
|
|
10563
10591
|
if (!resp.ok) {
|
|
10564
10592
|
const text = await resp.text().catch(() => "");
|
|
@@ -10784,10 +10812,14 @@ var Raindrop = class {
|
|
|
10784
10812
|
const endpoint = "events/track_partial";
|
|
10785
10813
|
const opName = `POST ${endpoint}`;
|
|
10786
10814
|
mirrorPartialEventToLocalDebugger(event, {
|
|
10815
|
+
baseUrl: this.localDebuggerUrlOpt,
|
|
10787
10816
|
writeKey: this.writeKey,
|
|
10788
10817
|
debug: this.debugLogs,
|
|
10789
10818
|
sdkName: "js-sdk"
|
|
10790
10819
|
});
|
|
10820
|
+
if (this.localOnly) {
|
|
10821
|
+
return;
|
|
10822
|
+
}
|
|
10791
10823
|
try {
|
|
10792
10824
|
const response = await withRetry(
|
|
10793
10825
|
async () => {
|
package/dist/tracing/index.d.mts
CHANGED
|
@@ -32,6 +32,18 @@ interface TracingOptions extends traceloop.InitializeOptions {
|
|
|
32
32
|
* the full base URL including the /v1/ path segment.
|
|
33
33
|
*/
|
|
34
34
|
directEndpoint?: string;
|
|
35
|
+
/**
|
|
36
|
+
* The user-facing `localWorkshopUrl` ctor option, normalized so `false` is
|
|
37
|
+
* pre-converted to `null`. Threaded through to local-debugger mirror paths
|
|
38
|
+
* to override env-var resolution.
|
|
39
|
+
*/
|
|
40
|
+
localDebuggerUrl?: string | null;
|
|
41
|
+
/**
|
|
42
|
+
* False when the parent SDK has no writeKey — disables cloud span shipping
|
|
43
|
+
* (no traceloop NodeSDK pointed at production, no DirectTraceShipper cloud POSTs).
|
|
44
|
+
* The local-debugger mirror still fires when a Workshop URL is resolved.
|
|
45
|
+
*/
|
|
46
|
+
cloudEnabled?: boolean;
|
|
35
47
|
}
|
|
36
48
|
declare const tracing: (analytics: Raindrop, apiUrl: string, writeKey: string, options: TracingOptions, isDebug?: boolean) => {
|
|
37
49
|
/**
|
package/dist/tracing/index.d.ts
CHANGED
|
@@ -32,6 +32,18 @@ interface TracingOptions extends traceloop.InitializeOptions {
|
|
|
32
32
|
* the full base URL including the /v1/ path segment.
|
|
33
33
|
*/
|
|
34
34
|
directEndpoint?: string;
|
|
35
|
+
/**
|
|
36
|
+
* The user-facing `localWorkshopUrl` ctor option, normalized so `false` is
|
|
37
|
+
* pre-converted to `null`. Threaded through to local-debugger mirror paths
|
|
38
|
+
* to override env-var resolution.
|
|
39
|
+
*/
|
|
40
|
+
localDebuggerUrl?: string | null;
|
|
41
|
+
/**
|
|
42
|
+
* False when the parent SDK has no writeKey — disables cloud span shipping
|
|
43
|
+
* (no traceloop NodeSDK pointed at production, no DirectTraceShipper cloud POSTs).
|
|
44
|
+
* The local-debugger mirror still fires when a Workshop URL is resolved.
|
|
45
|
+
*/
|
|
46
|
+
cloudEnabled?: boolean;
|
|
35
47
|
}
|
|
36
48
|
declare const tracing: (analytics: Raindrop, apiUrl: string, writeKey: string, options: TracingOptions, isDebug?: boolean) => {
|
|
37
49
|
/**
|
package/dist/tracing/index.js
CHANGED
|
@@ -50,7 +50,7 @@ var import_instrumentation_vertexai = require("@traceloop/instrumentation-vertex
|
|
|
50
50
|
var traceloop3 = __toESM(require("@traceloop/node-server-sdk"));
|
|
51
51
|
var import_weakref = require("weakref");
|
|
52
52
|
|
|
53
|
-
// ../core/dist/chunk-
|
|
53
|
+
// ../core/dist/chunk-LMIWKHOH.js
|
|
54
54
|
function wait(ms) {
|
|
55
55
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
56
56
|
}
|
|
@@ -141,10 +141,66 @@ async function postJson(url, body, headers, opts) {
|
|
|
141
141
|
);
|
|
142
142
|
}
|
|
143
143
|
var LOCAL_DEBUGGER_ENV_VAR = "RAINDROP_LOCAL_DEBUGGER";
|
|
144
|
+
var WORKSHOP_ENV_VAR = "RAINDROP_WORKSHOP";
|
|
145
|
+
var DEFAULT_LOCAL_WORKSHOP_URL = "http://localhost:5899/v1/";
|
|
146
|
+
function readEnvVar(name) {
|
|
147
|
+
var _a;
|
|
148
|
+
try {
|
|
149
|
+
const env = (_a = globalThis == null ? void 0 : globalThis.process) == null ? void 0 : _a.env;
|
|
150
|
+
if (env && typeof env[name] === "string" && env[name].length > 0) {
|
|
151
|
+
return env[name];
|
|
152
|
+
}
|
|
153
|
+
} catch (e) {
|
|
154
|
+
}
|
|
155
|
+
return void 0;
|
|
156
|
+
}
|
|
157
|
+
function readWorkshopEnv() {
|
|
158
|
+
const raw = readEnvVar(WORKSHOP_ENV_VAR);
|
|
159
|
+
if (raw === void 0) return void 0;
|
|
160
|
+
const trimmed = raw.trim();
|
|
161
|
+
if (trimmed.length === 0) return void 0;
|
|
162
|
+
if (/^https?:\/\//i.test(trimmed)) return { url: trimmed };
|
|
163
|
+
if (/^(1|true|yes|on)$/i.test(trimmed)) return "enable";
|
|
164
|
+
if (/^(0|false|no|off)$/i.test(trimmed)) return "disable";
|
|
165
|
+
return void 0;
|
|
166
|
+
}
|
|
167
|
+
function isLocalDevHost(hostname) {
|
|
168
|
+
if (!hostname) return false;
|
|
169
|
+
if (hostname === "localhost" || hostname === "127.0.0.1" || hostname === "0.0.0.0" || hostname === "::1") {
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
if (hostname.endsWith(".localhost")) return true;
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
function readRuntimeHostname() {
|
|
176
|
+
try {
|
|
177
|
+
const loc = globalThis == null ? void 0 : globalThis.location;
|
|
178
|
+
if (loc && typeof loc.hostname === "string" && loc.hostname.length > 0) {
|
|
179
|
+
return loc.hostname;
|
|
180
|
+
}
|
|
181
|
+
} catch (e) {
|
|
182
|
+
}
|
|
183
|
+
return void 0;
|
|
184
|
+
}
|
|
185
|
+
function shouldAutoEnableLocalWorkshop() {
|
|
186
|
+
if (isLocalDevHost(readRuntimeHostname())) return true;
|
|
187
|
+
if (readEnvVar("NODE_ENV") === "development") return true;
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
144
190
|
function resolveLocalDebuggerBaseUrl(baseUrl) {
|
|
145
191
|
var _a, _b, _c;
|
|
146
|
-
|
|
147
|
-
|
|
192
|
+
if (baseUrl === null) return null;
|
|
193
|
+
if (typeof baseUrl === "string" && baseUrl.length > 0) {
|
|
194
|
+
return (_a = formatEndpoint(baseUrl)) != null ? _a : null;
|
|
195
|
+
}
|
|
196
|
+
const explicitUrlEnv = readEnvVar(LOCAL_DEBUGGER_ENV_VAR);
|
|
197
|
+
if (explicitUrlEnv) return (_b = formatEndpoint(explicitUrlEnv)) != null ? _b : null;
|
|
198
|
+
const workshopEnv = readWorkshopEnv();
|
|
199
|
+
if (workshopEnv === "disable") return null;
|
|
200
|
+
if (workshopEnv === "enable") return DEFAULT_LOCAL_WORKSHOP_URL;
|
|
201
|
+
if (workshopEnv && "url" in workshopEnv) return (_c = formatEndpoint(workshopEnv.url)) != null ? _c : null;
|
|
202
|
+
if (shouldAutoEnableLocalWorkshop()) return DEFAULT_LOCAL_WORKSHOP_URL;
|
|
203
|
+
return null;
|
|
148
204
|
}
|
|
149
205
|
function localDebuggerEnabled(baseUrl) {
|
|
150
206
|
return resolveLocalDebuggerBaseUrl(baseUrl) !== null;
|
|
@@ -336,7 +392,7 @@ function base64ToHex(base64) {
|
|
|
336
392
|
// package.json
|
|
337
393
|
var package_default = {
|
|
338
394
|
name: "raindrop-ai",
|
|
339
|
-
version: "0.0
|
|
395
|
+
version: "0.1.0",
|
|
340
396
|
main: "dist/index.js",
|
|
341
397
|
module: "dist/index.mjs",
|
|
342
398
|
types: "dist/index.d.ts",
|
|
@@ -532,19 +588,18 @@ var DirectTraceShipper = class {
|
|
|
532
588
|
constructor(opts) {
|
|
533
589
|
this.queue = [];
|
|
534
590
|
this.inFlight = /* @__PURE__ */ new Set();
|
|
535
|
-
var _a, _b, _c, _d, _e;
|
|
591
|
+
var _a, _b, _c, _d, _e, _f;
|
|
536
592
|
this.writeKey = opts.writeKey;
|
|
537
593
|
this.baseUrl = (_a = formatEndpoint2(opts.endpoint)) != null ? _a : "https://api.raindrop.ai/v1/";
|
|
538
594
|
this.enabled = (_b = opts.enabled) != null ? _b : true;
|
|
595
|
+
this.cloudEnabled = (_c = opts.cloudEnabled) != null ? _c : true;
|
|
539
596
|
this.debug = opts.debug;
|
|
540
|
-
this.flushIntervalMs = (
|
|
541
|
-
this.maxBatchSize = (
|
|
542
|
-
this.maxQueueSize = (
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
this.localDebuggerUrl = resolved;
|
|
547
|
-
}
|
|
597
|
+
this.flushIntervalMs = (_d = opts.flushIntervalMs) != null ? _d : 1e3;
|
|
598
|
+
this.maxBatchSize = (_e = opts.maxBatchSize) != null ? _e : 50;
|
|
599
|
+
this.maxQueueSize = (_f = opts.maxQueueSize) != null ? _f : 5e3;
|
|
600
|
+
const resolved = resolveLocalDebuggerBaseUrl(opts.localDebuggerUrl);
|
|
601
|
+
if (resolved && resolved !== this.baseUrl) {
|
|
602
|
+
this.localDebuggerUrl = resolved;
|
|
548
603
|
}
|
|
549
604
|
}
|
|
550
605
|
/**
|
|
@@ -653,6 +708,10 @@ var DirectTraceShipper = class {
|
|
|
653
708
|
}
|
|
654
709
|
while (this.queue.length > 0) {
|
|
655
710
|
const batch = this.queue.splice(0, this.maxBatchSize);
|
|
711
|
+
if (!this.cloudEnabled) {
|
|
712
|
+
if (this.debug) console.log(`[raindrop] direct: dropped ${batch.length} cloud spans (local-only)`);
|
|
713
|
+
continue;
|
|
714
|
+
}
|
|
656
715
|
const body = buildExportTraceServiceRequest2(batch);
|
|
657
716
|
const url = `${this.baseUrl}traces`;
|
|
658
717
|
const p = postJson2(
|
|
@@ -1583,8 +1642,8 @@ function isLocalDebuggerUrl(baseUrl) {
|
|
|
1583
1642
|
return false;
|
|
1584
1643
|
}
|
|
1585
1644
|
}
|
|
1586
|
-
function resolveLocalDebuggerExporterBaseUrl() {
|
|
1587
|
-
const localDebuggerUrl = resolveLocalDebuggerBaseUrl();
|
|
1645
|
+
function resolveLocalDebuggerExporterBaseUrl(baseUrlOpt) {
|
|
1646
|
+
const localDebuggerUrl = resolveLocalDebuggerBaseUrl(baseUrlOpt);
|
|
1588
1647
|
if (!localDebuggerUrl || !isLocalDebuggerUrl(localDebuggerUrl)) {
|
|
1589
1648
|
return null;
|
|
1590
1649
|
}
|
|
@@ -1594,7 +1653,7 @@ function createLocalDebuggerOtlpExporter(config) {
|
|
|
1594
1653
|
return new import_exporter_trace_otlp_http.OTLPTraceExporter(config);
|
|
1595
1654
|
}
|
|
1596
1655
|
function createLocalDebuggerSpanProcessor(options) {
|
|
1597
|
-
const localDebuggerUrl = resolveLocalDebuggerExporterBaseUrl();
|
|
1656
|
+
const localDebuggerUrl = resolveLocalDebuggerExporterBaseUrl(options.localDebuggerUrlOpt);
|
|
1598
1657
|
if (!localDebuggerUrl) {
|
|
1599
1658
|
return void 0;
|
|
1600
1659
|
}
|
|
@@ -1884,7 +1943,18 @@ function getCurrentTraceId() {
|
|
|
1884
1943
|
return (_a = import_api4.trace.getSpan(import_api4.context.active())) == null ? void 0 : _a.spanContext().traceId;
|
|
1885
1944
|
}
|
|
1886
1945
|
var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
|
|
1887
|
-
const {
|
|
1946
|
+
const {
|
|
1947
|
+
logLevel,
|
|
1948
|
+
useExternalOtel,
|
|
1949
|
+
tracingEnabled,
|
|
1950
|
+
disableBatching,
|
|
1951
|
+
bypassOtelForTools,
|
|
1952
|
+
directEndpoint,
|
|
1953
|
+
localDebuggerUrl,
|
|
1954
|
+
cloudEnabled,
|
|
1955
|
+
...otherOptions
|
|
1956
|
+
} = options;
|
|
1957
|
+
const cloudEnabledResolved = cloudEnabled != null ? cloudEnabled : true;
|
|
1888
1958
|
if (isDebug) {
|
|
1889
1959
|
const mode = useExternalOtel ? "(external OTEL mode)" : tracingEnabled === false ? "(tracing disabled)" : "";
|
|
1890
1960
|
console.log("[raindrop] Initializing tracing", mode);
|
|
@@ -1896,7 +1966,9 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
|
|
|
1896
1966
|
writeKey,
|
|
1897
1967
|
endpoint: directEndpoint != null ? directEndpoint : apiUrl,
|
|
1898
1968
|
debug: isDebug,
|
|
1899
|
-
enabled: tracingEnabled !== false
|
|
1969
|
+
enabled: tracingEnabled !== false,
|
|
1970
|
+
localDebuggerUrl,
|
|
1971
|
+
cloudEnabled: cloudEnabledResolved
|
|
1900
1972
|
}) : void 0;
|
|
1901
1973
|
let traceloopInitialized = false;
|
|
1902
1974
|
try {
|
|
@@ -1925,22 +1997,46 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
|
|
|
1925
1997
|
const localDebuggerProcessor = createLocalDebuggerSpanProcessor({
|
|
1926
1998
|
writeKey,
|
|
1927
1999
|
disableBatching,
|
|
1928
|
-
allowedInstrumentationLibraries: traceloop3.ALL_INSTRUMENTATION_LIBRARIES
|
|
2000
|
+
allowedInstrumentationLibraries: traceloop3.ALL_INSTRUMENTATION_LIBRARIES,
|
|
2001
|
+
localDebuggerUrlOpt: localDebuggerUrl
|
|
1929
2002
|
});
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
2003
|
+
if (!cloudEnabledResolved) {
|
|
2004
|
+
if (localDebuggerProcessor) {
|
|
2005
|
+
traceloop3.initialize({
|
|
2006
|
+
baseUrl: apiUrl,
|
|
2007
|
+
apiKey: writeKey,
|
|
2008
|
+
...otherOptions,
|
|
2009
|
+
logLevel,
|
|
2010
|
+
tracingEnabled: tracingEnabled !== false,
|
|
2011
|
+
disableBatch: disableBatching,
|
|
2012
|
+
processor: localDebuggerProcessor
|
|
2013
|
+
});
|
|
2014
|
+
traceloopInitialized = true;
|
|
2015
|
+
} else {
|
|
2016
|
+
traceloop3.initialize({
|
|
2017
|
+
baseUrl: apiUrl,
|
|
2018
|
+
apiKey: writeKey,
|
|
2019
|
+
logLevel,
|
|
2020
|
+
tracingEnabled: false
|
|
2021
|
+
});
|
|
2022
|
+
traceloopInitialized = true;
|
|
2023
|
+
}
|
|
2024
|
+
} else {
|
|
2025
|
+
const processor = mergeWithBestEffortLocalDebuggerProcessor(
|
|
2026
|
+
otherOptions.processor,
|
|
2027
|
+
localDebuggerProcessor
|
|
2028
|
+
);
|
|
2029
|
+
traceloop3.initialize({
|
|
2030
|
+
baseUrl: apiUrl,
|
|
2031
|
+
apiKey: writeKey,
|
|
2032
|
+
...otherOptions,
|
|
2033
|
+
logLevel,
|
|
2034
|
+
tracingEnabled: tracingEnabled !== false,
|
|
2035
|
+
disableBatch: disableBatching,
|
|
2036
|
+
...processor ? { processor } : {}
|
|
2037
|
+
});
|
|
2038
|
+
traceloopInitialized = true;
|
|
2039
|
+
}
|
|
1944
2040
|
}
|
|
1945
2041
|
} catch (error) {
|
|
1946
2042
|
console.warn(
|
|
@@ -2014,6 +2110,24 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
|
|
|
2014
2110
|
}
|
|
2015
2111
|
};
|
|
2016
2112
|
}
|
|
2113
|
+
if (!cloudEnabledResolved) {
|
|
2114
|
+
const localOnlyProcessor = createLocalDebuggerSpanProcessor({
|
|
2115
|
+
writeKey,
|
|
2116
|
+
disableBatching,
|
|
2117
|
+
allowedInstrumentationLibraries: processorOptions == null ? void 0 : processorOptions.allowedInstrumentationLibraries,
|
|
2118
|
+
localDebuggerUrlOpt: localDebuggerUrl
|
|
2119
|
+
});
|
|
2120
|
+
return localOnlyProcessor != null ? localOnlyProcessor : {
|
|
2121
|
+
forceFlush: async () => {
|
|
2122
|
+
},
|
|
2123
|
+
onStart: () => {
|
|
2124
|
+
},
|
|
2125
|
+
onEnd: () => {
|
|
2126
|
+
},
|
|
2127
|
+
shutdown: async () => {
|
|
2128
|
+
}
|
|
2129
|
+
};
|
|
2130
|
+
}
|
|
2017
2131
|
const productionProcessor = traceloop3.createSpanProcessor({
|
|
2018
2132
|
baseUrl: apiUrl,
|
|
2019
2133
|
apiKey: writeKey,
|
|
@@ -2023,7 +2137,8 @@ var tracing = (analytics, apiUrl, writeKey, options, isDebug = false) => {
|
|
|
2023
2137
|
const localDebuggerProcessor = createLocalDebuggerSpanProcessor({
|
|
2024
2138
|
writeKey,
|
|
2025
2139
|
disableBatching,
|
|
2026
|
-
allowedInstrumentationLibraries: processorOptions == null ? void 0 : processorOptions.allowedInstrumentationLibraries
|
|
2140
|
+
allowedInstrumentationLibraries: processorOptions == null ? void 0 : processorOptions.allowedInstrumentationLibraries,
|
|
2141
|
+
localDebuggerUrlOpt: localDebuggerUrl
|
|
2027
2142
|
});
|
|
2028
2143
|
return mergeWithBestEffortLocalDebuggerProcessor(
|
|
2029
2144
|
productionProcessor,
|
package/dist/tracing/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "raindrop-ai",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0-otelv2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"dist/**"
|
|
38
38
|
],
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"ai": "^6.0.0",
|
|
41
40
|
"@opentelemetry/resources": "^2.0.1",
|
|
42
41
|
"@types/node": "^20.11.17",
|
|
42
|
+
"ai": "^6.0.0",
|
|
43
43
|
"msw": "^2.12.8",
|
|
44
44
|
"tsup": "^8.4.0",
|
|
45
45
|
"tsx": "^4.20.3",
|
|
@@ -52,8 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@opentelemetry/api": "^1.9.0",
|
|
55
|
-
"@opentelemetry/exporter-trace-otlp-http": "^0.
|
|
56
|
-
"@traceloop/node-server-sdk": "0.19.0-otel-v1",
|
|
55
|
+
"@opentelemetry/exporter-trace-otlp-http": "^0.203.0",
|
|
57
56
|
"weakref": "^0.2.1",
|
|
58
57
|
"zod": "^3.23.8"
|
|
59
58
|
},
|
|
@@ -96,6 +95,9 @@
|
|
|
96
95
|
},
|
|
97
96
|
"clean": true
|
|
98
97
|
},
|
|
98
|
+
"optionalDependencies": {
|
|
99
|
+
"@traceloop/node-server-sdk": "0.22.2"
|
|
100
|
+
},
|
|
99
101
|
"scripts": {
|
|
100
102
|
"build": "tsup",
|
|
101
103
|
"dev": "tsup --watch",
|