humanbehavior-js
Version:
SDK for HumanBehavior session and event recording
157 lines (155 loc) • 4.51 kB
TypeScript
/**
* HumanBehavior SDK Auto-Installation Wizard
*
* This wizard automatically detects the user's framework and modifies their codebase
* to integrate the SDK with minimal user intervention.
*/
interface FrameworkInfo {
name: string;
type: 'react' | 'vue' | 'angular' | 'svelte' | 'nextjs' | 'nuxt' | 'remix' | 'vanilla' | 'astro' | 'gatsby' | 'node' | 'auto';
bundler?: 'vite' | 'webpack' | 'esbuild' | 'rollup';
packageManager?: 'npm' | 'yarn' | 'pnpm';
hasTypeScript?: boolean;
hasRouter?: boolean;
projectRoot?: string;
version?: string;
majorVersion?: number;
features?: {
hasReact18?: boolean;
hasVue3?: boolean;
hasNuxt3?: boolean;
hasAngularStandalone?: boolean;
hasNextAppRouter?: boolean;
hasSvelteKit?: boolean;
};
}
interface CodeModification {
filePath: string;
action: 'create' | 'modify' | 'append';
content: string;
description: string;
}
interface InstallationResult {
success: boolean;
framework: FrameworkInfo;
modifications: CodeModification[];
errors: string[];
nextSteps: string[];
}
declare class AutoInstallationWizard {
protected apiKey: string;
protected projectRoot: string;
protected framework: FrameworkInfo | null;
constructor(apiKey: string, projectRoot?: string);
/**
* Simple version comparison utility
*/
private compareVersions;
private isVersionGte;
private getMajorVersion;
/**
* Main installation method - detects framework and auto-installs
*/
install(): Promise<InstallationResult>;
/**
* Detect the current framework and project setup
*/
detectFramework(): Promise<FrameworkInfo>;
/**
* Install the SDK package
*/
protected installPackage(): Promise<void>;
/**
* Generate code modifications based on framework
*/
protected generateModifications(): Promise<CodeModification[]>;
/**
* Generate React-specific modifications
*/
private generateReactModifications;
/**
* Generate Next.js-specific modifications
*/
private generateNextJSModifications;
/**
* Generate Astro-specific modifications
*/
private generateAstroModifications;
/**
* Generate Nuxt-specific modifications
*/
private generateNuxtModifications;
/**
* Generate Remix-specific modifications
*/
private generateRemixModifications;
/**
* Generate Vue-specific modifications
*/
private generateVueModifications;
/**
* Generate Angular-specific modifications
*/
private generateAngularModifications;
/**
* Generate Svelte-specific modifications
*/
private generateSvelteModifications;
/**
* Generate vanilla JS/TS modifications
*/
private generateVanillaModifications;
/**
* Generate Gatsby-specific modifications
*/
private generateGatsbyModifications;
/**
* Apply modifications to the codebase
*/
protected applyModifications(modifications: CodeModification[]): Promise<void>;
/**
* Generate next steps for the user
*/
private generateNextSteps;
private findReactAppFile;
private findVueMainFile;
private findSvelteMainFile;
private findHTMLFile;
private injectReactProvider;
private injectNextJSAppRouter;
private injectNextJSPagesRouter;
private injectRemixProvider;
private injectVuePlugin;
private injectAngularModule;
private injectAngularStandaloneInit;
private injectSvelteStore;
private injectSvelteKitLayout;
private injectVanillaScript;
/**
* Inject Astro layout with HumanBehavior component
*/
private injectAstroLayout;
private injectNuxtConfig;
private injectGatsbyLayout;
private injectGatsbyBrowser;
/**
* Helper method to find the best environment file for a framework
*/
private findBestEnvFile;
/**
* Helper method to create or append to environment files
*/
private createEnvironmentModification;
}
/**
* Browser-based auto-installation wizard
*/
declare class BrowserAutoInstallationWizard {
private apiKey;
constructor(apiKey: string);
install(): Promise<InstallationResult>;
private detectFramework;
private generateBrowserModifications;
}
export { AutoInstallationWizard, BrowserAutoInstallationWizard };
export type { CodeModification, FrameworkInfo, InstallationResult };