@meistrari/chat-nuxt 3.6.0 → 3.7.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/module.d.mts +2 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +4 -1
- package/dist/runtime/conversations/composables/conversations.js +5 -0
- package/dist/runtime/embed/components/chat-embed-inner.vue +38 -2
- package/dist/runtime/server/utils/chat-api-proxy.js +10 -1
- package/dist/runtime/shared/composables/feature-flags.d.ts +8 -1
- package/dist/runtime/shared/composables/feature-flags.js +10 -1
- package/dist/runtime/types/schemas/chat/usage.d.ts +2 -0
- package/dist/runtime/types/schemas/chat/usage.js +1 -0
- package/package.json +1 -1
package/dist/module.d.mts
CHANGED
|
@@ -6,6 +6,8 @@ type ChatNuxtConfigValidationMode = false | 'warn' | 'error';
|
|
|
6
6
|
interface ChatNuxtModuleOptions {
|
|
7
7
|
/** Dedicated Chat API base URL used by Nuxt server routes. */
|
|
8
8
|
chatApiUrl?: string;
|
|
9
|
+
/** Host app identifier reported to the chat-api (e.g. `'chat-app'`). */
|
|
10
|
+
source?: string;
|
|
9
11
|
/**
|
|
10
12
|
* Whether to fail fast (`'error'`), warn (`'warn'`), or skip (`false`) when
|
|
11
13
|
* required runtime config keys are unset.
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -149,6 +149,7 @@ function resolveWorkspaceSettingsResolverEntry(srcDir, fallbackResolverBase) {
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
const _chatNuxtRequire = createRequire(import.meta.url);
|
|
152
|
+
const _chatNuxtPackageVersion = _chatNuxtRequire("../package.json").version;
|
|
152
153
|
const VUE_COMPONENT_EXTENSIONS = [".vue"];
|
|
153
154
|
const FEATURE_DIRS = ["conversations", "embed", "files", "messages", "rendering", "shared", "usage", "workspace"];
|
|
154
155
|
const FULL_NAME_COMPONENT_DIRS = ["conversations", "embed", "files", "messages", "usage"];
|
|
@@ -358,7 +359,9 @@ const module$1 = defineNuxtModule({
|
|
|
358
359
|
rc.public = rc.public || {};
|
|
359
360
|
const existingChatNuxtRuntimeConfig = rc.chatNuxt;
|
|
360
361
|
rc.chatNuxt = {
|
|
361
|
-
chatApiUrl: existingChatNuxtRuntimeConfig?.chatApiUrl || rc.chatApiUrl
|
|
362
|
+
chatApiUrl: existingChatNuxtRuntimeConfig?.chatApiUrl || rc.chatApiUrl,
|
|
363
|
+
source: options.source || existingChatNuxtRuntimeConfig?.source,
|
|
364
|
+
clientVersion: _chatNuxtPackageVersion
|
|
362
365
|
};
|
|
363
366
|
validateRuntimeConfig(rc, options.validateConfig ?? false);
|
|
364
367
|
nuxt.options.css = nuxt.options.css || [];
|
|
@@ -293,6 +293,7 @@ export function useConversations() {
|
|
|
293
293
|
};
|
|
294
294
|
const createConversation = async (input) => {
|
|
295
295
|
error.value = null;
|
|
296
|
+
const statusToast = useStatusToast();
|
|
296
297
|
const requestRuntimeScope = runtimeScope.value;
|
|
297
298
|
const metadataSnapshot = snapshotConversationMetadata(requestRuntimeScope);
|
|
298
299
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -333,6 +334,10 @@ export function useConversations() {
|
|
|
333
334
|
restoreConversationMetadata(requestRuntimeScope, metadataSnapshot);
|
|
334
335
|
const message = err instanceof Error ? err.message : "Erro ao criar conversa";
|
|
335
336
|
error.value = message;
|
|
337
|
+
statusToast.update({
|
|
338
|
+
text: "Erro ao criar conversa",
|
|
339
|
+
icon: "i-ph-warning"
|
|
340
|
+
});
|
|
336
341
|
return null;
|
|
337
342
|
}
|
|
338
343
|
};
|
|
@@ -398,6 +398,32 @@ const editTitle = ref("");
|
|
|
398
398
|
const justStartedEditing = ref(false);
|
|
399
399
|
const showDebugModal = ref(false);
|
|
400
400
|
const debugSessionId = computed(() => currentConversation.value?.threadSessionId ?? "Sess\xE3o ainda n\xE3o criada");
|
|
401
|
+
async function copyDebugInfo() {
|
|
402
|
+
const conversation = currentConversation.value;
|
|
403
|
+
const conversationId = conversation?.id ?? activeConversationId.value;
|
|
404
|
+
const sessionId = conversation?.threadSessionId ?? null;
|
|
405
|
+
const telaAgentId = conversation?.telaAgentId ?? null;
|
|
406
|
+
const createdAt = conversation?.createdAt ? new Date(conversation.createdAt) : null;
|
|
407
|
+
const datadogTimeRange = createdAt ? `&from_ts=${createdAt.getTime()}&to_ts=${Date.now()}&live=false` : "";
|
|
408
|
+
const datadogLogsUrl = (facet, value) => `https://us5.datadoghq.com/logs?query=${encodeURIComponent(`@${facet}:${value}`)}${datadogTimeRange}`;
|
|
409
|
+
const environment = useRuntimeConfig().public.environment;
|
|
410
|
+
const telaAppUrl = environment === "production" ? "https://app.tela.com" : "https://app.telastaging.com";
|
|
411
|
+
const debugInfo = {
|
|
412
|
+
conversationId: conversationId ?? null,
|
|
413
|
+
sessionId,
|
|
414
|
+
telaAgentId,
|
|
415
|
+
createdAt: createdAt?.toISOString() ?? null,
|
|
416
|
+
seeConversationInDatadog: conversationId ? datadogLogsUrl("conversationId", conversationId) : null,
|
|
417
|
+
seeSessionInDatadog: sessionId ? datadogLogsUrl("sessionId", sessionId) : null,
|
|
418
|
+
linkToTelaAgent: telaAgentId ? `${telaAppUrl}/agent/${telaAgentId}` : null
|
|
419
|
+
};
|
|
420
|
+
try {
|
|
421
|
+
await navigator.clipboard.writeText(JSON.stringify(debugInfo, null, 2));
|
|
422
|
+
statusToast.update({ text: "Dados de debug copiados", icon: "i-ph-check" });
|
|
423
|
+
} catch {
|
|
424
|
+
statusToast.update({ text: "Erro ao copiar dados de debug", icon: "i-ph-warning" });
|
|
425
|
+
}
|
|
426
|
+
}
|
|
401
427
|
function startEditing() {
|
|
402
428
|
editTitle.value = displayTitle.value;
|
|
403
429
|
isEditing.value = true;
|
|
@@ -888,7 +914,7 @@ async function handleDelete() {
|
|
|
888
914
|
<div flex="~ col" w-full my-24px gap-24px>
|
|
889
915
|
<div flex="~ col" gap-4px w-full>
|
|
890
916
|
<p text-14px font-580 text-gray-700 leading-18px>
|
|
891
|
-
|
|
917
|
+
Conversation Id
|
|
892
918
|
</p>
|
|
893
919
|
<div
|
|
894
920
|
px-12px py-10px
|
|
@@ -906,7 +932,7 @@ async function handleDelete() {
|
|
|
906
932
|
</div>
|
|
907
933
|
<div flex="~ col" gap-4px w-full>
|
|
908
934
|
<p text-14px font-580 text-gray-700 leading-18px>
|
|
909
|
-
|
|
935
|
+
Session Id
|
|
910
936
|
</p>
|
|
911
937
|
<div
|
|
912
938
|
px-12px py-10px
|
|
@@ -923,6 +949,16 @@ async function handleDelete() {
|
|
|
923
949
|
</div>
|
|
924
950
|
</div>
|
|
925
951
|
</div>
|
|
952
|
+
<template #footer>
|
|
953
|
+
<div flex justify-between items-center gap-12px w-full>
|
|
954
|
+
<p text-12px font-400 leading-16px text-tertiary>
|
|
955
|
+
Inclui os ids da conversa e os links de debug no Datadog e no Tela
|
|
956
|
+
</p>
|
|
957
|
+
<TelaButton variant="primary" icon="i-ph-copy" leading flex-shrink-0 @click="copyDebugInfo">
|
|
958
|
+
Copiar dados completos
|
|
959
|
+
</TelaButton>
|
|
960
|
+
</div>
|
|
961
|
+
</template>
|
|
926
962
|
</TelaModal>
|
|
927
963
|
</div>
|
|
928
964
|
|
|
@@ -58,8 +58,17 @@ function buildProxyHeaders(event) {
|
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
60
|
const headers = {
|
|
61
|
-
authorization: `Bearer ${token}
|
|
61
|
+
"authorization": `Bearer ${token}`,
|
|
62
|
+
"x-chat-client": "chat-nuxt"
|
|
62
63
|
};
|
|
64
|
+
const config = useRuntimeConfig(event);
|
|
65
|
+
if (config.chatNuxt?.clientVersion) {
|
|
66
|
+
headers["x-chat-client-version"] = config.chatNuxt.clientVersion;
|
|
67
|
+
}
|
|
68
|
+
const source = config.chatNuxt?.source || getRequestURL(event).host;
|
|
69
|
+
if (source) {
|
|
70
|
+
headers["x-chat-source"] = source;
|
|
71
|
+
}
|
|
63
72
|
for (const headerName of CHAT_COMPAT_HEADERS) {
|
|
64
73
|
const value = getHeader(event, headerName)?.trim();
|
|
65
74
|
if (value) {
|
|
@@ -8,7 +8,14 @@ type Workspace = {
|
|
|
8
8
|
id: string;
|
|
9
9
|
name?: string | null;
|
|
10
10
|
};
|
|
11
|
-
export
|
|
11
|
+
export type PosthogLogsOptions = {
|
|
12
|
+
captureConsoleLogs?: boolean;
|
|
13
|
+
/** Shown as `service.name` in the PostHog Logs UI. Defaults to `unknown_service`. */
|
|
14
|
+
serviceName?: string;
|
|
15
|
+
/** Shown as `deployment.environment` in the PostHog Logs UI. */
|
|
16
|
+
environment?: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function initPosthog(publicKey: string, host: string, defaults: string, logs?: PosthogLogsOptions): Promise<void>;
|
|
12
19
|
export declare function identifyPosthogUser(user: AuthUser): void;
|
|
13
20
|
export declare function resetPosthogIdentity(): void;
|
|
14
21
|
export declare function setPosthogWorkspace(workspace: Workspace): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const posthogClient = shallowRef(null);
|
|
2
2
|
const flagsVersion = ref(0);
|
|
3
3
|
let identifiedUserFingerprint = null;
|
|
4
|
-
export async function initPosthog(publicKey, host, defaults) {
|
|
4
|
+
export async function initPosthog(publicKey, host, defaults, logs) {
|
|
5
5
|
if (posthogClient.value)
|
|
6
6
|
return;
|
|
7
7
|
try {
|
|
@@ -10,6 +10,15 @@ export async function initPosthog(publicKey, host, defaults) {
|
|
|
10
10
|
api_host: host,
|
|
11
11
|
defaults,
|
|
12
12
|
person_profiles: "identified_only",
|
|
13
|
+
// serviceName/environment are supported at runtime but missing
|
|
14
|
+
// from PostHogConfig['logs'] in the pinned posthog-js version.
|
|
15
|
+
...logs?.captureConsoleLogs ? {
|
|
16
|
+
logs: {
|
|
17
|
+
captureConsoleLogs: true,
|
|
18
|
+
serviceName: logs.serviceName,
|
|
19
|
+
environment: logs.environment
|
|
20
|
+
}
|
|
21
|
+
} : {},
|
|
13
22
|
loaded: (c) => {
|
|
14
23
|
if (import.meta.dev)
|
|
15
24
|
c.debug();
|
|
@@ -183,6 +183,7 @@ export declare const workspaceUsageResponseSchema: z.ZodObject<{
|
|
|
183
183
|
export type WorkspaceUsageResponse = z.infer<typeof workspaceUsageResponseSchema>;
|
|
184
184
|
export declare const dailyUsageRowSchema: z.ZodObject<{
|
|
185
185
|
workspaceId: z.ZodString;
|
|
186
|
+
source: z.ZodNullable<z.ZodString>;
|
|
186
187
|
totalTokens: z.ZodNumber;
|
|
187
188
|
totalCost: z.ZodNumber;
|
|
188
189
|
promptTokens: z.ZodNumber;
|
|
@@ -196,6 +197,7 @@ export type DailyUsageRow = z.infer<typeof dailyUsageRowSchema>;
|
|
|
196
197
|
export declare const dailyUsageResponseSchema: z.ZodObject<{
|
|
197
198
|
rows: z.ZodArray<z.ZodObject<{
|
|
198
199
|
workspaceId: z.ZodString;
|
|
200
|
+
source: z.ZodNullable<z.ZodString>;
|
|
199
201
|
totalTokens: z.ZodNumber;
|
|
200
202
|
totalCost: z.ZodNumber;
|
|
201
203
|
promptTokens: z.ZodNumber;
|