create-mastra 1.9.2-alpha.0 → 1.9.2-alpha.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # create-mastra
2
2
 
3
+ ## 1.9.2-alpha.3
4
+
5
+ ## 1.9.2-alpha.2
6
+
7
+ ## 1.9.2-alpha.1
8
+
9
+ ### Patch Changes
10
+
11
+ - Improve `npm create mastra` telemetry delivery so command completion events are tracked and flushed before the process exits. ([#16582](https://github.com/mastra-ai/mastra/pull/16582))
12
+
3
13
  ## 1.9.2-alpha.0
4
14
 
5
15
  ## 1.9.1
package/dist/index.js CHANGED
@@ -14508,7 +14508,7 @@ var FileService = class {
14508
14508
  }
14509
14509
  };
14510
14510
  var exec$1 = util.promisify(child_process.exec);
14511
- async function promptForObservability() {
14511
+ async function promptForObservability(command, onObservabilitySelected) {
14512
14512
  while (true) {
14513
14513
  const choice = await Ee({
14514
14514
  message: "Enable Mastra Observability? (will open auth flow)",
@@ -14519,7 +14519,15 @@ async function promptForObservability() {
14519
14519
  initialValue: "yes"
14520
14520
  });
14521
14521
  if (q(choice)) return {};
14522
- if (choice !== "yes") return { enabled: false };
14522
+ const answer = choice === "yes" ? "yes" : "no";
14523
+ const enabled = answer === "yes";
14524
+ onObservabilitySelected?.({
14525
+ command,
14526
+ enabled,
14527
+ answer,
14528
+ selection_method: "interactive"
14529
+ });
14530
+ if (!enabled) return { enabled: false };
14523
14531
  const hadCachedCreds = await loadCredentials() !== null;
14524
14532
  try {
14525
14533
  const token = await getToken();
@@ -15058,7 +15066,7 @@ var LLM_PROVIDERS = [
15058
15066
  { value: "mistral", label: "Mistral" }
15059
15067
  ];
15060
15068
  var interactivePrompt = async (args = {}) => {
15061
- const { skip = {}, options: { showBanner = true } = {} } = args;
15069
+ const { skip = {}, options: { command, showBanner = true, onObservabilitySelected } = {} } = args;
15062
15070
  if (showBanner) {
15063
15071
  ge(color.inverse(" Mastra Init "));
15064
15072
  }
@@ -15097,7 +15105,7 @@ var interactivePrompt = async (args = {}) => {
15097
15105
  },
15098
15106
  observability: async () => {
15099
15107
  if (skip?.observability) return void 0;
15100
- return promptForObservability();
15108
+ return promptForObservability(command, onObservabilitySelected);
15101
15109
  },
15102
15110
  configureMastraToolingForAgents: async () => {
15103
15111
  if (skip?.skills && skip?.mcpServer) return { skills: void 0, mcpServer: void 0 };
@@ -15444,6 +15452,9 @@ var analyticsInstance = null;
15444
15452
  function getAnalytics() {
15445
15453
  return analyticsInstance;
15446
15454
  }
15455
+ function setAnalytics(instance) {
15456
+ analyticsInstance = instance;
15457
+ }
15447
15458
  var PosthogAnalytics = class {
15448
15459
  sessionId;
15449
15460
  client;
@@ -15778,7 +15789,7 @@ var PinoLogger = class _PinoLogger extends MastraLogger {
15778
15789
  };
15779
15790
 
15780
15791
  var package_default = {
15781
- version: "1.9.2-alpha.0"};
15792
+ version: "1.9.2-alpha.3"};
15782
15793
  var logger = createLogger(false);
15783
15794
  function createLogger(debug = false) {
15784
15795
  return new PinoLogger({
@@ -16444,7 +16455,8 @@ var createMastraProject = async ({
16444
16455
  skills,
16445
16456
  mcpServer,
16446
16457
  observability,
16447
- needsInteractive
16458
+ needsInteractive,
16459
+ onObservabilitySelected
16448
16460
  }) => {
16449
16461
  ge(color.inverse(" Mastra Create "));
16450
16462
  const projectName = name ?? await Re({
@@ -16465,7 +16477,7 @@ var createMastraProject = async ({
16465
16477
  if (needsInteractive) {
16466
16478
  const skipGitInit = await isGitInitialized({ cwd: process.cwd() });
16467
16479
  result = await interactivePrompt({
16468
- options: { showBanner: false },
16480
+ options: { command: "create", showBanner: false, onObservabilitySelected },
16469
16481
  skip: {
16470
16482
  llmProvider: llmProvider !== void 0,
16471
16483
  llmApiKey: llmApiKey !== void 0,
@@ -16621,10 +16633,24 @@ var create = async (args) => {
16621
16633
  skills: args?.skills,
16622
16634
  mcpServer: args?.mcpServer,
16623
16635
  observability: args?.observability,
16624
- needsInteractive
16636
+ needsInteractive,
16637
+ onObservabilitySelected: (event) => getAnalytics()?.trackEvent("cli_observability_selected", event)
16625
16638
  });
16626
16639
  if (needsInteractive && result) {
16640
+ const analytics = getAnalytics();
16641
+ if (analytics && result?.llmProvider) {
16642
+ analytics.trackEvent("cli_model_provider_selected", {
16643
+ provider: result.llmProvider,
16644
+ selection_method: "interactive"
16645
+ });
16646
+ }
16627
16647
  const interactiveComponents = ["agents", "tools", "workflows", "scorers"];
16648
+ if (analytics) {
16649
+ analytics.trackEvent("cli_components_selected", {
16650
+ components: interactiveComponents,
16651
+ selection_method: "interactive"
16652
+ });
16653
+ }
16628
16654
  await init({
16629
16655
  ...result,
16630
16656
  llmApiKey: result?.llmApiKey,
@@ -16642,6 +16668,21 @@ var create = async (args) => {
16642
16668
  return;
16643
16669
  }
16644
16670
  const { components = [], llmProvider = "openai", addExample = false, llmApiKey } = args;
16671
+ const cliAnalytics = getAnalytics();
16672
+ if (cliAnalytics) {
16673
+ cliAnalytics.trackEvent("cli_model_provider_selected", {
16674
+ provider: llmProvider,
16675
+ selection_method: "cli_args"
16676
+ });
16677
+ cliAnalytics.trackEvent("cli_components_selected", {
16678
+ components,
16679
+ has_agents: components.includes("agents"),
16680
+ has_tools: components.includes("tools"),
16681
+ has_workflows: components.includes("workflows"),
16682
+ has_scorers: components.includes("scorers"),
16683
+ selection_method: "cli_args"
16684
+ });
16685
+ }
16645
16686
  await init({
16646
16687
  directory,
16647
16688
  components,
@@ -16902,6 +16943,7 @@ const analytics = new PosthogAnalytics({
16902
16943
  host: "https://us.posthog.com",
16903
16944
  version
16904
16945
  });
16946
+ setAnalytics(analytics);
16905
16947
  const program = new Command();
16906
16948
  program.version(`${version}`, "-v, --version").description(`create-mastra ${version}`).action(async () => {
16907
16949
  try {
@@ -16918,41 +16960,62 @@ program.name("create-mastra").description("Create a new Mastra project").argumen
16918
16960
  ).option("--default", "Quick start with defaults (src, OpenAI, examples)").option("-c, --components <components>", "Comma-separated list of components (agents, tools, workflows, scorers)").option("-l, --llm <model-provider>", "Default model provider (openai, anthropic, groq, google, or cerebras)").option("-k, --llm-api-key <api-key>", "API key for the model provider").option("-e, --example", "Include example code").option("-n, --no-example", "Do not include example code").option("-t, --timeout [timeout]", "Configurable timeout for package installation, defaults to 60000 ms").option("-d, --dir <directory>", "Target directory for Mastra source code (default: src/)").option("-m, --mcp <mcp>", "MCP Server for code editor (cursor, cursor-global, windsurf, vscode, antigravity)").option(
16919
16961
  "--template [template-name]",
16920
16962
  "Create project from a template (use template name, public GitHub URL, or leave blank to select from list)"
16921
- ).option("--observe", "Enable Mastra Observe (writes MASTRA_CLOUD_ACCESS_TOKEN placeholder to .env)").option("--no-observe", "Do not enable Mastra Observe").action(async (projectNameArg, args) => {
16922
- const projectName = projectNameArg || args.projectName;
16923
- const timeout = args?.timeout ? args?.timeout === true ? 6e4 : parseInt(args?.timeout, 10) : void 0;
16924
- if (args.default) {
16925
- await create({
16926
- components: ["agents", "tools", "workflows", "scorers"],
16927
- llmProvider: "openai",
16928
- addExample: true,
16929
- createVersionTag,
16930
- timeout,
16931
- projectName,
16932
- mcpServer: args.mcp,
16933
- directory: "src/",
16963
+ ).option("--observe", "Enable Mastra Observe (writes MASTRA_CLOUD_ACCESS_TOKEN placeholder to .env)").option("--no-observe", "Do not enable Mastra Observe").action(
16964
+ async (projectNameArg, args) => analytics.trackCommandExecution({
16965
+ command: "create",
16966
+ args: {
16967
+ projectName: projectNameArg || args.projectName,
16968
+ components: args.components,
16969
+ llmProvider: args.llm,
16970
+ addExample: args.example,
16971
+ default: args.default,
16934
16972
  template: args.template,
16935
- analytics,
16936
- observe: args.observe
16937
- });
16938
- return;
16939
- }
16940
- await create({
16941
- components: args.components ? args.components.split(",") : [],
16942
- llmProvider: args.llm,
16943
- addExample: args.example,
16944
- llmApiKey: args.llmApiKey,
16945
- createVersionTag,
16946
- timeout,
16947
- projectName,
16948
- directory: args.dir,
16949
- mcpServer: args.mcp,
16950
- template: args.template,
16951
- analytics,
16952
- observe: args.observe
16953
- });
16954
- });
16955
- program.parse(process.argv);
16973
+ observability: args.observe
16974
+ },
16975
+ execution: async () => {
16976
+ const projectName = projectNameArg || args.projectName;
16977
+ const timeout = args?.timeout ? args?.timeout === true ? 6e4 : parseInt(args?.timeout, 10) : void 0;
16978
+ if (args.default) {
16979
+ await create({
16980
+ components: ["agents", "tools", "workflows", "scorers"],
16981
+ llmProvider: "openai",
16982
+ addExample: true,
16983
+ createVersionTag,
16984
+ timeout,
16985
+ projectName,
16986
+ mcpServer: args.mcp,
16987
+ directory: "src/",
16988
+ template: args.template,
16989
+ analytics,
16990
+ observability: args.observe
16991
+ });
16992
+ return;
16993
+ }
16994
+ await create({
16995
+ components: args.components ? args.components.split(",") : [],
16996
+ llmProvider: args.llm,
16997
+ addExample: args.example,
16998
+ llmApiKey: args.llmApiKey,
16999
+ createVersionTag,
17000
+ timeout,
17001
+ projectName,
17002
+ directory: args.dir,
17003
+ mcpServer: args.mcp,
17004
+ template: args.template,
17005
+ analytics,
17006
+ observability: args.observe
17007
+ });
17008
+ }
17009
+ })
17010
+ );
17011
+ try {
17012
+ await program.parseAsync(process.argv);
17013
+ } catch (err) {
17014
+ console.error(`Error: ${err instanceof Error ? err.message : String(err)}`);
17015
+ process.exitCode = 1;
17016
+ } finally {
17017
+ await analytics.shutdown(1e3);
17018
+ }
16956
17019
 
16957
17020
  export { getToken as a, login as b, clearCredentials as c, setCurrentOrgId as d, verifyToken as e, fetchOrgs as f, getCurrentOrgId as g, loadCredentials as l, saveCredentials as s, tryRefreshToken as t, validateOrgAccess as v };
16958
17021
  //# sourceMappingURL=index.js.map