@noodleseed/assistant 1.29.0 → 1.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-3VZ3M5BE.js → chunk-5EVZFPTD.js} +29 -2
- package/dist/chunk-5EVZFPTD.js.map +1 -0
- package/dist/{chunk-DOWFW3KA.js → chunk-PIYWT67H.js} +3 -3
- package/dist/{chunk-DOWFW3KA.js.map → chunk-PIYWT67H.js.map} +1 -1
- package/dist/client.cjs +31 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +1 -1
- package/dist/embed.global.js +38 -38
- package/dist/index.cjs +29 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/react/client.cjs +31 -1
- package/dist/react/client.cjs.map +1 -1
- package/dist/react/client.js +1 -1
- package/dist/react.cjs +29 -2
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-3VZ3M5BE.js.map +0 -1
package/dist/client.cjs
CHANGED
|
@@ -23408,6 +23408,9 @@ function resolveSessionSource(options) {
|
|
|
23408
23408
|
}
|
|
23409
23409
|
return { kind: "exchange", url: sessionEndpoint };
|
|
23410
23410
|
}
|
|
23411
|
+
function sessionSourceKey(options) {
|
|
23412
|
+
return `${options.embedId ?? ""}|${options.serviceUrl ?? ""}|${options.sessionEndpoint ?? ""}`;
|
|
23413
|
+
}
|
|
23411
23414
|
|
|
23412
23415
|
// src/transcript-replay.ts
|
|
23413
23416
|
function parseTranscriptEntries(value) {
|
|
@@ -23577,6 +23580,32 @@ function isAbortError2(error51) {
|
|
|
23577
23580
|
return error51 instanceof DOMException && error51.name === "AbortError";
|
|
23578
23581
|
}
|
|
23579
23582
|
|
|
23583
|
+
// src/visitor-id.ts
|
|
23584
|
+
var STORAGE_PREFIX = "noodleseed.assistant.visitor.";
|
|
23585
|
+
function randomVisitorId() {
|
|
23586
|
+
try {
|
|
23587
|
+
return globalThis.crypto.randomUUID();
|
|
23588
|
+
} catch {
|
|
23589
|
+
return void 0;
|
|
23590
|
+
}
|
|
23591
|
+
}
|
|
23592
|
+
function visitorIdForSource(sourceKey) {
|
|
23593
|
+
const key = `${STORAGE_PREFIX}${sourceKey}`;
|
|
23594
|
+
try {
|
|
23595
|
+
const stored = globalThis.localStorage?.getItem(key);
|
|
23596
|
+
if (typeof stored === "string" && stored.length > 0) return stored;
|
|
23597
|
+
} catch {
|
|
23598
|
+
return void 0;
|
|
23599
|
+
}
|
|
23600
|
+
const created = randomVisitorId();
|
|
23601
|
+
if (created === void 0) return void 0;
|
|
23602
|
+
try {
|
|
23603
|
+
globalThis.localStorage?.setItem(key, created);
|
|
23604
|
+
} catch {
|
|
23605
|
+
}
|
|
23606
|
+
return created;
|
|
23607
|
+
}
|
|
23608
|
+
|
|
23580
23609
|
// src/client.ts
|
|
23581
23610
|
var DefaultAssistantClient = class {
|
|
23582
23611
|
#source;
|
|
@@ -23971,11 +24000,12 @@ var DefaultAssistantClient = class {
|
|
|
23971
24000
|
}
|
|
23972
24001
|
async #createSession(signal) {
|
|
23973
24002
|
const source = this.#source;
|
|
24003
|
+
const visitorId = source.kind === "public" ? visitorIdForSource(sessionSourceKey({ embedId: source.embedId, serviceUrl: source.url })) : void 0;
|
|
23974
24004
|
const response = await this.#requestSession(source, {
|
|
23975
24005
|
method: "POST",
|
|
23976
24006
|
headers: { Accept: "application/json", "Content-Type": "application/json" },
|
|
23977
24007
|
body: JSON.stringify(
|
|
23978
|
-
source.kind === "public" ? { embedId: source.embedId } : this.#context ? { context: this.#context } : {}
|
|
24008
|
+
source.kind === "public" ? { embedId: source.embedId, ...visitorId ? { visitorId } : {} } : this.#context ? { context: this.#context } : {}
|
|
23979
24009
|
),
|
|
23980
24010
|
credentials: source.kind === "public" ? "omit" : "same-origin",
|
|
23981
24011
|
signal
|