humanbehavior-js 0.4.28 → 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 -79
  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,557 +0,0 @@
1
- import React, { useState, useEffect } from 'react';
2
- import { BrowserAutoInstallationWizard } from '../wizard/core/install-wizard';
3
-
4
- interface AutoInstallWizardProps {
5
- apiKey: string;
6
- projectName?: string;
7
- onComplete?: (result: any) => void;
8
- onError?: (error: string) => void;
9
- }
10
-
11
- interface InstallationStep {
12
- id: string;
13
- title: string;
14
- description: string;
15
- status: 'pending' | 'running' | 'completed' | 'error';
16
- code?: string;
17
- filePath?: string;
18
- }
19
-
20
- export const AutoInstallWizard: React.FC<AutoInstallWizardProps> = ({
21
- apiKey,
22
- projectName,
23
- onComplete,
24
- onError
25
- }) => {
26
- const [isInstalling, setIsInstalling] = useState(false);
27
- const [currentStep, setCurrentStep] = useState(0);
28
- const [steps, setSteps] = useState<InstallationStep[]>([]);
29
- const [result, setResult] = useState<any>(null);
30
- const [error, setError] = useState<string | null>(null);
31
-
32
- useEffect(() => {
33
- initializeSteps();
34
- }, []);
35
-
36
- const initializeSteps = () => {
37
- const initialSteps: InstallationStep[] = [
38
- {
39
- id: 'detect',
40
- title: 'Detecting Framework',
41
- description: 'Analyzing your project structure',
42
- status: 'pending'
43
- },
44
- {
45
- id: 'install',
46
- title: 'Installing SDK',
47
- description: 'Adding humanbehavior-js to your project',
48
- status: 'pending'
49
- },
50
- {
51
- id: 'configure',
52
- title: 'Configuring Integration',
53
- description: 'Modifying your codebase',
54
- status: 'pending'
55
- },
56
- {
57
- id: 'complete',
58
- title: 'Installation Complete',
59
- description: 'Your app is ready to track user behavior',
60
- status: 'pending'
61
- }
62
- ];
63
- setSteps(initialSteps);
64
- };
65
-
66
- const startInstallation = async () => {
67
- setIsInstalling(true);
68
- setError(null);
69
-
70
- try {
71
- // Step 1: Detect framework
72
- updateStepStatus(0, 'running');
73
- await simulateStep(1000);
74
- updateStepStatus(0, 'completed');
75
-
76
- // Step 2: Install package
77
- updateStepStatus(1, 'running');
78
- await simulateStep(1500);
79
- updateStepStatus(1, 'completed');
80
-
81
- // Step 3: Configure integration
82
- updateStepStatus(2, 'running');
83
- await simulateStep(2000);
84
- updateStepStatus(2, 'completed');
85
-
86
- // Step 4: Complete
87
- updateStepStatus(3, 'completed');
88
-
89
- // Generate result
90
- const wizard = new BrowserAutoInstallationWizard(apiKey);
91
- const installationResult = await wizard.install();
92
- setResult(installationResult);
93
-
94
- onComplete?.(installationResult);
95
-
96
- } catch (err) {
97
- const errorMessage = err instanceof Error ? err.message : 'Installation failed';
98
- setError(errorMessage);
99
- onError?.(errorMessage);
100
-
101
- // Mark current step as error
102
- updateStepStatus(currentStep, 'error');
103
- } finally {
104
- setIsInstalling(false);
105
- }
106
- };
107
-
108
- const updateStepStatus = (stepIndex: number, status: InstallationStep['status']) => {
109
- setSteps(prev => prev.map((step, index) =>
110
- index === stepIndex ? { ...step, status } : step
111
- ));
112
- setCurrentStep(stepIndex);
113
- };
114
-
115
- const simulateStep = (duration: number) => {
116
- return new Promise(resolve => setTimeout(resolve, duration));
117
- };
118
-
119
- const copyToClipboard = async (text: string) => {
120
- try {
121
- await navigator.clipboard.writeText(text);
122
- // You could add a toast notification here
123
- } catch (err) {
124
- console.error('Failed to copy to clipboard:', err);
125
- }
126
- };
127
-
128
- const getStepIcon = (status: InstallationStep['status']) => {
129
- switch (status) {
130
- case 'completed':
131
- return '✅';
132
- case 'running':
133
- return '🔄';
134
- case 'error':
135
- return '❌';
136
- default:
137
- return '⏳';
138
- }
139
- };
140
-
141
- const getStepClass = (status: InstallationStep['status']) => {
142
- switch (status) {
143
- case 'completed':
144
- return 'step-completed';
145
- case 'running':
146
- return 'step-running';
147
- case 'error':
148
- return 'step-error';
149
- default:
150
- return 'step-pending';
151
- }
152
- };
153
-
154
- return (
155
- <div className="auto-install-wizard">
156
- <div className="wizard-header">
157
- <h2>🚀 Auto-Installation Wizard</h2>
158
- <p>Automatically integrate HumanBehavior SDK into your project</p>
159
- </div>
160
-
161
- {!isInstalling && steps.every(step => step.status === 'pending') && (
162
- <div className="wizard-start">
163
- <div className="start-content">
164
- <h3>Ready to Install</h3>
165
- <p>This wizard will automatically:</p>
166
- <ul>
167
- <li>🔍 Detect your project's framework</li>
168
- <li>📦 Install the humanbehavior-js package</li>
169
- <li>✏️ Modify your codebase to integrate the SDK</li>
170
- <li>🔧 Create environment files with your API key</li>
171
- <li>🚀 Make your app ready to track user behavior</li>
172
- </ul>
173
-
174
- <button
175
- onClick={startInstallation}
176
- className="btn btn-primary"
177
- disabled={isInstalling}
178
- >
179
- {isInstalling ? 'Installing...' : 'Start Auto-Installation'}
180
- </button>
181
- </div>
182
- </div>
183
- )}
184
-
185
- {isInstalling && (
186
- <div className="wizard-progress">
187
- <div className="progress-bar">
188
- <div
189
- className="progress-fill"
190
- style={{
191
- width: `${((currentStep + 1) / steps.length) * 100}%`
192
- }}
193
- />
194
- </div>
195
-
196
- <div className="steps-list">
197
- {steps.map((step, index) => (
198
- <div
199
- key={step.id}
200
- className={`step-item ${getStepClass(step.status)}`}
201
- >
202
- <div className="step-icon">
203
- {getStepIcon(step.status)}
204
- </div>
205
- <div className="step-content">
206
- <h4>{step.title}</h4>
207
- <p>{step.description}</p>
208
- {step.status === 'running' && (
209
- <div className="step-spinner">
210
- <div className="spinner" />
211
- </div>
212
- )}
213
- </div>
214
- </div>
215
- ))}
216
- </div>
217
- </div>
218
- )}
219
-
220
- {result && result.success && (
221
- <div className="wizard-success">
222
- <div className="success-header">
223
- <h3>✅ Installation Complete!</h3>
224
- <p>Your HumanBehavior SDK has been successfully integrated.</p>
225
- </div>
226
-
227
- <div className="result-details">
228
- <div className="framework-info">
229
- <h4>Framework Detected</h4>
230
- <p><strong>{result.framework.name}</strong></p>
231
- {result.framework.bundler && (
232
- <p>Bundler: {result.framework.bundler}</p>
233
- )}
234
- </div>
235
-
236
- <div className="changes-made">
237
- <h4>Changes Made</h4>
238
- <ul>
239
- {result.modifications.map((mod: any, index: number) => (
240
- <li key={index}>
241
- <strong>{mod.description}</strong>
242
- <br />
243
- <code>{mod.filePath}</code>
244
- {mod.content && (
245
- <button
246
- onClick={() => copyToClipboard(mod.content)}
247
- className="btn-copy"
248
- >
249
- Copy Code
250
- </button>
251
- )}
252
- </li>
253
- ))}
254
- </ul>
255
- </div>
256
-
257
- <div className="next-steps">
258
- <h4>Next Steps</h4>
259
- <ul>
260
- {result.nextSteps.map((step: string, index: number) => (
261
- <li key={index}>{step}</li>
262
- ))}
263
- </ul>
264
- </div>
265
- </div>
266
- </div>
267
- )}
268
-
269
- {error && (
270
- <div className="wizard-error">
271
- <h3>❌ Installation Failed</h3>
272
- <p>{error}</p>
273
- <button
274
- onClick={() => {
275
- setError(null);
276
- initializeSteps();
277
- }}
278
- className="btn btn-secondary"
279
- >
280
- Try Again
281
- </button>
282
- </div>
283
- )}
284
-
285
- <style>{`
286
- .auto-install-wizard {
287
- max-width: 800px;
288
- margin: 0 auto;
289
- padding: 2rem;
290
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
291
- }
292
-
293
- .wizard-header {
294
- text-align: center;
295
- margin-bottom: 2rem;
296
- }
297
-
298
- .wizard-header h2 {
299
- font-size: 2rem;
300
- margin-bottom: 0.5rem;
301
- color: #1f2937;
302
- }
303
-
304
- .wizard-header p {
305
- color: #6b7280;
306
- font-size: 1.1rem;
307
- }
308
-
309
- .wizard-start {
310
- background: white;
311
- border-radius: 12px;
312
- padding: 2rem;
313
- box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
314
- text-align: center;
315
- }
316
-
317
- .start-content h3 {
318
- margin-bottom: 1rem;
319
- color: #1f2937;
320
- }
321
-
322
- .start-content ul {
323
- text-align: left;
324
- margin: 1.5rem 0;
325
- padding-left: 1.5rem;
326
- }
327
-
328
- .start-content li {
329
- margin-bottom: 0.5rem;
330
- color: #374151;
331
- }
332
-
333
- .btn {
334
- padding: 0.75rem 1.5rem;
335
- border-radius: 8px;
336
- font-weight: 600;
337
- cursor: pointer;
338
- border: none;
339
- font-size: 1rem;
340
- transition: all 0.2s;
341
- }
342
-
343
- .btn-primary {
344
- background: #10b981;
345
- color: white;
346
- }
347
-
348
- .btn-primary:hover {
349
- background: #059669;
350
- }
351
-
352
- .btn-secondary {
353
- background: #6b7280;
354
- color: white;
355
- }
356
-
357
- .btn-secondary:hover {
358
- background: #4b5563;
359
- }
360
-
361
- .wizard-progress {
362
- background: white;
363
- border-radius: 12px;
364
- padding: 2rem;
365
- box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
366
- }
367
-
368
- .progress-bar {
369
- width: 100%;
370
- height: 8px;
371
- background: #e5e7eb;
372
- border-radius: 4px;
373
- overflow: hidden;
374
- margin-bottom: 2rem;
375
- }
376
-
377
- .progress-fill {
378
- height: 100%;
379
- background: #10b981;
380
- transition: width 0.3s ease;
381
- }
382
-
383
- .steps-list {
384
- space-y: 1rem;
385
- }
386
-
387
- .step-item {
388
- display: flex;
389
- align-items: flex-start;
390
- gap: 1rem;
391
- padding: 1rem;
392
- border-radius: 8px;
393
- margin-bottom: 1rem;
394
- }
395
-
396
- .step-pending {
397
- background: #f9fafb;
398
- border: 1px solid #e5e7eb;
399
- }
400
-
401
- .step-running {
402
- background: #eff6ff;
403
- border: 1px solid #3b82f6;
404
- }
405
-
406
- .step-completed {
407
- background: #f0fdf4;
408
- border: 1px solid #22c55e;
409
- }
410
-
411
- .step-error {
412
- background: #fef2f2;
413
- border: 1px solid #ef4444;
414
- }
415
-
416
- .step-icon {
417
- font-size: 1.5rem;
418
- flex-shrink: 0;
419
- }
420
-
421
- .step-content h4 {
422
- margin: 0 0 0.25rem 0;
423
- color: #1f2937;
424
- }
425
-
426
- .step-content p {
427
- margin: 0;
428
- color: #6b7280;
429
- }
430
-
431
- .step-spinner {
432
- margin-top: 0.5rem;
433
- }
434
-
435
- .spinner {
436
- width: 20px;
437
- height: 20px;
438
- border: 2px solid #e5e7eb;
439
- border-top: 2px solid #3b82f6;
440
- border-radius: 50%;
441
- animation: spin 1s linear infinite;
442
- }
443
-
444
- @keyframes spin {
445
- 0% { transform: rotate(0deg); }
446
- 100% { transform: rotate(360deg); }
447
- }
448
-
449
- .wizard-success {
450
- background: white;
451
- border-radius: 12px;
452
- padding: 2rem;
453
- box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
454
- }
455
-
456
- .success-header {
457
- text-align: center;
458
- margin-bottom: 2rem;
459
- }
460
-
461
- .success-header h3 {
462
- color: #059669;
463
- margin-bottom: 0.5rem;
464
- }
465
-
466
- .result-details {
467
- display: grid;
468
- gap: 2rem;
469
- }
470
-
471
- .framework-info, .changes-made, .next-steps {
472
- background: #f9fafb;
473
- padding: 1.5rem;
474
- border-radius: 8px;
475
- }
476
-
477
- .framework-info h4, .changes-made h4, .next-steps h4 {
478
- margin: 0 0 1rem 0;
479
- color: #1f2937;
480
- }
481
-
482
- .changes-made ul {
483
- list-style: none;
484
- padding: 0;
485
- }
486
-
487
- .changes-made li {
488
- margin-bottom: 1rem;
489
- padding: 1rem;
490
- background: white;
491
- border-radius: 6px;
492
- border: 1px solid #e5e7eb;
493
- }
494
-
495
- .changes-made code {
496
- background: #f3f4f6;
497
- padding: 0.25rem 0.5rem;
498
- border-radius: 4px;
499
- font-size: 0.875rem;
500
- color: #374151;
501
- }
502
-
503
- .btn-copy {
504
- margin-top: 0.5rem;
505
- padding: 0.25rem 0.5rem;
506
- background: #10b981;
507
- color: white;
508
- border: none;
509
- border-radius: 4px;
510
- font-size: 0.75rem;
511
- cursor: pointer;
512
- }
513
-
514
- .btn-copy:hover {
515
- background: #059669;
516
- }
517
-
518
- .next-steps ul {
519
- list-style: none;
520
- padding: 0;
521
- }
522
-
523
- .next-steps li {
524
- margin-bottom: 0.5rem;
525
- padding-left: 1.5rem;
526
- position: relative;
527
- }
528
-
529
- .next-steps li:before {
530
- content: '✅';
531
- position: absolute;
532
- left: 0;
533
- }
534
-
535
- .wizard-error {
536
- background: white;
537
- border-radius: 12px;
538
- padding: 2rem;
539
- box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
540
- text-align: center;
541
- }
542
-
543
- .wizard-error h3 {
544
- color: #dc2626;
545
- margin-bottom: 1rem;
546
- }
547
-
548
- .wizard-error p {
549
- color: #6b7280;
550
- margin-bottom: 1.5rem;
551
- }
552
- `}</style>
553
- </div>
554
- );
555
- };
556
-
557
- export default AutoInstallWizard;
@@ -1,8 +0,0 @@
1
- // Browser-safe version of HumanBehaviorTracker
2
- import { HumanBehaviorTracker } from '../tracker';
3
-
4
- // Re-export only browser-safe functionality
5
- export { HumanBehaviorTracker };
6
-
7
- // Export browser-safe utilities
8
- export { logError, logWarn, logDebug } from '../utils/logger';