@gymmymac/bob-widget 1.2.2 → 1.4.3
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/BobProvider.d.ts +38 -1
- package/dist/components/BobWidget.d.ts +17 -0
- package/dist/hooks/useBobAnalytics.d.ts +77 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.js +13 -13
- package/dist/index.mjs +2389 -2066
- package/dist/style.css +1 -1
- package/dist/types/analytics.d.ts +99 -0
- package/dist/types/context.d.ts +12 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/product.d.ts +4 -0
- package/package.json +2 -2
package/dist/BobProvider.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { ReactNode } from 'react';
|
|
|
2
2
|
import { SupabaseClient } from '@supabase/supabase-js';
|
|
3
3
|
import { QueryClient } from '@tanstack/react-query';
|
|
4
4
|
import { BobConfig, HostApiConfig, HostContext, BobCallbacks } from './types';
|
|
5
|
+
import { BobGA4Config } from './types/analytics';
|
|
6
|
+
import { useBobAnalytics } from './hooks/useBobAnalytics';
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* Internal context value structure
|
|
@@ -19,6 +21,14 @@ interface BobContextValue {
|
|
|
19
21
|
callbacks: BobCallbacks;
|
|
20
22
|
/** Update host context (for dynamic updates) */
|
|
21
23
|
updateHostContext: (updates: Partial<HostContext>) => void;
|
|
24
|
+
/** GA4 configuration */
|
|
25
|
+
ga4Config?: BobGA4Config;
|
|
26
|
+
/** Whether analytics is enabled */
|
|
27
|
+
analyticsEnabled: boolean;
|
|
28
|
+
/** Bottom offset in pixels for host navigation bars */
|
|
29
|
+
bottomOffset: number;
|
|
30
|
+
/** Base z-index for Bob's UI elements */
|
|
31
|
+
zIndexBase: number;
|
|
22
32
|
}
|
|
23
33
|
interface BobProviderProps {
|
|
24
34
|
children: ReactNode;
|
|
@@ -32,6 +42,14 @@ interface BobProviderProps {
|
|
|
32
42
|
callbacks?: BobCallbacks;
|
|
33
43
|
/** Optional external QueryClient - if not provided, an internal one is created */
|
|
34
44
|
queryClient?: QueryClient;
|
|
45
|
+
/** GA4 configuration for analytics */
|
|
46
|
+
ga4Config?: BobGA4Config;
|
|
47
|
+
/** Enable/disable analytics tracking */
|
|
48
|
+
analyticsEnabled?: boolean;
|
|
49
|
+
/** Bottom offset in pixels for host navigation bars */
|
|
50
|
+
bottomOffset?: number;
|
|
51
|
+
/** Base z-index for Bob's UI elements */
|
|
52
|
+
zIndexBase?: number;
|
|
35
53
|
}
|
|
36
54
|
/**
|
|
37
55
|
* BobProvider - Context provider for the Bob widget
|
|
@@ -65,7 +83,7 @@ interface BobProviderProps {
|
|
|
65
83
|
* </BobProvider>
|
|
66
84
|
* ```
|
|
67
85
|
*/
|
|
68
|
-
export declare function BobProvider({ children, bobConfig, hostApiConfig, hostContext: initialHostContext, callbacks, queryClient: externalQueryClient, }: BobProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
86
|
+
export declare function BobProvider({ children, bobConfig, hostApiConfig, hostContext: initialHostContext, callbacks, queryClient: externalQueryClient, ga4Config, analyticsEnabled, bottomOffset, zIndexBase, }: BobProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
69
87
|
/**
|
|
70
88
|
* Hook to access Bob context
|
|
71
89
|
* Must be used within a BobProvider
|
|
@@ -87,4 +105,23 @@ export declare function useHostApiConfig(): HostApiConfig;
|
|
|
87
105
|
* Hook to access Bob callbacks
|
|
88
106
|
*/
|
|
89
107
|
export declare function useBobCallbacks(): BobCallbacks;
|
|
108
|
+
/**
|
|
109
|
+
* Hook to access GA4 config and analytics status
|
|
110
|
+
*/
|
|
111
|
+
export declare function useBobAnalyticsConfig(): {
|
|
112
|
+
ga4Config?: BobGA4Config;
|
|
113
|
+
enabled: boolean;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Hook to access layout configuration (bottomOffset, zIndexBase)
|
|
117
|
+
* Returns safe defaults when used outside BobProvider (for demo/standalone usage)
|
|
118
|
+
*/
|
|
119
|
+
export declare function useBobLayoutConfig(): {
|
|
120
|
+
bottomOffset: number;
|
|
121
|
+
zIndexBase: number;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Re-export the analytics hook with context wiring
|
|
125
|
+
*/
|
|
126
|
+
export { useBobAnalytics };
|
|
90
127
|
export default BobProvider;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { BobVariant } from './Bob';
|
|
3
3
|
import { BobConfig, HostApiConfig, HostContext, BobCallbacks } from '../types';
|
|
4
|
+
import { BobGA4Config } from '../types/analytics';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Props for the self-contained BobWidget component
|
|
@@ -34,6 +35,22 @@ export interface BobWidgetProps {
|
|
|
34
35
|
verticalOffset?: number;
|
|
35
36
|
/** Scale percentage for Bob character */
|
|
36
37
|
scale?: number;
|
|
38
|
+
/** GA4 configuration for analytics */
|
|
39
|
+
ga4Config?: BobGA4Config;
|
|
40
|
+
/** Enable/disable analytics tracking */
|
|
41
|
+
analyticsEnabled?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Bottom offset in pixels for host navigation bars.
|
|
44
|
+
* Bob's UI will be positioned this many pixels above the viewport bottom.
|
|
45
|
+
* Use this when your host site has a bottom navigation bar.
|
|
46
|
+
* @example bottomOffset={60} // For a 60px bottom nav
|
|
47
|
+
*/
|
|
48
|
+
bottomOffset?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Base z-index for Bob's UI elements. Default: 50
|
|
51
|
+
* Bob calculates internal z-indexes relative to this base.
|
|
52
|
+
*/
|
|
53
|
+
zIndexBase?: number;
|
|
37
54
|
}
|
|
38
55
|
/**
|
|
39
56
|
* BobWidget - Self-contained Bob widget component
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { BobEventName, BobGA4Config } from '../types/analytics';
|
|
2
|
+
import { HostContext, BobCallbacks } from '../types/context';
|
|
3
|
+
|
|
4
|
+
declare global {
|
|
5
|
+
interface Window {
|
|
6
|
+
gtag?: (command: 'event', eventName: string, eventParams?: Record<string, unknown>) => void;
|
|
7
|
+
dataLayer?: unknown[];
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
interface UseBobAnalyticsProps {
|
|
11
|
+
/** GA4 configuration */
|
|
12
|
+
ga4Config?: BobGA4Config;
|
|
13
|
+
/** Host context for user/vehicle info */
|
|
14
|
+
hostContext?: HostContext;
|
|
15
|
+
/** Callbacks including onAnalyticsEvent */
|
|
16
|
+
callbacks?: BobCallbacks;
|
|
17
|
+
/** Whether analytics is enabled */
|
|
18
|
+
enabled?: boolean;
|
|
19
|
+
}
|
|
20
|
+
interface UseBobAnalyticsReturn {
|
|
21
|
+
/** Track any event */
|
|
22
|
+
trackEvent: (eventName: BobEventName, parameters?: Record<string, unknown>) => void;
|
|
23
|
+
/** Session ID for this widget instance */
|
|
24
|
+
sessionId: string;
|
|
25
|
+
/** Track session start */
|
|
26
|
+
trackSessionStart: () => void;
|
|
27
|
+
/** Track message sent */
|
|
28
|
+
trackMessageSent: (messageLength: number, hasVehicle: boolean) => void;
|
|
29
|
+
/** Track vehicle identified */
|
|
30
|
+
trackVehicleIdentified: (vehicle: {
|
|
31
|
+
make?: string;
|
|
32
|
+
model?: string;
|
|
33
|
+
year?: string | number;
|
|
34
|
+
rego?: string;
|
|
35
|
+
}) => void;
|
|
36
|
+
/** Track parts viewed */
|
|
37
|
+
trackPartsViewed: (partCount: number, vehicleId?: string) => void;
|
|
38
|
+
/** Track product clicked */
|
|
39
|
+
trackProductClicked: (product: {
|
|
40
|
+
sku: string;
|
|
41
|
+
product_name: string;
|
|
42
|
+
price: number;
|
|
43
|
+
brand?: string;
|
|
44
|
+
}) => void;
|
|
45
|
+
/** Track product viewed (detail) */
|
|
46
|
+
trackProductViewed: (product: {
|
|
47
|
+
sku: string;
|
|
48
|
+
product_name: string;
|
|
49
|
+
price: number;
|
|
50
|
+
brand?: string;
|
|
51
|
+
}) => void;
|
|
52
|
+
/** Track add to cart */
|
|
53
|
+
trackAddToCart: (product: {
|
|
54
|
+
sku: string;
|
|
55
|
+
product_name: string;
|
|
56
|
+
price: number;
|
|
57
|
+
brand?: string;
|
|
58
|
+
quantity?: number;
|
|
59
|
+
}) => void;
|
|
60
|
+
/** Track checkout started */
|
|
61
|
+
trackCheckoutStarted: (cartValue: number, itemCount: number) => void;
|
|
62
|
+
/** Track speech played */
|
|
63
|
+
trackSpeechPlayed: (textLength: number) => void;
|
|
64
|
+
/** Track speech failed */
|
|
65
|
+
trackSpeechFailed: (textLength: number) => void;
|
|
66
|
+
/** Track error */
|
|
67
|
+
trackError: (errorType: string, errorMessage: string) => void;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Hook for tracking Bob widget analytics events
|
|
71
|
+
*
|
|
72
|
+
* Sends events to:
|
|
73
|
+
* 1. GA4 via gtag() if configured and available
|
|
74
|
+
* 2. onAnalyticsEvent callback for server-side storage
|
|
75
|
+
*/
|
|
76
|
+
export declare function useBobAnalytics({ ga4Config, hostContext, callbacks, enabled, }: UseBobAnalyticsProps): UseBobAnalyticsReturn;
|
|
77
|
+
export default useBobAnalytics;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* AI-powered automotive parts assistant widget - Full immersive experience
|
|
5
5
|
*
|
|
6
|
-
* v1.
|
|
6
|
+
* v1.4.0 - Redesigned PTT button: 3x larger, green "TALK" text, floating cartoon style
|
|
7
|
+
* v1.3.1 - Bottom offset support for host navigation bars
|
|
8
|
+
* v1.3.0 - GA4 Analytics integration
|
|
7
9
|
*/
|
|
8
10
|
export { BOB_VERSION, getBobVersion } from './version';
|
|
9
|
-
export { BobProvider, useBobContext, useBobSupabase, useHostContext, useHostApiConfig, useBobCallbacks, } from './BobProvider';
|
|
11
|
+
export { BobProvider, useBobContext, useBobSupabase, useHostContext, useHostApiConfig, useBobCallbacks, useBobAnalyticsConfig, useBobAnalytics, useBobLayoutConfig, } from './BobProvider';
|
|
10
12
|
export { BobWidget } from './components/BobWidget';
|
|
11
13
|
export type { BobWidgetProps } from './components/BobWidget';
|
|
12
14
|
export { Bob } from './components/Bob';
|
|
@@ -21,8 +23,9 @@ export { useBobAnimationData } from './hooks/useBobAnimationData';
|
|
|
21
23
|
export { useBobStateTransitions } from './hooks/useBobStateTransitions';
|
|
22
24
|
export { useSpeechRecognition } from './hooks/useSpeechRecognition';
|
|
23
25
|
export { useBobBackdrop } from './hooks/useBobBackdrop';
|
|
24
|
-
export type { HostContext, HostUserContext, HostVehicleContext, HostCartContext, HostHistoryContext, BobConfig, HostApiConfig, BobCallbacks, BobProviderConfig, } from './types/context';
|
|
26
|
+
export type { HostContext, HostUserContext, HostVehicleContext, HostCartContext, HostHistoryContext, BobConfig, HostApiConfig, BobCallbacks, BobProviderConfig, BobLayoutConfig, } from './types/context';
|
|
25
27
|
export type { Vehicle } from './types/vehicle';
|
|
26
28
|
export type { Product, APIPart, CartItem, ServicePackage, } from './types/product';
|
|
27
29
|
export type { Message, HighlightedProduct, } from './types/message';
|
|
28
30
|
export type { BobAnimationConfig, AnimationStateDefinition, BobLook, BobAnimationData, } from './hooks/useBobAnimationData';
|
|
31
|
+
export type { BobEventName, BobAnalyticsEvent, BobGA4Config, SessionStartParams, MessageSentParams, VehicleIdentifiedParams, PartsViewedParams, ProductParams, CheckoutParams, SpeechParams, ErrorParams, } from './types/analytics';
|