guideai-app 0.3.0 → 0.3.2
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/GuideAI.js +1 -1
- package/dist/GuideAI.js.map +1 -1
- package/dist/components/TranscriptBox.d.ts +1 -1
- package/dist/metric/event-listner.d.ts +19 -0
- package/dist/metric/metadata-tracker.d.ts +12 -1
- package/dist/utils/api.d.ts +1 -3
- package/dist/utils/constants.d.ts +1 -1
- package/package.json +1 -1
- package/visit-tracking-usage.md +134 -0
- package/components/Styles.d.ts +0 -3
- package/types/index.d.ts +0 -24
|
@@ -13,5 +13,5 @@ interface TranscriptBoxProps {
|
|
|
13
13
|
onTextKeyPress?: (event: React.KeyboardEvent) => void;
|
|
14
14
|
textPlaceholder?: string;
|
|
15
15
|
}
|
|
16
|
-
declare const TranscriptBox: React.
|
|
16
|
+
declare const TranscriptBox: React.NamedExoticComponent<TranscriptBoxProps>;
|
|
17
17
|
export default TranscriptBox;
|
|
@@ -33,18 +33,31 @@ declare class EventTracker {
|
|
|
33
33
|
private pendingEvents;
|
|
34
34
|
private currentUrl;
|
|
35
35
|
private organizationKey?;
|
|
36
|
+
private lastEventTime;
|
|
37
|
+
private eventThrottleInterval;
|
|
38
|
+
private lastEventsByType;
|
|
39
|
+
private duplicateEventBuffer;
|
|
40
|
+
private maxDuplicateBuffer;
|
|
41
|
+
private isInitialized;
|
|
36
42
|
private customerMetadata;
|
|
37
43
|
constructor(options?: {
|
|
38
44
|
customerId?: string;
|
|
39
45
|
customerType?: string;
|
|
40
46
|
organizationId?: string;
|
|
41
47
|
organizationKey?: string;
|
|
48
|
+
batchSize?: number;
|
|
49
|
+
batchTimeout?: number;
|
|
50
|
+
eventThrottleInterval?: number;
|
|
42
51
|
});
|
|
52
|
+
private init;
|
|
53
|
+
private loadEventsFromStorage;
|
|
54
|
+
private saveEventsToStorage;
|
|
43
55
|
setCustomerMetadata(metadata: Partial<typeof this.customerMetadata>): void;
|
|
44
56
|
getCustomerMetadata(): typeof this.customerMetadata;
|
|
45
57
|
clearCustomerMetadata(): void;
|
|
46
58
|
initialize(): void;
|
|
47
59
|
private enrichEventData;
|
|
60
|
+
private sanitizeEventData;
|
|
48
61
|
private getSessionId;
|
|
49
62
|
private getDeviceType;
|
|
50
63
|
startTracking(): void;
|
|
@@ -65,6 +78,12 @@ declare class EventTracker {
|
|
|
65
78
|
private getSafeValue;
|
|
66
79
|
private isFocusable;
|
|
67
80
|
private isFormElement;
|
|
81
|
+
private generateEventKey;
|
|
82
|
+
private shouldThrottleEvent;
|
|
83
|
+
private isDuplicateEvent;
|
|
84
|
+
private isSignificantClickTarget;
|
|
85
|
+
private isSignificantFocusTarget;
|
|
86
|
+
private isSignificantRouteChange;
|
|
68
87
|
private logEvent;
|
|
69
88
|
private startBatchTimer;
|
|
70
89
|
private emitBatch;
|
|
@@ -6,11 +6,18 @@ declare class UserMetadataTracker {
|
|
|
6
6
|
private pendingUpdates;
|
|
7
7
|
private isInitialized;
|
|
8
8
|
private onError?;
|
|
9
|
+
private lastSyncTime;
|
|
10
|
+
private minSyncInterval;
|
|
11
|
+
private lastMetadataHash;
|
|
12
|
+
private pendingUpdateTypes;
|
|
9
13
|
constructor(organizationKey: string, config?: MetadataConfig, onError?: (error: Error, context: string) => void);
|
|
10
|
-
|
|
14
|
+
init(): void;
|
|
11
15
|
updateUserInfo(userInfo: Partial<UserMetadata>): void;
|
|
12
16
|
trackLogin(additionalInfo?: Partial<UserMetadata>): void;
|
|
17
|
+
private trackVisitOncePerSession;
|
|
13
18
|
trackVisit(): void;
|
|
19
|
+
resetSessionVisitTracking(): void;
|
|
20
|
+
trackVisitManually(): void;
|
|
14
21
|
trackCustomEvent(eventType: string, customData: Record<string, any>): void;
|
|
15
22
|
getMetadata(): UserMetadata;
|
|
16
23
|
getPendingUpdates(): MetadataUpdate[];
|
|
@@ -21,6 +28,10 @@ declare class UserMetadataTracker {
|
|
|
21
28
|
private collectBrowserInfo;
|
|
22
29
|
private parseBrowserInfo;
|
|
23
30
|
private startSyncTimer;
|
|
31
|
+
private shouldSync;
|
|
32
|
+
private addPendingUpdate;
|
|
33
|
+
private isDataDuplicate;
|
|
34
|
+
private generateDataHash;
|
|
24
35
|
private setupEventTrackerIntegration;
|
|
25
36
|
private stopSyncTimer;
|
|
26
37
|
private emitPendingUpdates;
|
package/dist/utils/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MetadataUpdate } from '../types/metadata.types';
|
|
2
2
|
interface ConversationData {
|
|
3
3
|
id: string;
|
|
4
4
|
ephemeralToken: string;
|
|
@@ -6,7 +6,5 @@ interface ConversationData {
|
|
|
6
6
|
}
|
|
7
7
|
export declare const createNewConversation: (organizationKey: string, onError: (error: Error, context: string) => void) => Promise<ConversationData | null>;
|
|
8
8
|
export declare const logMessage: (content: string, sender: "GUIDEAI" | "HUMAN", conversationId: string | null, organizationKey: string, onError: (error: Error, context: string) => void) => Promise<void>;
|
|
9
|
-
export declare const sendUserMetadata: (metadata: UserMetadata, organizationKey: string, onError: (error: Error, context: string) => void) => Promise<boolean>;
|
|
10
9
|
export declare const sendMetadataUpdates: (updates: MetadataUpdate[], organizationKey: string, onError: (error: Error, context: string) => void) => Promise<boolean>;
|
|
11
|
-
export declare const updateUserMetadata: (userId: string, metadataUpdate: Partial<UserMetadata>, organizationKey: string, onError: (error: Error, context: string) => void) => Promise<boolean>;
|
|
12
10
|
export {};
|
|
@@ -2,6 +2,6 @@ export declare const DEFAULT_PROMPT = "you are Guide AI.\n Your role is to
|
|
|
2
2
|
export declare const IGNORE_MESSAGE_TYPES: string[];
|
|
3
3
|
export declare const GUIDE_AI_API_BASE = "https://www.getguide.ai/api";
|
|
4
4
|
export declare const OPENAI_REALTIME_BASE = "https://api.openai.com/v1/realtime";
|
|
5
|
-
export declare const OPENAI_REALTIME_MODEL = "gpt-
|
|
5
|
+
export declare const OPENAI_REALTIME_MODEL = "gpt-realtime-2025-08-28";
|
|
6
6
|
export declare const GEMINI_API_KEY = "AIzaSyBiFyzjYVupLyk8BdmfWzBL1GbzX8OUdPc";
|
|
7
7
|
export declare const GEMINI_API_ENDPOINT = "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent";
|
package/package.json
CHANGED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# GuideAI Visit Tracking Usage
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
The GuideAI component now includes an improved visit tracking system that prevents continuous API calls and only tracks visits once per session.
|
|
6
|
+
|
|
7
|
+
## How It Works
|
|
8
|
+
|
|
9
|
+
### Automatic Visit Tracking
|
|
10
|
+
- **Session-based**: Visit tracking only occurs once per browser session
|
|
11
|
+
- **No continuous API calls**: The system prevents multiple visit tracking calls
|
|
12
|
+
- **Automatic initialization**: Visit tracking happens automatically when the component loads
|
|
13
|
+
|
|
14
|
+
### Manual Visit Tracking for Login Events
|
|
15
|
+
|
|
16
|
+
When a user logs in to your application, you can manually trigger visit tracking:
|
|
17
|
+
|
|
18
|
+
```javascript
|
|
19
|
+
// Reset session tracking and manually track a visit
|
|
20
|
+
window.GuideAI.metadata.resetSessionVisitTracking();
|
|
21
|
+
window.GuideAI.metadata.trackVisitManually();
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## API Methods
|
|
25
|
+
|
|
26
|
+
### `window.GuideAI.metadata.resetSessionVisitTracking()`
|
|
27
|
+
Resets the session visit tracking flag, allowing a new visit to be tracked.
|
|
28
|
+
|
|
29
|
+
### `window.GuideAI.metadata.trackVisitManually()`
|
|
30
|
+
Manually tracks a visit and increments the visit count. This is useful for login events.
|
|
31
|
+
|
|
32
|
+
### `window.GuideAI.metadata.trackLogin(additionalInfo?)`
|
|
33
|
+
Tracks a login event with optional additional user information.
|
|
34
|
+
|
|
35
|
+
## Usage Examples
|
|
36
|
+
|
|
37
|
+
### Basic Login Integration
|
|
38
|
+
|
|
39
|
+
```javascript
|
|
40
|
+
// When user successfully logs in
|
|
41
|
+
function onUserLogin(userData) {
|
|
42
|
+
// Reset session tracking to allow new visit tracking
|
|
43
|
+
window.GuideAI.metadata.resetSessionVisitTracking();
|
|
44
|
+
|
|
45
|
+
// Manually track the visit
|
|
46
|
+
window.GuideAI.metadata.trackVisitManually();
|
|
47
|
+
|
|
48
|
+
// Track the login event
|
|
49
|
+
window.GuideAI.metadata.trackLogin({
|
|
50
|
+
userId: userData.id,
|
|
51
|
+
userEmail: userData.email,
|
|
52
|
+
userRole: userData.role
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### React Component Integration
|
|
58
|
+
|
|
59
|
+
```jsx
|
|
60
|
+
import { useEffect } from 'react';
|
|
61
|
+
|
|
62
|
+
function LoginComponent() {
|
|
63
|
+
const handleLogin = async (credentials) => {
|
|
64
|
+
try {
|
|
65
|
+
const userData = await loginUser(credentials);
|
|
66
|
+
|
|
67
|
+
// Track visit and login after successful authentication
|
|
68
|
+
if (window.GuideAI?.metadata) {
|
|
69
|
+
window.GuideAI.metadata.resetSessionVisitTracking();
|
|
70
|
+
window.GuideAI.metadata.trackVisitManually();
|
|
71
|
+
window.GuideAI.metadata.trackLogin({
|
|
72
|
+
userId: userData.id,
|
|
73
|
+
userEmail: userData.email
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Navigate to dashboard
|
|
78
|
+
router.push('/dashboard');
|
|
79
|
+
} catch (error) {
|
|
80
|
+
console.error('Login failed:', error);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<form onSubmit={handleLogin}>
|
|
86
|
+
{/* Login form */}
|
|
87
|
+
</form>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Configuration
|
|
93
|
+
|
|
94
|
+
You can configure visit tracking behavior in the GuideAI component props:
|
|
95
|
+
|
|
96
|
+
```jsx
|
|
97
|
+
<GuideAI
|
|
98
|
+
organizationKey="your-org-key"
|
|
99
|
+
metadata={{
|
|
100
|
+
config: {
|
|
101
|
+
trackVisits: true, // Enable/disable visit tracking
|
|
102
|
+
trackLogins: true, // Enable/disable login tracking
|
|
103
|
+
syncInterval: 30000, // Sync interval in milliseconds
|
|
104
|
+
collectBrowserInfo: true, // Collect browser information
|
|
105
|
+
collectUserAgent: true // Collect user agent string
|
|
106
|
+
}
|
|
107
|
+
}}
|
|
108
|
+
/>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Benefits
|
|
112
|
+
|
|
113
|
+
1. **Reduced API calls**: Visit tracking only happens once per session
|
|
114
|
+
2. **Accurate analytics**: Proper visit counting without duplicates
|
|
115
|
+
3. **Login integration**: Manual tracking for login events
|
|
116
|
+
4. **Session management**: Automatic session-based tracking
|
|
117
|
+
5. **Performance**: No continuous background API calls
|
|
118
|
+
|
|
119
|
+
## Troubleshooting
|
|
120
|
+
|
|
121
|
+
### Visit tracking not working
|
|
122
|
+
- Ensure `trackVisits: true` is set in the metadata config
|
|
123
|
+
- Check browser console for any errors
|
|
124
|
+
- Verify the GuideAI component is properly initialized
|
|
125
|
+
|
|
126
|
+
### Multiple API calls still occurring
|
|
127
|
+
- Check if the component is being re-mounted multiple times
|
|
128
|
+
- Ensure you're not calling `trackVisitManually()` repeatedly
|
|
129
|
+
- Verify session storage is working in your browser
|
|
130
|
+
|
|
131
|
+
### Login tracking not working
|
|
132
|
+
- Ensure `trackLogins: true` is set in the metadata config
|
|
133
|
+
- Call `resetSessionVisitTracking()` before `trackVisitManually()`
|
|
134
|
+
- Check that the user is properly authenticated before tracking
|
package/components/Styles.d.ts
DELETED
package/types/index.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export interface ConversationItem {
|
|
2
|
-
event_id?: string;
|
|
3
|
-
type: string;
|
|
4
|
-
previous_item_id: string | null;
|
|
5
|
-
item: Record<string, any>;
|
|
6
|
-
timestamp: number;
|
|
7
|
-
}
|
|
8
|
-
export type RecordingStatus = 'idle' | 'recording' | 'processing' | 'playing' | 'initializing';
|
|
9
|
-
export interface GuideAIProps {
|
|
10
|
-
apiKey?: string;
|
|
11
|
-
organizationKey: string;
|
|
12
|
-
position?: {
|
|
13
|
-
top?: string;
|
|
14
|
-
right?: string;
|
|
15
|
-
bottom?: string;
|
|
16
|
-
left?: string;
|
|
17
|
-
marginTop?: string;
|
|
18
|
-
marginRight?: string;
|
|
19
|
-
marginBottom?: string;
|
|
20
|
-
marginLeft?: string;
|
|
21
|
-
transform?: string;
|
|
22
|
-
};
|
|
23
|
-
onError?: (error: string | Error, context?: string) => void;
|
|
24
|
-
}
|