@snf/qa-bot-core 0.2.11-rc.4 → 0.2.12
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/README.md +43 -1
- package/build/static/js/main.js +1 -1
- package/build/static/js/main.js.map +1 -1
- package/dist/qa-bot-core.js +1 -1
- package/dist/qa-bot-core.js.map +1 -1
- package/dist/qa-bot-core.standalone.js +4 -4
- package/dist/qa-bot-core.standalone.js.map +1 -1
- package/dist/qa-bot-core.umd.cjs +1 -1
- package/dist/qa-bot-core.umd.cjs.map +1 -1
- package/dist/types/config.d.ts +18 -9
- package/dist/types/contexts/AnalyticsContext.d.ts +11 -3
- package/dist/types/utils/flows/qa-flow.d.ts +4 -4
- package/dist/types/utils/logger.d.ts +1 -1
- package/package.json +1 -1
package/dist/types/config.d.ts
CHANGED
|
@@ -5,20 +5,29 @@ import type { Settings, Flow } from 'react-chatbotify';
|
|
|
5
5
|
export type QABotAnalyticsEventType = 'qa_bot_opened' | 'qa_bot_closed' | 'qa_new_chat_started' | 'qa_question_asked' | 'qa_response_received' | 'qa_response_error' | 'qa_response_rated' | 'qa_login_prompt_shown';
|
|
6
6
|
/**
|
|
7
7
|
* Analytics event payload
|
|
8
|
-
*
|
|
9
|
-
* -
|
|
10
|
-
* -
|
|
11
|
-
* -
|
|
12
|
-
* -
|
|
13
|
-
* -
|
|
14
|
-
*
|
|
15
|
-
* -
|
|
16
|
-
* -
|
|
8
|
+
*
|
|
9
|
+
* Common fields (auto-populated for all events):
|
|
10
|
+
* - timestamp: When the event occurred
|
|
11
|
+
* - sessionId: Current chat session ID
|
|
12
|
+
* - pageUrl: URL where the bot is displayed
|
|
13
|
+
* - isEmbedded: Whether bot is in embedded mode (true) or floating/widget mode (false)
|
|
14
|
+
*
|
|
15
|
+
* Event-specific fields:
|
|
16
|
+
* - qa_bot_opened: (common fields only)
|
|
17
|
+
* - qa_bot_closed: messageCount, durationMs
|
|
18
|
+
* - qa_new_chat_started: previousMessageCount
|
|
19
|
+
* - qa_question_asked: queryId, questionLength
|
|
20
|
+
* - qa_response_received: queryId, responseTimeMs, success, responseLength, hasMetadata
|
|
21
|
+
* - qa_response_error: queryId, errorType
|
|
22
|
+
* - qa_response_rated: queryId, rating
|
|
23
|
+
* - qa_login_prompt_shown: (common fields only)
|
|
17
24
|
*/
|
|
18
25
|
export interface QABotAnalyticsEvent {
|
|
19
26
|
type: QABotAnalyticsEventType;
|
|
20
27
|
timestamp: number;
|
|
21
28
|
sessionId?: string;
|
|
29
|
+
pageUrl?: string;
|
|
30
|
+
isEmbedded?: boolean;
|
|
22
31
|
queryId?: string;
|
|
23
32
|
questionLength?: number;
|
|
24
33
|
responseTimeMs?: number;
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { QABotAnalyticsEvent } from '../config';
|
|
3
|
+
/**
|
|
4
|
+
* Event type without auto-populated fields.
|
|
5
|
+
* Call sites provide event-specific data; common fields are added by the enriched tracker.
|
|
6
|
+
*/
|
|
7
|
+
export type AnalyticsEventInput = Omit<QABotAnalyticsEvent, 'timestamp' | 'sessionId' | 'pageUrl' | 'isEmbedded'>;
|
|
3
8
|
interface AnalyticsContextValue {
|
|
4
|
-
trackEvent: (event:
|
|
9
|
+
trackEvent: (event: AnalyticsEventInput) => void;
|
|
5
10
|
}
|
|
6
11
|
interface AnalyticsProviderProps {
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Pre-enriched track function that adds common fields (timestamp, sessionId, pageUrl, isEmbedded).
|
|
14
|
+
* Created by QABot and passed down to ensure consistent enrichment across all call sites.
|
|
15
|
+
*/
|
|
16
|
+
trackEvent: (event: AnalyticsEventInput) => void;
|
|
9
17
|
children: React.ReactNode;
|
|
10
18
|
}
|
|
11
19
|
export declare const AnalyticsProvider: React.FC<AnalyticsProviderProps>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AnalyticsEventInput } from '../../contexts/AnalyticsContext';
|
|
3
3
|
/**
|
|
4
4
|
* Configuration for creating a Q&A flow
|
|
5
5
|
*/
|
|
@@ -22,14 +22,14 @@ export interface CreateQAFlowParams {
|
|
|
22
22
|
loginUrl?: string;
|
|
23
23
|
/** The acting user's identifier (optional) */
|
|
24
24
|
actingUser?: string;
|
|
25
|
-
/**
|
|
26
|
-
|
|
25
|
+
/** Enriched analytics tracker (adds common fields automatically) */
|
|
26
|
+
trackEvent?: (event: AnalyticsEventInput) => void;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* Creates the basic Q&A conversation flow
|
|
30
30
|
* Handles questions, responses, and optional ratings
|
|
31
31
|
*/
|
|
32
|
-
export declare const createQAFlow: ({ endpoint, ratingEndpoint, apiKey, sessionId: getSessionId, isResetting, isLoggedIn, allowAnonAccess, loginUrl, actingUser,
|
|
32
|
+
export declare const createQAFlow: ({ endpoint, ratingEndpoint, apiKey, sessionId: getSessionId, isResetting, isLoggedIn, allowAnonAccess, loginUrl, actingUser, trackEvent }: CreateQAFlowParams) => {
|
|
33
33
|
qa_loop: {
|
|
34
34
|
message: string;
|
|
35
35
|
component: React.JSX.Element;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Usage for consumers:
|
|
8
8
|
* localStorage.setItem('QA_BOT_DEBUG', 'true'); // Enable debug logs + version
|
|
9
9
|
*/
|
|
10
|
-
export declare const LIB_VERSION = "0.2.
|
|
10
|
+
export declare const LIB_VERSION = "0.2.12";
|
|
11
11
|
export declare const logger: {
|
|
12
12
|
version: () => void;
|
|
13
13
|
session: (action: string, ...args: unknown[]) => void;
|
package/package.json
CHANGED