New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

langfuse

Package Overview
Dependencies
Maintainers
1
Versions
220
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

langfuse - npm Package Compare versions

Comparing version 0.1.0-beta.5 to 0.1.0-beta.6

276

lib/index.cjs.js

@@ -22,80 +22,80 @@ 'use strict';

var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};

@@ -110,9 +110,9 @@

var LangfusePostApiRoutes = {
createTrace: ['POST', '/api/public/traces'],
createEvent: ['POST', '/api/public/events'],
createSpan: ['POST', '/api/public/spans'],
updateSpan: ['PATCH', '/api/public/spans'],
createGeneration: ['POST', '/api/public/generations'],
updateGeneration: ['PATCH', '/api/public/generations'],
createScore: ['POST', '/api/public/scores'],
createTrace: ["POST", "/api/public/traces"],
createEvent: ["POST", "/api/public/events"],
createSpan: ["POST", "/api/public/spans"],
updateSpan: ["PATCH", "/api/public/spans"],
createGeneration: ["POST", "/api/public/generations"],
updateGeneration: ["PATCH", "/api/public/generations"],
createScore: ["POST", "/api/public/scores"],
};

@@ -126,3 +126,3 @@

function removeTrailingSlash(url) {
return url === null || url === void 0 ? void 0 : url.replace(/\/+$/, '');
return url === null || url === void 0 ? void 0 : url.replace(/\/+$/, "");
}

@@ -177,3 +177,3 @@ function retriable(fn, props, log) {

var d2 = (globalThis && globalThis.performance && globalThis.performance.now && globalThis.performance.now() * 1000) || 0; //Time in microseconds since page-load or 0 if unsupported
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
var r = Math.random() * 16; //random number between 0 and 16

@@ -190,3 +190,3 @@ if (d > 0) {

}
return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16);
return (c === "x" ? r : (r & 0x3) | 0x8).toString(16);
});

@@ -223,3 +223,3 @@ }

}
for (var _b = 0, _c = this.events['*'] || []; _b < _c.length; _b++) {
for (var _b = 0, _c = this.events["*"] || []; _b < _c.length; _b++) {
var listener = _c[_b];

@@ -235,5 +235,5 @@ listener(event, payload);

function LangfuseFetchHttpError(response) {
var _this = _super.call(this, 'HTTP error while fetching Langfuse: ' + response.status) || this;
var _this = _super.call(this, "HTTP error while fetching Langfuse: " + response.status) || this;
_this.response = response;
_this.name = 'LangfuseFetchHttpError';
_this.name = "LangfuseFetchHttpError";
return _this;

@@ -246,5 +246,5 @@ }

function LangfuseFetchNetworkError(error) {
var _this = _super.call(this, 'Network error while fetching Langfuse', error instanceof Error ? { cause: error } : {}) || this;
var _this = _super.call(this, "Network error while fetching Langfuse", error instanceof Error ? { cause: error } : {}) || this;
_this.error = error;
_this.name = 'LangfuseFetchNetworkError';
_this.name = "LangfuseFetchNetworkError";
return _this;

@@ -255,7 +255,7 @@ }

function isLangfuseFetchError(err) {
return typeof err === 'object' && (err.name === 'LangfuseFetchHttpError' || err.name === 'LangfuseFetchNetworkError');
return typeof err === "object" && (err.name === "LangfuseFetchHttpError" || err.name === "LangfuseFetchNetworkError");
}
var LangfuseCoreStateless = /** @class */ (function () {
function LangfuseCoreStateless(params) {
var _a, _b, _c, _d;
var _a, _b, _c, _d, _e, _f;
this.debugMode = false;

@@ -269,11 +269,12 @@ this.pendingPromises = {};

this.secretKey = secretKey;
this.host = removeTrailingSlash((options === null || options === void 0 ? void 0 : options.host) || 'https://cloud.langfuse.com');
this.host = removeTrailingSlash((options === null || options === void 0 ? void 0 : options.host) || "https://cloud.langfuse.com");
this.flushAt = (options === null || options === void 0 ? void 0 : options.flushAt) ? Math.max(options === null || options === void 0 ? void 0 : options.flushAt, 1) : 20;
this.flushInterval = (_a = options === null || options === void 0 ? void 0 : options.flushInterval) !== null && _a !== void 0 ? _a : 10000;
this.release = (_c = (_b = options === null || options === void 0 ? void 0 : options.release) !== null && _b !== void 0 ? _b : process.env.LANGFUSE_RELEASE) !== null && _c !== void 0 ? _c : undefined;
this._retryOptions = {
retryCount: (_b = options === null || options === void 0 ? void 0 : options.fetchRetryCount) !== null && _b !== void 0 ? _b : 3,
retryDelay: (_c = options === null || options === void 0 ? void 0 : options.fetchRetryDelay) !== null && _c !== void 0 ? _c : 3000,
retryCount: (_d = options === null || options === void 0 ? void 0 : options.fetchRetryCount) !== null && _d !== void 0 ? _d : 3,
retryDelay: (_e = options === null || options === void 0 ? void 0 : options.fetchRetryDelay) !== null && _e !== void 0 ? _e : 3000,
retryCheck: isLangfuseFetchError,
};
this.requestTimeout = (_d = options === null || options === void 0 ? void 0 : options.requestTimeout) !== null && _d !== void 0 ? _d : 10000; // 10 seconds
this.requestTimeout = (_f = options === null || options === void 0 ? void 0 : options.requestTimeout) !== null && _f !== void 0 ? _f : 10000; // 10 seconds
}

@@ -295,3 +296,3 @@ LangfuseCoreStateless.prototype.getCommonEventProperties = function () {

if (enabled) {
this.removeDebugCallback = this.on('*', function (event, payload) { return console.log('Langfuse Debug', event, payload); });
this.removeDebugCallback = this.on("*", function (event, payload) { return console.log("Langfuse Debug", event, payload); });
}

@@ -303,6 +304,7 @@ };

LangfuseCoreStateless.prototype.traceStateless = function (body) {
var bodyId = body.id, rest = __rest(body, ["id"]);
var id = bodyId || generateUUID();
var parsedBody = __assign({ id: id }, rest);
this.enqueue('createTrace', parsedBody);
var bodyId = body.id, bodyRelease = body.release, rest = __rest(body, ["id", "release"]);
var id = bodyId !== null && bodyId !== void 0 ? bodyId : generateUUID();
var release = bodyRelease !== null && bodyRelease !== void 0 ? bodyRelease : this.release;
var parsedBody = __assign({ id: id, release: release }, rest);
this.enqueue("createTrace", parsedBody);
return id;

@@ -314,3 +316,3 @@ };

var parsedBody = __assign({ id: id, startTime: bodyStartTime !== null && bodyStartTime !== void 0 ? bodyStartTime : new Date() }, rest);
this.enqueue('createEvent', parsedBody);
this.enqueue("createEvent", parsedBody);
return id;

@@ -322,3 +324,3 @@ };

var parsedBody = __assign({ id: id, startTime: bodyStartTime !== null && bodyStartTime !== void 0 ? bodyStartTime : new Date() }, rest);
this.enqueue('createSpan', parsedBody);
this.enqueue("createSpan", parsedBody);
return id;

@@ -330,3 +332,3 @@ };

var parsedBody = __assign({ id: id, startTime: bodyStartTime !== null && bodyStartTime !== void 0 ? bodyStartTime : new Date() }, rest);
this.enqueue('createGeneration', parsedBody);
this.enqueue("createGeneration", parsedBody);
return id;

@@ -338,13 +340,11 @@ };

var parsedBody = __assign({ id: id }, rest);
this.enqueue('createScore', parsedBody);
this.enqueue("createScore", parsedBody);
return id;
};
LangfuseCoreStateless.prototype.updateSpanStateless = function (body) {
var parsedBody = __assign({}, body);
this.enqueue('updateSpan', parsedBody);
this.enqueue("updateSpan", body);
return body.spanId;
};
LangfuseCoreStateless.prototype.updateGenerationStateless = function (body) {
var parsedBody = __assign({}, body);
this.enqueue('updateGeneration', parsedBody);
this.enqueue("updateGeneration", body);
return body.generationId;

@@ -405,7 +405,7 @@ };

if (err) {
_this._events.emit('error', err);
_this._events.emit("error", err);
}
// remove promise from pendingPromises
delete _this.pendingPromises[item.id];
_this._events.emit('flush', item);
_this._events.emit("flush", item);
};

@@ -416,3 +416,3 @@ var payload = JSON.stringify(item.body); // implicit conversion also of dates to strings

method: item.method,
headers: __assign({ 'Content-Type': 'application/json' }, _this.constructAuthorizationHeader(_this.publicKey, _this.secretKey)),
headers: __assign({ "Content-Type": "application/json" }, _this.constructAuthorizationHeader(_this.publicKey, _this.secretKey)),
body: payload,

@@ -433,11 +433,11 @@ };

if (secretKey === undefined) {
return { Authorization: 'Bearer ' + publicKey };
return { Authorization: "Bearer " + publicKey };
}
else {
var encodedCredentials = typeof btoa === 'function'
var encodedCredentials = typeof btoa === "function"
? // btoa() is available, the code is running in a browser or edge environment
btoa(publicKey + ':' + secretKey)
btoa(publicKey + ":" + secretKey)
: // btoa() is not available, the code is running in Node.js
Buffer.from(publicKey + ':' + secretKey).toString('base64');
return { Authorization: 'Basic ' + encodedCredentials };
Buffer.from(publicKey + ":" + secretKey).toString("base64");
return { Authorization: "Basic " + encodedCredentials };
}

@@ -482,3 +482,3 @@ };

});
}); }, __assign(__assign({}, this._retryOptions), retryOptions), function (string) { return _this._events.emit('retry', string + ', ' + url + ', ' + JSON.stringify(options)); })];
}); }, __assign(__assign({}, this._retryOptions), retryOptions), function (string) { return _this._events.emit("retry", string + ", " + url + ", " + JSON.stringify(options)); })];
case 1: return [2 /*return*/, _c.sent()];

@@ -515,3 +515,3 @@ }

}
console.error('Error while shutting down Langfuse', e_2);
console.error("Error while shutting down Langfuse", e_2);
return [3 /*break*/, 5];

@@ -649,3 +649,3 @@ case 5: return [2 /*return*/];

LangfuseSpanClient.prototype.update = function (body) {
this.client._updateSpan(__assign(__assign({}, body), { spanId: this.id }));
this.client._updateSpan(__assign(__assign({}, body), { spanId: this.id, traceId: this.traceId }));
return this;

@@ -661,3 +661,3 @@ };

LangfuseGenerationClient.prototype.update = function (body) {
this.client._updateGeneration(__assign(__assign({}, body), { generationId: this.id }));
this.client._updateGeneration(__assign(__assign({}, body), { generationId: this.id, traceId: this.traceId }));
return this;

@@ -679,7 +679,7 @@ };

try {
var nameEQ = key + '=';
var ca = document.cookie.split(';');
var nameEQ = key + "=";
var ca = document.cookie.split(";");
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
while (c.charAt(0) == " ") {
c = c.substring(1, c.length);

@@ -696,6 +696,6 @@ }

try {
var cdomain = '',
expires = '',
secure = '';
var new_cookie_val = key + '=' + encodeURIComponent(value) + expires + '; path=/' + cdomain + secure;
var cdomain = "",
expires = "",
secure = "";
var new_cookie_val = key + "=" + encodeURIComponent(value) + expires + "; path=/" + cdomain + secure;
document.cookie = new_cookie_val;

@@ -708,3 +708,3 @@ } catch (err) {

try {
cookieStore.setItem(name, '');
cookieStore.setItem(name, "");
} catch (err) {

@@ -715,13 +715,13 @@ return;

clear: function () {
document.cookie = '';
document.cookie = "";
},
getAllKeys: function () {
var ca = document.cookie.split(';');
var ca = document.cookie.split(";");
var keys = [];
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
while (c.charAt(0) == " ") {
c = c.substring(1, c.length);
}
keys.push(c.split('=')[0]);
keys.push(c.split("=")[0]);
}

@@ -756,3 +756,3 @@ return keys;

if (key === void 0) {
key = '__mplssupport__';
key = "__mplssupport__";
}

@@ -763,3 +763,3 @@ if (!window) {

try {
var val = 'xyz';
var val = "xyz";
storage.setItem(key, val);

@@ -816,9 +816,9 @@ if (storage.getItem(key) !== val) {

switch (type) {
case 'cookie':
case "cookie":
return cookieStore || localStore || sessionStore || createMemoryStorage();
case 'localStorage':
case "localStorage":
return localStore || sessionStore || createMemoryStorage();
case 'sessionStorage':
case "sessionStorage":
return sessionStore || createMemoryStorage();
case 'memory':
case "memory":
return createMemoryStorage();

@@ -830,3 +830,3 @@ default:

var version = "0.1.0-beta.5";
var version = "0.1.0-beta.6";

@@ -840,8 +840,8 @@ var Langfuse = /** @class */function (_super) {

var options = __rest(params, ["publicKey", "secretKey"]);
if (typeof window !== 'undefined') {
if (typeof window !== "undefined") {
_this._storageKey = (options === null || options === void 0 ? void 0 : options.persistence_name) ? "lf_".concat(options.persistence_name) : "lf_".concat(publicKey, "_langfuse");
_this._storage = getStorage((options === null || options === void 0 ? void 0 : options.persistence) || 'localStorage', window);
_this._storage = getStorage((options === null || options === void 0 ? void 0 : options.persistence) || "localStorage", window);
} else {
_this._storageKey = "lf_".concat(publicKey, "_langfuse");
_this._storage = getStorage('memory', undefined);
_this._storage = getStorage("memory", undefined);
}

@@ -852,3 +852,3 @@ return _this;

if (!this._storageCache) {
this._storageCache = JSON.parse(this._storage.getItem(this._storageKey) || '{}') || {};
this._storageCache = JSON.parse(this._storage.getItem(this._storageKey) || "{}") || {};
}

@@ -859,3 +859,3 @@ return this._storageCache[key];

if (!this._storageCache) {
this._storageCache = JSON.parse(this._storage.getItem(this._storageKey) || '{}') || {};
this._storageCache = JSON.parse(this._storage.getItem(this._storageKey) || "{}") || {};
}

@@ -873,3 +873,3 @@ if (value === null) {

Langfuse.prototype.getLibraryId = function () {
return 'langfuse';
return "langfuse";
};

@@ -890,8 +890,8 @@ Langfuse.prototype.getLibraryVersion = function () {

options = __rest(params, ["publicKey"]);
if (typeof window !== 'undefined') {
if (typeof window !== "undefined") {
_this._storageKey = (options === null || options === void 0 ? void 0 : options.persistence_name) ? "lf_".concat(options.persistence_name) : "lf_".concat(publicKey, "_langfuse");
_this._storage = getStorage((options === null || options === void 0 ? void 0 : options.persistence) || 'localStorage', window);
_this._storage = getStorage((options === null || options === void 0 ? void 0 : options.persistence) || "localStorage", window);
} else {
_this._storageKey = "lf_".concat(publicKey, "_langfuse");
_this._storage = getStorage('memory', undefined);
_this._storage = getStorage("memory", undefined);
}

@@ -902,3 +902,3 @@ return _this;

if (!this._storageCache) {
this._storageCache = JSON.parse(this._storage.getItem(this._storageKey) || '{}') || {};
this._storageCache = JSON.parse(this._storage.getItem(this._storageKey) || "{}") || {};
}

@@ -909,3 +909,3 @@ return this._storageCache[key];

if (!this._storageCache) {
this._storageCache = JSON.parse(this._storage.getItem(this._storageKey) || '{}') || {};
this._storageCache = JSON.parse(this._storage.getItem(this._storageKey) || "{}") || {};
}

@@ -923,3 +923,3 @@ if (value === null) {

LangfuseWeb.prototype.getLibraryId = function () {
return 'langfuse-frontend';
return "langfuse-frontend";
};

@@ -937,3 +937,3 @@ LangfuseWeb.prototype.getLibraryVersion = function () {

exports.LangfuseWeb = LangfuseWeb;
exports["default"] = Langfuse;
exports.default = Langfuse;
//# sourceMappingURL=index.cjs.js.map

@@ -10,35 +10,35 @@ /**

interface paths {
'/api/public/events': {
"/api/public/events": {
/** @description Add an event to the database */
post: operations['event_create'];
post: operations["event_create"];
};
'/api/public/generations': {
post: operations['generations_log'];
patch: operations['generations_update'];
"/api/public/generations": {
post: operations["generations_log"];
patch: operations["generations_update"];
};
'/api/public/observations/{observationId}': {
"/api/public/observations/{observationId}": {
/** @description Get a specific observation */
get: operations['observations_get'];
get: operations["observations_get"];
};
'/api/public/scores': {
"/api/public/scores": {
/** @description Get scores */
get: operations['score_get'];
get: operations["score_get"];
/** @description Add a score to the database */
post: operations['score_create'];
post: operations["score_create"];
};
'/api/public/spans': {
"/api/public/spans": {
/** @description Add a span to the database */
post: operations['span_create'];
post: operations["span_create"];
/** @description Update a span to the database */
patch: operations['span_update'];
patch: operations["span_update"];
};
'/api/public/traces': {
"/api/public/traces": {
/** @description Get list of traces */
get: operations['trace_list'];
get: operations["trace_list"];
/** @description Add a trace to the database */
post: operations['trace_create'];
post: operations["trace_create"];
};
'/api/public/traces/{traceId}': {
"/api/public/traces/{traceId}": {
/** @description Get a specific trace */
get: operations['trace_get'];
get: operations["trace_get"];
};

@@ -52,3 +52,3 @@ }

traceId?: string | null;
traceIdType?: components['schemas']['TraceIdTypeEnum'];
traceIdType?: components["schemas"]["TraceIdTypeEnum"];
name?: string | null;

@@ -60,3 +60,3 @@ /** Format: date-time */

output?: Record<string, unknown> | null;
level?: components['schemas']['ObservationLevel'];
level?: components["schemas"]["ObservationLevel"];
statusMessage?: string | null;

@@ -70,3 +70,3 @@ parentObservationId?: string | null;

endTime?: string | null;
} & components['schemas']['CreateEventRequest'];
} & components["schemas"]["CreateEventRequest"];
/** CreateGenerationRequest */

@@ -78,8 +78,8 @@ CreateGenerationRequest: {

modelParameters?: {
[key: string]: components['schemas']['MapValue'] | undefined;
[key: string]: components["schemas"]["MapValue"] | undefined;
} | null;
prompt?: Record<string, unknown> | null;
completion?: string | null;
usage?: components['schemas']['LLMUsage'];
} & components['schemas']['CreateSpanRequest'];
usage?: components["schemas"]["LLMUsage"];
} & components["schemas"]["CreateSpanRequest"];
/** Trace */

@@ -104,12 +104,12 @@ Trace: {

scores: string[];
} & components['schemas']['Trace'], 'observations' | 'scores'>;
} & components["schemas"]["Trace"], "observations" | "scores">;
/** TraceWithFullDetails */
TraceWithFullDetails: WithRequired<{
observations: components['schemas']['Observation'][];
scores: components['schemas']['Score'][];
} & components['schemas']['Trace'], 'observations' | 'scores'>;
observations: components["schemas"]["Observation"][];
scores: components["schemas"]["Score"][];
} & components["schemas"]["Trace"], "observations" | "scores">;
/** Observation */
Observation: {
id: string;
traceId: string;
traceId?: string | null;
type: string;

@@ -125,3 +125,3 @@ name?: string | null;

modelParameters?: {
[key: string]: components['schemas']['MapValue'] | undefined;
[key: string]: components["schemas"]["MapValue"] | undefined;
} | null;

@@ -135,3 +135,3 @@ prompt?: Record<string, unknown> | null;

totalTokens: number;
level: components['schemas']['ObservationLevel'];
level: components["schemas"]["ObservationLevel"];
statusMessage?: string | null;

@@ -155,3 +155,3 @@ parentObservationId?: string | null;

*/
ObservationLevel: 'DEBUG' | 'DEFAULT' | 'WARNING' | 'ERROR';
ObservationLevel: "DEBUG" | "DEFAULT" | "WARNING" | "ERROR";
/** MapValue */

@@ -163,3 +163,3 @@ MapValue: (string | null) | (number | null) | (boolean | null);

*/
TraceIdTypeEnum: 'LANGFUSE' | 'EXTERNAL';
TraceIdTypeEnum: "LANGFUSE" | "EXTERNAL";
/** LLMUsage */

@@ -174,2 +174,3 @@ LLMUsage: {

generationId: string;
traceId?: string | null;
name?: string | null;

@@ -182,3 +183,3 @@ /** Format: date-time */

modelParameters?: {
[key: string]: components['schemas']['MapValue'] | undefined;
[key: string]: components["schemas"]["MapValue"] | undefined;
} | null;

@@ -189,4 +190,4 @@ prompt?: Record<string, unknown> | null;

completion?: string | null;
usage?: components['schemas']['LLMUsage'];
level?: components['schemas']['ObservationLevel'];
usage?: components["schemas"]["LLMUsage"];
level?: components["schemas"]["ObservationLevel"];
statusMessage?: string | null;

@@ -198,3 +199,3 @@ };

traceId: string;
traceIdType?: components['schemas']['TraceIdTypeEnum'];
traceIdType?: components["schemas"]["TraceIdTypeEnum"];
name: string;

@@ -207,4 +208,4 @@ value: number;

Scores: {
data: components['schemas']['Score'][];
meta: components['schemas']['utilsMetaResponse'];
data: components["schemas"]["Score"][];
meta: components["schemas"]["utilsMetaResponse"];
};

@@ -214,2 +215,3 @@ /** UpdateSpanRequest */

spanId: string;
traceId?: string | null;
/** Format: date-time */

@@ -220,3 +222,3 @@ endTime?: string | null;

output?: Record<string, unknown> | null;
level?: components['schemas']['ObservationLevel'];
level?: components["schemas"]["ObservationLevel"];
version?: string | null;

@@ -237,4 +239,4 @@ statusMessage?: string | null;

Traces: {
data: components['schemas']['TraceWithDetails'][];
meta: components['schemas']['utilsMetaResponse'];
data: components["schemas"]["TraceWithDetails"][];
meta: components["schemas"]["utilsMetaResponse"];
};

@@ -264,3 +266,3 @@ /** utilsMetaResponse */

content: {
'application/json': components['schemas']['CreateEventRequest'];
"application/json": components["schemas"]["CreateEventRequest"];
};

@@ -271,3 +273,3 @@ };

content: {
'application/json': components['schemas']['Observation'];
"application/json": components["schemas"]["Observation"];
};

@@ -277,3 +279,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -283,3 +285,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -289,3 +291,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -295,3 +297,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -301,3 +303,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -310,3 +312,3 @@ };

content: {
'application/json': components['schemas']['CreateGenerationRequest'];
"application/json": components["schemas"]["CreateGenerationRequest"];
};

@@ -317,3 +319,3 @@ };

content: {
'application/json': components['schemas']['Observation'];
"application/json": components["schemas"]["Observation"];
};

@@ -323,3 +325,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -329,3 +331,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -335,3 +337,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -341,3 +343,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -347,3 +349,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -356,3 +358,3 @@ };

content: {
'application/json': components['schemas']['UpdateGenerationRequest'];
"application/json": components["schemas"]["UpdateGenerationRequest"];
};

@@ -363,3 +365,3 @@ };

content: {
'application/json': components['schemas']['Observation'];
"application/json": components["schemas"]["Observation"];
};

@@ -369,3 +371,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -375,3 +377,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -381,3 +383,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -387,3 +389,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -393,3 +395,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -410,3 +412,3 @@ };

content: {
'application/json': components['schemas']['Observation'];
"application/json": components["schemas"]["Observation"];
};

@@ -416,3 +418,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -422,3 +424,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -428,3 +430,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -434,3 +436,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -440,3 +442,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -459,3 +461,3 @@ };

content: {
'application/json': components['schemas']['Scores'];
"application/json": components["schemas"]["Scores"];
};

@@ -465,3 +467,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -471,3 +473,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -477,3 +479,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -483,3 +485,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -489,3 +491,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -499,3 +501,3 @@ };

content: {
'application/json': components['schemas']['CreateScoreRequest'];
"application/json": components["schemas"]["CreateScoreRequest"];
};

@@ -506,3 +508,3 @@ };

content: {
'application/json': components['schemas']['Score'];
"application/json": components["schemas"]["Score"];
};

@@ -512,3 +514,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -518,3 +520,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -524,3 +526,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -530,3 +532,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -536,3 +538,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -546,3 +548,3 @@ };

content: {
'application/json': components['schemas']['CreateSpanRequest'];
"application/json": components["schemas"]["CreateSpanRequest"];
};

@@ -553,3 +555,3 @@ };

content: {
'application/json': components['schemas']['Observation'];
"application/json": components["schemas"]["Observation"];
};

@@ -559,3 +561,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -565,3 +567,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -571,3 +573,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -577,3 +579,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -583,3 +585,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -593,3 +595,3 @@ };

content: {
'application/json': components['schemas']['UpdateSpanRequest'];
"application/json": components["schemas"]["UpdateSpanRequest"];
};

@@ -600,3 +602,3 @@ };

content: {
'application/json': components['schemas']['Observation'];
"application/json": components["schemas"]["Observation"];
};

@@ -606,3 +608,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -612,3 +614,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -618,3 +620,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -624,3 +626,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -630,3 +632,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -649,3 +651,3 @@ };

content: {
'application/json': components['schemas']['Traces'];
"application/json": components["schemas"]["Traces"];
};

@@ -655,3 +657,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -661,3 +663,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -667,3 +669,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -673,3 +675,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -679,3 +681,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -689,3 +691,3 @@ };

content: {
'application/json': components['schemas']['CreateTraceRequest'];
"application/json": components["schemas"]["CreateTraceRequest"];
};

@@ -696,3 +698,3 @@ };

content: {
'application/json': components['schemas']['Trace'];
"application/json": components["schemas"]["Trace"];
};

@@ -702,3 +704,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -708,3 +710,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -714,3 +716,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -720,3 +722,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -726,3 +728,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -743,3 +745,3 @@ };

content: {
'application/json': components['schemas']['TraceWithFullDetails'];
"application/json": components["schemas"]["TraceWithFullDetails"];
};

@@ -749,3 +751,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -755,3 +757,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -761,3 +763,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -767,3 +769,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -773,3 +775,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -788,2 +790,3 @@ };

requestTimeout?: number;
release?: string;
};

@@ -796,3 +799,3 @@ declare enum LangfusePersistedProperty {

type LangfuseFetchOptions = {
method: 'GET' | 'POST' | 'PUT' | 'PATCH';
method: "GET" | "POST" | "PUT" | "PATCH";
headers: {

@@ -809,15 +812,15 @@ [key: string]: string;

};
type CreateLangfuseTraceBody = FixTypes<paths['/api/public/traces']['post']['requestBody']['content']['application/json']>;
type CreateLangfuseEventBody = FixTypes<paths['/api/public/events']['post']['requestBody']['content']['application/json']>;
type CreateLangfuseSpanBody = FixTypes<paths['/api/public/spans']['post']['requestBody']['content']['application/json']>;
type CreateLangfuseGenerationBody = FixTypes<paths['/api/public/generations']['post']['requestBody']['content']['application/json']>;
type CreateLangfuseScoreBody = FixTypes<paths['/api/public/scores']['post']['requestBody']['content']['application/json']>;
type UpdateLangfuseSpanBody = FixTypes<paths['/api/public/spans']['patch']['requestBody']['content']['application/json']>;
type UpdateLangfuseGenerationBody = FixTypes<paths['/api/public/generations']['patch']['requestBody']['content']['application/json']>;
type LangfuseObject = 'createTrace' | 'createEvent' | 'createSpan' | 'createGeneration' | 'createScore' | 'updateSpan' | 'updateGeneration';
type CreateLangfuseTraceBody = FixTypes<paths["/api/public/traces"]["post"]["requestBody"]["content"]["application/json"]>;
type CreateLangfuseEventBody = FixTypes<paths["/api/public/events"]["post"]["requestBody"]["content"]["application/json"]>;
type CreateLangfuseSpanBody = FixTypes<paths["/api/public/spans"]["post"]["requestBody"]["content"]["application/json"]>;
type CreateLangfuseGenerationBody = FixTypes<paths["/api/public/generations"]["post"]["requestBody"]["content"]["application/json"]>;
type CreateLangfuseScoreBody = FixTypes<paths["/api/public/scores"]["post"]["requestBody"]["content"]["application/json"]>;
type UpdateLangfuseSpanBody = FixTypes<paths["/api/public/spans"]["patch"]["requestBody"]["content"]["application/json"]>;
type UpdateLangfuseGenerationBody = FixTypes<paths["/api/public/generations"]["patch"]["requestBody"]["content"]["application/json"]>;
type LangfuseObject = "createTrace" | "createEvent" | "createSpan" | "createGeneration" | "createScore" | "updateSpan" | "updateGeneration";
type OptionalTypes<T> = T extends null | undefined ? T : never;
type FixTypes<T> = Omit<{
[P in keyof T]: P extends 'startTime' | 'endTime' | 'timestamp' | 'completionStartTime' ? // Dates instead of strings
[P in keyof T]: P extends "startTime" | "endTime" | "timestamp" | "completionStartTime" ? // Dates instead of strings
Date | OptionalTypes<T[P]> : T[P];
}, 'externalId' | 'traceIdType'>;
}, "externalId" | "traceIdType">;

@@ -849,2 +852,3 @@ interface RetriableOptions {

private pendingPromises;
private release;
protected _events: SimpleEventEmitter;

@@ -918,6 +922,6 @@ protected _flushTimer?: any;

});
event(body: Omit<CreateLangfuseEventBody, 'traceId' | 'parentObservationId'>): LangfuseEventClient;
span(body: Omit<CreateLangfuseSpanBody, 'traceId' | 'parentObservationId'>): LangfuseSpanClient;
generation(body: Omit<CreateLangfuseGenerationBody, 'traceId' | 'parentObservationId'>): LangfuseGenerationClient;
score(body: Omit<CreateLangfuseScoreBody, 'traceId' | 'parentObservationId'>): this;
event(body: Omit<CreateLangfuseEventBody, "traceId" | "parentObservationId">): LangfuseEventClient;
span(body: Omit<CreateLangfuseSpanBody, "traceId" | "parentObservationId">): LangfuseSpanClient;
generation(body: Omit<CreateLangfuseGenerationBody, "traceId" | "parentObservationId">): LangfuseGenerationClient;
score(body: Omit<CreateLangfuseScoreBody, "traceId" | "parentObservationId">): this;
}

@@ -932,7 +936,7 @@ declare class LangfuseTraceClient extends LangfuseObjectClient {

constructor(client: LangfuseCore, id: string, traceId: string);
update(body: Omit<UpdateLangfuseSpanBody, 'spanId'>): this;
update(body: Omit<UpdateLangfuseSpanBody, "spanId">): this;
}
declare class LangfuseGenerationClient extends LangfuseObservationClient {
constructor(client: LangfuseCore, id: string, traceId: string);
update(body: Omit<UpdateLangfuseGenerationBody, 'generationId'>): this;
update(body: Omit<UpdateLangfuseGenerationBody, "generationId">): this;
}

@@ -944,3 +948,3 @@ declare class LangfuseEventClient extends LangfuseObservationClient {

type LangfuseOptions = {
persistence?: 'localStorage' | 'sessionStorage' | 'cookie' | 'memory';
persistence?: "localStorage" | "sessionStorage" | "cookie" | "memory";
persistence_name?: string;

@@ -947,0 +951,0 @@ } & LangfuseCoreOptions;

@@ -18,80 +18,80 @@ /******************************************************************************

var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};

@@ -106,9 +106,9 @@

var LangfusePostApiRoutes = {
createTrace: ['POST', '/api/public/traces'],
createEvent: ['POST', '/api/public/events'],
createSpan: ['POST', '/api/public/spans'],
updateSpan: ['PATCH', '/api/public/spans'],
createGeneration: ['POST', '/api/public/generations'],
updateGeneration: ['PATCH', '/api/public/generations'],
createScore: ['POST', '/api/public/scores'],
createTrace: ["POST", "/api/public/traces"],
createEvent: ["POST", "/api/public/events"],
createSpan: ["POST", "/api/public/spans"],
updateSpan: ["PATCH", "/api/public/spans"],
createGeneration: ["POST", "/api/public/generations"],
updateGeneration: ["PATCH", "/api/public/generations"],
createScore: ["POST", "/api/public/scores"],
};

@@ -122,3 +122,3 @@

function removeTrailingSlash(url) {
return url === null || url === void 0 ? void 0 : url.replace(/\/+$/, '');
return url === null || url === void 0 ? void 0 : url.replace(/\/+$/, "");
}

@@ -173,3 +173,3 @@ function retriable(fn, props, log) {

var d2 = (globalThis && globalThis.performance && globalThis.performance.now && globalThis.performance.now() * 1000) || 0; //Time in microseconds since page-load or 0 if unsupported
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
var r = Math.random() * 16; //random number between 0 and 16

@@ -186,3 +186,3 @@ if (d > 0) {

}
return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16);
return (c === "x" ? r : (r & 0x3) | 0x8).toString(16);
});

@@ -219,3 +219,3 @@ }

}
for (var _b = 0, _c = this.events['*'] || []; _b < _c.length; _b++) {
for (var _b = 0, _c = this.events["*"] || []; _b < _c.length; _b++) {
var listener = _c[_b];

@@ -231,5 +231,5 @@ listener(event, payload);

function LangfuseFetchHttpError(response) {
var _this = _super.call(this, 'HTTP error while fetching Langfuse: ' + response.status) || this;
var _this = _super.call(this, "HTTP error while fetching Langfuse: " + response.status) || this;
_this.response = response;
_this.name = 'LangfuseFetchHttpError';
_this.name = "LangfuseFetchHttpError";
return _this;

@@ -242,5 +242,5 @@ }

function LangfuseFetchNetworkError(error) {
var _this = _super.call(this, 'Network error while fetching Langfuse', error instanceof Error ? { cause: error } : {}) || this;
var _this = _super.call(this, "Network error while fetching Langfuse", error instanceof Error ? { cause: error } : {}) || this;
_this.error = error;
_this.name = 'LangfuseFetchNetworkError';
_this.name = "LangfuseFetchNetworkError";
return _this;

@@ -251,7 +251,7 @@ }

function isLangfuseFetchError(err) {
return typeof err === 'object' && (err.name === 'LangfuseFetchHttpError' || err.name === 'LangfuseFetchNetworkError');
return typeof err === "object" && (err.name === "LangfuseFetchHttpError" || err.name === "LangfuseFetchNetworkError");
}
var LangfuseCoreStateless = /** @class */ (function () {
function LangfuseCoreStateless(params) {
var _a, _b, _c, _d;
var _a, _b, _c, _d, _e, _f;
this.debugMode = false;

@@ -265,11 +265,12 @@ this.pendingPromises = {};

this.secretKey = secretKey;
this.host = removeTrailingSlash((options === null || options === void 0 ? void 0 : options.host) || 'https://cloud.langfuse.com');
this.host = removeTrailingSlash((options === null || options === void 0 ? void 0 : options.host) || "https://cloud.langfuse.com");
this.flushAt = (options === null || options === void 0 ? void 0 : options.flushAt) ? Math.max(options === null || options === void 0 ? void 0 : options.flushAt, 1) : 20;
this.flushInterval = (_a = options === null || options === void 0 ? void 0 : options.flushInterval) !== null && _a !== void 0 ? _a : 10000;
this.release = (_c = (_b = options === null || options === void 0 ? void 0 : options.release) !== null && _b !== void 0 ? _b : process.env.LANGFUSE_RELEASE) !== null && _c !== void 0 ? _c : undefined;
this._retryOptions = {
retryCount: (_b = options === null || options === void 0 ? void 0 : options.fetchRetryCount) !== null && _b !== void 0 ? _b : 3,
retryDelay: (_c = options === null || options === void 0 ? void 0 : options.fetchRetryDelay) !== null && _c !== void 0 ? _c : 3000,
retryCount: (_d = options === null || options === void 0 ? void 0 : options.fetchRetryCount) !== null && _d !== void 0 ? _d : 3,
retryDelay: (_e = options === null || options === void 0 ? void 0 : options.fetchRetryDelay) !== null && _e !== void 0 ? _e : 3000,
retryCheck: isLangfuseFetchError,
};
this.requestTimeout = (_d = options === null || options === void 0 ? void 0 : options.requestTimeout) !== null && _d !== void 0 ? _d : 10000; // 10 seconds
this.requestTimeout = (_f = options === null || options === void 0 ? void 0 : options.requestTimeout) !== null && _f !== void 0 ? _f : 10000; // 10 seconds
}

@@ -291,3 +292,3 @@ LangfuseCoreStateless.prototype.getCommonEventProperties = function () {

if (enabled) {
this.removeDebugCallback = this.on('*', function (event, payload) { return console.log('Langfuse Debug', event, payload); });
this.removeDebugCallback = this.on("*", function (event, payload) { return console.log("Langfuse Debug", event, payload); });
}

@@ -299,6 +300,7 @@ };

LangfuseCoreStateless.prototype.traceStateless = function (body) {
var bodyId = body.id, rest = __rest(body, ["id"]);
var id = bodyId || generateUUID();
var parsedBody = __assign({ id: id }, rest);
this.enqueue('createTrace', parsedBody);
var bodyId = body.id, bodyRelease = body.release, rest = __rest(body, ["id", "release"]);
var id = bodyId !== null && bodyId !== void 0 ? bodyId : generateUUID();
var release = bodyRelease !== null && bodyRelease !== void 0 ? bodyRelease : this.release;
var parsedBody = __assign({ id: id, release: release }, rest);
this.enqueue("createTrace", parsedBody);
return id;

@@ -310,3 +312,3 @@ };

var parsedBody = __assign({ id: id, startTime: bodyStartTime !== null && bodyStartTime !== void 0 ? bodyStartTime : new Date() }, rest);
this.enqueue('createEvent', parsedBody);
this.enqueue("createEvent", parsedBody);
return id;

@@ -318,3 +320,3 @@ };

var parsedBody = __assign({ id: id, startTime: bodyStartTime !== null && bodyStartTime !== void 0 ? bodyStartTime : new Date() }, rest);
this.enqueue('createSpan', parsedBody);
this.enqueue("createSpan", parsedBody);
return id;

@@ -326,3 +328,3 @@ };

var parsedBody = __assign({ id: id, startTime: bodyStartTime !== null && bodyStartTime !== void 0 ? bodyStartTime : new Date() }, rest);
this.enqueue('createGeneration', parsedBody);
this.enqueue("createGeneration", parsedBody);
return id;

@@ -334,13 +336,11 @@ };

var parsedBody = __assign({ id: id }, rest);
this.enqueue('createScore', parsedBody);
this.enqueue("createScore", parsedBody);
return id;
};
LangfuseCoreStateless.prototype.updateSpanStateless = function (body) {
var parsedBody = __assign({}, body);
this.enqueue('updateSpan', parsedBody);
this.enqueue("updateSpan", body);
return body.spanId;
};
LangfuseCoreStateless.prototype.updateGenerationStateless = function (body) {
var parsedBody = __assign({}, body);
this.enqueue('updateGeneration', parsedBody);
this.enqueue("updateGeneration", body);
return body.generationId;

@@ -401,7 +401,7 @@ };

if (err) {
_this._events.emit('error', err);
_this._events.emit("error", err);
}
// remove promise from pendingPromises
delete _this.pendingPromises[item.id];
_this._events.emit('flush', item);
_this._events.emit("flush", item);
};

@@ -412,3 +412,3 @@ var payload = JSON.stringify(item.body); // implicit conversion also of dates to strings

method: item.method,
headers: __assign({ 'Content-Type': 'application/json' }, _this.constructAuthorizationHeader(_this.publicKey, _this.secretKey)),
headers: __assign({ "Content-Type": "application/json" }, _this.constructAuthorizationHeader(_this.publicKey, _this.secretKey)),
body: payload,

@@ -429,11 +429,11 @@ };

if (secretKey === undefined) {
return { Authorization: 'Bearer ' + publicKey };
return { Authorization: "Bearer " + publicKey };
}
else {
var encodedCredentials = typeof btoa === 'function'
var encodedCredentials = typeof btoa === "function"
? // btoa() is available, the code is running in a browser or edge environment
btoa(publicKey + ':' + secretKey)
btoa(publicKey + ":" + secretKey)
: // btoa() is not available, the code is running in Node.js
Buffer.from(publicKey + ':' + secretKey).toString('base64');
return { Authorization: 'Basic ' + encodedCredentials };
Buffer.from(publicKey + ":" + secretKey).toString("base64");
return { Authorization: "Basic " + encodedCredentials };
}

@@ -478,3 +478,3 @@ };

});
}); }, __assign(__assign({}, this._retryOptions), retryOptions), function (string) { return _this._events.emit('retry', string + ', ' + url + ', ' + JSON.stringify(options)); })];
}); }, __assign(__assign({}, this._retryOptions), retryOptions), function (string) { return _this._events.emit("retry", string + ", " + url + ", " + JSON.stringify(options)); })];
case 1: return [2 /*return*/, _c.sent()];

@@ -511,3 +511,3 @@ }

}
console.error('Error while shutting down Langfuse', e_2);
console.error("Error while shutting down Langfuse", e_2);
return [3 /*break*/, 5];

@@ -645,3 +645,3 @@ case 5: return [2 /*return*/];

LangfuseSpanClient.prototype.update = function (body) {
this.client._updateSpan(__assign(__assign({}, body), { spanId: this.id }));
this.client._updateSpan(__assign(__assign({}, body), { spanId: this.id, traceId: this.traceId }));
return this;

@@ -657,3 +657,3 @@ };

LangfuseGenerationClient.prototype.update = function (body) {
this.client._updateGeneration(__assign(__assign({}, body), { generationId: this.id }));
this.client._updateGeneration(__assign(__assign({}, body), { generationId: this.id, traceId: this.traceId }));
return this;

@@ -675,7 +675,7 @@ };

try {
var nameEQ = key + '=';
var ca = document.cookie.split(';');
var nameEQ = key + "=";
var ca = document.cookie.split(";");
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
while (c.charAt(0) == " ") {
c = c.substring(1, c.length);

@@ -692,6 +692,6 @@ }

try {
var cdomain = '',
expires = '',
secure = '';
var new_cookie_val = key + '=' + encodeURIComponent(value) + expires + '; path=/' + cdomain + secure;
var cdomain = "",
expires = "",
secure = "";
var new_cookie_val = key + "=" + encodeURIComponent(value) + expires + "; path=/" + cdomain + secure;
document.cookie = new_cookie_val;

@@ -704,3 +704,3 @@ } catch (err) {

try {
cookieStore.setItem(name, '');
cookieStore.setItem(name, "");
} catch (err) {

@@ -711,13 +711,13 @@ return;

clear: function () {
document.cookie = '';
document.cookie = "";
},
getAllKeys: function () {
var ca = document.cookie.split(';');
var ca = document.cookie.split(";");
var keys = [];
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
while (c.charAt(0) == " ") {
c = c.substring(1, c.length);
}
keys.push(c.split('=')[0]);
keys.push(c.split("=")[0]);
}

@@ -752,3 +752,3 @@ return keys;

if (key === void 0) {
key = '__mplssupport__';
key = "__mplssupport__";
}

@@ -759,3 +759,3 @@ if (!window) {

try {
var val = 'xyz';
var val = "xyz";
storage.setItem(key, val);

@@ -812,9 +812,9 @@ if (storage.getItem(key) !== val) {

switch (type) {
case 'cookie':
case "cookie":
return cookieStore || localStore || sessionStore || createMemoryStorage();
case 'localStorage':
case "localStorage":
return localStore || sessionStore || createMemoryStorage();
case 'sessionStorage':
case "sessionStorage":
return sessionStore || createMemoryStorage();
case 'memory':
case "memory":
return createMemoryStorage();

@@ -826,3 +826,3 @@ default:

var version = "0.1.0-beta.5";
var version = "0.1.0-beta.6";

@@ -836,8 +836,8 @@ var Langfuse = /** @class */function (_super) {

var options = __rest(params, ["publicKey", "secretKey"]);
if (typeof window !== 'undefined') {
if (typeof window !== "undefined") {
_this._storageKey = (options === null || options === void 0 ? void 0 : options.persistence_name) ? "lf_".concat(options.persistence_name) : "lf_".concat(publicKey, "_langfuse");
_this._storage = getStorage((options === null || options === void 0 ? void 0 : options.persistence) || 'localStorage', window);
_this._storage = getStorage((options === null || options === void 0 ? void 0 : options.persistence) || "localStorage", window);
} else {
_this._storageKey = "lf_".concat(publicKey, "_langfuse");
_this._storage = getStorage('memory', undefined);
_this._storage = getStorage("memory", undefined);
}

@@ -848,3 +848,3 @@ return _this;

if (!this._storageCache) {
this._storageCache = JSON.parse(this._storage.getItem(this._storageKey) || '{}') || {};
this._storageCache = JSON.parse(this._storage.getItem(this._storageKey) || "{}") || {};
}

@@ -855,3 +855,3 @@ return this._storageCache[key];

if (!this._storageCache) {
this._storageCache = JSON.parse(this._storage.getItem(this._storageKey) || '{}') || {};
this._storageCache = JSON.parse(this._storage.getItem(this._storageKey) || "{}") || {};
}

@@ -869,3 +869,3 @@ if (value === null) {

Langfuse.prototype.getLibraryId = function () {
return 'langfuse';
return "langfuse";
};

@@ -886,8 +886,8 @@ Langfuse.prototype.getLibraryVersion = function () {

options = __rest(params, ["publicKey"]);
if (typeof window !== 'undefined') {
if (typeof window !== "undefined") {
_this._storageKey = (options === null || options === void 0 ? void 0 : options.persistence_name) ? "lf_".concat(options.persistence_name) : "lf_".concat(publicKey, "_langfuse");
_this._storage = getStorage((options === null || options === void 0 ? void 0 : options.persistence) || 'localStorage', window);
_this._storage = getStorage((options === null || options === void 0 ? void 0 : options.persistence) || "localStorage", window);
} else {
_this._storageKey = "lf_".concat(publicKey, "_langfuse");
_this._storage = getStorage('memory', undefined);
_this._storage = getStorage("memory", undefined);
}

@@ -898,3 +898,3 @@ return _this;

if (!this._storageCache) {
this._storageCache = JSON.parse(this._storage.getItem(this._storageKey) || '{}') || {};
this._storageCache = JSON.parse(this._storage.getItem(this._storageKey) || "{}") || {};
}

@@ -905,3 +905,3 @@ return this._storageCache[key];

if (!this._storageCache) {
this._storageCache = JSON.parse(this._storage.getItem(this._storageKey) || '{}') || {};
this._storageCache = JSON.parse(this._storage.getItem(this._storageKey) || "{}") || {};
}

@@ -919,3 +919,3 @@ if (value === null) {

LangfuseWeb.prototype.getLibraryId = function () {
return 'langfuse-frontend';
return "langfuse-frontend";
};

@@ -922,0 +922,0 @@ LangfuseWeb.prototype.getLibraryVersion = function () {

@@ -0,0 +0,0 @@ export declare class SimpleEventEmitter {

@@ -1,5 +0,5 @@

import { LangfuseFetchOptions, LangfuseFetchResponse, LangfuseCoreOptions, LangfusePersistedProperty, CreateLangfuseTraceBody, LangfuseObject, CreateLangfuseEventBody, CreateLangfuseSpanBody, CreateLangfuseGenerationBody, CreateLangfuseScoreBody, UpdateLangfuseSpanBody, UpdateLangfuseGenerationBody } from './types';
import { RetriableOptions } from './utils';
export * as utils from './utils';
import { SimpleEventEmitter } from './eventemitter';
import { type LangfuseFetchOptions, type LangfuseFetchResponse, type LangfuseCoreOptions, LangfusePersistedProperty, type CreateLangfuseTraceBody, type LangfuseObject, type CreateLangfuseEventBody, type CreateLangfuseSpanBody, type CreateLangfuseGenerationBody, type CreateLangfuseScoreBody, type UpdateLangfuseSpanBody, type UpdateLangfuseGenerationBody } from "./types";
import { type RetriableOptions } from "./utils";
export * as utils from "./utils";
import { SimpleEventEmitter } from "./eventemitter";
declare abstract class LangfuseCoreStateless {

@@ -15,2 +15,3 @@ private secretKey;

private pendingPromises;
private release;
protected _events: SimpleEventEmitter;

@@ -84,6 +85,6 @@ protected _flushTimer?: any;

});
event(body: Omit<CreateLangfuseEventBody, 'traceId' | 'parentObservationId'>): LangfuseEventClient;
span(body: Omit<CreateLangfuseSpanBody, 'traceId' | 'parentObservationId'>): LangfuseSpanClient;
generation(body: Omit<CreateLangfuseGenerationBody, 'traceId' | 'parentObservationId'>): LangfuseGenerationClient;
score(body: Omit<CreateLangfuseScoreBody, 'traceId' | 'parentObservationId'>): this;
event(body: Omit<CreateLangfuseEventBody, "traceId" | "parentObservationId">): LangfuseEventClient;
span(body: Omit<CreateLangfuseSpanBody, "traceId" | "parentObservationId">): LangfuseSpanClient;
generation(body: Omit<CreateLangfuseGenerationBody, "traceId" | "parentObservationId">): LangfuseGenerationClient;
score(body: Omit<CreateLangfuseScoreBody, "traceId" | "parentObservationId">): this;
}

@@ -98,7 +99,7 @@ export declare class LangfuseTraceClient extends LangfuseObjectClient {

constructor(client: LangfuseCore, id: string, traceId: string);
update(body: Omit<UpdateLangfuseSpanBody, 'spanId'>): this;
update(body: Omit<UpdateLangfuseSpanBody, "spanId">): this;
}
export declare class LangfuseGenerationClient extends LangfuseObservationClient {
constructor(client: LangfuseCore, id: string, traceId: string);
update(body: Omit<UpdateLangfuseGenerationBody, 'generationId'>): this;
update(body: Omit<UpdateLangfuseGenerationBody, "generationId">): this;
}

@@ -108,3 +109,3 @@ export declare class LangfuseEventClient extends LangfuseObservationClient {

}
export * from './types';
export * from './openapi/server';
export * from "./types";
export * from "./openapi/server";

@@ -10,35 +10,35 @@ /**

export interface paths {
'/api/public/events': {
"/api/public/events": {
/** @description Add an event to the database */
post: operations['event_create'];
post: operations["event_create"];
};
'/api/public/generations': {
post: operations['generations_log'];
patch: operations['generations_update'];
"/api/public/generations": {
post: operations["generations_log"];
patch: operations["generations_update"];
};
'/api/public/observations/{observationId}': {
"/api/public/observations/{observationId}": {
/** @description Get a specific observation */
get: operations['observations_get'];
get: operations["observations_get"];
};
'/api/public/scores': {
"/api/public/scores": {
/** @description Get scores */
get: operations['score_get'];
get: operations["score_get"];
/** @description Add a score to the database */
post: operations['score_create'];
post: operations["score_create"];
};
'/api/public/spans': {
"/api/public/spans": {
/** @description Add a span to the database */
post: operations['span_create'];
post: operations["span_create"];
/** @description Update a span to the database */
patch: operations['span_update'];
patch: operations["span_update"];
};
'/api/public/traces': {
"/api/public/traces": {
/** @description Get list of traces */
get: operations['trace_list'];
get: operations["trace_list"];
/** @description Add a trace to the database */
post: operations['trace_create'];
post: operations["trace_create"];
};
'/api/public/traces/{traceId}': {
"/api/public/traces/{traceId}": {
/** @description Get a specific trace */
get: operations['trace_get'];
get: operations["trace_get"];
};

@@ -53,3 +53,3 @@ }

traceId?: string | null;
traceIdType?: components['schemas']['TraceIdTypeEnum'];
traceIdType?: components["schemas"]["TraceIdTypeEnum"];
name?: string | null;

@@ -61,3 +61,3 @@ /** Format: date-time */

output?: Record<string, unknown> | null;
level?: components['schemas']['ObservationLevel'];
level?: components["schemas"]["ObservationLevel"];
statusMessage?: string | null;

@@ -71,3 +71,3 @@ parentObservationId?: string | null;

endTime?: string | null;
} & components['schemas']['CreateEventRequest'];
} & components["schemas"]["CreateEventRequest"];
/** CreateGenerationRequest */

@@ -79,8 +79,8 @@ CreateGenerationRequest: {

modelParameters?: {
[key: string]: components['schemas']['MapValue'] | undefined;
[key: string]: components["schemas"]["MapValue"] | undefined;
} | null;
prompt?: Record<string, unknown> | null;
completion?: string | null;
usage?: components['schemas']['LLMUsage'];
} & components['schemas']['CreateSpanRequest'];
usage?: components["schemas"]["LLMUsage"];
} & components["schemas"]["CreateSpanRequest"];
/** Trace */

@@ -105,12 +105,12 @@ Trace: {

scores: string[];
} & components['schemas']['Trace'], 'observations' | 'scores'>;
} & components["schemas"]["Trace"], "observations" | "scores">;
/** TraceWithFullDetails */
TraceWithFullDetails: WithRequired<{
observations: components['schemas']['Observation'][];
scores: components['schemas']['Score'][];
} & components['schemas']['Trace'], 'observations' | 'scores'>;
observations: components["schemas"]["Observation"][];
scores: components["schemas"]["Score"][];
} & components["schemas"]["Trace"], "observations" | "scores">;
/** Observation */
Observation: {
id: string;
traceId: string;
traceId?: string | null;
type: string;

@@ -126,3 +126,3 @@ name?: string | null;

modelParameters?: {
[key: string]: components['schemas']['MapValue'] | undefined;
[key: string]: components["schemas"]["MapValue"] | undefined;
} | null;

@@ -136,3 +136,3 @@ prompt?: Record<string, unknown> | null;

totalTokens: number;
level: components['schemas']['ObservationLevel'];
level: components["schemas"]["ObservationLevel"];
statusMessage?: string | null;

@@ -156,3 +156,3 @@ parentObservationId?: string | null;

*/
ObservationLevel: 'DEBUG' | 'DEFAULT' | 'WARNING' | 'ERROR';
ObservationLevel: "DEBUG" | "DEFAULT" | "WARNING" | "ERROR";
/** MapValue */

@@ -164,3 +164,3 @@ MapValue: (string | null) | (number | null) | (boolean | null);

*/
TraceIdTypeEnum: 'LANGFUSE' | 'EXTERNAL';
TraceIdTypeEnum: "LANGFUSE" | "EXTERNAL";
/** LLMUsage */

@@ -175,2 +175,3 @@ LLMUsage: {

generationId: string;
traceId?: string | null;
name?: string | null;

@@ -183,3 +184,3 @@ /** Format: date-time */

modelParameters?: {
[key: string]: components['schemas']['MapValue'] | undefined;
[key: string]: components["schemas"]["MapValue"] | undefined;
} | null;

@@ -190,4 +191,4 @@ prompt?: Record<string, unknown> | null;

completion?: string | null;
usage?: components['schemas']['LLMUsage'];
level?: components['schemas']['ObservationLevel'];
usage?: components["schemas"]["LLMUsage"];
level?: components["schemas"]["ObservationLevel"];
statusMessage?: string | null;

@@ -199,3 +200,3 @@ };

traceId: string;
traceIdType?: components['schemas']['TraceIdTypeEnum'];
traceIdType?: components["schemas"]["TraceIdTypeEnum"];
name: string;

@@ -208,4 +209,4 @@ value: number;

Scores: {
data: components['schemas']['Score'][];
meta: components['schemas']['utilsMetaResponse'];
data: components["schemas"]["Score"][];
meta: components["schemas"]["utilsMetaResponse"];
};

@@ -215,2 +216,3 @@ /** UpdateSpanRequest */

spanId: string;
traceId?: string | null;
/** Format: date-time */

@@ -221,3 +223,3 @@ endTime?: string | null;

output?: Record<string, unknown> | null;
level?: components['schemas']['ObservationLevel'];
level?: components["schemas"]["ObservationLevel"];
version?: string | null;

@@ -238,4 +240,4 @@ statusMessage?: string | null;

Traces: {
data: components['schemas']['TraceWithDetails'][];
meta: components['schemas']['utilsMetaResponse'];
data: components["schemas"]["TraceWithDetails"][];
meta: components["schemas"]["utilsMetaResponse"];
};

@@ -266,3 +268,3 @@ /** utilsMetaResponse */

content: {
'application/json': components['schemas']['CreateEventRequest'];
"application/json": components["schemas"]["CreateEventRequest"];
};

@@ -273,3 +275,3 @@ };

content: {
'application/json': components['schemas']['Observation'];
"application/json": components["schemas"]["Observation"];
};

@@ -279,3 +281,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -285,3 +287,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -291,3 +293,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -297,3 +299,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -303,3 +305,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -312,3 +314,3 @@ };

content: {
'application/json': components['schemas']['CreateGenerationRequest'];
"application/json": components["schemas"]["CreateGenerationRequest"];
};

@@ -319,3 +321,3 @@ };

content: {
'application/json': components['schemas']['Observation'];
"application/json": components["schemas"]["Observation"];
};

@@ -325,3 +327,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -331,3 +333,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -337,3 +339,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -343,3 +345,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -349,3 +351,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -358,3 +360,3 @@ };

content: {
'application/json': components['schemas']['UpdateGenerationRequest'];
"application/json": components["schemas"]["UpdateGenerationRequest"];
};

@@ -365,3 +367,3 @@ };

content: {
'application/json': components['schemas']['Observation'];
"application/json": components["schemas"]["Observation"];
};

@@ -371,3 +373,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -377,3 +379,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -383,3 +385,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -389,3 +391,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -395,3 +397,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -412,3 +414,3 @@ };

content: {
'application/json': components['schemas']['Observation'];
"application/json": components["schemas"]["Observation"];
};

@@ -418,3 +420,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -424,3 +426,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -430,3 +432,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -436,3 +438,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -442,3 +444,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -461,3 +463,3 @@ };

content: {
'application/json': components['schemas']['Scores'];
"application/json": components["schemas"]["Scores"];
};

@@ -467,3 +469,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -473,3 +475,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -479,3 +481,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -485,3 +487,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -491,3 +493,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -501,3 +503,3 @@ };

content: {
'application/json': components['schemas']['CreateScoreRequest'];
"application/json": components["schemas"]["CreateScoreRequest"];
};

@@ -508,3 +510,3 @@ };

content: {
'application/json': components['schemas']['Score'];
"application/json": components["schemas"]["Score"];
};

@@ -514,3 +516,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -520,3 +522,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -526,3 +528,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -532,3 +534,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -538,3 +540,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -548,3 +550,3 @@ };

content: {
'application/json': components['schemas']['CreateSpanRequest'];
"application/json": components["schemas"]["CreateSpanRequest"];
};

@@ -555,3 +557,3 @@ };

content: {
'application/json': components['schemas']['Observation'];
"application/json": components["schemas"]["Observation"];
};

@@ -561,3 +563,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -567,3 +569,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -573,3 +575,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -579,3 +581,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -585,3 +587,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -595,3 +597,3 @@ };

content: {
'application/json': components['schemas']['UpdateSpanRequest'];
"application/json": components["schemas"]["UpdateSpanRequest"];
};

@@ -602,3 +604,3 @@ };

content: {
'application/json': components['schemas']['Observation'];
"application/json": components["schemas"]["Observation"];
};

@@ -608,3 +610,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -614,3 +616,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -620,3 +622,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -626,3 +628,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -632,3 +634,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -651,3 +653,3 @@ };

content: {
'application/json': components['schemas']['Traces'];
"application/json": components["schemas"]["Traces"];
};

@@ -657,3 +659,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -663,3 +665,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -669,3 +671,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -675,3 +677,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -681,3 +683,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -691,3 +693,3 @@ };

content: {
'application/json': components['schemas']['CreateTraceRequest'];
"application/json": components["schemas"]["CreateTraceRequest"];
};

@@ -698,3 +700,3 @@ };

content: {
'application/json': components['schemas']['Trace'];
"application/json": components["schemas"]["Trace"];
};

@@ -704,3 +706,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -710,3 +712,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -716,3 +718,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -722,3 +724,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -728,3 +730,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -745,3 +747,3 @@ };

content: {
'application/json': components['schemas']['TraceWithFullDetails'];
"application/json": components["schemas"]["TraceWithFullDetails"];
};

@@ -751,3 +753,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -757,3 +759,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -763,3 +765,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -769,3 +771,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -775,3 +777,3 @@ };

content: {
'application/json': string;
"application/json": string;
};

@@ -778,0 +780,0 @@ };

@@ -1,2 +0,2 @@

import { type paths } from './openapi/server';
import { type paths } from "./openapi/server";
export type LangfuseCoreOptions = {

@@ -9,2 +9,3 @@ host?: string;

requestTimeout?: number;
release?: string;
};

@@ -17,3 +18,3 @@ export declare enum LangfusePersistedProperty {

export type LangfuseFetchOptions = {
method: 'GET' | 'POST' | 'PUT' | 'PATCH';
method: "GET" | "POST" | "PUT" | "PATCH";
headers: {

@@ -32,3 +33,3 @@ [key: string]: string;

apiRoute: keyof paths;
method: 'POST' | 'PATCH';
method: "POST" | "PATCH";
id: string;

@@ -44,11 +45,11 @@ body: any;

};
export type CreateLangfuseTraceBody = FixTypes<paths['/api/public/traces']['post']['requestBody']['content']['application/json']>;
export type CreateLangfuseEventBody = FixTypes<paths['/api/public/events']['post']['requestBody']['content']['application/json']>;
export type CreateLangfuseSpanBody = FixTypes<paths['/api/public/spans']['post']['requestBody']['content']['application/json']>;
export type CreateLangfuseGenerationBody = FixTypes<paths['/api/public/generations']['post']['requestBody']['content']['application/json']>;
export type CreateLangfuseScoreBody = FixTypes<paths['/api/public/scores']['post']['requestBody']['content']['application/json']>;
export type UpdateLangfuseSpanBody = FixTypes<paths['/api/public/spans']['patch']['requestBody']['content']['application/json']>;
export type UpdateLangfuseGenerationBody = FixTypes<paths['/api/public/generations']['patch']['requestBody']['content']['application/json']>;
export type LangfuseObject = 'createTrace' | 'createEvent' | 'createSpan' | 'createGeneration' | 'createScore' | 'updateSpan' | 'updateGeneration';
export declare const LangfusePostApiRoutes: Record<LangfuseObject, [LangfuseQueueItem['method'], keyof paths]>;
export type CreateLangfuseTraceBody = FixTypes<paths["/api/public/traces"]["post"]["requestBody"]["content"]["application/json"]>;
export type CreateLangfuseEventBody = FixTypes<paths["/api/public/events"]["post"]["requestBody"]["content"]["application/json"]>;
export type CreateLangfuseSpanBody = FixTypes<paths["/api/public/spans"]["post"]["requestBody"]["content"]["application/json"]>;
export type CreateLangfuseGenerationBody = FixTypes<paths["/api/public/generations"]["post"]["requestBody"]["content"]["application/json"]>;
export type CreateLangfuseScoreBody = FixTypes<paths["/api/public/scores"]["post"]["requestBody"]["content"]["application/json"]>;
export type UpdateLangfuseSpanBody = FixTypes<paths["/api/public/spans"]["patch"]["requestBody"]["content"]["application/json"]>;
export type UpdateLangfuseGenerationBody = FixTypes<paths["/api/public/generations"]["patch"]["requestBody"]["content"]["application/json"]>;
export type LangfuseObject = "createTrace" | "createEvent" | "createSpan" | "createGeneration" | "createScore" | "updateSpan" | "updateGeneration";
export declare const LangfusePostApiRoutes: Record<LangfuseObject, [LangfuseQueueItem["method"], keyof paths]>;
export type JsonType = string | number | boolean | null | {

@@ -59,5 +60,5 @@ [key: string]: JsonType;

type FixTypes<T> = Omit<{
[P in keyof T]: P extends 'startTime' | 'endTime' | 'timestamp' | 'completionStartTime' ? // Dates instead of strings
[P in keyof T]: P extends "startTime" | "endTime" | "timestamp" | "completionStartTime" ? // Dates instead of strings
Date | OptionalTypes<T[P]> : T[P];
}, 'externalId' | 'traceIdType'>;
}, "externalId" | "traceIdType">;
export {};

@@ -0,0 +0,0 @@ export declare function assert(truthyValue: any, message: string): void;

@@ -1,3 +0,3 @@

import { Langfuse } from './src/langfuse';
import { Langfuse } from "./src/langfuse";
export default Langfuse;
export * from './src/langfuse';
export * from "./src/langfuse";

@@ -1,3 +0,3 @@

import { LangfuseCore, LangfuseWebStateless, LangfuseFetchOptions, LangfuseFetchResponse, LangfusePersistedProperty } from '../../langfuse-core/src';
import { LangfuseOptions } from './types';
import { LangfuseCore, LangfuseWebStateless, type LangfuseFetchOptions, type LangfuseFetchResponse, type LangfusePersistedProperty } from "../../langfuse-core/src";
import { type LangfuseOptions } from "./types";
export declare class Langfuse extends LangfuseCore {

@@ -4,0 +4,0 @@ private _storage;

@@ -1,2 +0,2 @@

import { LangfuseOptions } from './types';
import { type LangfuseOptions } from "./types";
export type LangfuseStorage = {

@@ -10,2 +10,2 @@ getItem: (key: string) => string | null | undefined;

export declare const cookieStore: LangfuseStorage;
export declare const getStorage: (type: LangfuseOptions['persistence'], window: Window | undefined) => LangfuseStorage;
export declare const getStorage: (type: LangfuseOptions["persistence"], window: Window | undefined) => LangfuseStorage;

@@ -1,5 +0,5 @@

import { LangfuseCoreOptions } from '../../langfuse-core/src';
import { type LangfuseCoreOptions } from "../../langfuse-core/src";
export type LangfuseOptions = {
persistence?: 'localStorage' | 'sessionStorage' | 'cookie' | 'memory';
persistence?: "localStorage" | "sessionStorage" | "cookie" | "memory";
persistence_name?: string;
} & LangfuseCoreOptions;
{
"name": "langfuse",
"version": "0.1.0-beta.5",
"version": "0.1.0-beta.6",
"author": {

@@ -5,0 +5,0 @@ "name": "Langfuse",

# Langfuse JS/TS
[![MIT License](https://img.shields.io/badge/License-MIT-red.svg?style=flat-square)](https://opensource.org/licenses/MIT) [![npm package](https://img.shields.io/npm/v/langfuse?style=flat-square)](https://www.npmjs.com/package/langfuse) [![GitHub Repo stars](https://img.shields.io/github/stars/langfuse/langfuse?style=flat-square&logo=GitHub&label=langfuse%2Flangfuse)](https://github.com/langfuse/langfuse) [![Discord](https://img.shields.io/discord/1111061815649124414?style=flat-square&logo=Discord&logoColor=white&label=Discord&color=%23434EE4)](https://discord.gg/7NXusRtqYU) [![YC W23](https://img.shields.io/badge/Y%20Combinator-W23-orange?style=flat-square)](https://www.ycombinator.com/companies/langfuse)
This is the main JS/TS client for Langfuse.

@@ -4,0 +6,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc