humanbehavior-js 0.4.19 → 0.4.21

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 (66) hide show
  1. package/dist/cjs/angular/index.cjs +799 -13
  2. package/dist/cjs/angular/index.cjs.map +1 -1
  3. package/dist/cjs/index.cjs +815 -13
  4. package/dist/cjs/index.cjs.map +1 -1
  5. package/dist/cjs/install-wizard.cjs +56 -10
  6. package/dist/cjs/install-wizard.cjs.map +1 -1
  7. package/dist/cjs/react/index.cjs +800 -14
  8. package/dist/cjs/react/index.cjs.map +1 -1
  9. package/dist/cjs/remix/index.cjs +800 -14
  10. package/dist/cjs/remix/index.cjs.map +1 -1
  11. package/dist/cjs/svelte/index.cjs +799 -13
  12. package/dist/cjs/svelte/index.cjs.map +1 -1
  13. package/dist/cjs/vue/index.cjs +799 -13
  14. package/dist/cjs/vue/index.cjs.map +1 -1
  15. package/dist/cjs/wizard/index.cjs +56 -10
  16. package/dist/cjs/wizard/index.cjs.map +1 -1
  17. package/dist/cli/ai-auto-install.js +56 -10
  18. package/dist/cli/ai-auto-install.js.map +1 -1
  19. package/dist/cli/auto-install.js +56 -10
  20. package/dist/cli/auto-install.js.map +1 -1
  21. package/dist/esm/angular/index.js +799 -13
  22. package/dist/esm/angular/index.js.map +1 -1
  23. package/dist/esm/index.js +807 -14
  24. package/dist/esm/index.js.map +1 -1
  25. package/dist/esm/install-wizard.js +56 -10
  26. package/dist/esm/install-wizard.js.map +1 -1
  27. package/dist/esm/react/index.js +800 -14
  28. package/dist/esm/react/index.js.map +1 -1
  29. package/dist/esm/remix/index.js +800 -14
  30. package/dist/esm/remix/index.js.map +1 -1
  31. package/dist/esm/svelte/index.js +799 -13
  32. package/dist/esm/svelte/index.js.map +1 -1
  33. package/dist/esm/vue/index.js +799 -13
  34. package/dist/esm/vue/index.js.map +1 -1
  35. package/dist/esm/wizard/index.js +56 -10
  36. package/dist/esm/wizard/index.js.map +1 -1
  37. package/dist/index.min.js +1 -1
  38. package/dist/index.min.js.map +1 -1
  39. package/dist/types/angular/index.d.ts +60 -1
  40. package/dist/types/index.d.ts +258 -3
  41. package/dist/types/react/index.d.ts +60 -1
  42. package/dist/types/remix/index.d.ts +60 -1
  43. package/dist/types/svelte/index.d.ts +60 -1
  44. package/package/canvas-recording-demo.html +1 -1
  45. package/package/simple-spa.html +1 -1
  46. package/package/src/angular/index.ts +3 -3
  47. package/package/src/react/index.tsx +2 -2
  48. package/package/src/svelte/index.ts +1 -1
  49. package/package/src/tracker.ts +2 -2
  50. package/package/src/vue/index.ts +1 -1
  51. package/package.json +1 -1
  52. package/simple-spa.html +164 -2
  53. package/src/angular/index.ts +3 -3
  54. package/src/api.ts +40 -0
  55. package/src/index.ts +7 -0
  56. package/src/react/index.tsx +2 -2
  57. package/src/svelte/index.ts +1 -1
  58. package/src/tracker.ts +175 -11
  59. package/src/utils/ip-detector.ts +158 -0
  60. package/src/utils/property-detector.ts +345 -0
  61. package/src/utils/property-manager.ts +274 -0
  62. package/src/vue/index.ts +1 -1
  63. package/src/wizard/core/install-wizard.ts +60 -10
  64. package/canvas-recording-demo.html +0 -143
  65. package/clean-console-demo.html +0 -39
  66. package/simple-demo.html +0 -26
@@ -655,25 +655,72 @@ export default defineNuxtPlugin(() => {
655
655
  description: 'Added HumanBehaviorModule to Angular app'
656
656
  });
657
657
  }
658
- // Handle Angular environment file (legacy structure)
658
+ // Handle Angular environment files (proper Angular way)
659
659
  const envFile = path.join(this.projectRoot, 'src', 'environments', 'environment.ts');
660
+ const envProdFile = path.join(this.projectRoot, 'src', 'environments', 'environment.prod.ts');
661
+ // Create environments directory if it doesn't exist
662
+ const envDir = path.dirname(envFile);
663
+ if (!fs.existsSync(envDir)) {
664
+ fs.mkdirSync(envDir, { recursive: true });
665
+ }
666
+ // Create or update development environment
660
667
  if (fs.existsSync(envFile)) {
661
668
  const content = fs.readFileSync(envFile, 'utf8');
662
669
  if (!content.includes('humanBehaviorApiKey')) {
663
670
  const modifiedContent = content.replace(/export const environment = {([\s\S]*?)};/, `export const environment = {
664
671
  $1,
665
- humanBehaviorApiKey: process.env['HUMANBEHAVIOR_API_KEY'] || ''
672
+ humanBehaviorApiKey: '${this.apiKey}'
666
673
  };`);
667
674
  modifications.push({
668
675
  filePath: envFile,
669
676
  action: 'modify',
670
677
  content: modifiedContent,
671
- description: 'Added API key to Angular environment'
678
+ description: 'Added API key to Angular development environment'
672
679
  });
673
680
  }
674
681
  }
675
- // Create or append to environment file
676
- modifications.push(this.createEnvironmentModification(this.framework));
682
+ else {
683
+ // Create new development environment file
684
+ modifications.push({
685
+ filePath: envFile,
686
+ action: 'create',
687
+ content: `export const environment = {
688
+ production: false,
689
+ humanBehaviorApiKey: '${this.apiKey}'
690
+ };`,
691
+ description: 'Created Angular development environment file'
692
+ });
693
+ }
694
+ // Create or update production environment
695
+ if (fs.existsSync(envProdFile)) {
696
+ const content = fs.readFileSync(envProdFile, 'utf8');
697
+ if (!content.includes('humanBehaviorApiKey')) {
698
+ const modifiedContent = content.replace(/export const environment = {([\s\S]*?)};/, `export const environment = {
699
+ $1,
700
+ humanBehaviorApiKey: '${this.apiKey}'
701
+ };`);
702
+ modifications.push({
703
+ filePath: envProdFile,
704
+ action: 'modify',
705
+ content: modifiedContent,
706
+ description: 'Added API key to Angular production environment'
707
+ });
708
+ }
709
+ }
710
+ else {
711
+ // Create new production environment file
712
+ modifications.push({
713
+ filePath: envProdFile,
714
+ action: 'create',
715
+ content: `export const environment = {
716
+ production: true,
717
+ humanBehaviorApiKey: '${this.apiKey}'
718
+ };`,
719
+ description: 'Created Angular production environment file'
720
+ });
721
+ }
722
+ // For Angular, we don't need .env files since we use environment.ts
723
+ // The environment files are already created above
677
724
  return modifications;
678
725
  });
679
726
  }
@@ -1091,16 +1138,15 @@ export default function App()`);
1091
1138
  return content;
1092
1139
  }
1093
1140
  const importStatement = `import { initializeHumanBehavior } from 'humanbehavior-js/angular';`;
1094
- // Add import at the top
1095
- let modifiedContent = content.replace(/import.*from.*['"]@angular/, `${importStatement}\n$&`);
1141
+ const environmentImport = `import { environment } from './environments/environment';`;
1142
+ // Add imports at the top
1143
+ let modifiedContent = content.replace(/import.*from.*['"]@angular/, `${importStatement}\n${environmentImport}\n$&`);
1096
1144
  // Add initialization after bootstrapApplication
1097
1145
  modifiedContent = modifiedContent.replace(/(bootstrapApplication\([^}]+\}?\)(?:\s*\.catch[^;]+;)?)/, `$1
1098
1146
 
1099
1147
  // Initialize HumanBehavior SDK (client-side only)
1100
1148
  if (typeof window !== 'undefined') {
1101
- const tracker = initializeHumanBehavior(
1102
- '${this.apiKey}'
1103
- );
1149
+ const tracker = initializeHumanBehavior(environment.humanBehaviorApiKey);
1104
1150
  }`);
1105
1151
  return modifiedContent;
1106
1152
  }