guideai-app 0.3.5 → 0.4.2-1
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/API_DATA_CONTRACTS.md +516 -0
- package/API_SESSIONID_TESTING.md +215 -0
- package/GuideAI.js +1 -1
- package/GuideAI.js.map +1 -1
- package/PII_HASHING_EPIC.md +886 -0
- package/PII_HASHING_STORIES_SUMMARY.md +275 -0
- package/README.md +129 -0
- package/SESSION_ID_VERIFICATION.md +122 -0
- package/VISIT_COUNT_TESTING.md +453 -0
- package/dist/GuideAI.d.ts +1 -2
- package/dist/GuideAI.js +1 -1
- package/dist/GuideAI.js.LICENSE.txt +20 -0
- package/dist/GuideAI.js.map +1 -1
- package/dist/components/Onboarding.d.ts +2 -2
- package/dist/components/TranscriptBox.d.ts +10 -3
- package/dist/components/WelcomeBubble.d.ts +2 -2
- package/dist/index.d.ts +3 -0
- package/dist/metric/index.d.ts +0 -2
- package/dist/metric/metadata-tracker.d.ts +8 -2
- package/dist/styles/GuideAI.styles.d.ts +1 -1
- package/dist/types/GuideAI.types.d.ts +12 -6
- package/dist/types/metadata.types.d.ts +2 -0
- package/dist/utils/api.d.ts +18 -2
- package/dist/utils/constants.d.ts +1 -0
- package/dist/utils/elementInteractions.d.ts +92 -0
- package/dist/utils/gemini.d.ts +3 -0
- package/dist/utils/goToAElmLink.d.ts +1 -0
- package/dist/utils/highlightThenClick.d.ts +1 -0
- package/dist/utils/hoverThenClick.d.ts +1 -0
- package/dist/utils/logger.d.ts +37 -0
- package/dist/utils/session.d.ts +23 -0
- package/dist/utils/ui.d.ts +1 -1
- package/dist/utils/workflow.d.ts +62 -0
- package/dist/visualContext/VisualContextScheduler.d.ts +43 -0
- package/dist/visualContext/VisualContextStore.d.ts +11 -0
- package/dist/visualContext/debug-overlay.d.ts +10 -0
- package/dist/visualContext/defaultProvider.d.ts +15 -0
- package/dist/visualContext/index.d.ts +5 -0
- package/dist/visualContext/types.d.ts +45 -0
- package/index.d.ts +5 -1
- package/jest.config.js +26 -0
- package/jest.setup.js +21 -0
- package/metadata-tracking-example.md +11 -11
- package/package.json +15 -3
- package/structure.md +1 -1
- package/webpack.config.js +4 -15
- package/workflow-trigger-usage.md +398 -0
- package/dist/metric/event-listner.d.ts +0 -132
- package/dist/utils/highlight.d.ts +0 -2
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
# API SessionID Implementation - Testing Guide
|
|
2
|
+
|
|
3
|
+
## ✅ Implementation Complete
|
|
4
|
+
|
|
5
|
+
All metadata update methods now include `sessionId` in their data payloads to comply with backend validation requirements.
|
|
6
|
+
|
|
7
|
+
## What Changed
|
|
8
|
+
|
|
9
|
+
### UserMetadataTracker Updates
|
|
10
|
+
All 5 methods that call `addPendingUpdate()` now include `sessionId` in the data object:
|
|
11
|
+
|
|
12
|
+
1. ✅ **updateUserInfo()** - Line ~138
|
|
13
|
+
2. ✅ **trackLogin()** - Line ~173
|
|
14
|
+
3. ✅ **trackVisitIfNewSession()** - Line ~211
|
|
15
|
+
4. ✅ **trackVisitManually()** - Line ~274
|
|
16
|
+
5. ✅ **trackCustomEvent()** - Line ~311
|
|
17
|
+
|
|
18
|
+
### Event Tracking Status
|
|
19
|
+
⚠️ **EventTracker removed** - Event tracking has been removed from the frontend package.
|
|
20
|
+
|
|
21
|
+
## Testing Instructions
|
|
22
|
+
|
|
23
|
+
### 1. Deploy/Test the Updated Package
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# In testsite or wherever you're testing
|
|
27
|
+
npm install ../guide-ai-package
|
|
28
|
+
# or if already linked
|
|
29
|
+
npm run dev
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### 2. Open Browser DevTools
|
|
33
|
+
|
|
34
|
+
**Chrome/Firefox:**
|
|
35
|
+
- Press `F12` or `Cmd+Option+I` (Mac) / `Ctrl+Shift+I` (Windows)
|
|
36
|
+
- Go to **Network** tab
|
|
37
|
+
- Filter by: `metadata-updates` and `events`
|
|
38
|
+
|
|
39
|
+
### 3. Test /metadata-updates Endpoint
|
|
40
|
+
|
|
41
|
+
#### Trigger Metadata Updates:
|
|
42
|
+
- **Visit tracking**: Refresh the page (should trigger visit)
|
|
43
|
+
- **Login tracking**: Call `window.GuideAI.metadata.trackLogin()`
|
|
44
|
+
- **User info**: Call `window.GuideAI.metadata.updateUserInfo({ email: 'test@example.com' })`
|
|
45
|
+
|
|
46
|
+
#### Verify Request Payload:
|
|
47
|
+
Click on the `/metadata-updates` request in Network tab → **Payload** tab:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"organizationKey": "your-org-key",
|
|
52
|
+
"updates": [
|
|
53
|
+
{
|
|
54
|
+
"type": "visit",
|
|
55
|
+
"timestamp": 1234567890,
|
|
56
|
+
"data": {
|
|
57
|
+
"sessionId": "550e8400-e29b-41d4-a716-446655440000", // ✅ MUST BE PRESENT
|
|
58
|
+
"firstVisit": 1234567890,
|
|
59
|
+
"lastVisit": 1234567890,
|
|
60
|
+
"visitCount": 1
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
"batchTimestamp": 1234567890,
|
|
65
|
+
"updateCount": 1
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### Expected Response:
|
|
70
|
+
- ✅ **Status: 200** (Success)
|
|
71
|
+
- ❌ **Status: 400** (If sessionId is missing - should NOT happen)
|
|
72
|
+
|
|
73
|
+
### 4. Test /events Endpoint
|
|
74
|
+
|
|
75
|
+
#### Trigger Events:
|
|
76
|
+
- Click around the page
|
|
77
|
+
- Focus on input fields
|
|
78
|
+
- Submit forms
|
|
79
|
+
- Navigate between pages
|
|
80
|
+
|
|
81
|
+
#### Verify Request Payload:
|
|
82
|
+
Click on the `/events` request in Network tab → **Payload** tab:
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"organizationKey": "your-org-key",
|
|
87
|
+
"events": [
|
|
88
|
+
{
|
|
89
|
+
"type": "click",
|
|
90
|
+
"timestamp": 1234567890,
|
|
91
|
+
"url": "https://example.com/page",
|
|
92
|
+
"sessionId": "550e8400-e29b-41d4-a716-446655440000", // ✅ MUST BE PRESENT
|
|
93
|
+
"tagName": "BUTTON",
|
|
94
|
+
"className": "btn-primary",
|
|
95
|
+
"deviceType": "desktop",
|
|
96
|
+
"userAgent": "Mozilla/5.0..."
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
"batchTimestamp": 1234567890,
|
|
100
|
+
"eventCount": 1
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
#### Expected Response:
|
|
105
|
+
- ✅ **Status: 200** (Success)
|
|
106
|
+
- ❌ **Status: 400** (If sessionId is missing - should NOT happen)
|
|
107
|
+
|
|
108
|
+
## Validation Checklist
|
|
109
|
+
|
|
110
|
+
### /metadata-updates
|
|
111
|
+
- [ ] sessionId appears in every `updates[].data` object
|
|
112
|
+
- [ ] sessionId is a valid UUID format
|
|
113
|
+
- [ ] sessionId matches the one in sessionStorage
|
|
114
|
+
- [ ] API returns 200 (not 400)
|
|
115
|
+
- [ ] Backend logs show no sessionId warnings
|
|
116
|
+
|
|
117
|
+
### /events
|
|
118
|
+
- [ ] sessionId appears in every event object (at event level)
|
|
119
|
+
- [ ] sessionId is a valid UUID format
|
|
120
|
+
- [ ] sessionId matches the one in sessionStorage
|
|
121
|
+
- [ ] API returns 200 (not 400)
|
|
122
|
+
- [ ] Backend logs show no sessionId warnings
|
|
123
|
+
|
|
124
|
+
### Cross-Request Consistency
|
|
125
|
+
- [ ] Same sessionId across all events in same tab
|
|
126
|
+
- [ ] Same sessionId across all metadata updates in same tab
|
|
127
|
+
- [ ] Different sessionId in different browser tabs
|
|
128
|
+
- [ ] New sessionId after closing and reopening tab
|
|
129
|
+
|
|
130
|
+
## Common Issues & Solutions
|
|
131
|
+
|
|
132
|
+
### Issue: 400 Error - "sessionId is required"
|
|
133
|
+
**Cause**: sessionId is undefined or missing from data object
|
|
134
|
+
**Solution**:
|
|
135
|
+
1. Check sessionStorage has `guideai_session_id`
|
|
136
|
+
2. Check `this.metadata.sessionId` is set in UserMetadataTracker
|
|
137
|
+
3. Verify build was successful
|
|
138
|
+
|
|
139
|
+
### Issue: sessionId is "undefined" string
|
|
140
|
+
**Cause**: sessionId not initialized before first update
|
|
141
|
+
**Solution**: Ensure `init()` is called before any tracking methods
|
|
142
|
+
|
|
143
|
+
### Issue: sessionId changes during session
|
|
144
|
+
**Cause**: sessionStorage being cleared
|
|
145
|
+
**Solution**: Check for code that clears sessionStorage incorrectly
|
|
146
|
+
|
|
147
|
+
## Testing Commands
|
|
148
|
+
|
|
149
|
+
Open browser console and run:
|
|
150
|
+
|
|
151
|
+
```javascript
|
|
152
|
+
// Check current session ID
|
|
153
|
+
console.log('Session ID:', sessionStorage.getItem('guideai_session_id'));
|
|
154
|
+
|
|
155
|
+
// Check metadata tracker
|
|
156
|
+
console.log('Metadata:', window.GuideAI?.metadata?.getMetadata());
|
|
157
|
+
|
|
158
|
+
// Manually trigger login (to test metadata updates)
|
|
159
|
+
window.GuideAI?.metadata?.trackLogin({ userId: 'test-123', email: 'test@example.com' });
|
|
160
|
+
|
|
161
|
+
// Manually trigger custom event
|
|
162
|
+
window.GuideAI?.metadata?.trackCustomEvent('test_event', { key: 'value' });
|
|
163
|
+
|
|
164
|
+
// Check pending updates
|
|
165
|
+
window.GuideAI?.metadata?.syncMetadata();
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Backend Validation
|
|
169
|
+
|
|
170
|
+
Your backend should now:
|
|
171
|
+
- ✅ Accept requests with sessionId in correct locations
|
|
172
|
+
- ✅ Return 200 for valid requests
|
|
173
|
+
- ✅ Return 400 if sessionId is missing (with helpful error message)
|
|
174
|
+
- ✅ Log warnings if email/userId are missing (but still accept)
|
|
175
|
+
|
|
176
|
+
## Success Criteria
|
|
177
|
+
|
|
178
|
+
### All Must Pass:
|
|
179
|
+
1. ✅ No 400 errors from /metadata-updates
|
|
180
|
+
2. ✅ No 400 errors from /events
|
|
181
|
+
3. ✅ sessionId appears in all API calls
|
|
182
|
+
4. ✅ sessionId is consistent within same browser tab
|
|
183
|
+
5. ✅ sessionId format is valid UUID
|
|
184
|
+
6. ✅ Backend accepts and processes all requests
|
|
185
|
+
|
|
186
|
+
## Next Steps After Testing
|
|
187
|
+
|
|
188
|
+
Once testing confirms everything works:
|
|
189
|
+
|
|
190
|
+
1. **Commit the changes:**
|
|
191
|
+
```bash
|
|
192
|
+
git add guide-ai-package/src/metric/metadata-tracker.tsx
|
|
193
|
+
git commit -m "feat: Add sessionId to metadata-updates API calls
|
|
194
|
+
|
|
195
|
+
- Include sessionId in all MetadataUpdate.data objects
|
|
196
|
+
- Complies with backend validation requirements
|
|
197
|
+
- Fixes 400 errors from missing sessionId field"
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
2. **Push to your branch:**
|
|
201
|
+
```bash
|
|
202
|
+
git push origin improvement/api-integration
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
3. **Create PR** with test results
|
|
206
|
+
|
|
207
|
+
## Questions or Issues?
|
|
208
|
+
|
|
209
|
+
If you encounter any problems during testing:
|
|
210
|
+
- Check the browser console for errors
|
|
211
|
+
- Check the Network tab for full request/response
|
|
212
|
+
- Verify sessionStorage has `guideai_session_id`
|
|
213
|
+
- Ensure you rebuilt and reloaded the package
|
|
214
|
+
|
|
215
|
+
|