@amplitude/wizard 1.0.0-beta.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.
- package/LICENSE +47 -0
- package/README.md +119 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +763 -0
- package/dist/package.json +144 -0
- package/dist/src/frameworks/android/android-wizard-agent.d.ts +6 -0
- package/dist/src/frameworks/android/android-wizard-agent.js +72 -0
- package/dist/src/frameworks/android/utils.d.ts +11 -0
- package/dist/src/frameworks/android/utils.js +32 -0
- package/dist/src/frameworks/django/django-wizard-agent.d.ts +8 -0
- package/dist/src/frameworks/django/django-wizard-agent.js +171 -0
- package/dist/src/frameworks/django/utils.d.ts +31 -0
- package/dist/src/frameworks/django/utils.js +305 -0
- package/dist/src/frameworks/fastapi/fastapi-wizard-agent.d.ts +11 -0
- package/dist/src/frameworks/fastapi/fastapi-wizard-agent.js +189 -0
- package/dist/src/frameworks/fastapi/utils.d.ts +26 -0
- package/dist/src/frameworks/fastapi/utils.js +257 -0
- package/dist/src/frameworks/flask/flask-wizard-agent.d.ts +8 -0
- package/dist/src/frameworks/flask/flask-wizard-agent.js +177 -0
- package/dist/src/frameworks/flask/utils.d.ts +28 -0
- package/dist/src/frameworks/flask/utils.js +343 -0
- package/dist/src/frameworks/flutter/flutter-wizard-agent.d.ts +4 -0
- package/dist/src/frameworks/flutter/flutter-wizard-agent.js +57 -0
- package/dist/src/frameworks/flutter/utils.d.ts +7 -0
- package/dist/src/frameworks/flutter/utils.js +64 -0
- package/dist/src/frameworks/generic/generic-wizard-agent.d.ts +2 -0
- package/dist/src/frameworks/generic/generic-wizard-agent.js +176 -0
- package/dist/src/frameworks/go/go-wizard-agent.d.ts +4 -0
- package/dist/src/frameworks/go/go-wizard-agent.js +57 -0
- package/dist/src/frameworks/go/utils.d.ts +5 -0
- package/dist/src/frameworks/go/utils.js +44 -0
- package/dist/src/frameworks/java/java-wizard-agent.d.ts +7 -0
- package/dist/src/frameworks/java/java-wizard-agent.js +73 -0
- package/dist/src/frameworks/java/utils.d.ts +15 -0
- package/dist/src/frameworks/java/utils.js +64 -0
- package/dist/src/frameworks/javascript-node/javascript-node-wizard-agent.d.ts +4 -0
- package/dist/src/frameworks/javascript-node/javascript-node-wizard-agent.js +57 -0
- package/dist/src/frameworks/javascript-web/javascript-web-wizard-agent.d.ts +3 -0
- package/dist/src/frameworks/javascript-web/javascript-web-wizard-agent.js +151 -0
- package/dist/src/frameworks/javascript-web/utils.d.ts +28 -0
- package/dist/src/frameworks/javascript-web/utils.js +153 -0
- package/dist/src/frameworks/nextjs/nextjs-wizard-agent.d.ts +7 -0
- package/dist/src/frameworks/nextjs/nextjs-wizard-agent.js +98 -0
- package/dist/src/frameworks/nextjs/utils.d.ts +12 -0
- package/dist/src/frameworks/nextjs/utils.js +51 -0
- package/dist/src/frameworks/python/python-wizard-agent.d.ts +7 -0
- package/dist/src/frameworks/python/python-wizard-agent.js +193 -0
- package/dist/src/frameworks/python/utils.d.ts +28 -0
- package/dist/src/frameworks/python/utils.js +146 -0
- package/dist/src/frameworks/react-native/react-native-wizard-agent.d.ts +6 -0
- package/dist/src/frameworks/react-native/react-native-wizard-agent.js +84 -0
- package/dist/src/frameworks/react-native/utils.d.ts +21 -0
- package/dist/src/frameworks/react-native/utils.js +82 -0
- package/dist/src/frameworks/react-router/react-router-wizard-agent.d.ts +7 -0
- package/dist/src/frameworks/react-router/react-router-wizard-agent.js +98 -0
- package/dist/src/frameworks/react-router/utils.d.ts +13 -0
- package/dist/src/frameworks/react-router/utils.js +160 -0
- package/dist/src/frameworks/swift/swift-wizard-agent.d.ts +7 -0
- package/dist/src/frameworks/swift/swift-wizard-agent.js +72 -0
- package/dist/src/frameworks/swift/utils.d.ts +12 -0
- package/dist/src/frameworks/swift/utils.js +82 -0
- package/dist/src/frameworks/unity/unity-wizard-agent.d.ts +6 -0
- package/dist/src/frameworks/unity/unity-wizard-agent.js +79 -0
- package/dist/src/frameworks/unity/utils.d.ts +12 -0
- package/dist/src/frameworks/unity/utils.js +66 -0
- package/dist/src/frameworks/unreal/unreal-wizard-agent.d.ts +6 -0
- package/dist/src/frameworks/unreal/unreal-wizard-agent.js +77 -0
- package/dist/src/frameworks/unreal/utils.d.ts +10 -0
- package/dist/src/frameworks/unreal/utils.js +29 -0
- package/dist/src/frameworks/vue/vue-wizard-agent.d.ts +4 -0
- package/dist/src/frameworks/vue/vue-wizard-agent.js +64 -0
- package/dist/src/lib/agent-hooks.d.ts +26 -0
- package/dist/src/lib/agent-hooks.js +118 -0
- package/dist/src/lib/agent-interface.d.ts +175 -0
- package/dist/src/lib/agent-interface.js +1217 -0
- package/dist/src/lib/agent-runner.d.ts +9 -0
- package/dist/src/lib/agent-runner.js +415 -0
- package/dist/src/lib/ampli-config.d.ts +105 -0
- package/dist/src/lib/ampli-config.js +178 -0
- package/dist/src/lib/api.d.ts +107 -0
- package/dist/src/lib/api.js +442 -0
- package/dist/src/lib/commandments.d.ts +1 -0
- package/dist/src/lib/commandments.js +24 -0
- package/dist/src/lib/console-query.d.ts +27 -0
- package/dist/src/lib/console-query.js +121 -0
- package/dist/src/lib/constants.d.ts +124 -0
- package/dist/src/lib/constants.js +170 -0
- package/dist/src/lib/detect-amplitude.d.ts +31 -0
- package/dist/src/lib/detect-amplitude.js +407 -0
- package/dist/src/lib/framework-config.d.ts +188 -0
- package/dist/src/lib/framework-config.js +21 -0
- package/dist/src/lib/health-checks/endpoints.d.ts +3 -0
- package/dist/src/lib/health-checks/endpoints.js +45 -0
- package/dist/src/lib/health-checks/index.d.ts +4 -0
- package/dist/src/lib/health-checks/index.js +22 -0
- package/dist/src/lib/health-checks/readiness.d.ts +24 -0
- package/dist/src/lib/health-checks/readiness.js +118 -0
- package/dist/src/lib/health-checks/statuspage.d.ts +9 -0
- package/dist/src/lib/health-checks/statuspage.js +104 -0
- package/dist/src/lib/health-checks/types.d.ts +31 -0
- package/dist/src/lib/health-checks/types.js +9 -0
- package/dist/src/lib/helper-functions.d.ts +1 -0
- package/dist/src/lib/helper-functions.js +5 -0
- package/dist/src/lib/middleware/benchmark.d.ts +54 -0
- package/dist/src/lib/middleware/benchmark.js +48 -0
- package/dist/src/lib/middleware/benchmarks/cache-tracker.d.ts +44 -0
- package/dist/src/lib/middleware/benchmarks/cache-tracker.js +80 -0
- package/dist/src/lib/middleware/benchmarks/compaction-tracker.d.ts +29 -0
- package/dist/src/lib/middleware/benchmarks/compaction-tracker.js +59 -0
- package/dist/src/lib/middleware/benchmarks/context-size-tracker.d.ts +26 -0
- package/dist/src/lib/middleware/benchmarks/context-size-tracker.js +55 -0
- package/dist/src/lib/middleware/benchmarks/cost-tracker.d.ts +16 -0
- package/dist/src/lib/middleware/benchmarks/cost-tracker.js +75 -0
- package/dist/src/lib/middleware/benchmarks/duration-tracker.d.ts +20 -0
- package/dist/src/lib/middleware/benchmarks/duration-tracker.js +39 -0
- package/dist/src/lib/middleware/benchmarks/index.d.ts +9 -0
- package/dist/src/lib/middleware/benchmarks/index.js +67 -0
- package/dist/src/lib/middleware/benchmarks/json-writer.d.ts +15 -0
- package/dist/src/lib/middleware/benchmarks/json-writer.js +144 -0
- package/dist/src/lib/middleware/benchmarks/summary.d.ts +9 -0
- package/dist/src/lib/middleware/benchmarks/summary.js +105 -0
- package/dist/src/lib/middleware/benchmarks/token-tracker.d.ts +40 -0
- package/dist/src/lib/middleware/benchmarks/token-tracker.js +76 -0
- package/dist/src/lib/middleware/benchmarks/turn-counter.d.ts +34 -0
- package/dist/src/lib/middleware/benchmarks/turn-counter.js +58 -0
- package/dist/src/lib/middleware/config.d.ts +24 -0
- package/dist/src/lib/middleware/config.js +96 -0
- package/dist/src/lib/middleware/index.d.ts +11 -0
- package/dist/src/lib/middleware/index.js +17 -0
- package/dist/src/lib/middleware/phase-detector.d.ts +8 -0
- package/dist/src/lib/middleware/phase-detector.js +63 -0
- package/dist/src/lib/middleware/pipeline.d.ts +29 -0
- package/dist/src/lib/middleware/pipeline.js +81 -0
- package/dist/src/lib/middleware/schemas.d.ts +27 -0
- package/dist/src/lib/middleware/schemas.js +84 -0
- package/dist/src/lib/middleware/types.d.ts +94 -0
- package/dist/src/lib/middleware/types.js +8 -0
- package/dist/src/lib/package-manager-detection.d.ts +42 -0
- package/dist/src/lib/package-manager-detection.js +292 -0
- package/dist/src/lib/registry.d.ts +3 -0
- package/dist/src/lib/registry.js +42 -0
- package/dist/src/lib/safe-tools.d.ts +2 -0
- package/dist/src/lib/safe-tools.js +214 -0
- package/dist/src/lib/wizard-session.d.ts +220 -0
- package/dist/src/lib/wizard-session.js +127 -0
- package/dist/src/lib/wizard-tools.d.ts +82 -0
- package/dist/src/lib/wizard-tools.js +499 -0
- package/dist/src/run.d.ts +19 -0
- package/dist/src/run.js +151 -0
- package/dist/src/steps/add-mcp-server-to-clients/MCPClient.d.ts +30 -0
- package/dist/src/steps/add-mcp-server-to-clients/MCPClient.js +141 -0
- package/dist/src/steps/add-mcp-server-to-clients/clients/claude-code.d.ts +29 -0
- package/dist/src/steps/add-mcp-server-to-clients/clients/claude-code.js +180 -0
- package/dist/src/steps/add-mcp-server-to-clients/clients/claude.d.ts +20 -0
- package/dist/src/steps/add-mcp-server-to-clients/clients/claude.js +63 -0
- package/dist/src/steps/add-mcp-server-to-clients/clients/codex.d.ts +28 -0
- package/dist/src/steps/add-mcp-server-to-clients/clients/codex.js +77 -0
- package/dist/src/steps/add-mcp-server-to-clients/clients/cursor.d.ts +24 -0
- package/dist/src/steps/add-mcp-server-to-clients/clients/cursor.js +60 -0
- package/dist/src/steps/add-mcp-server-to-clients/clients/visual-studio-code.d.ts +27 -0
- package/dist/src/steps/add-mcp-server-to-clients/clients/visual-studio-code.js +101 -0
- package/dist/src/steps/add-mcp-server-to-clients/clients/zed.d.ts +26 -0
- package/dist/src/steps/add-mcp-server-to-clients/clients/zed.js +102 -0
- package/dist/src/steps/add-mcp-server-to-clients/defaults.d.ts +44 -0
- package/dist/src/steps/add-mcp-server-to-clients/defaults.js +123 -0
- package/dist/src/steps/add-mcp-server-to-clients/index.d.ts +19 -0
- package/dist/src/steps/add-mcp-server-to-clients/index.js +110 -0
- package/dist/src/steps/add-or-update-environment-variables.d.ts +10 -0
- package/dist/src/steps/add-or-update-environment-variables.js +188 -0
- package/dist/src/steps/index.d.ts +4 -0
- package/dist/src/steps/index.js +20 -0
- package/dist/src/steps/run-prettier.d.ts +5 -0
- package/dist/src/steps/run-prettier.js +90 -0
- package/dist/src/steps/upload-environment-variables/EnvironmentProvider.d.ts +11 -0
- package/dist/src/steps/upload-environment-variables/EnvironmentProvider.js +11 -0
- package/dist/src/steps/upload-environment-variables/index.d.ts +6 -0
- package/dist/src/steps/upload-environment-variables/index.js +37 -0
- package/dist/src/steps/upload-environment-variables/providers/vercel.d.ts +15 -0
- package/dist/src/steps/upload-environment-variables/providers/vercel.js +145 -0
- package/dist/src/telemetry.d.ts +2 -0
- package/dist/src/telemetry.js +12 -0
- package/dist/src/ui/index.d.ts +8 -0
- package/dist/src/ui/index.js +16 -0
- package/dist/src/ui/logging-ui.d.ts +56 -0
- package/dist/src/ui/logging-ui.js +157 -0
- package/dist/src/ui/tui/App.d.ts +6 -0
- package/dist/src/ui/tui/App.js +34 -0
- package/dist/src/ui/tui/components/AmplitudeLogo.d.ts +5 -0
- package/dist/src/ui/tui/components/AmplitudeLogo.js +81 -0
- package/dist/src/ui/tui/components/AmplitudeTextLogo.d.ts +3 -0
- package/dist/src/ui/tui/components/AmplitudeTextLogo.js +31 -0
- package/dist/src/ui/tui/components/ConsoleView.d.ts +23 -0
- package/dist/src/ui/tui/components/ConsoleView.js +220 -0
- package/dist/src/ui/tui/components/TitleBar.d.ts +6 -0
- package/dist/src/ui/tui/components/TitleBar.js +16 -0
- package/dist/src/ui/tui/console-commands.d.ts +16 -0
- package/dist/src/ui/tui/console-commands.js +31 -0
- package/dist/src/ui/tui/context/CommandModeContext.d.ts +2 -0
- package/dist/src/ui/tui/context/CommandModeContext.js +3 -0
- package/dist/src/ui/tui/flows.d.ts +48 -0
- package/dist/src/ui/tui/flows.js +154 -0
- package/dist/src/ui/tui/hooks/useScreenInput.d.ts +13 -0
- package/dist/src/ui/tui/hooks/useScreenInput.js +18 -0
- package/dist/src/ui/tui/hooks/useStdoutDimensions.d.ts +9 -0
- package/dist/src/ui/tui/hooks/useStdoutDimensions.js +29 -0
- package/dist/src/ui/tui/ink-ui.d.ts +62 -0
- package/dist/src/ui/tui/ink-ui.js +142 -0
- package/dist/src/ui/tui/primitives/CardLayout.d.ts +12 -0
- package/dist/src/ui/tui/primitives/CardLayout.js +9 -0
- package/dist/src/ui/tui/primitives/ConfirmationInput.d.ts +13 -0
- package/dist/src/ui/tui/primitives/ConfirmationInput.js +35 -0
- package/dist/src/ui/tui/primitives/DissolveTransition.d.ts +21 -0
- package/dist/src/ui/tui/primitives/DissolveTransition.js +143 -0
- package/dist/src/ui/tui/primitives/EventPlanViewer.d.ts +9 -0
- package/dist/src/ui/tui/primitives/EventPlanViewer.js +9 -0
- package/dist/src/ui/tui/primitives/KagiSmallWebViewer.d.ts +7 -0
- package/dist/src/ui/tui/primitives/KagiSmallWebViewer.js +101 -0
- package/dist/src/ui/tui/primitives/LoadingBox.d.ts +8 -0
- package/dist/src/ui/tui/primitives/LoadingBox.js +9 -0
- package/dist/src/ui/tui/primitives/LogViewer.d.ts +11 -0
- package/dist/src/ui/tui/primitives/LogViewer.js +55 -0
- package/dist/src/ui/tui/primitives/PickerMenu.d.ts +20 -0
- package/dist/src/ui/tui/primitives/PickerMenu.js +212 -0
- package/dist/src/ui/tui/primitives/ProgressList.d.ts +15 -0
- package/dist/src/ui/tui/primitives/ProgressList.js +29 -0
- package/dist/src/ui/tui/primitives/PromptLabel.d.ts +11 -0
- package/dist/src/ui/tui/primitives/PromptLabel.js +12 -0
- package/dist/src/ui/tui/primitives/ReportViewer.d.ts +12 -0
- package/dist/src/ui/tui/primitives/ReportViewer.js +99 -0
- package/dist/src/ui/tui/primitives/ScreenErrorBoundary.d.ts +26 -0
- package/dist/src/ui/tui/primitives/ScreenErrorBoundary.js +29 -0
- package/dist/src/ui/tui/primitives/SlashCommandInput.d.ts +21 -0
- package/dist/src/ui/tui/primitives/SlashCommandInput.js +85 -0
- package/dist/src/ui/tui/primitives/SnakeGame.d.ts +1 -0
- package/dist/src/ui/tui/primitives/SnakeGame.js +1 -0
- package/dist/src/ui/tui/primitives/SplitView.d.ts +11 -0
- package/dist/src/ui/tui/primitives/SplitView.js +8 -0
- package/dist/src/ui/tui/primitives/TabContainer.d.ts +18 -0
- package/dist/src/ui/tui/primitives/TabContainer.js +30 -0
- package/dist/src/ui/tui/primitives/index.d.ts +23 -0
- package/dist/src/ui/tui/primitives/index.js +19 -0
- package/dist/src/ui/tui/router.d.ts +61 -0
- package/dist/src/ui/tui/router.js +104 -0
- package/dist/src/ui/tui/screen-registry.d.ts +19 -0
- package/dist/src/ui/tui/screen-registry.js +56 -0
- package/dist/src/ui/tui/screens/ActivationOptionsScreen.d.ts +12 -0
- package/dist/src/ui/tui/screens/ActivationOptionsScreen.js +57 -0
- package/dist/src/ui/tui/screens/AuthScreen.d.ts +18 -0
- package/dist/src/ui/tui/screens/AuthScreen.js +107 -0
- package/dist/src/ui/tui/screens/ChecklistScreen.d.ts +22 -0
- package/dist/src/ui/tui/screens/ChecklistScreen.js +122 -0
- package/dist/src/ui/tui/screens/DataIngestionCheckScreen.d.ts +24 -0
- package/dist/src/ui/tui/screens/DataIngestionCheckScreen.js +113 -0
- package/dist/src/ui/tui/screens/DataSetupScreen.d.ts +17 -0
- package/dist/src/ui/tui/screens/DataSetupScreen.js +73 -0
- package/dist/src/ui/tui/screens/IntroScreen.d.ts +16 -0
- package/dist/src/ui/tui/screens/IntroScreen.js +86 -0
- package/dist/src/ui/tui/screens/LoginScreen.d.ts +15 -0
- package/dist/src/ui/tui/screens/LoginScreen.js +65 -0
- package/dist/src/ui/tui/screens/LogoutScreen.d.ts +12 -0
- package/dist/src/ui/tui/screens/LogoutScreen.js +28 -0
- package/dist/src/ui/tui/screens/McpScreen.d.ts +26 -0
- package/dist/src/ui/tui/screens/McpScreen.js +148 -0
- package/dist/src/ui/tui/screens/OutageScreen.d.ts +10 -0
- package/dist/src/ui/tui/screens/OutageScreen.js +17 -0
- package/dist/src/ui/tui/screens/OutroScreen.d.ts +11 -0
- package/dist/src/ui/tui/screens/OutroScreen.js +69 -0
- package/dist/src/ui/tui/screens/RegionSelectScreen.d.ts +17 -0
- package/dist/src/ui/tui/screens/RegionSelectScreen.js +40 -0
- package/dist/src/ui/tui/screens/RunScreen.d.ts +16 -0
- package/dist/src/ui/tui/screens/RunScreen.js +212 -0
- package/dist/src/ui/tui/screens/SettingsOverrideScreen.d.ts +10 -0
- package/dist/src/ui/tui/screens/SettingsOverrideScreen.js +23 -0
- package/dist/src/ui/tui/screens/SetupScreen.d.ts +13 -0
- package/dist/src/ui/tui/screens/SetupScreen.js +73 -0
- package/dist/src/ui/tui/screens/SlackScreen.d.ts +25 -0
- package/dist/src/ui/tui/screens/SlackScreen.js +97 -0
- package/dist/src/ui/tui/services/mcp-installer.d.ts +25 -0
- package/dist/src/ui/tui/services/mcp-installer.js +82 -0
- package/dist/src/ui/tui/start-tui.d.ts +10 -0
- package/dist/src/ui/tui/start-tui.js +50 -0
- package/dist/src/ui/tui/store.d.ts +231 -0
- package/dist/src/ui/tui/store.js +568 -0
- package/dist/src/ui/tui/styles.d.ts +31 -0
- package/dist/src/ui/tui/styles.js +33 -0
- package/dist/src/ui/wizard-ui.d.ts +110 -0
- package/dist/src/ui/wizard-ui.js +18 -0
- package/dist/src/utils/ampli-settings.d.ts +37 -0
- package/dist/src/utils/ampli-settings.js +182 -0
- package/dist/src/utils/analytics.d.ts +35 -0
- package/dist/src/utils/analytics.js +133 -0
- package/dist/src/utils/anthropic-status.d.ts +17 -0
- package/dist/src/utils/anthropic-status.js +51 -0
- package/dist/src/utils/api-key-store.d.ts +35 -0
- package/dist/src/utils/api-key-store.js +176 -0
- package/dist/src/utils/bash.d.ts +2 -0
- package/dist/src/utils/bash.js +53 -0
- package/dist/src/utils/custom-headers.d.ts +9 -0
- package/dist/src/utils/custom-headers.js +23 -0
- package/dist/src/utils/debug.d.ts +23 -0
- package/dist/src/utils/debug.js +86 -0
- package/dist/src/utils/environment.d.ts +4 -0
- package/dist/src/utils/environment.js +76 -0
- package/dist/src/utils/file-utils.d.ts +2 -0
- package/dist/src/utils/file-utils.js +16 -0
- package/dist/src/utils/get-api-key.d.ts +17 -0
- package/dist/src/utils/get-api-key.js +50 -0
- package/dist/src/utils/logging.d.ts +9 -0
- package/dist/src/utils/logging.js +48 -0
- package/dist/src/utils/oauth.d.ts +53 -0
- package/dist/src/utils/oauth.js +354 -0
- package/dist/src/utils/package-json.d.ts +25 -0
- package/dist/src/utils/package-json.js +26 -0
- package/dist/src/utils/package-manager.d.ts +21 -0
- package/dist/src/utils/package-manager.js +208 -0
- package/dist/src/utils/semver.d.ts +21 -0
- package/dist/src/utils/semver.js +61 -0
- package/dist/src/utils/setup-utils.d.ts +82 -0
- package/dist/src/utils/setup-utils.js +467 -0
- package/dist/src/utils/shell-completions.d.ts +10 -0
- package/dist/src/utils/shell-completions.js +199 -0
- package/dist/src/utils/string.d.ts +1 -0
- package/dist/src/utils/string.js +8 -0
- package/dist/src/utils/types.d.ts +72 -0
- package/dist/src/utils/types.js +2 -0
- package/dist/src/utils/urls.d.ts +14 -0
- package/dist/src/utils/urls.js +69 -0
- package/dist/src/utils/vendor/is-unicorn-supported.d.ts +1 -0
- package/dist/src/utils/vendor/is-unicorn-supported.js +23 -0
- package/dist/src/utils/wizard-abort.d.ts +13 -0
- package/dist/src/utils/wizard-abort.js +56 -0
- package/man/amplitude-wizard.1 +170 -0
- package/package.json +144 -0
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.getFlaskVersionBucket = exports.FlaskProjectType = void 0;
|
|
40
|
+
exports.getFlaskVersion = getFlaskVersion;
|
|
41
|
+
exports.getFlaskProjectType = getFlaskProjectType;
|
|
42
|
+
exports.getFlaskProjectTypeName = getFlaskProjectTypeName;
|
|
43
|
+
exports.findFlaskAppFile = findFlaskAppFile;
|
|
44
|
+
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
45
|
+
const ui_1 = require("../../ui");
|
|
46
|
+
const semver_1 = require("../../utils/semver");
|
|
47
|
+
const fs = __importStar(require("node:fs"));
|
|
48
|
+
const path = __importStar(require("node:path"));
|
|
49
|
+
var FlaskProjectType;
|
|
50
|
+
(function (FlaskProjectType) {
|
|
51
|
+
FlaskProjectType["STANDARD"] = "standard";
|
|
52
|
+
FlaskProjectType["RESTFUL"] = "restful";
|
|
53
|
+
FlaskProjectType["RESTX"] = "restx";
|
|
54
|
+
FlaskProjectType["SMOREST"] = "smorest";
|
|
55
|
+
FlaskProjectType["BLUEPRINT"] = "blueprint";
|
|
56
|
+
})(FlaskProjectType || (exports.FlaskProjectType = FlaskProjectType = {}));
|
|
57
|
+
const IGNORE_PATTERNS = [
|
|
58
|
+
'**/node_modules/**',
|
|
59
|
+
'**/dist/**',
|
|
60
|
+
'**/build/**',
|
|
61
|
+
'**/venv/**',
|
|
62
|
+
'**/.venv/**',
|
|
63
|
+
'**/env/**',
|
|
64
|
+
'**/.env/**',
|
|
65
|
+
'**/__pycache__/**',
|
|
66
|
+
'**/migrations/**',
|
|
67
|
+
'**/instance/**',
|
|
68
|
+
];
|
|
69
|
+
/**
|
|
70
|
+
* Get Flask version bucket for analytics
|
|
71
|
+
*/
|
|
72
|
+
exports.getFlaskVersionBucket = (0, semver_1.createVersionBucket)();
|
|
73
|
+
/**
|
|
74
|
+
* Extract Flask version from requirements files or pyproject.toml
|
|
75
|
+
*/
|
|
76
|
+
async function getFlaskVersion(options) {
|
|
77
|
+
const { installDir } = options;
|
|
78
|
+
// Check requirements files
|
|
79
|
+
const requirementsFiles = await (0, fast_glob_1.default)(['**/requirements*.txt', '**/pyproject.toml', '**/setup.py', '**/Pipfile'], {
|
|
80
|
+
cwd: installDir,
|
|
81
|
+
ignore: IGNORE_PATTERNS,
|
|
82
|
+
});
|
|
83
|
+
for (const reqFile of requirementsFiles) {
|
|
84
|
+
try {
|
|
85
|
+
const content = fs.readFileSync(path.join(installDir, reqFile), 'utf-8');
|
|
86
|
+
// Try to extract version from requirements.txt format (Flask==3.0.0 or flask>=2.0)
|
|
87
|
+
const requirementsMatch = content.match(/[Ff]lask[=<>~!]+([0-9]+\.[0-9]+(?:\.[0-9]+)?)/);
|
|
88
|
+
if (requirementsMatch) {
|
|
89
|
+
return requirementsMatch[1];
|
|
90
|
+
}
|
|
91
|
+
// Try to extract from pyproject.toml format
|
|
92
|
+
const pyprojectMatch = content.match(/[Ff]lask["\s]*[=<>~!]+\s*["']?([0-9]+\.[0-9]+(?:\.[0-9]+)?)/);
|
|
93
|
+
if (pyprojectMatch) {
|
|
94
|
+
return pyprojectMatch[1];
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
// Skip files that can't be read
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Check if Flask-RESTful is installed
|
|
106
|
+
*/
|
|
107
|
+
async function hasFlaskRESTful({ installDir, }) {
|
|
108
|
+
const requirementsFiles = await (0, fast_glob_1.default)(['**/requirements*.txt', '**/pyproject.toml', '**/Pipfile'], {
|
|
109
|
+
cwd: installDir,
|
|
110
|
+
ignore: IGNORE_PATTERNS,
|
|
111
|
+
});
|
|
112
|
+
for (const reqFile of requirementsFiles) {
|
|
113
|
+
try {
|
|
114
|
+
const content = fs.readFileSync(path.join(installDir, reqFile), 'utf-8');
|
|
115
|
+
if (content.includes('flask-restful') ||
|
|
116
|
+
content.includes('Flask-RESTful')) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// Also check imports in Python files
|
|
125
|
+
const pyFiles = await (0, fast_glob_1.default)(['**/*.py'], {
|
|
126
|
+
cwd: installDir,
|
|
127
|
+
ignore: IGNORE_PATTERNS,
|
|
128
|
+
});
|
|
129
|
+
for (const pyFile of pyFiles) {
|
|
130
|
+
try {
|
|
131
|
+
const content = fs.readFileSync(path.join(installDir, pyFile), 'utf-8');
|
|
132
|
+
if (content.includes('from flask_restful import') ||
|
|
133
|
+
content.includes('import flask_restful')) {
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Check if Flask-RESTX is installed
|
|
145
|
+
*/
|
|
146
|
+
async function hasFlaskRESTX({ installDir, }) {
|
|
147
|
+
const requirementsFiles = await (0, fast_glob_1.default)(['**/requirements*.txt', '**/pyproject.toml', '**/Pipfile'], {
|
|
148
|
+
cwd: installDir,
|
|
149
|
+
ignore: IGNORE_PATTERNS,
|
|
150
|
+
});
|
|
151
|
+
for (const reqFile of requirementsFiles) {
|
|
152
|
+
try {
|
|
153
|
+
const content = fs.readFileSync(path.join(installDir, reqFile), 'utf-8');
|
|
154
|
+
if (content.includes('flask-restx') || content.includes('Flask-RESTX')) {
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// Also check imports in Python files
|
|
163
|
+
const pyFiles = await (0, fast_glob_1.default)(['**/*.py'], {
|
|
164
|
+
cwd: installDir,
|
|
165
|
+
ignore: IGNORE_PATTERNS,
|
|
166
|
+
});
|
|
167
|
+
for (const pyFile of pyFiles) {
|
|
168
|
+
try {
|
|
169
|
+
const content = fs.readFileSync(path.join(installDir, pyFile), 'utf-8');
|
|
170
|
+
if (content.includes('from flask_restx import') ||
|
|
171
|
+
content.includes('import flask_restx')) {
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Check if flask-smorest is installed
|
|
183
|
+
*/
|
|
184
|
+
async function hasFlaskSmorest({ installDir, }) {
|
|
185
|
+
const requirementsFiles = await (0, fast_glob_1.default)(['**/requirements*.txt', '**/pyproject.toml', '**/Pipfile'], {
|
|
186
|
+
cwd: installDir,
|
|
187
|
+
ignore: IGNORE_PATTERNS,
|
|
188
|
+
});
|
|
189
|
+
for (const reqFile of requirementsFiles) {
|
|
190
|
+
try {
|
|
191
|
+
const content = fs.readFileSync(path.join(installDir, reqFile), 'utf-8');
|
|
192
|
+
if (content.includes('flask-smorest')) {
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
catch {
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
// Also check imports in Python files
|
|
201
|
+
const pyFiles = await (0, fast_glob_1.default)(['**/*.py'], {
|
|
202
|
+
cwd: installDir,
|
|
203
|
+
ignore: IGNORE_PATTERNS,
|
|
204
|
+
});
|
|
205
|
+
for (const pyFile of pyFiles) {
|
|
206
|
+
try {
|
|
207
|
+
const content = fs.readFileSync(path.join(installDir, pyFile), 'utf-8');
|
|
208
|
+
if (content.includes('from flask_smorest import') ||
|
|
209
|
+
content.includes('import flask_smorest')) {
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
catch {
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Check if app uses Flask Blueprints
|
|
221
|
+
*/
|
|
222
|
+
async function hasBlueprints({ installDir, }) {
|
|
223
|
+
const pyFiles = await (0, fast_glob_1.default)(['**/*.py'], {
|
|
224
|
+
cwd: installDir,
|
|
225
|
+
ignore: IGNORE_PATTERNS,
|
|
226
|
+
});
|
|
227
|
+
for (const pyFile of pyFiles) {
|
|
228
|
+
try {
|
|
229
|
+
const content = fs.readFileSync(path.join(installDir, pyFile), 'utf-8');
|
|
230
|
+
if (content.includes('Blueprint(') ||
|
|
231
|
+
content.includes('register_blueprint(') ||
|
|
232
|
+
content.includes('from flask import Blueprint')) {
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Detect Flask project type
|
|
244
|
+
*/
|
|
245
|
+
async function getFlaskProjectType(options) {
|
|
246
|
+
const { installDir } = options;
|
|
247
|
+
// Check for Flask-RESTX first (most specific - includes Swagger)
|
|
248
|
+
if (await hasFlaskRESTX({ installDir })) {
|
|
249
|
+
(0, ui_1.getUI)().setDetectedFramework('Flask-RESTX');
|
|
250
|
+
return FlaskProjectType.RESTX;
|
|
251
|
+
}
|
|
252
|
+
// Check for flask-smorest (OpenAPI-first)
|
|
253
|
+
if (await hasFlaskSmorest({ installDir })) {
|
|
254
|
+
(0, ui_1.getUI)().setDetectedFramework('flask-smorest');
|
|
255
|
+
return FlaskProjectType.SMOREST;
|
|
256
|
+
}
|
|
257
|
+
// Check for Flask-RESTful
|
|
258
|
+
if (await hasFlaskRESTful({ installDir })) {
|
|
259
|
+
(0, ui_1.getUI)().setDetectedFramework('Flask-RESTful');
|
|
260
|
+
return FlaskProjectType.RESTFUL;
|
|
261
|
+
}
|
|
262
|
+
// Check for Blueprints (large app structure)
|
|
263
|
+
if (await hasBlueprints({ installDir })) {
|
|
264
|
+
(0, ui_1.getUI)().setDetectedFramework('Flask with Blueprints');
|
|
265
|
+
return FlaskProjectType.BLUEPRINT;
|
|
266
|
+
}
|
|
267
|
+
// Default to standard Flask
|
|
268
|
+
(0, ui_1.getUI)().setDetectedFramework('Flask');
|
|
269
|
+
return FlaskProjectType.STANDARD;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Get human-readable name for Flask project type
|
|
273
|
+
*/
|
|
274
|
+
function getFlaskProjectTypeName(projectType) {
|
|
275
|
+
switch (projectType) {
|
|
276
|
+
case FlaskProjectType.STANDARD:
|
|
277
|
+
return 'Standard Flask';
|
|
278
|
+
case FlaskProjectType.RESTFUL:
|
|
279
|
+
return 'Flask-RESTful';
|
|
280
|
+
case FlaskProjectType.RESTX:
|
|
281
|
+
return 'Flask-RESTX';
|
|
282
|
+
case FlaskProjectType.SMOREST:
|
|
283
|
+
return 'flask-smorest';
|
|
284
|
+
case FlaskProjectType.BLUEPRINT:
|
|
285
|
+
return 'Flask with Blueprints';
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Find the main Flask app file
|
|
290
|
+
*/
|
|
291
|
+
async function findFlaskAppFile(options) {
|
|
292
|
+
const { installDir } = options;
|
|
293
|
+
// Common Flask app file patterns
|
|
294
|
+
const commonPatterns = [
|
|
295
|
+
'**/app.py',
|
|
296
|
+
'**/wsgi.py',
|
|
297
|
+
'**/application.py',
|
|
298
|
+
'**/run.py',
|
|
299
|
+
'**/main.py',
|
|
300
|
+
'**/__init__.py',
|
|
301
|
+
];
|
|
302
|
+
const appFiles = await (0, fast_glob_1.default)(commonPatterns, {
|
|
303
|
+
cwd: installDir,
|
|
304
|
+
ignore: IGNORE_PATTERNS,
|
|
305
|
+
});
|
|
306
|
+
// Look for files with Flask() instantiation or create_app() factory
|
|
307
|
+
for (const appFile of appFiles) {
|
|
308
|
+
try {
|
|
309
|
+
const content = fs.readFileSync(path.join(installDir, appFile), 'utf-8');
|
|
310
|
+
// Check for Flask app instantiation or application factory
|
|
311
|
+
if (content.includes('Flask(__name__)') ||
|
|
312
|
+
content.includes('Flask(') ||
|
|
313
|
+
content.includes('def create_app(')) {
|
|
314
|
+
return appFile;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
catch {
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
// If no file with Flask() found, check all Python files
|
|
322
|
+
const allPyFiles = await (0, fast_glob_1.default)(['**/*.py'], {
|
|
323
|
+
cwd: installDir,
|
|
324
|
+
ignore: IGNORE_PATTERNS,
|
|
325
|
+
});
|
|
326
|
+
for (const pyFile of allPyFiles) {
|
|
327
|
+
try {
|
|
328
|
+
const content = fs.readFileSync(path.join(installDir, pyFile), 'utf-8');
|
|
329
|
+
if (content.includes('Flask(__name__)') ||
|
|
330
|
+
content.includes('def create_app(')) {
|
|
331
|
+
return pyFile;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
catch {
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
// Return first common pattern file if exists
|
|
339
|
+
if (appFiles.length > 0) {
|
|
340
|
+
return appFiles[0];
|
|
341
|
+
}
|
|
342
|
+
return undefined;
|
|
343
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FLUTTER_AGENT_CONFIG = void 0;
|
|
4
|
+
const package_manager_detection_1 = require("../../lib/package-manager-detection");
|
|
5
|
+
const constants_1 = require("../../lib/constants");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
exports.FLUTTER_AGENT_CONFIG = {
|
|
8
|
+
metadata: {
|
|
9
|
+
name: 'Flutter',
|
|
10
|
+
integration: constants_1.Integration.flutter,
|
|
11
|
+
beta: true,
|
|
12
|
+
docsUrl: 'https://amplitude.com/docs/sdks/analytics/flutter/flutter-sdk-4',
|
|
13
|
+
},
|
|
14
|
+
detection: {
|
|
15
|
+
packageName: 'amplitude_flutter',
|
|
16
|
+
packageDisplayName: 'Flutter',
|
|
17
|
+
usesPackageJson: false,
|
|
18
|
+
getVersion: () => undefined,
|
|
19
|
+
detect: utils_1.detectFlutterProject,
|
|
20
|
+
detectPackageManager: package_manager_detection_1.flutterPackageManager,
|
|
21
|
+
},
|
|
22
|
+
environment: {
|
|
23
|
+
// Flutter apps don't use .env files — API keys are passed via --dart-define
|
|
24
|
+
// or stored in a constants file; the agent handles key storage
|
|
25
|
+
uploadToHosting: false,
|
|
26
|
+
getEnvVars: () => ({}),
|
|
27
|
+
},
|
|
28
|
+
analytics: {
|
|
29
|
+
getTags: () => ({}),
|
|
30
|
+
},
|
|
31
|
+
prompts: {
|
|
32
|
+
projectTypeDetection: 'This is a Flutter project. Look for pubspec.yaml with a flutter SDK reference, and android/ + ios/ directories.',
|
|
33
|
+
packageInstallation: 'Use Flutter pub: run `flutter pub add amplitude_flutter` to add the dependency (pubspec.yaml and pubspec.lock are updated automatically).',
|
|
34
|
+
getAdditionalContextLines: () => [
|
|
35
|
+
'Framework docs ID: flutter (use amplitude://docs/frameworks/flutter for documentation)',
|
|
36
|
+
'SDK: amplitude_flutter (pub.dev)',
|
|
37
|
+
'Initialization: final amplitude = Amplitude(Configuration(apiKey: const String.fromEnvironment("AMPLITUDE_API_KEY"))); await amplitude.isBuilt;',
|
|
38
|
+
'Always await amplitude.isBuilt before calling track() or flush()',
|
|
39
|
+
'Store the API key via --dart-define at build time (flutter run --dart-define=AMPLITUDE_API_KEY=...), not hardcoded in source',
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
ui: {
|
|
43
|
+
successMessage: 'Amplitude integration complete',
|
|
44
|
+
estimatedDurationMinutes: 8,
|
|
45
|
+
getOutroChanges: () => [
|
|
46
|
+
'Analyzed your Flutter project structure',
|
|
47
|
+
'Added amplitude_flutter to pubspec.yaml via flutter pub add',
|
|
48
|
+
'Configured Amplitude initialization with default session tracking',
|
|
49
|
+
],
|
|
50
|
+
getOutroNextSteps: () => [
|
|
51
|
+
'Run your app on a device or simulator to verify the integration',
|
|
52
|
+
'Visit your Amplitude dashboard to see incoming events',
|
|
53
|
+
'Use amplitude.track(BaseEvent("Event Name")) for custom events',
|
|
54
|
+
'Pass the API key at build time: flutter run --dart-define=AMPLITUDE_API_KEY=your_key',
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { WizardOptions } from '../../utils/types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns true when the directory contains a Flutter project.
|
|
4
|
+
* A Flutter project has pubspec.yaml that references the flutter SDK,
|
|
5
|
+
* or has the characteristic android/ + ios/ sibling directories.
|
|
6
|
+
*/
|
|
7
|
+
export declare function detectFlutterProject(options: Pick<WizardOptions, 'installDir'>): Promise<boolean>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.detectFlutterProject = detectFlutterProject;
|
|
37
|
+
const fs = __importStar(require("node:fs"));
|
|
38
|
+
const path = __importStar(require("node:path"));
|
|
39
|
+
/**
|
|
40
|
+
* Returns true when the directory contains a Flutter project.
|
|
41
|
+
* A Flutter project has pubspec.yaml that references the flutter SDK,
|
|
42
|
+
* or has the characteristic android/ + ios/ sibling directories.
|
|
43
|
+
*/
|
|
44
|
+
function detectFlutterProject(options) {
|
|
45
|
+
const { installDir } = options;
|
|
46
|
+
const pubspecPath = path.join(installDir, 'pubspec.yaml');
|
|
47
|
+
if (!fs.existsSync(pubspecPath)) {
|
|
48
|
+
return Promise.resolve(false);
|
|
49
|
+
}
|
|
50
|
+
// Check for flutter SDK reference in pubspec.yaml
|
|
51
|
+
try {
|
|
52
|
+
const content = fs.readFileSync(pubspecPath, 'utf-8');
|
|
53
|
+
if (/^\s*flutter\s*:/m.test(content) || content.includes('sdk: flutter')) {
|
|
54
|
+
return Promise.resolve(true);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// fall through to directory check
|
|
59
|
+
}
|
|
60
|
+
// Fallback: typical Flutter project has both android/ and ios/ dirs
|
|
61
|
+
const hasAndroid = fs.existsSync(path.join(installDir, 'android'));
|
|
62
|
+
const hasIos = fs.existsSync(path.join(installDir, 'ios'));
|
|
63
|
+
return Promise.resolve(hasAndroid && hasIos);
|
|
64
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GENERIC_AGENT_CONFIG = void 0;
|
|
4
|
+
const constants_1 = require("../../lib/constants");
|
|
5
|
+
const package_manager_detection_1 = require("../../lib/package-manager-detection");
|
|
6
|
+
exports.GENERIC_AGENT_CONFIG = {
|
|
7
|
+
metadata: {
|
|
8
|
+
name: 'Generic',
|
|
9
|
+
integration: constants_1.Integration.generic,
|
|
10
|
+
docsUrl: 'https://amplitude.com/docs/get-started/amplitude-quickstart',
|
|
11
|
+
},
|
|
12
|
+
detection: {
|
|
13
|
+
packageName: '',
|
|
14
|
+
packageDisplayName: 'Generic',
|
|
15
|
+
usesPackageJson: false,
|
|
16
|
+
getVersion: () => undefined,
|
|
17
|
+
detectPackageManager: package_manager_detection_1.detectNodePackageManagers,
|
|
18
|
+
detect: () => Promise.resolve(false),
|
|
19
|
+
},
|
|
20
|
+
environment: {
|
|
21
|
+
uploadToHosting: false,
|
|
22
|
+
getEnvVars: (apiKey, host) => ({
|
|
23
|
+
AMPLITUDE_API_KEY: apiKey,
|
|
24
|
+
AMPLITUDE_SERVER_URL: host,
|
|
25
|
+
}),
|
|
26
|
+
},
|
|
27
|
+
analytics: {
|
|
28
|
+
getTags: () => ({}),
|
|
29
|
+
},
|
|
30
|
+
prompts: {
|
|
31
|
+
projectTypeDetection: 'n/a',
|
|
32
|
+
buildPrompt: ({ projectApiKey, host, typescript }) => {
|
|
33
|
+
// Derive browser-side HTTP API endpoint from the server-side ingestion host.
|
|
34
|
+
// The Browser SDK uses a different endpoint from the server-side SDK.
|
|
35
|
+
const browserApiUrl = host.includes('eu.')
|
|
36
|
+
? 'https://api.eu.amplitude.com/2/httpapi'
|
|
37
|
+
: 'https://api2.amplitude.com/2/httpapi';
|
|
38
|
+
return `
|
|
39
|
+
You are integrating Amplitude analytics into a project.
|
|
40
|
+
|
|
41
|
+
Project context:
|
|
42
|
+
- Amplitude public API key: ${projectApiKey}
|
|
43
|
+
- Amplitude server-side host (Node.js / Python / server SDKs): ${host}
|
|
44
|
+
- Amplitude browser API URL (Browser SDK / CDN snippet): ${browserApiUrl}
|
|
45
|
+
- TypeScript: ${typescript ? 'Yes' : 'No'}
|
|
46
|
+
|
|
47
|
+
Use [STATUS] <message> at the start of any line to report progress (e.g. "[STATUS] Reading project structure"). These are shown to the user in the terminal.
|
|
48
|
+
|
|
49
|
+
Instructions (follow IN ORDER):
|
|
50
|
+
|
|
51
|
+
STEP 1: Check if Amplitude is already integrated.
|
|
52
|
+
Search the project for existing Amplitude references (e.g. "amplitude" in source files or templates).
|
|
53
|
+
- If Amplitude code is already present: skip to STEP 6 (build verification) and diagnose any issues.
|
|
54
|
+
- If not: continue to STEP 2.
|
|
55
|
+
|
|
56
|
+
STEP 2: Understand the project.
|
|
57
|
+
[STATUS] Analysing project structure
|
|
58
|
+
Use Glob to list key manifest files (package.json, requirements.txt, Gemfile, go.mod, netlify.toml, config.toml, etc.) and read the main entry point to determine the language and framework.
|
|
59
|
+
|
|
60
|
+
STEP 3: Choose the SDK and fetch documentation.
|
|
61
|
+
[STATUS] Fetching Amplitude documentation
|
|
62
|
+
Choose the correct SDK based on the project type, then fetch its docs:
|
|
63
|
+
|
|
64
|
+
SDK selection (choose the FIRST match):
|
|
65
|
+
- Browser / SPA / SSG (JS running in a browser):
|
|
66
|
+
Recommended: @amplitude/unified
|
|
67
|
+
npm install @amplitude/unified
|
|
68
|
+
import { initAll } from '@amplitude/unified';
|
|
69
|
+
initAll(API_KEY, { analytics: { autocapture: true } });
|
|
70
|
+
Alternative: @amplitude/analytics-browser
|
|
71
|
+
npm install @amplitude/analytics-browser
|
|
72
|
+
amplitude.init(API_KEY, { autocapture: { pageViews: true, sessions: true, formInteractions: true, fileDownloads: true } });
|
|
73
|
+
Static site (no build pipeline): CDN snippet — see https://amplitude.com/docs/sdks/analytics/browser/browser-sdk-2
|
|
74
|
+
- Node.js server:
|
|
75
|
+
npm install @amplitude/analytics-node
|
|
76
|
+
import { init, track, flush } from '@amplitude/analytics-node';
|
|
77
|
+
init(API_KEY); ... await flush().promise;
|
|
78
|
+
- Python:
|
|
79
|
+
pip install amplitude-analytics
|
|
80
|
+
from amplitude import Amplitude, BaseEvent
|
|
81
|
+
client = Amplitude(API_KEY)
|
|
82
|
+
client.track(BaseEvent(event_type="Event", user_id="user"))
|
|
83
|
+
- EU data residency: pass serverZone: 'EU' (JS) or client.configuration.server_zone = 'EU' (Python)
|
|
84
|
+
- Angular: initialize OUTSIDE Angular's zone: ngZone.runOutsideAngular(() => amplitude.init(API_KEY, options))
|
|
85
|
+
- SvelteKit/Astro: env var prefix is PUBLIC_ (e.g. PUBLIC_AMPLITUDE_API_KEY)
|
|
86
|
+
|
|
87
|
+
Env var naming by framework:
|
|
88
|
+
- Next.js: NEXT_PUBLIC_AMPLITUDE_API_KEY (browser), AMPLITUDE_API_KEY (server)
|
|
89
|
+
- Vite / Vue: VITE_AMPLITUDE_API_KEY
|
|
90
|
+
- SvelteKit / Astro: PUBLIC_AMPLITUDE_API_KEY
|
|
91
|
+
- Create React App: REACT_APP_AMPLITUDE_API_KEY
|
|
92
|
+
- Node.js / Python / generic server: AMPLITUDE_API_KEY
|
|
93
|
+
|
|
94
|
+
Use WebFetch to load the specific SDK docs if needed for exact API details.
|
|
95
|
+
|
|
96
|
+
STEP 4: Install and initialise the Amplitude SDK.
|
|
97
|
+
[STATUS] Installing Amplitude SDK
|
|
98
|
+
If the project uses a package manager: use the detect_package_manager tool to find it, then install the appropriate SDK package as a background task and proceed immediately.
|
|
99
|
+
If the project is a static site with no server-side build pipeline (e.g. Zola, Hugo, Jekyll, Eleventy): use the CDN script tag approach instead, and store the API key in the site's config file (e.g. config.toml, config.yaml, _config.yml) — that is the correct pattern for static sites, not a .env file.
|
|
100
|
+
For all other projects: reference env vars for the API key — never hardcode them in source files.
|
|
101
|
+
|
|
102
|
+
Add a sample tracking call demonstrating the integration.
|
|
103
|
+
|
|
104
|
+
BROWSER SDK / CDN SNIPPET — SERVER URL AND CORS:
|
|
105
|
+
When using the Amplitude Browser SDK (whether via CDN <script> tag or npm package in a browser context), you MUST:
|
|
106
|
+
1. Set serverUrl to the browser API URL: ${browserApiUrl}
|
|
107
|
+
This is NOT the same as the server-side host. Using the wrong URL will cause CORS errors or silent failures.
|
|
108
|
+
Example initialisation:
|
|
109
|
+
amplitude.init('${projectApiKey}', { serverUrl: '${browserApiUrl}' });
|
|
110
|
+
2. If the project is deployed on Netlify (netlify.toml present), add a reverse proxy redirect AND
|
|
111
|
+
CORS headers so events go through the site's own domain (bypasses ad blockers):
|
|
112
|
+
In netlify.toml:
|
|
113
|
+
[[redirects]]
|
|
114
|
+
from = "/amplitude-api/*"
|
|
115
|
+
to = "${host.includes('eu.')
|
|
116
|
+
? 'https://api.eu.amplitude.com'
|
|
117
|
+
: 'https://api2.amplitude.com'}/:splat"
|
|
118
|
+
status = 200
|
|
119
|
+
force = true
|
|
120
|
+
[[headers]]
|
|
121
|
+
for = "/amplitude-api/*"
|
|
122
|
+
[headers.values]
|
|
123
|
+
Access-Control-Allow-Origin = "*"
|
|
124
|
+
Access-Control-Allow-Methods = "GET, POST, OPTIONS"
|
|
125
|
+
Access-Control-Allow-Headers = "Content-Type"
|
|
126
|
+
Then set serverUrl to '/amplitude-api/2/httpapi' in the SDK init (or site config file).
|
|
127
|
+
3. If the project has a local dev server with a proxy config (Vite, webpack-dev-server, Next.js, etc.),
|
|
128
|
+
add a proxy rule so that requests to /amplitude-api are forwarded to ${browserApiUrl}.
|
|
129
|
+
Then set serverUrl to '/amplitude-api/2/httpapi' in the SDK init.
|
|
130
|
+
Only do this if the framework has a built-in proxy mechanism.
|
|
131
|
+
4. If there is no proxy mechanism (plain static site, no dev server, no Netlify), use the direct browserApiUrl.
|
|
132
|
+
CORS is supported by Amplitude's API, so it will work in production. In local development,
|
|
133
|
+
ad blockers or browser extensions may block requests — this is expected and not a code issue.
|
|
134
|
+
|
|
135
|
+
STEP 4b: Update Content Security Policy (CSP).
|
|
136
|
+
[STATUS] Checking Content Security Policy
|
|
137
|
+
This is MANDATORY — do not skip it even if the SDK was already present.
|
|
138
|
+
Search the entire project for any CSP definitions using Grep:
|
|
139
|
+
- Grep for "Content-Security-Policy" across all files
|
|
140
|
+
- Also check: netlify.toml, _headers, vercel.json, next.config.*, nginx.conf, .htaccess, any HTML <meta http-equiv="Content-Security-Policy"> tags
|
|
141
|
+
If any CSP is found, read the file and add the following to the relevant directives:
|
|
142
|
+
- script-src: https://*.amplitude.com
|
|
143
|
+
- connect-src: https://*.amplitude.com
|
|
144
|
+
Update ALL locations where a CSP is defined (there may be more than one).
|
|
145
|
+
If no CSP is found, skip to STEP 5.
|
|
146
|
+
|
|
147
|
+
STEP 5: Set environment variables (skip for static sites that store config in a site config file).
|
|
148
|
+
[STATUS] Writing environment variables
|
|
149
|
+
For projects that use env vars: use the wizard-tools MCP server.
|
|
150
|
+
- Use check_env_keys to see what already exists.
|
|
151
|
+
- Use set_env_values to write the API key and server URL.
|
|
152
|
+
The tool ensures .gitignore coverage automatically.
|
|
153
|
+
Use the naming convention for the framework (e.g. NEXT_PUBLIC_AMPLITUDE_API_KEY for Next.js, VITE_AMPLITUDE_API_KEY for Vite, AMPLITUDE_API_KEY for Node.js/Python/etc.).
|
|
154
|
+
For browser SDK projects, store AMPLITUDE_SERVER_URL=${browserApiUrl}.
|
|
155
|
+
For server-side SDK projects, store AMPLITUDE_SERVER_URL=${host}.
|
|
156
|
+
|
|
157
|
+
STEP 6: Verify the build.
|
|
158
|
+
[STATUS] Verifying build
|
|
159
|
+
Run the project's build command and check it exits cleanly:
|
|
160
|
+
- Package manager projects: use the detected package manager (e.g. npm run build, pnpm build, cargo build, go build, ./gradlew build)
|
|
161
|
+
- Static site generators: run the site's build command (e.g. zola build, hugo, jekyll build, mkdocs build, eleventy)
|
|
162
|
+
If the build fails, read the error output, fix the issue, and run it again. Repeat until the build passes or you have exhausted reasonable fixes.
|
|
163
|
+
|
|
164
|
+
Important: You must read a file immediately before writing it. Always use environment variables — never hardcode the public token.
|
|
165
|
+
`.trim();
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
ui: {
|
|
169
|
+
successMessage: 'Amplitude integration complete',
|
|
170
|
+
estimatedDurationMinutes: 5,
|
|
171
|
+
getOutroChanges: () => ['Amplitude SDK installed and initialized'],
|
|
172
|
+
getOutroNextSteps: () => [
|
|
173
|
+
'Verify events are appearing in your Amplitude project dashboard',
|
|
174
|
+
],
|
|
175
|
+
},
|
|
176
|
+
};
|