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
@@ -679,25 +679,72 @@ export default defineNuxtPlugin(() => {
679
679
  description: 'Added HumanBehaviorModule to Angular app'
680
680
  });
681
681
  }
682
- // Handle Angular environment file (legacy structure)
682
+ // Handle Angular environment files (proper Angular way)
683
683
  const envFile = path__namespace.join(this.projectRoot, 'src', 'environments', 'environment.ts');
684
+ const envProdFile = path__namespace.join(this.projectRoot, 'src', 'environments', 'environment.prod.ts');
685
+ // Create environments directory if it doesn't exist
686
+ const envDir = path__namespace.dirname(envFile);
687
+ if (!fs__namespace.existsSync(envDir)) {
688
+ fs__namespace.mkdirSync(envDir, { recursive: true });
689
+ }
690
+ // Create or update development environment
684
691
  if (fs__namespace.existsSync(envFile)) {
685
692
  const content = fs__namespace.readFileSync(envFile, 'utf8');
686
693
  if (!content.includes('humanBehaviorApiKey')) {
687
694
  const modifiedContent = content.replace(/export const environment = {([\s\S]*?)};/, `export const environment = {
688
695
  $1,
689
- humanBehaviorApiKey: process.env['HUMANBEHAVIOR_API_KEY'] || ''
696
+ humanBehaviorApiKey: '${this.apiKey}'
690
697
  };`);
691
698
  modifications.push({
692
699
  filePath: envFile,
693
700
  action: 'modify',
694
701
  content: modifiedContent,
695
- description: 'Added API key to Angular environment'
702
+ description: 'Added API key to Angular development environment'
696
703
  });
697
704
  }
698
705
  }
699
- // Create or append to environment file
700
- modifications.push(this.createEnvironmentModification(this.framework));
706
+ else {
707
+ // Create new development environment file
708
+ modifications.push({
709
+ filePath: envFile,
710
+ action: 'create',
711
+ content: `export const environment = {
712
+ production: false,
713
+ humanBehaviorApiKey: '${this.apiKey}'
714
+ };`,
715
+ description: 'Created Angular development environment file'
716
+ });
717
+ }
718
+ // Create or update production environment
719
+ if (fs__namespace.existsSync(envProdFile)) {
720
+ const content = fs__namespace.readFileSync(envProdFile, 'utf8');
721
+ if (!content.includes('humanBehaviorApiKey')) {
722
+ const modifiedContent = content.replace(/export const environment = {([\s\S]*?)};/, `export const environment = {
723
+ $1,
724
+ humanBehaviorApiKey: '${this.apiKey}'
725
+ };`);
726
+ modifications.push({
727
+ filePath: envProdFile,
728
+ action: 'modify',
729
+ content: modifiedContent,
730
+ description: 'Added API key to Angular production environment'
731
+ });
732
+ }
733
+ }
734
+ else {
735
+ // Create new production environment file
736
+ modifications.push({
737
+ filePath: envProdFile,
738
+ action: 'create',
739
+ content: `export const environment = {
740
+ production: true,
741
+ humanBehaviorApiKey: '${this.apiKey}'
742
+ };`,
743
+ description: 'Created Angular production environment file'
744
+ });
745
+ }
746
+ // For Angular, we don't need .env files since we use environment.ts
747
+ // The environment files are already created above
701
748
  return modifications;
702
749
  });
703
750
  }
@@ -1115,16 +1162,15 @@ export default function App()`);
1115
1162
  return content;
1116
1163
  }
1117
1164
  const importStatement = `import { initializeHumanBehavior } from 'humanbehavior-js/angular';`;
1118
- // Add import at the top
1119
- let modifiedContent = content.replace(/import.*from.*['"]@angular/, `${importStatement}\n$&`);
1165
+ const environmentImport = `import { environment } from './environments/environment';`;
1166
+ // Add imports at the top
1167
+ let modifiedContent = content.replace(/import.*from.*['"]@angular/, `${importStatement}\n${environmentImport}\n$&`);
1120
1168
  // Add initialization after bootstrapApplication
1121
1169
  modifiedContent = modifiedContent.replace(/(bootstrapApplication\([^}]+\}?\)(?:\s*\.catch[^;]+;)?)/, `$1
1122
1170
 
1123
1171
  // Initialize HumanBehavior SDK (client-side only)
1124
1172
  if (typeof window !== 'undefined') {
1125
- const tracker = initializeHumanBehavior(
1126
- '${this.apiKey}'
1127
- );
1173
+ const tracker = initializeHumanBehavior(environment.humanBehaviorApiKey);
1128
1174
  }`);
1129
1175
  return modifiedContent;
1130
1176
  }