guideai-app 0.3.1 → 0.3.4
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 +138 -246
- 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/logger.d.ts +41 -0
- package/dist/utils/workflow.d.ts +62 -0
- package/metadata-tracking-example.md +324 -0
- package/obfuscate.js +40 -0
- package/obfuscator.prod.json +24 -0
- package/package.json +1 -1
- package/structure.md +128 -0
- package/text-input-usage.md +321 -0
- package/transcript-toggle-usage.md +267 -0
- package/visit-tracking-usage.md +134 -0
- package/components/Styles.d.ts +0 -3
- package/types/index.d.ts +0 -24
|
@@ -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
|
-
}
|