humanbehavior-js 0.4.27 → 0.5.0

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.
Files changed (140) hide show
  1. package/README.md +151 -0
  2. package/package.json +114 -71
  3. package/packages/angular/dist/index.d.ts +46 -0
  4. package/packages/angular/dist/index.d.ts.map +1 -0
  5. package/packages/angular/dist/index.js +2 -0
  6. package/packages/angular/dist/index.js.map +1 -0
  7. package/packages/angular/dist/index.mjs +2 -0
  8. package/packages/angular/dist/index.mjs.map +1 -0
  9. package/packages/browser/dist/index.d.ts +5 -0
  10. package/packages/browser/dist/index.d.ts.map +1 -0
  11. package/packages/browser/dist/index.iife.js +12095 -0
  12. package/packages/browser/dist/index.iife.js.map +1 -0
  13. package/packages/browser/dist/index.js +2 -0
  14. package/packages/browser/dist/index.js.map +1 -0
  15. package/packages/browser/dist/index.min.js +2 -0
  16. package/packages/browser/dist/index.min.js.map +1 -0
  17. package/packages/browser/dist/index.mjs +2 -0
  18. package/packages/browser/dist/index.mjs.map +1 -0
  19. package/packages/react/dist/browser.d.ts +2 -0
  20. package/packages/react/dist/browser.d.ts.map +1 -0
  21. package/packages/react/dist/index.d.ts +48 -0
  22. package/packages/react/dist/index.d.ts.map +1 -0
  23. package/packages/react/dist/index.js +2 -0
  24. package/packages/react/dist/index.js.map +1 -0
  25. package/packages/react/dist/index.mjs +2 -0
  26. package/packages/react/dist/index.mjs.map +1 -0
  27. package/packages/remix/dist/index.d.ts +8 -0
  28. package/packages/remix/dist/index.d.ts.map +1 -0
  29. package/packages/remix/dist/index.js +2 -0
  30. package/packages/remix/dist/index.js.map +1 -0
  31. package/packages/remix/dist/index.mjs +2 -0
  32. package/packages/remix/dist/index.mjs.map +1 -0
  33. package/packages/svelte/dist/index.d.ts +11 -0
  34. package/packages/svelte/dist/index.d.ts.map +1 -0
  35. package/packages/svelte/dist/index.js +2 -0
  36. package/packages/svelte/dist/index.js.map +1 -0
  37. package/packages/svelte/dist/index.mjs +2 -0
  38. package/packages/svelte/dist/index.mjs.map +1 -0
  39. package/{dist/types/vue → packages/vue/dist}/index.d.ts +4 -5
  40. package/packages/vue/dist/index.d.ts.map +1 -0
  41. package/packages/vue/dist/index.js +2 -0
  42. package/packages/vue/dist/index.js.map +1 -0
  43. package/packages/vue/dist/index.mjs +2 -0
  44. package/packages/vue/dist/index.mjs.map +1 -0
  45. package/packages/wizard/dist/ai/ai-install-wizard.d.ts +145 -0
  46. package/packages/wizard/dist/ai/ai-install-wizard.d.ts.map +1 -0
  47. package/packages/wizard/dist/ai/manual-framework-wizard.d.ts +52 -0
  48. package/packages/wizard/dist/ai/manual-framework-wizard.d.ts.map +1 -0
  49. package/packages/wizard/dist/cli/ai-auto-install.d.ts +27 -0
  50. package/packages/wizard/dist/cli/ai-auto-install.d.ts.map +1 -0
  51. package/{dist → packages/wizard/dist}/cli/ai-auto-install.js +821 -905
  52. package/packages/wizard/dist/cli/ai-auto-install.js.map +1 -0
  53. package/packages/wizard/dist/cli/auto-install.d.ts +26 -0
  54. package/packages/wizard/dist/cli/auto-install.d.ts.map +1 -0
  55. package/{dist → packages/wizard/dist}/cli/auto-install.js +821 -905
  56. package/packages/wizard/dist/cli/auto-install.js.map +1 -0
  57. package/{dist/types → packages/wizard/dist/core}/install-wizard.d.ts +6 -8
  58. package/packages/wizard/dist/core/install-wizard.d.ts.map +1 -0
  59. package/packages/wizard/dist/index.d.ts +18 -0
  60. package/packages/wizard/dist/index.d.ts.map +1 -0
  61. package/packages/wizard/dist/index.js +2 -0
  62. package/packages/wizard/dist/index.js.map +1 -0
  63. package/packages/wizard/dist/index.mjs +2 -0
  64. package/packages/wizard/dist/index.mjs.map +1 -0
  65. package/packages/wizard/dist/services/centralized-ai-service.d.ts +159 -0
  66. package/packages/wizard/dist/services/centralized-ai-service.d.ts.map +1 -0
  67. package/packages/wizard/dist/services/remote-ai-service.d.ts +58 -0
  68. package/packages/wizard/dist/services/remote-ai-service.d.ts.map +1 -0
  69. package/WIZARD_USAGE_GUIDE.md +0 -381
  70. package/dist/cjs/angular/index.cjs +0 -14979
  71. package/dist/cjs/angular/index.cjs.map +0 -1
  72. package/dist/cjs/index.cjs +0 -14964
  73. package/dist/cjs/index.cjs.map +0 -1
  74. package/dist/cjs/install-wizard.cjs +0 -1576
  75. package/dist/cjs/install-wizard.cjs.map +0 -1
  76. package/dist/cjs/react/index.cjs +0 -15103
  77. package/dist/cjs/react/index.cjs.map +0 -1
  78. package/dist/cjs/remix/index.cjs +0 -15077
  79. package/dist/cjs/remix/index.cjs.map +0 -1
  80. package/dist/cjs/svelte/index.cjs +0 -14933
  81. package/dist/cjs/svelte/index.cjs.map +0 -1
  82. package/dist/cjs/vue/index.cjs +0 -14942
  83. package/dist/cjs/vue/index.cjs.map +0 -1
  84. package/dist/cjs/wizard/index.cjs +0 -3490
  85. package/dist/cjs/wizard/index.cjs.map +0 -1
  86. package/dist/cli/ai-auto-install.js.map +0 -1
  87. package/dist/cli/auto-install.js.map +0 -1
  88. package/dist/esm/angular/index.js +0 -14975
  89. package/dist/esm/angular/index.js.map +0 -1
  90. package/dist/esm/index.js +0 -14941
  91. package/dist/esm/index.js.map +0 -1
  92. package/dist/esm/install-wizard.js +0 -1553
  93. package/dist/esm/install-wizard.js.map +0 -1
  94. package/dist/esm/react/index.js +0 -15097
  95. package/dist/esm/react/index.js.map +0 -1
  96. package/dist/esm/remix/index.js +0 -15073
  97. package/dist/esm/remix/index.js.map +0 -1
  98. package/dist/esm/svelte/index.js +0 -14931
  99. package/dist/esm/svelte/index.js.map +0 -1
  100. package/dist/esm/vue/index.js +0 -14940
  101. package/dist/esm/vue/index.js.map +0 -1
  102. package/dist/esm/wizard/index.js +0 -3459
  103. package/dist/esm/wizard/index.js.map +0 -1
  104. package/dist/index.min.js +0 -2
  105. package/dist/index.min.js.map +0 -1
  106. package/dist/types/angular/index.d.ts +0 -357
  107. package/dist/types/index.d.ts +0 -644
  108. package/dist/types/react/index.d.ts +0 -345
  109. package/dist/types/remix/index.d.ts +0 -336
  110. package/dist/types/svelte/index.d.ts +0 -322
  111. package/dist/types/wizard/index.d.ts +0 -523
  112. package/readme.md +0 -335
  113. package/rollup.config.js +0 -422
  114. package/simple-spa.html +0 -1000
  115. package/src/angular/index.ts +0 -79
  116. package/src/api.ts +0 -416
  117. package/src/index.ts +0 -35
  118. package/src/react/AutoInstallWizard.tsx +0 -557
  119. package/src/react/browser.ts +0 -8
  120. package/src/react/index.tsx +0 -308
  121. package/src/redact.ts +0 -327
  122. package/src/remix/index.ts +0 -16
  123. package/src/svelte/index.ts +0 -14
  124. package/src/tracker.ts +0 -1587
  125. package/src/types/clack.d.ts +0 -31
  126. package/src/utils/ip-detector.ts +0 -158
  127. package/src/utils/logger.ts +0 -144
  128. package/src/utils/property-detector.ts +0 -345
  129. package/src/utils/property-manager.ts +0 -274
  130. package/src/vue/index.ts +0 -29
  131. package/src/wizard/README.md +0 -114
  132. package/src/wizard/ai/ai-install-wizard.ts +0 -897
  133. package/src/wizard/ai/manual-framework-wizard.ts +0 -238
  134. package/src/wizard/cli/ai-auto-install.ts +0 -241
  135. package/src/wizard/cli/auto-install.ts +0 -224
  136. package/src/wizard/core/install-wizard.ts +0 -1794
  137. package/src/wizard/index.ts +0 -23
  138. package/src/wizard/services/centralized-ai-service.ts +0 -668
  139. package/src/wizard/services/remote-ai-service.ts +0 -240
  140. package/tsconfig.json +0 -24
@@ -1,274 +0,0 @@
1
- /**
2
- * Property Manager for HumanBehavior SDK
3
- * Handles automatic properties, session properties, and user properties
4
- */
5
-
6
- import { getAutomaticProperties, getInitialProperties, getCurrentPageProperties, AutomaticProperties } from './property-detector';
7
-
8
- export interface Properties {
9
- [key: string]: any;
10
- }
11
-
12
- export interface PropertyManagerConfig {
13
- enableAutomaticProperties?: boolean;
14
- enableSessionProperties?: boolean;
15
- enableUserProperties?: boolean;
16
- propertyDenylist?: string[];
17
- }
18
-
19
- export class PropertyManager {
20
- private config: PropertyManagerConfig;
21
- private automaticProperties: AutomaticProperties;
22
- private sessionProperties: Properties = {};
23
- private userProperties: Properties = {};
24
- private initialProperties: Properties = {};
25
- private isInitialized: boolean = false;
26
-
27
- constructor(config: PropertyManagerConfig = {}) {
28
- this.config = {
29
- enableAutomaticProperties: true,
30
- enableSessionProperties: true,
31
- enableUserProperties: true,
32
- propertyDenylist: [],
33
- ...config
34
- };
35
-
36
- this.automaticProperties = getAutomaticProperties();
37
- this.initialize();
38
- }
39
-
40
- /**
41
- * Initialize the property manager
42
- */
43
- private initialize(): void {
44
- if (this.isInitialized) return;
45
-
46
- // Capture initial properties once
47
- this.initialProperties = getInitialProperties();
48
-
49
- // Load session properties from sessionStorage
50
- this.loadSessionProperties();
51
-
52
- this.isInitialized = true;
53
- }
54
-
55
- /**
56
- * Get all properties for an event
57
- */
58
- public getEventProperties(eventProperties: Properties = {}): Properties {
59
- const properties: Properties = { ...eventProperties };
60
-
61
- // Add automatic properties
62
- if (this.config.enableAutomaticProperties) {
63
- Object.assign(properties, this.getAutomaticProperties());
64
- }
65
-
66
- // Add session properties
67
- if (this.config.enableSessionProperties) {
68
- Object.assign(properties, this.sessionProperties);
69
- }
70
-
71
- // Add user properties
72
- if (this.config.enableUserProperties) {
73
- Object.assign(properties, this.userProperties);
74
- }
75
-
76
- // Add initial properties (only once per session)
77
- if (!this.sessionProperties['$initial_properties_captured']) {
78
- Object.assign(properties, this.initialProperties);
79
- this.setSessionProperty('$initial_properties_captured', true);
80
- }
81
-
82
- // Apply denylist
83
- this.applyDenylist(properties);
84
-
85
- return properties;
86
- }
87
-
88
- /**
89
- * Get automatic properties
90
- */
91
- public getAutomaticProperties(): Properties {
92
- return {
93
- ...this.automaticProperties,
94
- ...getCurrentPageProperties() // Always get fresh page properties
95
- };
96
- }
97
-
98
- /**
99
- * Get automatic properties with GeoIP data merged in
100
- */
101
- public getAutomaticPropertiesWithGeoIP(geoIPProperties: Record<string, any> = {}): Properties {
102
- return {
103
- ...this.automaticProperties,
104
- ...getCurrentPageProperties(), // Always get fresh page properties
105
- ...geoIPProperties
106
- };
107
- }
108
-
109
- /**
110
- * Set a session property
111
- */
112
- public setSessionProperty(key: string, value: any): void {
113
- this.sessionProperties[key] = value;
114
- this.saveSessionProperties();
115
- }
116
-
117
- /**
118
- * Set multiple session properties
119
- */
120
- public setSessionProperties(properties: Properties): void {
121
- Object.assign(this.sessionProperties, properties);
122
- this.saveSessionProperties();
123
- }
124
-
125
- /**
126
- * Get a session property
127
- */
128
- public getSessionProperty(key: string): any {
129
- return this.sessionProperties[key];
130
- }
131
-
132
- /**
133
- * Remove a session property
134
- */
135
- public removeSessionProperty(key: string): void {
136
- delete this.sessionProperties[key];
137
- this.saveSessionProperties();
138
- }
139
-
140
- /**
141
- * Set a user property
142
- */
143
- public setUserProperty(key: string, value: any): void {
144
- this.userProperties[key] = value;
145
- }
146
-
147
- /**
148
- * Set multiple user properties
149
- */
150
- public setUserProperties(properties: Properties): void {
151
- Object.assign(this.userProperties, properties);
152
- }
153
-
154
- /**
155
- * Get a user property
156
- */
157
- public getUserProperty(key: string): any {
158
- return this.userProperties[key];
159
- }
160
-
161
- /**
162
- * Remove a user property
163
- */
164
- public removeUserProperty(key: string): void {
165
- delete this.userProperties[key];
166
- }
167
-
168
- /**
169
- * Set a property only if it hasn't been set before
170
- */
171
- public setOnce(key: string, value: any, scope: 'session' | 'user' = 'user'): void {
172
- if (scope === 'session') {
173
- if (!(key in this.sessionProperties)) {
174
- this.setSessionProperty(key, value);
175
- }
176
- } else {
177
- if (!(key in this.userProperties)) {
178
- this.setUserProperty(key, value);
179
- }
180
- }
181
- }
182
-
183
- /**
184
- * Clear all session properties
185
- */
186
- public clearSessionProperties(): void {
187
- this.sessionProperties = {};
188
- this.saveSessionProperties();
189
- }
190
-
191
- /**
192
- * Clear all user properties
193
- */
194
- public clearUserProperties(): void {
195
- this.userProperties = {};
196
- }
197
-
198
- /**
199
- * Reset all properties
200
- */
201
- public reset(): void {
202
- this.clearSessionProperties();
203
- this.clearUserProperties();
204
- this.initialProperties = {};
205
- this.isInitialized = false;
206
- this.initialize();
207
- }
208
-
209
- /**
210
- * Load session properties from sessionStorage
211
- */
212
- private loadSessionProperties(): void {
213
- if (typeof sessionStorage === 'undefined') return;
214
-
215
- try {
216
- const stored = sessionStorage.getItem('hb_session_properties');
217
- if (stored) {
218
- this.sessionProperties = JSON.parse(stored);
219
- }
220
- } catch (error) {
221
- console.warn('Failed to load session properties:', error);
222
- }
223
- }
224
-
225
- /**
226
- * Save session properties to sessionStorage
227
- */
228
- private saveSessionProperties(): void {
229
- if (typeof sessionStorage === 'undefined') return;
230
-
231
- try {
232
- sessionStorage.setItem('hb_session_properties', JSON.stringify(this.sessionProperties));
233
- } catch (error) {
234
- console.warn('Failed to save session properties:', error);
235
- }
236
- }
237
-
238
- /**
239
- * Apply property denylist
240
- */
241
- private applyDenylist(properties: Properties): void {
242
- if (!this.config.propertyDenylist || this.config.propertyDenylist.length === 0) {
243
- return;
244
- }
245
-
246
- this.config.propertyDenylist.forEach(deniedKey => {
247
- delete properties[deniedKey];
248
- });
249
- }
250
-
251
- /**
252
- * Update automatic properties (call when page changes)
253
- */
254
- public updateAutomaticProperties(): void {
255
- this.automaticProperties = getAutomaticProperties();
256
- }
257
-
258
- /**
259
- * Get all properties for debugging
260
- */
261
- public getAllProperties(): {
262
- automatic: Properties;
263
- session: Properties;
264
- user: Properties;
265
- initial: Properties;
266
- } {
267
- return {
268
- automatic: this.getAutomaticProperties(),
269
- session: { ...this.sessionProperties },
270
- user: { ...this.userProperties },
271
- initial: { ...this.initialProperties }
272
- };
273
- }
274
- }
package/src/vue/index.ts DELETED
@@ -1,29 +0,0 @@
1
- import { HumanBehaviorTracker } from '../index.js';
2
- import type { App } from 'vue';
3
-
4
- interface HumanBehaviorPluginOptions {
5
- apiKey: string;
6
- ingestionUrl?: string;
7
- logLevel?: 'none' | 'error' | 'warn' | 'info' | 'debug';
8
- redactFields?: string[];
9
- suppressConsoleErrors?: boolean;
10
- recordCanvas?: boolean; // Enable canvas recording with protection
11
- }
12
-
13
- export const HumanBehaviorPlugin = {
14
- install: (app: App, options: HumanBehaviorPluginOptions) => {
15
- const tracker = HumanBehaviorTracker.init(options.apiKey, {
16
- ingestionUrl: options.ingestionUrl,
17
- logLevel: options.logLevel,
18
- redactFields: options.redactFields,
19
- suppressConsoleErrors: options.suppressConsoleErrors,
20
- recordCanvas: options.recordCanvas, // Pass canvas recording option
21
- });
22
-
23
- // Make tracker available globally
24
- app.config.globalProperties.$humanBehavior = tracker;
25
-
26
- // Also provide it via inject/provide
27
- app.provide('humanBehavior', tracker);
28
- }
29
- };
@@ -1,114 +0,0 @@
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.