humanbehavior-js 0.3.6 → 0.3.8

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 (59) hide show
  1. package/WIZARD_USAGE_GUIDE.md +381 -0
  2. package/dist/cjs/angular/index.cjs +53 -0
  3. package/dist/cjs/angular/index.cjs.map +1 -0
  4. package/dist/cjs/index.cjs +14230 -0
  5. package/dist/cjs/index.cjs.map +1 -0
  6. package/dist/cjs/install-wizard.cjs +1157 -0
  7. package/dist/cjs/install-wizard.cjs.map +1 -0
  8. package/dist/cjs/react/index.cjs +14387 -0
  9. package/dist/cjs/react/index.cjs.map +1 -0
  10. package/dist/cjs/remix/index.cjs +57 -0
  11. package/dist/cjs/remix/index.cjs.map +1 -0
  12. package/dist/cjs/svelte/index.cjs +13 -0
  13. package/dist/cjs/svelte/index.cjs.map +1 -0
  14. package/dist/cjs/vue/index.cjs +16 -0
  15. package/dist/cjs/vue/index.cjs.map +1 -0
  16. package/dist/cli/auto-install.js +1170 -0
  17. package/dist/cli/auto-install.js.map +1 -0
  18. package/dist/esm/angular/index.js +49 -0
  19. package/dist/esm/angular/index.js.map +1 -0
  20. package/dist/esm/index.js +12160 -3894
  21. package/dist/esm/index.js.map +1 -1
  22. package/dist/esm/install-wizard.js +1134 -0
  23. package/dist/esm/install-wizard.js.map +1 -0
  24. package/dist/esm/react/index.js +14113 -70
  25. package/dist/esm/react/index.js.map +1 -1
  26. package/dist/esm/remix/index.js +47 -0
  27. package/dist/esm/remix/index.js.map +1 -0
  28. package/dist/esm/svelte/index.js +11 -0
  29. package/dist/esm/svelte/index.js.map +1 -0
  30. package/dist/esm/vue/index.js +14 -0
  31. package/dist/esm/vue/index.js.map +1 -0
  32. package/dist/index.min.js +1 -15
  33. package/dist/index.min.js.map +1 -1
  34. package/dist/types/angular/index.d.ts +240 -0
  35. package/dist/types/index.d.ts +2 -2
  36. package/dist/types/install-wizard.d.ts +126 -0
  37. package/dist/types/react/index.d.ts +212 -3
  38. package/dist/types/remix/index.d.ts +10 -0
  39. package/dist/types/svelte/index.d.ts +216 -0
  40. package/dist/types/vue/index.d.ts +10 -0
  41. package/package.json +41 -9
  42. package/readme.md +72 -3
  43. package/rollup.config.js +263 -13
  44. package/src/angular/index.ts +54 -0
  45. package/src/api.ts +19 -2
  46. package/src/cli/auto-install.ts +225 -0
  47. package/src/index.ts +5 -2
  48. package/src/install-wizard.ts +1304 -0
  49. package/src/react/AutoInstallWizard.tsx +557 -0
  50. package/src/react/browser.ts +8 -0
  51. package/src/react/index.tsx +2 -4
  52. package/src/remix/index.ts +16 -0
  53. package/src/svelte/index.ts +8 -0
  54. package/src/tracker.ts +54 -24
  55. package/src/vue/index.ts +18 -0
  56. package/dist/cjs/index.js +0 -5967
  57. package/dist/cjs/index.js.map +0 -1
  58. package/dist/cjs/react/index.js +0 -346
  59. package/dist/cjs/react/index.js.map +0 -1
@@ -0,0 +1,1134 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+
4
+ /******************************************************************************
5
+ Copyright (c) Microsoft Corporation.
6
+
7
+ Permission to use, copy, modify, and/or distribute this software for any
8
+ purpose with or without fee is hereby granted.
9
+
10
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
11
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
13
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
15
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16
+ PERFORMANCE OF THIS SOFTWARE.
17
+ ***************************************************************************** */
18
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
19
+
20
+
21
+ function __awaiter(thisArg, _arguments, P, generator) {
22
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
+ return new (P || (P = Promise))(function (resolve, reject) {
24
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
28
+ });
29
+ }
30
+
31
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
32
+ var e = new Error(message);
33
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
34
+ };
35
+
36
+ /**
37
+ * HumanBehavior SDK Auto-Installation Wizard
38
+ *
39
+ * This wizard automatically detects the user's framework and modifies their codebase
40
+ * to integrate the SDK with minimal user intervention.
41
+ */
42
+ class AutoInstallationWizard {
43
+ constructor(apiKey, projectRoot = process.cwd()) {
44
+ this.framework = null;
45
+ this.apiKey = apiKey;
46
+ this.projectRoot = projectRoot;
47
+ }
48
+ /**
49
+ * Main installation method - detects framework and auto-installs
50
+ */
51
+ install() {
52
+ return __awaiter(this, void 0, void 0, function* () {
53
+ try {
54
+ // Step 1: Detect framework
55
+ this.framework = yield this.detectFramework();
56
+ // Step 2: Install package
57
+ yield this.installPackage();
58
+ // Step 3: Generate and apply code modifications
59
+ const modifications = yield this.generateModifications();
60
+ yield this.applyModifications(modifications);
61
+ // Step 4: Generate next steps
62
+ const nextSteps = this.generateNextSteps();
63
+ return {
64
+ success: true,
65
+ framework: this.framework,
66
+ modifications,
67
+ errors: [],
68
+ nextSteps
69
+ };
70
+ }
71
+ catch (error) {
72
+ return {
73
+ success: false,
74
+ framework: this.framework || { name: 'unknown', type: 'vanilla' },
75
+ modifications: [],
76
+ errors: [error instanceof Error ? error.message : 'Unknown error'],
77
+ nextSteps: []
78
+ };
79
+ }
80
+ });
81
+ }
82
+ /**
83
+ * Detect the current framework and project setup
84
+ */
85
+ detectFramework() {
86
+ return __awaiter(this, void 0, void 0, function* () {
87
+ const packageJsonPath = path.join(this.projectRoot, 'package.json');
88
+ if (!fs.existsSync(packageJsonPath)) {
89
+ return {
90
+ name: 'vanilla',
91
+ type: 'vanilla',
92
+ projectRoot: this.projectRoot
93
+ };
94
+ }
95
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
96
+ const dependencies = Object.assign(Object.assign({}, packageJson.dependencies), packageJson.devDependencies);
97
+ // Detect framework
98
+ let framework = {
99
+ name: 'vanilla',
100
+ type: 'vanilla',
101
+ projectRoot: this.projectRoot
102
+ };
103
+ if (dependencies.nuxt) {
104
+ framework = {
105
+ name: 'nuxt',
106
+ type: 'nuxt',
107
+ hasTypeScript: !!dependencies.typescript,
108
+ hasRouter: true,
109
+ projectRoot: this.projectRoot
110
+ };
111
+ }
112
+ else if (dependencies.next) {
113
+ framework = {
114
+ name: 'nextjs',
115
+ type: 'nextjs',
116
+ hasTypeScript: !!dependencies.typescript || !!dependencies['@types/node'],
117
+ hasRouter: true,
118
+ projectRoot: this.projectRoot
119
+ };
120
+ }
121
+ else if (dependencies['@remix-run/react'] || dependencies['@remix-run/dev']) {
122
+ framework = {
123
+ name: 'remix',
124
+ type: 'remix',
125
+ hasTypeScript: !!dependencies.typescript || !!dependencies['@types/react'],
126
+ hasRouter: true,
127
+ projectRoot: this.projectRoot
128
+ };
129
+ }
130
+ else if (dependencies.react) {
131
+ framework = {
132
+ name: 'react',
133
+ type: 'react',
134
+ hasTypeScript: !!dependencies.typescript || !!dependencies['@types/react'],
135
+ hasRouter: !!dependencies['react-router-dom'] || !!dependencies['react-router'],
136
+ projectRoot: this.projectRoot
137
+ };
138
+ }
139
+ else if (dependencies.vue) {
140
+ framework = {
141
+ name: 'vue',
142
+ type: 'vue',
143
+ hasTypeScript: !!dependencies.typescript || !!dependencies['@vue/cli-service'],
144
+ hasRouter: !!dependencies['vue-router'],
145
+ projectRoot: this.projectRoot
146
+ };
147
+ }
148
+ else if (dependencies['@angular/core']) {
149
+ framework = {
150
+ name: 'angular',
151
+ type: 'angular',
152
+ hasTypeScript: true,
153
+ hasRouter: true,
154
+ projectRoot: this.projectRoot
155
+ };
156
+ }
157
+ else if (dependencies.svelte) {
158
+ framework = {
159
+ name: 'svelte',
160
+ type: 'svelte',
161
+ hasTypeScript: !!dependencies.typescript || !!dependencies['svelte-check'],
162
+ hasRouter: !!dependencies['svelte-routing'] || !!dependencies['@sveltejs/kit'],
163
+ projectRoot: this.projectRoot
164
+ };
165
+ }
166
+ // Detect bundler
167
+ if (dependencies.vite) {
168
+ framework.bundler = 'vite';
169
+ }
170
+ else if (dependencies.webpack) {
171
+ framework.bundler = 'webpack';
172
+ }
173
+ else if (dependencies.esbuild) {
174
+ framework.bundler = 'esbuild';
175
+ }
176
+ else if (dependencies.rollup) {
177
+ framework.bundler = 'rollup';
178
+ }
179
+ // Detect package manager
180
+ if (fs.existsSync(path.join(this.projectRoot, 'yarn.lock'))) {
181
+ framework.packageManager = 'yarn';
182
+ }
183
+ else if (fs.existsSync(path.join(this.projectRoot, 'pnpm-lock.yaml'))) {
184
+ framework.packageManager = 'pnpm';
185
+ }
186
+ else {
187
+ framework.packageManager = 'npm';
188
+ }
189
+ return framework;
190
+ });
191
+ }
192
+ /**
193
+ * Install the SDK package
194
+ */
195
+ installPackage() {
196
+ return __awaiter(this, void 0, void 0, function* () {
197
+ var _a, _b;
198
+ const { execSync } = yield import('child_process');
199
+ const command = ((_a = this.framework) === null || _a === void 0 ? void 0 : _a.packageManager) === 'yarn'
200
+ ? 'yarn add humanbehavior-js'
201
+ : ((_b = this.framework) === null || _b === void 0 ? void 0 : _b.packageManager) === 'pnpm'
202
+ ? 'pnpm add humanbehavior-js'
203
+ : 'npm install humanbehavior-js';
204
+ try {
205
+ execSync(command, { cwd: this.projectRoot, stdio: 'inherit' });
206
+ }
207
+ catch (error) {
208
+ throw new Error(`Failed to install humanbehavior-js: ${error}`);
209
+ }
210
+ });
211
+ }
212
+ /**
213
+ * Generate code modifications based on framework
214
+ */
215
+ generateModifications() {
216
+ return __awaiter(this, void 0, void 0, function* () {
217
+ var _a;
218
+ const modifications = [];
219
+ switch ((_a = this.framework) === null || _a === void 0 ? void 0 : _a.type) {
220
+ case 'react':
221
+ modifications.push(...yield this.generateReactModifications());
222
+ break;
223
+ case 'nextjs':
224
+ modifications.push(...yield this.generateNextJSModifications());
225
+ break;
226
+ case 'nuxt':
227
+ modifications.push(...yield this.generateNuxtModifications());
228
+ break;
229
+ case 'remix':
230
+ modifications.push(...yield this.generateRemixModifications());
231
+ break;
232
+ case 'vue':
233
+ modifications.push(...yield this.generateVueModifications());
234
+ break;
235
+ case 'angular':
236
+ modifications.push(...yield this.generateAngularModifications());
237
+ break;
238
+ case 'svelte':
239
+ modifications.push(...yield this.generateSvelteModifications());
240
+ break;
241
+ default:
242
+ modifications.push(...yield this.generateVanillaModifications());
243
+ }
244
+ return modifications;
245
+ });
246
+ }
247
+ /**
248
+ * Generate React-specific modifications
249
+ */
250
+ generateReactModifications() {
251
+ return __awaiter(this, void 0, void 0, function* () {
252
+ const modifications = [];
253
+ // Find main App component or index file
254
+ const appFile = this.findReactAppFile();
255
+ if (appFile) {
256
+ const content = fs.readFileSync(appFile, 'utf8');
257
+ const modifiedContent = this.injectReactProvider(content, appFile);
258
+ modifications.push({
259
+ filePath: appFile,
260
+ action: 'modify',
261
+ content: modifiedContent,
262
+ description: 'Added HumanBehaviorProvider to React app'
263
+ });
264
+ }
265
+ // Create or append to environment file
266
+ modifications.push(this.createEnvironmentModification(this.framework));
267
+ return modifications;
268
+ });
269
+ }
270
+ /**
271
+ * Generate Next.js-specific modifications
272
+ */
273
+ generateNextJSModifications() {
274
+ return __awaiter(this, void 0, void 0, function* () {
275
+ const modifications = [];
276
+ // Check for App Router
277
+ const appLayoutFile = path.join(this.projectRoot, 'src', 'app', 'layout.tsx');
278
+ const pagesLayoutFile = path.join(this.projectRoot, 'src', 'pages', '_app.tsx');
279
+ if (fs.existsSync(appLayoutFile)) {
280
+ // Create providers.tsx file for App Router
281
+ modifications.push({
282
+ filePath: path.join(this.projectRoot, 'src', 'app', 'providers.tsx'),
283
+ action: 'create',
284
+ content: `'use client';
285
+
286
+ import { HumanBehaviorProvider } from 'humanbehavior-js/react';
287
+
288
+ export function Providers({ children }: { children: React.ReactNode }) {
289
+ return (
290
+ <HumanBehaviorProvider apiKey={process.env.NEXT_PUBLIC_HUMANBEHAVIOR_API_KEY}>
291
+ {children}
292
+ </HumanBehaviorProvider>
293
+ );
294
+ }`,
295
+ description: 'Created providers.tsx file for Next.js App Router'
296
+ });
297
+ // Modify layout.tsx to use the provider
298
+ const content = fs.readFileSync(appLayoutFile, 'utf8');
299
+ const modifiedContent = this.injectNextJSAppRouter(content);
300
+ modifications.push({
301
+ filePath: appLayoutFile,
302
+ action: 'modify',
303
+ content: modifiedContent,
304
+ description: 'Added Providers wrapper to Next.js App Router layout'
305
+ });
306
+ }
307
+ else if (fs.existsSync(pagesLayoutFile)) {
308
+ // Create providers.tsx file for Pages Router
309
+ modifications.push({
310
+ filePath: path.join(this.projectRoot, 'src', 'components', 'providers.tsx'),
311
+ action: 'create',
312
+ content: `'use client';
313
+
314
+ import { HumanBehaviorProvider } from 'humanbehavior-js/react';
315
+
316
+ export function Providers({ children }: { children: React.ReactNode }) {
317
+ return (
318
+ <HumanBehaviorProvider apiKey={process.env.NEXT_PUBLIC_HUMANBEHAVIOR_API_KEY}>
319
+ {children}
320
+ </HumanBehaviorProvider>
321
+ );
322
+ }`,
323
+ description: 'Created providers.tsx file for Pages Router'
324
+ });
325
+ // Modify _app.tsx to use the provider
326
+ const content = fs.readFileSync(pagesLayoutFile, 'utf8');
327
+ const modifiedContent = this.injectNextJSPagesRouter(content);
328
+ modifications.push({
329
+ filePath: pagesLayoutFile,
330
+ action: 'modify',
331
+ content: modifiedContent,
332
+ description: 'Added Providers wrapper to Next.js Pages Router'
333
+ });
334
+ }
335
+ // Create or append to environment file
336
+ modifications.push(this.createEnvironmentModification(this.framework));
337
+ return modifications;
338
+ });
339
+ }
340
+ /**
341
+ * Generate Nuxt-specific modifications
342
+ */
343
+ generateNuxtModifications() {
344
+ return __awaiter(this, void 0, void 0, function* () {
345
+ const modifications = [];
346
+ // Create plugin file for Nuxt (in app directory)
347
+ const pluginFile = path.join(this.projectRoot, 'app', 'plugins', 'humanbehavior.client.ts');
348
+ modifications.push({
349
+ filePath: pluginFile,
350
+ action: 'create',
351
+ content: `import { HumanBehaviorTracker } from 'humanbehavior-js';
352
+
353
+ export default defineNuxtPlugin(() => {
354
+ const config = useRuntimeConfig();
355
+
356
+ // Initialize HumanBehavior SDK (client-side only)
357
+ if (typeof window !== 'undefined') {
358
+ const apiKey = config.public.humanBehaviorApiKey;
359
+ console.log('HumanBehavior: API key:', apiKey ? 'present' : 'missing');
360
+
361
+ if (apiKey) {
362
+ try {
363
+ const tracker = HumanBehaviorTracker.init(apiKey);
364
+ console.log('HumanBehavior: Tracker initialized successfully');
365
+ } catch (error) {
366
+ console.error('HumanBehavior: Failed to initialize tracker:', error);
367
+ }
368
+ } else {
369
+ console.error('HumanBehavior: No API key found in runtime config');
370
+ }
371
+ }
372
+ });`,
373
+ description: 'Created Nuxt plugin for HumanBehavior SDK in app directory'
374
+ });
375
+ // Create environment configuration
376
+ const nuxtConfigFile = path.join(this.projectRoot, 'nuxt.config.ts');
377
+ if (fs.existsSync(nuxtConfigFile)) {
378
+ const content = fs.readFileSync(nuxtConfigFile, 'utf8');
379
+ const modifiedContent = this.injectNuxtConfig(content);
380
+ modifications.push({
381
+ filePath: nuxtConfigFile,
382
+ action: 'modify',
383
+ content: modifiedContent,
384
+ description: 'Added HumanBehavior runtime config to Nuxt config'
385
+ });
386
+ }
387
+ // Create or append to environment file
388
+ modifications.push(this.createEnvironmentModification(this.framework));
389
+ return modifications;
390
+ });
391
+ }
392
+ /**
393
+ * Generate Remix-specific modifications
394
+ */
395
+ generateRemixModifications() {
396
+ return __awaiter(this, void 0, void 0, function* () {
397
+ const modifications = [];
398
+ // Find root.tsx file
399
+ const rootFile = path.join(this.projectRoot, 'app', 'root.tsx');
400
+ if (fs.existsSync(rootFile)) {
401
+ const content = fs.readFileSync(rootFile, 'utf8');
402
+ const modifiedContent = this.injectRemixProvider(content);
403
+ modifications.push({
404
+ filePath: rootFile,
405
+ action: 'modify',
406
+ content: modifiedContent,
407
+ description: 'Added HumanBehaviorProvider to Remix root component'
408
+ });
409
+ }
410
+ // Create or append to environment file
411
+ modifications.push(this.createEnvironmentModification(this.framework));
412
+ return modifications;
413
+ });
414
+ }
415
+ /**
416
+ * Generate Vue-specific modifications
417
+ */
418
+ generateVueModifications() {
419
+ return __awaiter(this, void 0, void 0, function* () {
420
+ const modifications = [];
421
+ // Find main.js or main.ts
422
+ const mainFile = this.findVueMainFile();
423
+ if (mainFile) {
424
+ const content = fs.readFileSync(mainFile, 'utf8');
425
+ const modifiedContent = this.injectVuePlugin(content);
426
+ modifications.push({
427
+ filePath: mainFile,
428
+ action: 'modify',
429
+ content: modifiedContent,
430
+ description: 'Added HumanBehaviorPlugin to Vue app'
431
+ });
432
+ }
433
+ // Create or append to environment file
434
+ modifications.push(this.createEnvironmentModification(this.framework));
435
+ return modifications;
436
+ });
437
+ }
438
+ /**
439
+ * Generate Angular-specific modifications
440
+ */
441
+ generateAngularModifications() {
442
+ return __awaiter(this, void 0, void 0, function* () {
443
+ const modifications = [];
444
+ // Check for modern Angular (standalone components) vs legacy (NgModule)
445
+ const appModuleFile = path.join(this.projectRoot, 'src', 'app', 'app.module.ts');
446
+ const appComponentFile = path.join(this.projectRoot, 'src', 'app', 'app.ts');
447
+ const mainFile = path.join(this.projectRoot, 'src', 'main.ts');
448
+ const isModernAngular = fs.existsSync(appComponentFile) && !fs.existsSync(appModuleFile);
449
+ if (isModernAngular) {
450
+ // Modern Angular 17+ with standalone components
451
+ if (fs.existsSync(mainFile)) {
452
+ const content = fs.readFileSync(mainFile, 'utf8');
453
+ const modifiedContent = this.injectAngularStandaloneInit(content);
454
+ modifications.push({
455
+ filePath: mainFile,
456
+ action: 'modify',
457
+ content: modifiedContent,
458
+ description: 'Added HumanBehavior initialization to Angular main.ts'
459
+ });
460
+ }
461
+ }
462
+ else if (fs.existsSync(appModuleFile)) {
463
+ // Legacy Angular with NgModule
464
+ const content = fs.readFileSync(appModuleFile, 'utf8');
465
+ const modifiedContent = this.injectAngularModule(content);
466
+ modifications.push({
467
+ filePath: appModuleFile,
468
+ action: 'modify',
469
+ content: modifiedContent,
470
+ description: 'Added HumanBehaviorModule to Angular app'
471
+ });
472
+ }
473
+ // Handle Angular environment file (legacy structure)
474
+ const envFile = path.join(this.projectRoot, 'src', 'environments', 'environment.ts');
475
+ if (fs.existsSync(envFile)) {
476
+ const content = fs.readFileSync(envFile, 'utf8');
477
+ if (!content.includes('humanBehaviorApiKey')) {
478
+ const modifiedContent = content.replace(/export const environment = {([\s\S]*?)};/, `export const environment = {
479
+ $1,
480
+ humanBehaviorApiKey: process.env['HUMANBEHAVIOR_API_KEY'] || ''
481
+ };`);
482
+ modifications.push({
483
+ filePath: envFile,
484
+ action: 'modify',
485
+ content: modifiedContent,
486
+ description: 'Added API key to Angular environment'
487
+ });
488
+ }
489
+ }
490
+ // Create or append to environment file
491
+ modifications.push(this.createEnvironmentModification(this.framework));
492
+ return modifications;
493
+ });
494
+ }
495
+ /**
496
+ * Generate Svelte-specific modifications
497
+ */
498
+ generateSvelteModifications() {
499
+ return __awaiter(this, void 0, void 0, function* () {
500
+ const modifications = [];
501
+ // Check for SvelteKit
502
+ const svelteConfigFile = path.join(this.projectRoot, 'svelte.config.js');
503
+ const isSvelteKit = fs.existsSync(svelteConfigFile);
504
+ if (isSvelteKit) {
505
+ // SvelteKit - create layout file
506
+ const layoutFile = path.join(this.projectRoot, 'src', 'routes', '+layout.svelte');
507
+ if (fs.existsSync(layoutFile)) {
508
+ const content = fs.readFileSync(layoutFile, 'utf8');
509
+ const modifiedContent = this.injectSvelteKitLayout(content);
510
+ modifications.push({
511
+ filePath: layoutFile,
512
+ action: 'modify',
513
+ content: modifiedContent,
514
+ description: 'Added HumanBehavior store to SvelteKit layout'
515
+ });
516
+ }
517
+ }
518
+ else {
519
+ // Regular Svelte - modify main file
520
+ const mainFile = this.findSvelteMainFile();
521
+ if (mainFile) {
522
+ const content = fs.readFileSync(mainFile, 'utf8');
523
+ const modifiedContent = this.injectSvelteStore(content);
524
+ modifications.push({
525
+ filePath: mainFile,
526
+ action: 'modify',
527
+ content: modifiedContent,
528
+ description: 'Added HumanBehavior store to Svelte app'
529
+ });
530
+ }
531
+ }
532
+ // Create or append to environment file
533
+ modifications.push(this.createEnvironmentModification(this.framework));
534
+ return modifications;
535
+ });
536
+ }
537
+ /**
538
+ * Generate vanilla JS/TS modifications
539
+ */
540
+ generateVanillaModifications() {
541
+ return __awaiter(this, void 0, void 0, function* () {
542
+ const modifications = [];
543
+ // Find HTML file to inject script
544
+ const htmlFile = this.findHTMLFile();
545
+ if (htmlFile) {
546
+ const content = fs.readFileSync(htmlFile, 'utf8');
547
+ const modifiedContent = this.injectVanillaScript(content);
548
+ modifications.push({
549
+ filePath: htmlFile,
550
+ action: 'modify',
551
+ content: modifiedContent,
552
+ description: 'Added HumanBehavior CDN script to HTML file'
553
+ });
554
+ }
555
+ // Create or append to environment file
556
+ modifications.push(this.createEnvironmentModification(this.framework));
557
+ return modifications;
558
+ });
559
+ }
560
+ /**
561
+ * Apply modifications to the codebase
562
+ */
563
+ applyModifications(modifications) {
564
+ return __awaiter(this, void 0, void 0, function* () {
565
+ for (const modification of modifications) {
566
+ try {
567
+ const dir = path.dirname(modification.filePath);
568
+ if (!fs.existsSync(dir)) {
569
+ fs.mkdirSync(dir, { recursive: true });
570
+ }
571
+ switch (modification.action) {
572
+ case 'create':
573
+ fs.writeFileSync(modification.filePath, modification.content);
574
+ break;
575
+ case 'modify':
576
+ fs.writeFileSync(modification.filePath, modification.content);
577
+ break;
578
+ case 'append':
579
+ fs.appendFileSync(modification.filePath, '\n' + modification.content);
580
+ break;
581
+ }
582
+ }
583
+ catch (error) {
584
+ throw new Error(`Failed to apply modification to ${modification.filePath}: ${error}`);
585
+ }
586
+ }
587
+ });
588
+ }
589
+ /**
590
+ * Generate next steps for the user
591
+ */
592
+ generateNextSteps() {
593
+ var _a, _b;
594
+ const steps = [
595
+ '✅ SDK installed and configured automatically!',
596
+ '🚀 Your app is now tracking user behavior',
597
+ '📊 View sessions in your HumanBehavior dashboard',
598
+ '🔧 Customize tracking in your code as needed'
599
+ ];
600
+ if (((_a = this.framework) === null || _a === void 0 ? void 0 : _a.type) === 'react' || ((_b = this.framework) === null || _b === void 0 ? void 0 : _b.type) === 'nextjs') {
601
+ steps.push('💡 Use the useHumanBehavior() hook to track custom events');
602
+ }
603
+ return steps;
604
+ }
605
+ // Helper methods for file detection and content injection
606
+ findReactAppFile() {
607
+ const possibleFiles = [
608
+ 'src/App.jsx', 'src/App.js', 'src/App.tsx', 'src/App.ts',
609
+ 'src/index.js', 'src/index.tsx', 'src/main.js', 'src/main.tsx'
610
+ ];
611
+ for (const file of possibleFiles) {
612
+ const fullPath = path.join(this.projectRoot, file);
613
+ if (fs.existsSync(fullPath)) {
614
+ return fullPath;
615
+ }
616
+ }
617
+ return null;
618
+ }
619
+ findVueMainFile() {
620
+ const possibleFiles = [
621
+ 'src/main.js', 'src/main.ts', 'src/main.jsx', 'src/main.tsx'
622
+ ];
623
+ for (const file of possibleFiles) {
624
+ const fullPath = path.join(this.projectRoot, file);
625
+ if (fs.existsSync(fullPath)) {
626
+ return fullPath;
627
+ }
628
+ }
629
+ return null;
630
+ }
631
+ findSvelteMainFile() {
632
+ const possibleFiles = [
633
+ 'src/main.js', 'src/main.ts', 'src/main.svelte'
634
+ ];
635
+ for (const file of possibleFiles) {
636
+ const fullPath = path.join(this.projectRoot, file);
637
+ if (fs.existsSync(fullPath)) {
638
+ return fullPath;
639
+ }
640
+ }
641
+ return null;
642
+ }
643
+ findHTMLFile() {
644
+ const possibleFiles = ['index.html', 'public/index.html', 'dist/index.html'];
645
+ for (const file of possibleFiles) {
646
+ const fullPath = path.join(this.projectRoot, file);
647
+ if (fs.existsSync(fullPath)) {
648
+ return fullPath;
649
+ }
650
+ }
651
+ return null;
652
+ }
653
+ injectReactProvider(content, filePath) {
654
+ var _a;
655
+ filePath.endsWith('.tsx') || filePath.endsWith('.ts');
656
+ // Check if already has HumanBehaviorProvider
657
+ if (content.includes('HumanBehaviorProvider')) {
658
+ return content;
659
+ }
660
+ // Determine the correct environment variable syntax based on bundler
661
+ const isVite = ((_a = this.framework) === null || _a === void 0 ? void 0 : _a.bundler) === 'vite';
662
+ const envVar = isVite
663
+ ? 'import.meta.env.VITE_HUMANBEHAVIOR_API_KEY!'
664
+ : 'process.env.HUMANBEHAVIOR_API_KEY!';
665
+ const importStatement = `import { HumanBehaviorProvider } from 'humanbehavior-js/react';`;
666
+ // Simple injection - in production, you'd want more sophisticated parsing
667
+ if (content.includes('function App()') || content.includes('const App =')) {
668
+ return content.replace(/(function App\(\)|const App =)/, `${importStatement}\n\n$1`).replace(/return \(([\s\S]*?)\);/, `return (
669
+ <HumanBehaviorProvider apiKey={${envVar}}>
670
+ $1
671
+ </HumanBehaviorProvider>
672
+ );`);
673
+ }
674
+ return `${importStatement}\n\n${content}`;
675
+ }
676
+ injectNextJSAppRouter(content) {
677
+ if (content.includes('Providers')) {
678
+ return content;
679
+ }
680
+ const importStatement = `import { Providers } from './providers';`;
681
+ // First, add the import statement
682
+ let modifiedContent = content.replace(/export default function RootLayout/, `${importStatement}\n\nexport default function RootLayout`);
683
+ // Then wrap the body content with Providers
684
+ // Use a more specific approach to handle the body content
685
+ modifiedContent = modifiedContent.replace(/<body([^>]*)>([\s\S]*?)<\/body>/, (match, bodyAttrs, bodyContent) => {
686
+ // Trim whitespace and newlines from bodyContent
687
+ const trimmedContent = bodyContent.trim();
688
+ return `<body${bodyAttrs}>
689
+ <Providers>
690
+ ${trimmedContent}
691
+ </Providers>
692
+ </body>`;
693
+ });
694
+ return modifiedContent;
695
+ }
696
+ injectNextJSPagesRouter(content) {
697
+ if (content.includes('Providers')) {
698
+ return content;
699
+ }
700
+ const importStatement = `import { Providers } from '../components/providers';`;
701
+ return content.replace(/function MyApp/, `${importStatement}\n\nfunction MyApp`).replace(/return \(([\s\S]*?)\);/, `return (
702
+ <Providers>
703
+ $1
704
+ </Providers>
705
+ );`);
706
+ }
707
+ injectRemixProvider(content) {
708
+ if (content.includes('HumanBehaviorProvider')) {
709
+ return content;
710
+ }
711
+ const importStatement = `import { HumanBehaviorProvider, createHumanBehaviorLoader } from 'humanbehavior-js/remix';`;
712
+ const useLoaderDataImport = `import { useLoaderData } from "@remix-run/react";`;
713
+ // Add imports more robustly
714
+ let modifiedContent = content;
715
+ // Add HumanBehaviorProvider import - find the last import and add after it
716
+ if (!content.includes('HumanBehaviorProvider')) {
717
+ const lastImportIndex = modifiedContent.lastIndexOf('import');
718
+ if (lastImportIndex !== -1) {
719
+ const nextLineIndex = modifiedContent.indexOf('\n', lastImportIndex);
720
+ if (nextLineIndex !== -1) {
721
+ modifiedContent = modifiedContent.slice(0, nextLineIndex + 1) +
722
+ importStatement + '\n' +
723
+ modifiedContent.slice(nextLineIndex + 1);
724
+ }
725
+ else {
726
+ modifiedContent = modifiedContent + '\n' + importStatement;
727
+ }
728
+ }
729
+ else {
730
+ modifiedContent = importStatement + '\n' + modifiedContent;
731
+ }
732
+ }
733
+ // Add useLoaderData import - find the last import and add after it
734
+ if (!content.includes('useLoaderData')) {
735
+ const lastImportIndex = modifiedContent.lastIndexOf('import');
736
+ if (lastImportIndex !== -1) {
737
+ const nextLineIndex = modifiedContent.indexOf('\n', lastImportIndex);
738
+ if (nextLineIndex !== -1) {
739
+ modifiedContent = modifiedContent.slice(0, nextLineIndex + 1) +
740
+ useLoaderDataImport + '\n' +
741
+ modifiedContent.slice(nextLineIndex + 1);
742
+ }
743
+ else {
744
+ modifiedContent = modifiedContent + '\n' + useLoaderDataImport;
745
+ }
746
+ }
747
+ else {
748
+ modifiedContent = useLoaderDataImport + '\n' + modifiedContent;
749
+ }
750
+ }
751
+ // Add loader function before the App component
752
+ if (!content.includes('export const loader')) {
753
+ modifiedContent = modifiedContent.replace(/export default function App\(\)/, `export const loader = createHumanBehaviorLoader();
754
+
755
+ export default function App()`);
756
+ }
757
+ // Wrap the App component content with HumanBehaviorProvider
758
+ modifiedContent = modifiedContent.replace(/export default function App\(\) \{[\s\S]*?return \(([\s\S]*?)\);[\s\S]*?\}/, `export default function App() {
759
+ const data = useLoaderData<typeof loader>();
760
+
761
+ return (
762
+ <HumanBehaviorProvider apiKey={data.ENV.HUMANBEHAVIOR_API_KEY}>
763
+ $1
764
+ </HumanBehaviorProvider>
765
+ );
766
+ }`);
767
+ return modifiedContent;
768
+ }
769
+ injectVuePlugin(content) {
770
+ if (content.includes('HumanBehaviorPlugin')) {
771
+ return content;
772
+ }
773
+ const importStatement = `import { HumanBehaviorPlugin } from 'humanbehavior-js/vue';`;
774
+ const pluginUsage = `app.use(HumanBehaviorPlugin, {
775
+ apiKey: import.meta.env.VITE_HUMANBEHAVIOR_API_KEY
776
+ });`;
777
+ // Handle both Vue 2 and Vue 3 patterns
778
+ if (content.includes('createApp')) {
779
+ // Vue 3
780
+ return content.replace(/import.*from.*['"]vue['"]/, `$&\n${importStatement}`).replace(/app\.mount\(/, `${pluginUsage}\n\napp.mount(`);
781
+ }
782
+ else {
783
+ // Vue 2
784
+ return content.replace(/import.*from.*['"]vue['"]/, `$&\n${importStatement}`).replace(/new Vue\(/, `${pluginUsage}\n\nnew Vue(`);
785
+ }
786
+ }
787
+ injectAngularModule(content) {
788
+ if (content.includes('HumanBehaviorModule')) {
789
+ return content;
790
+ }
791
+ const importStatement = `import { HumanBehaviorModule } from 'humanbehavior-js/angular';`;
792
+ const environmentImport = `import { environment } from '../environments/environment';`;
793
+ // Add environment import if not present
794
+ let modifiedContent = content;
795
+ if (!content.includes('environment')) {
796
+ modifiedContent = content.replace(/import.*from.*['"]@angular/, `${environmentImport}\n$&`);
797
+ }
798
+ return modifiedContent.replace(/imports:\s*\[([\s\S]*?)\]/, `imports: [
799
+ $1,
800
+ HumanBehaviorModule.forRoot({
801
+ apiKey: environment.humanBehaviorApiKey
802
+ })
803
+ ]`).replace(/import.*from.*['"]@angular/, `$&\n${importStatement}`);
804
+ }
805
+ injectAngularStandaloneInit(content) {
806
+ if (content.includes('initializeHumanBehavior')) {
807
+ return content;
808
+ }
809
+ const importStatement = `import { initializeHumanBehavior } from 'humanbehavior-js/angular';`;
810
+ // Add import at the top
811
+ let modifiedContent = content.replace(/import.*from.*['"]@angular/, `${importStatement}\n$&`);
812
+ // Add initialization after bootstrapApplication
813
+ modifiedContent = modifiedContent.replace(/(bootstrapApplication\([^}]+\}?\)(?:\s*\.catch[^;]+;)?)/, `$1
814
+
815
+ // Initialize HumanBehavior SDK (client-side only)
816
+ if (typeof window !== 'undefined') {
817
+ const tracker = initializeHumanBehavior(
818
+ '${this.apiKey}'
819
+ );
820
+ }`);
821
+ return modifiedContent;
822
+ }
823
+ injectSvelteStore(content) {
824
+ if (content.includes('humanBehaviorStore')) {
825
+ return content;
826
+ }
827
+ const importStatement = `import { humanBehaviorStore } from 'humanbehavior-js/svelte';`;
828
+ const initCode = `humanBehaviorStore.init(process.env.PUBLIC_HUMANBEHAVIOR_API_KEY || '');`;
829
+ return `${importStatement}\n${initCode}\n\n${content}`;
830
+ }
831
+ injectSvelteKitLayout(content) {
832
+ if (content.includes('humanBehaviorStore')) {
833
+ return content;
834
+ }
835
+ const importStatement = `import { humanBehaviorStore } from 'humanbehavior-js/svelte';`;
836
+ const envImport = `import { PUBLIC_HUMANBEHAVIOR_API_KEY } from '$env/static/public';`;
837
+ const initCode = `humanBehaviorStore.init(PUBLIC_HUMANBEHAVIOR_API_KEY || '');`;
838
+ // Add to script section - handle different script tag patterns
839
+ if (content.includes('<script lang="ts">')) {
840
+ return content.replace(/<script lang="ts">/, `<script lang="ts">\n\t${envImport}\n\t${importStatement}\n\t${initCode}`);
841
+ }
842
+ else if (content.includes('<script>')) {
843
+ return content.replace(/<script>/, `<script>\n\t${envImport}\n\t${importStatement}\n\t${initCode}`);
844
+ }
845
+ else if (content.includes('<script context="module">')) {
846
+ return content.replace(/<script\s+context="module">/, `<script context="module">\n\t${envImport}\n\t${importStatement}\n\t${initCode}`);
847
+ }
848
+ else {
849
+ // If no script tag found, add one at the beginning
850
+ return content.replace(/<svelte:head>/, `<script lang="ts">\n\t${envImport}\n\t${importStatement}\n\t${initCode}\n</script>\n\n<svelte:head>`);
851
+ }
852
+ }
853
+ injectVanillaScript(content) {
854
+ if (content.includes('humanbehavior-js')) {
855
+ return content;
856
+ }
857
+ const cdnScript = `<script src="https://unpkg.com/humanbehavior-js@latest/dist/index.min.js"></script>`;
858
+ const initScript = `<script>
859
+ // Initialize HumanBehavior SDK
860
+ // Note: For vanilla HTML, the API key must be hardcoded since env vars aren't available
861
+ const tracker = HumanBehaviorTracker.init('${this.apiKey}');
862
+ </script>`;
863
+ return content.replace(/<\/head>/, ` ${cdnScript}\n ${initScript}\n</head>`);
864
+ }
865
+ injectNuxtConfig(content) {
866
+ if (content.includes('humanBehaviorApiKey')) {
867
+ return content;
868
+ }
869
+ // Add runtime config by inserting it after the opening brace
870
+ return content.replace(/export default defineNuxtConfig\(\{/, `export default defineNuxtConfig({
871
+ runtimeConfig: {
872
+ public: {
873
+ humanBehaviorApiKey: process.env.NUXT_PUBLIC_HUMANBEHAVIOR_API_KEY
874
+ }
875
+ },`);
876
+ }
877
+ /**
878
+ * Helper method to find the best environment file for a framework
879
+ */
880
+ findBestEnvFile(framework) {
881
+ const possibleEnvFiles = [
882
+ '.env.local',
883
+ '.env.development.local',
884
+ '.env.development',
885
+ '.env.local.development',
886
+ '.env',
887
+ '.env.production',
888
+ '.env.staging'
889
+ ];
890
+ // Framework-specific environment variable names
891
+ const getEnvVarName = (framework) => {
892
+ // Handle React+Vite specifically
893
+ if (framework.type === 'react' && framework.bundler === 'vite') {
894
+ return 'VITE_HUMANBEHAVIOR_API_KEY';
895
+ }
896
+ // Framework-specific mappings
897
+ const envVarNames = {
898
+ react: 'HUMANBEHAVIOR_API_KEY',
899
+ nextjs: 'NEXT_PUBLIC_HUMANBEHAVIOR_API_KEY',
900
+ vue: 'VITE_HUMANBEHAVIOR_API_KEY',
901
+ svelte: 'PUBLIC_HUMANBEHAVIOR_API_KEY',
902
+ angular: 'HUMANBEHAVIOR_API_KEY',
903
+ nuxt: 'NUXT_PUBLIC_HUMANBEHAVIOR_API_KEY',
904
+ remix: 'HUMANBEHAVIOR_API_KEY',
905
+ vanilla: 'HUMANBEHAVIOR_API_KEY',
906
+ node: 'HUMANBEHAVIOR_API_KEY'
907
+ };
908
+ return envVarNames[framework.type] || 'HUMANBEHAVIOR_API_KEY';
909
+ };
910
+ const envVarName = getEnvVarName(framework);
911
+ // Check for existing files
912
+ for (const envFile of possibleEnvFiles) {
913
+ const fullPath = path.join(this.projectRoot, envFile);
914
+ if (fs.existsSync(fullPath)) {
915
+ return { filePath: fullPath, envVarName };
916
+ }
917
+ }
918
+ // Framework-specific default file creation
919
+ const defaultFiles = {
920
+ react: '.env.local',
921
+ nextjs: '.env.local',
922
+ vue: '.env.local',
923
+ svelte: '.env',
924
+ angular: '.env',
925
+ nuxt: '.env',
926
+ remix: '.env.local',
927
+ vanilla: '.env',
928
+ node: '.env'
929
+ };
930
+ const defaultFile = defaultFiles[framework.type] || '.env';
931
+ return {
932
+ filePath: path.join(this.projectRoot, defaultFile),
933
+ envVarName
934
+ };
935
+ }
936
+ /**
937
+ * Helper method to create or append to environment files
938
+ */
939
+ createEnvironmentModification(framework) {
940
+ const { filePath, envVarName } = this.findBestEnvFile(framework);
941
+ if (fs.existsSync(filePath)) {
942
+ // Check if the variable already exists
943
+ const content = fs.readFileSync(filePath, 'utf8');
944
+ if (content.includes(envVarName)) {
945
+ // Variable exists, don't modify
946
+ return {
947
+ filePath,
948
+ action: 'modify',
949
+ content: content, // No change
950
+ description: `API key already exists in ${path.basename(filePath)}`
951
+ };
952
+ }
953
+ else {
954
+ // Append to existing file
955
+ return {
956
+ filePath,
957
+ action: 'append',
958
+ content: `\n${envVarName}=${this.apiKey}`,
959
+ description: `Added API key to existing ${path.basename(filePath)}`
960
+ };
961
+ }
962
+ }
963
+ else {
964
+ // Create new file
965
+ return {
966
+ filePath,
967
+ action: 'create',
968
+ content: `${envVarName}=${this.apiKey}`,
969
+ description: `Created ${path.basename(filePath)} with API key`
970
+ };
971
+ }
972
+ }
973
+ }
974
+ /**
975
+ * Browser-based auto-installation wizard
976
+ */
977
+ class BrowserAutoInstallationWizard {
978
+ constructor(apiKey) {
979
+ this.apiKey = apiKey;
980
+ }
981
+ install() {
982
+ return __awaiter(this, void 0, void 0, function* () {
983
+ try {
984
+ // Detect framework in browser
985
+ const framework = this.detectFramework();
986
+ // Generate installation instructions
987
+ const modifications = this.generateBrowserModifications(framework);
988
+ return {
989
+ success: true,
990
+ framework,
991
+ modifications,
992
+ errors: [],
993
+ nextSteps: [
994
+ '✅ Framework detected automatically',
995
+ '📋 Copy the generated code to your project',
996
+ '🚀 Your app will be ready to track user behavior'
997
+ ]
998
+ };
999
+ }
1000
+ catch (error) {
1001
+ return {
1002
+ success: false,
1003
+ framework: { name: 'unknown', type: 'vanilla' },
1004
+ modifications: [],
1005
+ errors: [error instanceof Error ? error.message : 'Unknown error'],
1006
+ nextSteps: []
1007
+ };
1008
+ }
1009
+ });
1010
+ }
1011
+ detectFramework() {
1012
+ if (typeof window !== 'undefined') {
1013
+ if (window.React) {
1014
+ return { name: 'react', type: 'react' };
1015
+ }
1016
+ if (window.Vue) {
1017
+ return { name: 'vue', type: 'vue' };
1018
+ }
1019
+ if (window.angular) {
1020
+ return { name: 'angular', type: 'angular' };
1021
+ }
1022
+ }
1023
+ return { name: 'vanilla', type: 'vanilla' };
1024
+ }
1025
+ generateBrowserModifications(framework) {
1026
+ // Return code snippets for browser environment
1027
+ const modifications = [];
1028
+ switch (framework.type) {
1029
+ case 'react':
1030
+ modifications.push({
1031
+ filePath: 'App.jsx',
1032
+ action: 'create',
1033
+ content: `import { HumanBehaviorProvider } from 'humanbehavior-js/react';
1034
+
1035
+ function App() {
1036
+ return (
1037
+ <HumanBehaviorProvider apiKey="${this.apiKey}">
1038
+ {/* Your app components */}
1039
+ </HumanBehaviorProvider>
1040
+ );
1041
+ }
1042
+
1043
+ export default App;`,
1044
+ description: 'React component with HumanBehaviorProvider'
1045
+ });
1046
+ break;
1047
+ case 'remix':
1048
+ modifications.push({
1049
+ filePath: 'app/root.tsx',
1050
+ action: 'create',
1051
+ content: `import {
1052
+ Links,
1053
+ Meta,
1054
+ Outlet,
1055
+ Scripts,
1056
+ ScrollRestoration,
1057
+ useLoaderData,
1058
+ } from "@remix-run/react";
1059
+ import { HumanBehaviorProvider } from 'humanbehavior-js/react';
1060
+ import type { LoaderFunctionArgs } from "@remix-run/node";
1061
+
1062
+ export async function loader({ request }: LoaderFunctionArgs) {
1063
+ return {
1064
+ ENV: {
1065
+ HUMANBEHAVIOR_API_KEY: process.env.HUMANBEHAVIOR_API_KEY,
1066
+ },
1067
+ };
1068
+ }
1069
+
1070
+ export function Layout({ children }: { children: React.ReactNode }) {
1071
+ return (
1072
+ <html lang="en">
1073
+ <head>
1074
+ <meta charSet="utf-8" />
1075
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
1076
+ <Meta />
1077
+ <Links />
1078
+ </head>
1079
+ <body>
1080
+ {children}
1081
+ <ScrollRestoration />
1082
+ <Scripts />
1083
+ </body>
1084
+ </html>
1085
+ );
1086
+ }
1087
+
1088
+ export default function App() {
1089
+ const data = useLoaderData<typeof loader>();
1090
+
1091
+ return (
1092
+ <HumanBehaviorProvider apiKey={data.ENV.HUMANBEHAVIOR_API_KEY}>
1093
+ <div className="min-h-screen bg-gray-50">
1094
+ {/* Your app content */}
1095
+ <Outlet />
1096
+ </div>
1097
+ </HumanBehaviorProvider>
1098
+ );
1099
+ }`,
1100
+ description: 'Remix root component with HumanBehaviorProvider'
1101
+ });
1102
+ break;
1103
+ case 'vue':
1104
+ modifications.push({
1105
+ filePath: 'main.js',
1106
+ action: 'create',
1107
+ content: `import { createApp } from 'vue';
1108
+ import { HumanBehaviorPlugin } from 'humanbehavior-js/vue';
1109
+ import App from './App.vue';
1110
+
1111
+ const app = createApp(App);
1112
+ app.use(HumanBehaviorPlugin, {
1113
+ apiKey: '${this.apiKey}'
1114
+ });
1115
+ app.mount('#app');`,
1116
+ description: 'Vue app with HumanBehaviorPlugin'
1117
+ });
1118
+ break;
1119
+ default:
1120
+ modifications.push({
1121
+ filePath: 'humanbehavior-init.js',
1122
+ action: 'create',
1123
+ content: `import { HumanBehaviorTracker } from 'humanbehavior-js';
1124
+
1125
+ const tracker = HumanBehaviorTracker.init('${this.apiKey}');`,
1126
+ description: 'Vanilla JS initialization'
1127
+ });
1128
+ }
1129
+ return modifications;
1130
+ }
1131
+ }
1132
+
1133
+ export { AutoInstallationWizard, BrowserAutoInstallationWizard };
1134
+ //# sourceMappingURL=install-wizard.js.map