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
@@ -0,0 +1,159 @@
1
+ /**
2
+ * Centralized AI Service Implementation
3
+ *
4
+ * This service runs on your backend infrastructure and provides AI-powered
5
+ * code analysis without requiring users to provide their own API keys.
6
+ *
7
+ * The service can be deployed as:
8
+ * - AWS Lambda function
9
+ * - Docker container
10
+ * - Express.js server
11
+ * - Cloud function
12
+ */
13
+ import { AICodeAnalysis } from '../ai/ai-install-wizard';
14
+ export interface FrameworkInfo {
15
+ name: string;
16
+ type: 'react' | 'vue' | 'angular' | 'svelte' | 'nextjs' | 'nuxt' | 'remix' | 'vanilla' | 'astro' | 'node';
17
+ bundler?: 'vite' | 'webpack' | 'esbuild' | 'rollup';
18
+ packageManager?: 'npm' | 'yarn' | 'pnpm';
19
+ hasTypeScript?: boolean;
20
+ hasRouter?: boolean;
21
+ projectRoot?: string;
22
+ }
23
+ export interface CentralizedAIServiceConfig {
24
+ openaiApiKey: string;
25
+ openaiModel?: string;
26
+ maxTokens?: number;
27
+ temperature?: number;
28
+ enableCaching?: boolean;
29
+ cacheTTL?: number;
30
+ }
31
+ export interface AIAnalysisRequest {
32
+ codeSamples: string[];
33
+ projectType?: string;
34
+ userAgent?: string;
35
+ timestamp: string;
36
+ }
37
+ export interface AIAnalysisResponse {
38
+ analysis: AICodeAnalysis;
39
+ processingTime: number;
40
+ cacheHit?: boolean;
41
+ modelUsed: string;
42
+ }
43
+ export interface ConflictResolutionRequest {
44
+ conflicts: string[];
45
+ framework: FrameworkInfo;
46
+ codeContext?: string;
47
+ }
48
+ export interface OptimizationRequest {
49
+ framework: FrameworkInfo;
50
+ patterns: string[];
51
+ projectContext?: string;
52
+ }
53
+ /**
54
+ * Centralized AI Service Implementation
55
+ * This runs on your backend infrastructure
56
+ */
57
+ export declare class CentralizedAIService {
58
+ private config;
59
+ private cache;
60
+ private openai;
61
+ constructor(config: CentralizedAIServiceConfig);
62
+ /**
63
+ * Initialize OpenAI client
64
+ */
65
+ private initializeOpenAI;
66
+ /**
67
+ * Analyze code patterns using AI
68
+ */
69
+ analyzeCodePatterns(codeSamples: string[]): Promise<AICodeAnalysis>;
70
+ /**
71
+ * Resolve conflicts using AI
72
+ */
73
+ resolveConflicts(conflicts: string[], framework: FrameworkInfo): Promise<string[]>;
74
+ /**
75
+ * Generate optimizations using AI
76
+ */
77
+ generateOptimizations(framework: FrameworkInfo, patterns: string[]): Promise<string[]>;
78
+ /**
79
+ * Perform AI analysis
80
+ */
81
+ private performAIAnalysis;
82
+ /**
83
+ * Build analysis prompt
84
+ */
85
+ private buildAnalysisPrompt;
86
+ /**
87
+ * Build conflict resolution prompt
88
+ */
89
+ private buildConflictResolutionPrompt;
90
+ /**
91
+ * Build optimization prompt
92
+ */
93
+ private buildOptimizationPrompt;
94
+ /**
95
+ * Parse analysis result
96
+ */
97
+ private parseAnalysisResult;
98
+ /**
99
+ * Parse conflict resolutions
100
+ */
101
+ private parseConflictResolutions;
102
+ /**
103
+ * Parse optimizations
104
+ */
105
+ private parseOptimizations;
106
+ /**
107
+ * Heuristic analysis fallback
108
+ */
109
+ private performHeuristicAnalysis;
110
+ /**
111
+ * Heuristic conflict resolution
112
+ */
113
+ private resolveConflictsHeuristic;
114
+ /**
115
+ * Heuristic optimization generation
116
+ */
117
+ private generateOptimizationsHeuristic;
118
+ /**
119
+ * Generate cache key
120
+ */
121
+ private generateCacheKey;
122
+ /**
123
+ * Check if cache is valid
124
+ */
125
+ private isCacheValid;
126
+ /**
127
+ * Get default analysis
128
+ */
129
+ private getDefaultAnalysis;
130
+ /**
131
+ * Get service statistics
132
+ */
133
+ getStats(): {
134
+ cacheSize: number;
135
+ config: {
136
+ model: string | undefined;
137
+ maxTokens: number | undefined;
138
+ temperature: number | undefined;
139
+ caching: boolean | undefined;
140
+ };
141
+ openaiAvailable: boolean;
142
+ };
143
+ /**
144
+ * Clear cache
145
+ */
146
+ clearCache(): void;
147
+ }
148
+ /**
149
+ * Express.js server implementation
150
+ */
151
+ export declare function createAIServiceServer(config: CentralizedAIServiceConfig): any;
152
+ /**
153
+ * AWS Lambda handler
154
+ */
155
+ export declare function lambdaHandler(event: any, context: any): Promise<{
156
+ statusCode: number;
157
+ body: string;
158
+ }>;
159
+ //# sourceMappingURL=centralized-ai-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"centralized-ai-service.d.ts","sourceRoot":"","sources":["../../src/services/centralized-ai-service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC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OAAO,EAAE,GAAG;;;GAmD3D"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Remote AI Service Implementation
3
+ *
4
+ * This connects to your deployed Lambda function via API Gateway
5
+ */
6
+ import { AICodeAnalysis } from '../ai/ai-install-wizard';
7
+ export interface FrameworkInfo {
8
+ name: string;
9
+ type: 'react' | 'vue' | 'angular' | 'svelte' | 'nextjs' | 'nuxt' | 'remix' | 'vanilla' | 'astro' | 'gatsby' | 'node';
10
+ bundler?: 'vite' | 'webpack' | 'esbuild' | 'rollup';
11
+ packageManager?: 'npm' | 'yarn' | 'pnpm';
12
+ hasTypeScript?: boolean;
13
+ hasRouter?: boolean;
14
+ projectRoot?: string;
15
+ version?: string;
16
+ majorVersion?: number;
17
+ features?: {
18
+ hasReact18?: boolean;
19
+ hasVue3?: boolean;
20
+ hasNuxt3?: boolean;
21
+ hasAngularStandalone?: boolean;
22
+ hasNextAppRouter?: boolean;
23
+ hasSvelteKit?: boolean;
24
+ };
25
+ }
26
+ export interface RemoteAIServiceConfig {
27
+ apiEndpoint: string;
28
+ timeout?: number;
29
+ }
30
+ export declare class RemoteAIService {
31
+ private config;
32
+ constructor(config: RemoteAIServiceConfig);
33
+ /**
34
+ * Analyze code patterns using your deployed AI service
35
+ */
36
+ analyzeCodePatterns(codeSamples: string[]): Promise<AICodeAnalysis>;
37
+ /**
38
+ * Resolve conflicts using your deployed AI service
39
+ */
40
+ resolveConflicts(conflicts: string[], framework: FrameworkInfo): Promise<string[]>;
41
+ /**
42
+ * Generate optimizations using your deployed AI service
43
+ */
44
+ generateOptimizations(framework: FrameworkInfo, patterns: string[]): Promise<string[]>;
45
+ /**
46
+ * Heuristic analysis fallback
47
+ */
48
+ private performHeuristicAnalysis;
49
+ /**
50
+ * Heuristic conflict resolution
51
+ */
52
+ private resolveConflictsHeuristic;
53
+ /**
54
+ * Heuristic optimization generation
55
+ */
56
+ private generateOptimizationsHeuristic;
57
+ }
58
+ //# sourceMappingURL=remote-ai-service.d.ts.map
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EG;IACG,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAuBxF;;OAEG;IACG,qBAAqB,CAAC,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAuB5F;;OAEG;IACH,OAAO,CAAC,wBAAwB;IA4DhC;;OAEG;IACH,OAAO,CAAC,yBAAyB;IAsBjC;;OAEG;IACH,OAAO,CAAC,8BAA8B;CA2BvC"}
@@ -1,381 +0,0 @@
1
- # HumanBehavior SDK Auto-Installation Wizard
2
-
3
- The HumanBehavior SDK includes an intelligent auto-installation wizard that can detect your project's framework and automatically integrate the SDK with minimal user intervention.
4
-
5
- ## 🚀 Quick Start
6
-
7
- ### Single Command Installation
8
-
9
- **When the package is published to npm:**
10
- ```bash
11
- npx humanbehavior-js auto-install YOUR_API_KEY
12
- ```
13
-
14
- **For local development/testing:**
15
- ```bash
16
- node path/to/humanbehavior-js/dist/cli/auto-install.js YOUR_API_KEY
17
- ```
18
-
19
- That's it! The wizard will:
20
- - 🔍 Auto-detect your project's framework
21
- - 📦 Install the humanbehavior-js package
22
- - ✏️ Modify your codebase to integrate the SDK
23
- - 🔧 Create environment files with your API key
24
- - 🚀 Make your app ready to track user behavior
25
-
26
- ## 📋 Supported Frameworks
27
-
28
- The wizard automatically detects and configures:
29
-
30
- - ✅ **React** (CRA, Vite, Webpack)
31
- - ✅ **Next.js** (App Router, Pages Router)
32
- - ✅ **Vue** (Vue CLI, Vite)
33
- - ✅ **Angular**
34
- - ✅ **Svelte** (SvelteKit, Vite)
35
- - ✅ **Nuxt.js**
36
- - ✅ **Vanilla JS/TS**
37
- - ✅ **Node.js** (CommonJS & ESM)
38
-
39
- ## 🛠️ Installation Options
40
-
41
- ### Basic Usage
42
-
43
- **When the package is published to npm:**
44
- ```bash
45
- # Interactive mode (prompts for API key)
46
- npx humanbehavior-js auto-install
47
-
48
- # With API key as argument
49
- npx humanbehavior-js auto-install your-api-key-here
50
-
51
- # Skip all prompts
52
- npx humanbehavior-js auto-install your-api-key-here --yes
53
- ```
54
-
55
- **For local development/testing:**
56
- ```bash
57
- # Interactive mode (prompts for API key)
58
- node path/to/humanbehavior-js/dist/cli/auto-install.js
59
-
60
- # With API key as argument
61
- node path/to/humanbehavior-js/dist/cli/auto-install.js your-api-key-here
62
-
63
- # Skip all prompts
64
- node path/to/humanbehavior-js/dist/cli/auto-install.js your-api-key-here --yes
65
- ```
66
-
67
- ### Advanced Options
68
-
69
- **When the package is published to npm:**
70
- ```bash
71
- # Specify project directory
72
- npx humanbehavior-js auto-install your-api-key -p /path/to/project
73
-
74
- # Dry run (show what would be changed without making changes)
75
- npx humanbehavior-js auto-install your-api-key --dry-run
76
-
77
- # Get help
78
- npx humanbehavior-js auto-install --help
79
- ```
80
-
81
- **For local development/testing:**
82
- ```bash
83
- # Specify project directory
84
- node path/to/humanbehavior-js/dist/cli/auto-install.js your-api-key -p /path/to/project
85
-
86
- # Dry run (show what would be changed without making changes)
87
- node path/to/humanbehavior-js auto-install.js your-api-key --dry-run
88
-
89
- # Get help
90
- node path/to/humanbehavior-js/dist/cli/auto-install.js --help
91
- ```
92
-
93
- ## 🔧 Framework-Specific Integration
94
-
95
- ### React
96
- ```jsx
97
- // The wizard automatically wraps your app with HumanBehaviorProvider
98
- import { HumanBehaviorProvider } from 'humanbehavior-js/react';
99
-
100
- function App() {
101
- return (
102
- <HumanBehaviorProvider apiKey={process.env.HUMANBEHAVIOR_API_KEY}>
103
- {/* Your app content */}
104
- </HumanBehaviorProvider>
105
- );
106
- }
107
- ```
108
-
109
- ### Next.js (App Router)
110
- ```tsx
111
- // Creates app/providers.tsx
112
- 'use client';
113
- import { HumanBehaviorProvider } from 'humanbehavior-js/react';
114
-
115
- export function Providers({ children }: { children: React.ReactNode }) {
116
- return (
117
- <HumanBehaviorProvider apiKey={process.env.HUMANBEHAVIOR_API_KEY}>
118
- {children}
119
- </HumanBehaviorProvider>
120
- );
121
- }
122
-
123
- // Modifies app/layout.tsx to use Providers
124
- ```
125
-
126
- ### Next.js (Pages Router)
127
- ```tsx
128
- // Creates components/providers.tsx
129
- 'use client';
130
- import { HumanBehaviorProvider } from 'humanbehavior-js/react';
131
-
132
- export function Providers({ children }: { children: React.ReactNode }) {
133
- return (
134
- <HumanBehaviorProvider apiKey={process.env.HUMANBEHAVIOR_API_KEY}>
135
- {children}
136
- </HumanBehaviorProvider>
137
- );
138
- }
139
-
140
- // Modifies pages/_app.tsx to use Providers
141
- ```
142
-
143
- ### Vue
144
- ```js
145
- // The wizard adds the plugin to your main.js/ts
146
- import { HumanBehaviorPlugin } from 'humanbehavior-js/vue';
147
-
148
- app.use(HumanBehaviorPlugin, {
149
- apiKey: import.meta.env.VITE_HUMANBEHAVIOR_API_KEY
150
- });
151
- ```
152
-
153
- ### Angular
154
- ```typescript
155
- // The wizard adds the module to app.module.ts
156
- import { HumanBehaviorModule } from 'humanbehavior-js/angular';
157
-
158
- @NgModule({
159
- imports: [
160
- // ... other imports
161
- HumanBehaviorModule.forRoot({
162
- apiKey: environment.humanBehaviorApiKey
163
- })
164
- ]
165
- })
166
- ```
167
-
168
- ### Svelte
169
- ```javascript
170
- // The wizard adds the store to your main file
171
- import { humanBehaviorStore } from 'humanbehavior-js/svelte';
172
-
173
- humanBehaviorStore.init('your-api-key');
174
- ```
175
-
176
- ### Nuxt.js
177
- ```typescript
178
- // Creates plugins/humanbehavior.client.ts
179
- import { HumanBehaviorPlugin } from 'humanbehavior-js/vue';
180
-
181
- export default defineNuxtPlugin((nuxtApp) => {
182
- nuxtApp.vueApp.use(HumanBehaviorPlugin, {
183
- apiKey: useRuntimeConfig().public.humanBehaviorApiKey
184
- });
185
- });
186
- ```
187
-
188
- ## 🔐 Environment Variables
189
-
190
- The wizard intelligently handles environment files:
191
-
192
- ### Smart File Detection
193
- The wizard checks for existing environment files in this order:
194
- 1. `.env.local`
195
- 2. `.env.development.local`
196
- 3. `.env.development`
197
- 4. `.env.local.development`
198
- 5. `.env`
199
- 6. `.env.production`
200
- 7. `.env.staging`
201
-
202
- ### Framework-Specific Variables
203
- - **React/Next.js**: `HUMANBEHAVIOR_API_KEY`
204
- - **Vue**: `VITE_HUMANBEHAVIOR_API_KEY`
205
- - **Svelte**: `PUBLIC_HUMANBEHAVIOR_API_KEY`
206
- - **Angular**: `humanBehaviorApiKey` (in environment.ts)
207
- - **Nuxt**: `HUMANBEHAVIOR_API_KEY`
208
-
209
- ### Safe Environment Handling
210
- - ✅ **Preserves existing files** (never overwrites)
211
- - ✅ **Appends to existing files** (adds API key safely)
212
- - ✅ **Skips duplicates** (won't add same variable twice)
213
- - ✅ **Works with gitignored files** (finds .env files even if ignored)
214
-
215
- ## 📁 Project Structure After Installation
216
-
217
- ### React/Next.js Project
218
- ```
219
- your-project/
220
- ├── .env.local # Created with API key
221
- ├── src/
222
- │ ├── App.tsx # Modified with provider
223
- │ └── index.tsx # Unchanged
224
- ├── package.json # humanbehavior-js added
225
- └── node_modules/
226
- ```
227
-
228
- ### Next.js App Router
229
- ```
230
- your-project/
231
- ├── .env.local # Created with API key
232
- ├── app/
233
- │ ├── layout.tsx # Modified to use providers
234
- │ └── providers.tsx # Created with provider
235
- ├── package.json # humanbehavior-js added
236
- └── node_modules/
237
- ```
238
-
239
- ### Vue Project
240
- ```
241
- your-project/
242
- ├── .env.local # Created with API key
243
- ├── src/
244
- │ └── main.js # Modified with plugin
245
- ├── package.json # humanbehavior-js added
246
- └── node_modules/
247
- ```
248
-
249
- ## 🎯 What Gets Modified
250
-
251
- ### Code Changes
252
- - **Main entry point**: Wrapped with provider/plugin
253
- - **Environment files**: API key added safely
254
- - **Package.json**: humanbehavior-js dependency added
255
-
256
- ### Files Created
257
- - **Environment files**: `.env.local`, `.env`, etc.
258
- - **Provider files**: `providers.tsx` (Next.js)
259
- - **Plugin files**: `humanbehavior.client.ts` (Nuxt)
260
-
261
- ### Files Modified
262
- - **Main app file**: `App.tsx`, `main.js`, `layout.tsx`, etc.
263
- - **Package.json**: Dependencies updated
264
- - **Environment files**: API key appended
265
-
266
- ## 🚨 Troubleshooting
267
-
268
- ### Common Issues
269
-
270
- **"Framework not detected"**
271
- - Ensure you're running the command from your project root
272
- - Check that `package.json` exists and has dependencies
273
-
274
- **"Permission denied"**
275
- - Make sure you have write permissions to your project directory
276
- - Try running with `sudo` if needed (not recommended)
277
-
278
- **"Package installation failed"**
279
- - Check your internet connection
280
- - Ensure npm/yarn is properly configured
281
- - Try running `npm install` manually first
282
-
283
- ### Manual Fallback
284
-
285
- If the wizard fails, you can install manually:
286
-
287
- ```bash
288
- # Install the package
289
- npm install humanbehavior-js
290
-
291
- # Add environment variable
292
- echo "HUMANBEHAVIOR_API_KEY=your-api-key" >> .env.local
293
-
294
- # Then follow framework-specific setup in the main README
295
- ```
296
-
297
- ## 🚀 Current Status
298
-
299
- **Note**: The auto-installation wizard is currently in development and not yet published to npm. To test it locally:
300
-
301
- 1. **Clone the repository**:
302
- ```bash
303
- git clone https://github.com/humanbehavior-gh/humanbehavior-js.git
304
- cd humanbehavior-js
305
- ```
306
-
307
- 2. **Build the wizard**:
308
- ```bash
309
- npm install
310
- npm run build
311
- ```
312
-
313
- 3. **Test in your project**:
314
- ```bash
315
- node dist/cli/auto-install.js your-api-key --yes
316
- ```
317
-
318
- Once the package is published to npm, you'll be able to use the `npx` commands shown above.
319
-
320
- ## 🔍 Debugging
321
-
322
- ### Dry Run Mode
323
- **When the package is published to npm:**
324
- ```bash
325
- npx humanbehavior-js auto-install your-api-key --dry-run
326
- ```
327
-
328
- **For local development/testing:**
329
- ```bash
330
- node path/to/humanbehavior-js/dist/cli/auto-install.js your-api-key --dry-run
331
- ```
332
-
333
- Shows what changes would be made without actually making them.
334
-
335
- ### Verbose Output
336
- The wizard provides detailed output showing:
337
- - Framework detection results
338
- - Package installation status
339
- - Files created/modified
340
- - Next steps for the user
341
-
342
- ## 📚 Next Steps After Installation
343
-
344
- Once the wizard completes:
345
-
346
- 1. **Start your development server**
347
- ```bash
348
- npm start
349
- # or
350
- yarn dev
351
- ```
352
-
353
- 2. **Verify integration**
354
- - Check browser console for SDK initialization
355
- - Visit your app and trigger some interactions
356
- - Check your HumanBehavior dashboard for sessions
357
-
358
- 3. **Customize tracking** (optional)
359
- ```javascript
360
- // React
361
- import { useHumanBehavior } from 'humanbehavior-js/react';
362
-
363
- function MyComponent() {
364
- const { trackEvent } = useHumanBehavior();
365
-
366
- const handleClick = () => {
367
- trackEvent('button_clicked', { button: 'submit' });
368
- };
369
- }
370
- ```
371
-
372
- ## 🎉 Success Indicators
373
-
374
- The wizard is successful when you see:
375
- - ✅ "Installation completed successfully!"
376
- - ✅ Framework detected correctly
377
- - ✅ Package installed without errors
378
- - ✅ Environment file created
379
- - ✅ Code modifications applied
380
-
381
- Your app is now ready to track user behavior! 🚀