humanbehavior-js 0.4.7 → 0.4.9
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/cjs/angular/index.cjs +13 -14
- package/dist/cjs/angular/index.cjs.map +1 -1
- package/dist/cjs/index.cjs +14 -15
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/install-wizard.cjs +4 -2
- package/dist/cjs/install-wizard.cjs.map +1 -1
- package/dist/cjs/react/index.cjs +13 -14
- package/dist/cjs/react/index.cjs.map +1 -1
- package/dist/cjs/remix/index.cjs +13 -14
- package/dist/cjs/remix/index.cjs.map +1 -1
- package/dist/cjs/svelte/index.cjs +13 -14
- package/dist/cjs/svelte/index.cjs.map +1 -1
- package/dist/cjs/vue/index.cjs +13 -14
- package/dist/cjs/vue/index.cjs.map +1 -1
- package/dist/cjs/wizard/index.cjs +3208 -0
- package/dist/cjs/wizard/index.cjs.map +1 -0
- package/dist/cli/ai-auto-install.js +2024 -0
- package/dist/cli/ai-auto-install.js.map +1 -0
- package/dist/cli/auto-install.js +4 -2
- package/dist/cli/auto-install.js.map +1 -1
- package/dist/esm/angular/index.js +13 -14
- package/dist/esm/angular/index.js.map +1 -1
- package/dist/esm/index.js +14 -15
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/install-wizard.js +4 -2
- package/dist/esm/install-wizard.js.map +1 -1
- package/dist/esm/react/index.js +13 -14
- package/dist/esm/react/index.js.map +1 -1
- package/dist/esm/remix/index.js +13 -14
- package/dist/esm/remix/index.js.map +1 -1
- package/dist/esm/svelte/index.js +13 -14
- package/dist/esm/svelte/index.js.map +1 -1
- package/dist/esm/vue/index.js +13 -14
- package/dist/esm/vue/index.js.map +1 -1
- package/dist/esm/wizard/index.js +3178 -0
- package/dist/esm/wizard/index.js.map +1 -0
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/types/install-wizard.d.ts +8 -8
- package/dist/types/wizard/index.d.ts +489 -0
- package/package.json +14 -8
- package/rollup.config.js +65 -3
- package/src/api.ts +9 -9
- package/src/react/AutoInstallWizard.tsx +1 -1
- package/src/tracker.ts +6 -7
- package/src/wizard/README.md +114 -0
- package/src/wizard/ai/ai-install-wizard.ts +894 -0
- package/src/wizard/ai/manual-framework-wizard.ts +236 -0
- package/src/wizard/cli/ai-auto-install.ts +369 -0
- package/src/{cli → wizard/cli}/auto-install.ts +1 -1
- package/src/{install-wizard.ts → wizard/core/install-wizard.ts} +12 -10
- package/src/wizard/index.ts +23 -0
- package/src/wizard/services/centralized-ai-service.ts +668 -0
- package/src/wizard/services/remote-ai-service.ts +224 -0
package/src/api.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logError, logInfo, logDebug } from './utils/logger';
|
|
1
|
+
import { logError, logInfo, logDebug, logWarn } from './utils/logger';
|
|
2
2
|
|
|
3
3
|
export const MAX_CHUNK_SIZE_BYTES = 1024 * 1024; // 1MB chunk size - more conservative
|
|
4
4
|
|
|
@@ -19,7 +19,7 @@ export function validateSingleEventSize(event: any, sessionId: string): void {
|
|
|
19
19
|
|
|
20
20
|
if (singleEventSize > MAX_CHUNK_SIZE_BYTES) {
|
|
21
21
|
// Instead of throwing, log a warning and suggest reducing event size
|
|
22
|
-
|
|
22
|
+
logWarn(`Single event size (${singleEventSize} bytes) exceeds maximum chunk size (${MAX_CHUNK_SIZE_BYTES} bytes). Consider reducing event data size.`);
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -102,7 +102,7 @@ export class HumanBehaviorAPI {
|
|
|
102
102
|
referrer = document.referrer;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
logInfo('API init called with:', { sessionId, userId, entryURL, referrer, baseUrl: this.baseUrl });
|
|
106
106
|
|
|
107
107
|
try {
|
|
108
108
|
const response = await fetch(`${this.baseUrl}/api/ingestion/init`, {
|
|
@@ -120,22 +120,22 @@ export class HumanBehaviorAPI {
|
|
|
120
120
|
})
|
|
121
121
|
});
|
|
122
122
|
|
|
123
|
-
|
|
123
|
+
logInfo('API init response status:', response.status);
|
|
124
124
|
|
|
125
125
|
if (!response.ok) {
|
|
126
126
|
const errorText = await response.text();
|
|
127
|
-
|
|
127
|
+
logError('API init failed:', response.status, errorText);
|
|
128
128
|
throw new Error(`Failed to initialize ingestion: ${response.statusText} - ${errorText}`);
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
const responseJson = await response.json();
|
|
132
|
-
|
|
132
|
+
logInfo('API init success:', responseJson);
|
|
133
133
|
return {
|
|
134
134
|
sessionId: responseJson.sessionId,
|
|
135
135
|
endUserId: responseJson.endUserId
|
|
136
136
|
}
|
|
137
137
|
} catch (error) {
|
|
138
|
-
|
|
138
|
+
logError('API init error:', error);
|
|
139
139
|
throw error;
|
|
140
140
|
}
|
|
141
141
|
}
|
|
@@ -246,7 +246,7 @@ export class HumanBehaviorAPI {
|
|
|
246
246
|
posthogName: userData.email || userData.name || null // Update user name with email
|
|
247
247
|
};
|
|
248
248
|
|
|
249
|
-
|
|
249
|
+
logInfo('Sending user data to server:', payload);
|
|
250
250
|
|
|
251
251
|
const response = await fetch(`${this.baseUrl}/api/ingestion/user`, {
|
|
252
252
|
method: 'POST',
|
|
@@ -262,7 +262,7 @@ export class HumanBehaviorAPI {
|
|
|
262
262
|
}
|
|
263
263
|
|
|
264
264
|
const result = await response.json();
|
|
265
|
-
|
|
265
|
+
logInfo('Server response:', result);
|
|
266
266
|
return result;
|
|
267
267
|
} catch (error) {
|
|
268
268
|
logError('Error sending user data:', error);
|
package/src/tracker.ts
CHANGED
|
@@ -229,7 +229,7 @@ export class HumanBehaviorTracker {
|
|
|
229
229
|
// Track navigation event
|
|
230
230
|
this.trackNavigationEvent('pushState', this.previousUrl, this.currentUrl);
|
|
231
231
|
|
|
232
|
-
// Take FullSnapshot on navigation
|
|
232
|
+
// Take FullSnapshot on navigation
|
|
233
233
|
this.takeFullSnapshot();
|
|
234
234
|
};
|
|
235
235
|
|
|
@@ -244,7 +244,7 @@ export class HumanBehaviorTracker {
|
|
|
244
244
|
// Track navigation event
|
|
245
245
|
this.trackNavigationEvent('replaceState', this.previousUrl, this.currentUrl);
|
|
246
246
|
|
|
247
|
-
// Take FullSnapshot on navigation
|
|
247
|
+
// Take FullSnapshot on navigation
|
|
248
248
|
this.takeFullSnapshot();
|
|
249
249
|
};
|
|
250
250
|
|
|
@@ -254,7 +254,7 @@ export class HumanBehaviorTracker {
|
|
|
254
254
|
this.currentUrl = window.location.href;
|
|
255
255
|
this.trackNavigationEvent('popstate', this.previousUrl, this.currentUrl);
|
|
256
256
|
|
|
257
|
-
// Take FullSnapshot on navigation
|
|
257
|
+
// Take FullSnapshot on navigation
|
|
258
258
|
this.takeFullSnapshot();
|
|
259
259
|
};
|
|
260
260
|
|
|
@@ -718,7 +718,7 @@ export class HumanBehaviorTracker {
|
|
|
718
718
|
public viewLogs() {
|
|
719
719
|
try {
|
|
720
720
|
const logs = logger.getLogs();
|
|
721
|
-
|
|
721
|
+
logInfo('HumanBehavior Logs:', logs);
|
|
722
722
|
logger.clearLogs(); // Clear logs after viewing
|
|
723
723
|
} catch (e) {
|
|
724
724
|
logError('Failed to read logs:', e);
|
|
@@ -797,9 +797,8 @@ export class HumanBehaviorTracker {
|
|
|
797
797
|
// ✅ CANVAS RECORDING - Disabled to prevent large data URIs
|
|
798
798
|
recordCanvas: false, // Disabled to prevent large data URIs
|
|
799
799
|
|
|
800
|
-
// ✅ FULLSNAPSHOT GENERATION -
|
|
801
|
-
//
|
|
802
|
-
// They rely on initial FullSnapshot + navigation-triggered ones only
|
|
800
|
+
// ✅ FULLSNAPSHOT GENERATION - No periodic snapshots to avoid animation issues
|
|
801
|
+
// Rely on initial FullSnapshot + navigation-triggered ones only
|
|
803
802
|
});
|
|
804
803
|
|
|
805
804
|
// Store the record instance for cleanup
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# HumanBehavior SDK Wizard Module
|
|
2
|
+
|
|
3
|
+
This module provides AI-enhanced auto-installation capabilities for the HumanBehavior SDK.
|
|
4
|
+
|
|
5
|
+
## 📁 Directory Structure
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
src/wizard/
|
|
9
|
+
├── core/ # Core installation wizard
|
|
10
|
+
│ └── install-wizard.ts
|
|
11
|
+
├── ai/ # AI-enhanced wizard components
|
|
12
|
+
│ └── ai-install-wizard.ts
|
|
13
|
+
├── cli/ # Command-line interfaces
|
|
14
|
+
│ ├── auto-install.ts
|
|
15
|
+
│ └── ai-auto-install.ts
|
|
16
|
+
├── services/ # AI service implementations
|
|
17
|
+
│ ├── remote-ai-service.ts
|
|
18
|
+
│ └── centralized-ai-service.ts
|
|
19
|
+
├── index.ts # Main exports
|
|
20
|
+
└── README.md # This file
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 🚀 Key Components
|
|
24
|
+
|
|
25
|
+
### Core (`core/`)
|
|
26
|
+
- **`install-wizard.ts`**: Traditional installation wizard
|
|
27
|
+
- Framework detection and code modification
|
|
28
|
+
- Environment variable management
|
|
29
|
+
- Package installation
|
|
30
|
+
|
|
31
|
+
### AI (`ai/`)
|
|
32
|
+
- **`ai-install-wizard.ts`**: AI-enhanced installation wizard
|
|
33
|
+
- AI-powered framework detection
|
|
34
|
+
- Intelligent code analysis
|
|
35
|
+
- Conflict resolution
|
|
36
|
+
- Learning system
|
|
37
|
+
|
|
38
|
+
### CLI (`cli/`)
|
|
39
|
+
- **`auto-install.ts`**: Traditional CLI interface
|
|
40
|
+
- **`ai-auto-install.ts`**: AI-enhanced CLI interface
|
|
41
|
+
- User interaction and command parsing
|
|
42
|
+
- Installation mode selection
|
|
43
|
+
|
|
44
|
+
### Services (`services/`)
|
|
45
|
+
- **`remote-ai-service.ts`**: Connects to deployed Lambda AI service
|
|
46
|
+
- **`centralized-ai-service.ts`**: Local AI service implementation
|
|
47
|
+
- Heuristic fallback when AI is unavailable
|
|
48
|
+
|
|
49
|
+
## 🔧 Usage
|
|
50
|
+
|
|
51
|
+
### Traditional Installation
|
|
52
|
+
```typescript
|
|
53
|
+
import { AutoInstallationWizard } from 'humanbehavior-js/wizard';
|
|
54
|
+
|
|
55
|
+
const wizard = new AutoInstallationWizard(apiKey, projectPath);
|
|
56
|
+
const result = await wizard.install();
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### AI-Enhanced Installation
|
|
60
|
+
```typescript
|
|
61
|
+
import { AIEnhancedInstallationWizard, RemoteAIService } from 'humanbehavior-js/wizard';
|
|
62
|
+
|
|
63
|
+
const aiService = new RemoteAIService({
|
|
64
|
+
apiEndpoint: 'https://your-lambda-api.execute-api.region.amazonaws.com/prod'
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const wizard = new AIEnhancedInstallationWizard(apiKey, projectPath, aiService);
|
|
68
|
+
const result = await wizard.install();
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### CLI Usage
|
|
72
|
+
```bash
|
|
73
|
+
# Traditional installation
|
|
74
|
+
npx humanbehavior-js auto-install YOUR_API_KEY
|
|
75
|
+
|
|
76
|
+
# AI-enhanced installation
|
|
77
|
+
npx humanbehavior-js ai-auto-install YOUR_API_KEY --ai
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## 🧠 AI Features
|
|
81
|
+
|
|
82
|
+
- **Intelligent Framework Detection**: Beyond package.json analysis
|
|
83
|
+
- **Code Pattern Analysis**: Understands project structure and patterns
|
|
84
|
+
- **Conflict Resolution**: Smart handling of existing integrations
|
|
85
|
+
- **Future-Proofing**: Adaptive strategies for new frameworks
|
|
86
|
+
- **Learning System**: Improves over time with usage patterns
|
|
87
|
+
|
|
88
|
+
## 🔄 Backward Compatibility
|
|
89
|
+
|
|
90
|
+
All existing imports continue to work:
|
|
91
|
+
- `humanbehavior-js/install-wizard` → `humanbehavior-js/wizard`
|
|
92
|
+
- Traditional wizard functionality unchanged
|
|
93
|
+
- AI features are additive, not breaking
|
|
94
|
+
|
|
95
|
+
## 🚀 Lambda Deployment
|
|
96
|
+
|
|
97
|
+
The `lambda-deployment/` directory contains the AI service for AWS Lambda deployment. This is separate from the client-side wizard code and should not be modified unless deploying AI service updates.
|
|
98
|
+
|
|
99
|
+
### 📁 Lambda Deployment Structure
|
|
100
|
+
```
|
|
101
|
+
lambda-deployment/
|
|
102
|
+
├── index.js # Lambda entry point
|
|
103
|
+
├── ai-install-wizard.ts # AI service implementation
|
|
104
|
+
├── install-wizard.ts # Core wizard logic
|
|
105
|
+
├── centralized-ai-service.ts # AI service interface
|
|
106
|
+
└── README.md # Deployment documentation
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### 🔗 Client-Server Relationship
|
|
110
|
+
- **Client**: `src/wizard/` - User-facing installation wizard
|
|
111
|
+
- **Server**: `lambda-deployment/` - AI service backend
|
|
112
|
+
- **Connection**: `RemoteAIService` connects client to Lambda
|
|
113
|
+
|
|
114
|
+
See `lambda-deployment/README.md` for detailed deployment instructions.
|