Comparing version 0.1.0-beta.1 to 0.1.0-beta.2
@@ -250,3 +250,3 @@ 'use strict'; | ||
var LangfuseCoreStateless = /** @class */ (function () { | ||
function LangfuseCoreStateless(apiPublicKey, apiSecretKey, options) { | ||
function LangfuseCoreStateless(params) { | ||
var _a, _b, _c, _d; | ||
@@ -257,5 +257,6 @@ this.debugMode = false; | ||
this._events = new SimpleEventEmitter(); | ||
assert(apiPublicKey, "You must pass your Langfuse project's api public key."); | ||
this.apiPublicKey = apiPublicKey; | ||
this.apiSecretKey = apiSecretKey; | ||
var publicKey = params.publicKey, secretKey = params.secretKey, options = __rest(params, ["publicKey", "secretKey"]); | ||
assert(publicKey, "You must pass your Langfuse project's api public key."); | ||
this.publicKey = publicKey; | ||
this.secretKey = secretKey; | ||
this.host = removeTrailingSlash((options === null || options === void 0 ? void 0 : options.host) || 'https://cloud.langfuse.com'); | ||
@@ -400,3 +401,3 @@ this.flushAt = (options === null || options === void 0 ? void 0 : options.flushAt) ? Math.max(options === null || options === void 0 ? void 0 : options.flushAt, 1) : 20; | ||
method: item.method, | ||
headers: __assign({ 'Content-Type': 'application/json' }, _this.constructAuthorizationHeader(_this.apiPublicKey, _this.apiSecretKey)), | ||
headers: __assign({ 'Content-Type': 'application/json' }, _this.constructAuthorizationHeader(_this.publicKey, _this.secretKey)), | ||
body: payload, | ||
@@ -509,19 +510,19 @@ }; | ||
}()); | ||
var LangfusePublic = /** @class */ (function (_super) { | ||
__extends(LangfusePublic, _super); | ||
function LangfusePublic(apiPublicKey, options) { | ||
return _super.call(this, apiPublicKey, undefined, options) || this; | ||
var LangfuseWebStateless = /** @class */ (function (_super) { | ||
__extends(LangfuseWebStateless, _super); | ||
function LangfuseWebStateless(params) { | ||
return _super.call(this, params) || this; | ||
} | ||
LangfusePublic.prototype.score = function (body) { | ||
LangfuseWebStateless.prototype.score = function (body) { | ||
this.scoreStateless(body); | ||
return this; | ||
}; | ||
return LangfusePublic; | ||
return LangfuseWebStateless; | ||
}(LangfuseCoreStateless)); | ||
var LangfuseCore = /** @class */ (function (_super) { | ||
__extends(LangfuseCore, _super); | ||
function LangfuseCore(apiPublicKey, apiSecretKey, options) { | ||
assert(apiPublicKey, "You must pass your Langfuse project's api public key."); | ||
assert(apiSecretKey, "You must pass your Langfuse project's api secret key."); | ||
return _super.call(this, apiPublicKey, apiSecretKey, options) || this; | ||
function LangfuseCore(params) { | ||
assert(params.publicKey, "You must pass your Langfuse project's api public key."); | ||
assert(params.secretKey, "You must pass your Langfuse project's api secret key."); | ||
return _super.call(this, params) || this; | ||
} | ||
@@ -776,17 +777,16 @@ LangfuseCore.prototype.trace = function (body) { | ||
var version = "0.1.0-beta.1"; | ||
var version = "0.1.0-beta.2"; | ||
var Langfuse = /** @class */function (_super) { | ||
__extends(Langfuse, _super); | ||
function Langfuse(apiPublicKey, apiSecretKey, options) { | ||
if (options === void 0) { | ||
options = {}; | ||
} | ||
var _this = _super.call(this, apiPublicKey, apiSecretKey, options) || this; | ||
// posthog-js stores options in one object on | ||
function Langfuse(params) { | ||
var _this = _super.call(this, params) || this; | ||
var publicKey = params.publicKey; | ||
params.secretKey; | ||
var options = __rest(params, ["publicKey", "secretKey"]); | ||
if (typeof window !== 'undefined') { | ||
_this._storageKey = (options === null || options === void 0 ? void 0 : options.persistence_name) ? "lf_".concat(options.persistence_name) : "lf_".concat(apiPublicKey, "_langfuse"); | ||
_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); | ||
} else { | ||
_this._storageKey = "lf_".concat(apiPublicKey, "_langfuse"); | ||
_this._storageKey = "lf_".concat(publicKey, "_langfuse"); | ||
_this._storage = getStorage('memory', undefined); | ||
@@ -829,13 +829,11 @@ } | ||
__extends(LangfuseWeb, _super); | ||
function LangfuseWeb(apiPublicKey, options) { | ||
if (options === void 0) { | ||
options = {}; | ||
} | ||
var _this = _super.call(this, apiPublicKey, options) || this; | ||
// posthog-js stores options in one object on | ||
function LangfuseWeb(params) { | ||
var _this = _super.call(this, params) || this; | ||
var publicKey = params.publicKey, | ||
options = __rest(params, ["publicKey"]); | ||
if (typeof window !== 'undefined') { | ||
_this._storageKey = (options === null || options === void 0 ? void 0 : options.persistence_name) ? "lf_".concat(options.persistence_name) : "lf_".concat(apiPublicKey, "_langfuse"); | ||
_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); | ||
} else { | ||
_this._storageKey = "lf_".concat(apiPublicKey, "_langfuse"); | ||
_this._storageKey = "lf_".concat(publicKey, "_langfuse"); | ||
_this._storage = getStorage('memory', undefined); | ||
@@ -875,3 +873,3 @@ } | ||
return LangfuseWeb; | ||
}(LangfusePublic); | ||
}(LangfuseWebStateless); | ||
@@ -878,0 +876,0 @@ exports.Langfuse = Langfuse; |
@@ -746,4 +746,4 @@ /** | ||
declare abstract class LangfuseCoreStateless { | ||
private apiSecretKey; | ||
private apiPublicKey; | ||
private secretKey; | ||
private publicKey; | ||
host: string; | ||
@@ -764,3 +764,6 @@ private flushAt; | ||
abstract setPersistedProperty<T>(key: LangfusePersistedProperty, value: T | null): void; | ||
constructor(apiPublicKey: string, apiSecretKey?: string, options?: LangfuseCoreOptions); | ||
constructor(params: { | ||
publicKey: string; | ||
secretKey?: string; | ||
} & LangfuseCoreOptions); | ||
protected getCommonEventProperties(): any; | ||
@@ -791,8 +794,13 @@ on(event: string, cb: (...args: any[]) => void): () => void; | ||
} | ||
declare abstract class LangfusePublic extends LangfuseCoreStateless { | ||
constructor(apiPublicKey: string, options?: LangfuseCoreOptions); | ||
declare abstract class LangfuseWebStateless extends LangfuseCoreStateless { | ||
constructor(params: { | ||
publicKey: string; | ||
} & LangfuseCoreOptions); | ||
score(body: CreateLangfuseScoreBody): this; | ||
} | ||
declare abstract class LangfuseCore extends LangfuseCoreStateless { | ||
constructor(apiPublicKey: string, apiSecretKey: string, options?: LangfuseCoreOptions); | ||
constructor(params: { | ||
publicKey: string; | ||
secretKey: string; | ||
} & LangfuseCoreOptions); | ||
trace(body: CreateLangfuseTraceBody): LangfuseTraceClient; | ||
@@ -849,3 +857,6 @@ span(body: CreateLangfuseSpanBody): LangfuseSpanClient; | ||
private _storageKey; | ||
constructor(apiPublicKey: string, apiSecretKey: string, options?: LangfuseOptions); | ||
constructor(params: { | ||
publicKey: string; | ||
secretKey: string; | ||
} & LangfuseOptions); | ||
getPersistedProperty<T>(key: LangfusePersistedProperty): T | undefined; | ||
@@ -858,7 +869,9 @@ setPersistedProperty<T>(key: LangfusePersistedProperty, value: T | null): void; | ||
} | ||
declare class LangfuseWeb extends LangfusePublic { | ||
declare class LangfuseWeb extends LangfuseWebStateless { | ||
private _storage; | ||
private _storageCache; | ||
private _storageKey; | ||
constructor(apiPublicKey: string, options?: LangfuseOptions); | ||
constructor(params: { | ||
publicKey: string; | ||
} & LangfuseOptions); | ||
getPersistedProperty<T>(key: LangfusePersistedProperty): T | undefined; | ||
@@ -865,0 +878,0 @@ setPersistedProperty<T>(key: LangfusePersistedProperty, value: T | null): void; |
@@ -246,3 +246,3 @@ /****************************************************************************** | ||
var LangfuseCoreStateless = /** @class */ (function () { | ||
function LangfuseCoreStateless(apiPublicKey, apiSecretKey, options) { | ||
function LangfuseCoreStateless(params) { | ||
var _a, _b, _c, _d; | ||
@@ -253,5 +253,6 @@ this.debugMode = false; | ||
this._events = new SimpleEventEmitter(); | ||
assert(apiPublicKey, "You must pass your Langfuse project's api public key."); | ||
this.apiPublicKey = apiPublicKey; | ||
this.apiSecretKey = apiSecretKey; | ||
var publicKey = params.publicKey, secretKey = params.secretKey, options = __rest(params, ["publicKey", "secretKey"]); | ||
assert(publicKey, "You must pass your Langfuse project's api public key."); | ||
this.publicKey = publicKey; | ||
this.secretKey = secretKey; | ||
this.host = removeTrailingSlash((options === null || options === void 0 ? void 0 : options.host) || 'https://cloud.langfuse.com'); | ||
@@ -396,3 +397,3 @@ this.flushAt = (options === null || options === void 0 ? void 0 : options.flushAt) ? Math.max(options === null || options === void 0 ? void 0 : options.flushAt, 1) : 20; | ||
method: item.method, | ||
headers: __assign({ 'Content-Type': 'application/json' }, _this.constructAuthorizationHeader(_this.apiPublicKey, _this.apiSecretKey)), | ||
headers: __assign({ 'Content-Type': 'application/json' }, _this.constructAuthorizationHeader(_this.publicKey, _this.secretKey)), | ||
body: payload, | ||
@@ -505,19 +506,19 @@ }; | ||
}()); | ||
var LangfusePublic = /** @class */ (function (_super) { | ||
__extends(LangfusePublic, _super); | ||
function LangfusePublic(apiPublicKey, options) { | ||
return _super.call(this, apiPublicKey, undefined, options) || this; | ||
var LangfuseWebStateless = /** @class */ (function (_super) { | ||
__extends(LangfuseWebStateless, _super); | ||
function LangfuseWebStateless(params) { | ||
return _super.call(this, params) || this; | ||
} | ||
LangfusePublic.prototype.score = function (body) { | ||
LangfuseWebStateless.prototype.score = function (body) { | ||
this.scoreStateless(body); | ||
return this; | ||
}; | ||
return LangfusePublic; | ||
return LangfuseWebStateless; | ||
}(LangfuseCoreStateless)); | ||
var LangfuseCore = /** @class */ (function (_super) { | ||
__extends(LangfuseCore, _super); | ||
function LangfuseCore(apiPublicKey, apiSecretKey, options) { | ||
assert(apiPublicKey, "You must pass your Langfuse project's api public key."); | ||
assert(apiSecretKey, "You must pass your Langfuse project's api secret key."); | ||
return _super.call(this, apiPublicKey, apiSecretKey, options) || this; | ||
function LangfuseCore(params) { | ||
assert(params.publicKey, "You must pass your Langfuse project's api public key."); | ||
assert(params.secretKey, "You must pass your Langfuse project's api secret key."); | ||
return _super.call(this, params) || this; | ||
} | ||
@@ -772,17 +773,16 @@ LangfuseCore.prototype.trace = function (body) { | ||
var version = "0.1.0-beta.1"; | ||
var version = "0.1.0-beta.2"; | ||
var Langfuse = /** @class */function (_super) { | ||
__extends(Langfuse, _super); | ||
function Langfuse(apiPublicKey, apiSecretKey, options) { | ||
if (options === void 0) { | ||
options = {}; | ||
} | ||
var _this = _super.call(this, apiPublicKey, apiSecretKey, options) || this; | ||
// posthog-js stores options in one object on | ||
function Langfuse(params) { | ||
var _this = _super.call(this, params) || this; | ||
var publicKey = params.publicKey; | ||
params.secretKey; | ||
var options = __rest(params, ["publicKey", "secretKey"]); | ||
if (typeof window !== 'undefined') { | ||
_this._storageKey = (options === null || options === void 0 ? void 0 : options.persistence_name) ? "lf_".concat(options.persistence_name) : "lf_".concat(apiPublicKey, "_langfuse"); | ||
_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); | ||
} else { | ||
_this._storageKey = "lf_".concat(apiPublicKey, "_langfuse"); | ||
_this._storageKey = "lf_".concat(publicKey, "_langfuse"); | ||
_this._storage = getStorage('memory', undefined); | ||
@@ -825,13 +825,11 @@ } | ||
__extends(LangfuseWeb, _super); | ||
function LangfuseWeb(apiPublicKey, options) { | ||
if (options === void 0) { | ||
options = {}; | ||
} | ||
var _this = _super.call(this, apiPublicKey, options) || this; | ||
// posthog-js stores options in one object on | ||
function LangfuseWeb(params) { | ||
var _this = _super.call(this, params) || this; | ||
var publicKey = params.publicKey, | ||
options = __rest(params, ["publicKey"]); | ||
if (typeof window !== 'undefined') { | ||
_this._storageKey = (options === null || options === void 0 ? void 0 : options.persistence_name) ? "lf_".concat(options.persistence_name) : "lf_".concat(apiPublicKey, "_langfuse"); | ||
_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); | ||
} else { | ||
_this._storageKey = "lf_".concat(apiPublicKey, "_langfuse"); | ||
_this._storageKey = "lf_".concat(publicKey, "_langfuse"); | ||
_this._storage = getStorage('memory', undefined); | ||
@@ -871,5 +869,5 @@ } | ||
return LangfuseWeb; | ||
}(LangfusePublic); | ||
}(LangfuseWebStateless); | ||
export { Langfuse, LangfuseWeb, Langfuse as default }; | ||
//# sourceMappingURL=index.esm.js.map |
@@ -6,4 +6,4 @@ import { LangfuseFetchOptions, LangfuseFetchResponse, LangfuseCoreOptions, LangfusePersistedProperty, CreateLangfuseTraceBody, LangfuseObject, CreateLangfuseEventBody, CreateLangfuseSpanBody, CreateLangfuseGenerationBody, CreateLangfuseScoreBody, UpdateLangfuseSpanBody, UpdateLangfuseGenerationBody } from './types'; | ||
declare abstract class LangfuseCoreStateless { | ||
private apiSecretKey; | ||
private apiPublicKey; | ||
private secretKey; | ||
private publicKey; | ||
host: string; | ||
@@ -24,3 +24,6 @@ private flushAt; | ||
abstract setPersistedProperty<T>(key: LangfusePersistedProperty, value: T | null): void; | ||
constructor(apiPublicKey: string, apiSecretKey?: string, options?: LangfuseCoreOptions); | ||
constructor(params: { | ||
publicKey: string; | ||
secretKey?: string; | ||
} & LangfuseCoreOptions); | ||
protected getCommonEventProperties(): any; | ||
@@ -51,8 +54,13 @@ on(event: string, cb: (...args: any[]) => void): () => void; | ||
} | ||
export declare abstract class LangfusePublic extends LangfuseCoreStateless { | ||
constructor(apiPublicKey: string, options?: LangfuseCoreOptions); | ||
export declare abstract class LangfuseWebStateless extends LangfuseCoreStateless { | ||
constructor(params: { | ||
publicKey: string; | ||
} & LangfuseCoreOptions); | ||
score(body: CreateLangfuseScoreBody): this; | ||
} | ||
export declare abstract class LangfuseCore extends LangfuseCoreStateless { | ||
constructor(apiPublicKey: string, apiSecretKey: string, options?: LangfuseCoreOptions); | ||
constructor(params: { | ||
publicKey: string; | ||
secretKey: string; | ||
} & LangfuseCoreOptions); | ||
trace(body: CreateLangfuseTraceBody): LangfuseTraceClient; | ||
@@ -59,0 +67,0 @@ span(body: CreateLangfuseSpanBody): LangfuseSpanClient; |
@@ -1,2 +0,2 @@ | ||
import { LangfuseCore, LangfusePublic, LangfuseFetchOptions, LangfuseFetchResponse, LangfusePersistedProperty } from '../../langfuse-core/src'; | ||
import { LangfuseCore, LangfuseWebStateless, LangfuseFetchOptions, LangfuseFetchResponse, LangfusePersistedProperty } from '../../langfuse-core/src'; | ||
import { LangfuseOptions } from './types'; | ||
@@ -7,3 +7,6 @@ export declare class Langfuse extends LangfuseCore { | ||
private _storageKey; | ||
constructor(apiPublicKey: string, apiSecretKey: string, options?: LangfuseOptions); | ||
constructor(params: { | ||
publicKey: string; | ||
secretKey: string; | ||
} & LangfuseOptions); | ||
getPersistedProperty<T>(key: LangfusePersistedProperty): T | undefined; | ||
@@ -16,7 +19,9 @@ setPersistedProperty<T>(key: LangfusePersistedProperty, value: T | null): void; | ||
} | ||
export declare class LangfuseWeb extends LangfusePublic { | ||
export declare class LangfuseWeb extends LangfuseWebStateless { | ||
private _storage; | ||
private _storageCache; | ||
private _storageKey; | ||
constructor(apiPublicKey: string, options?: LangfuseOptions); | ||
constructor(params: { | ||
publicKey: string; | ||
} & LangfuseOptions); | ||
getPersistedProperty<T>(key: LangfusePersistedProperty): T | undefined; | ||
@@ -23,0 +28,0 @@ setPersistedProperty<T>(key: LangfusePersistedProperty, value: T | null): void; |
{ | ||
"name": "langfuse", | ||
"version": "0.1.0-beta.1", | ||
"version": "0.1.0-beta.2", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "Langfuse", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
3549
309747