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

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,13 @@
1
1
  # create-mastra
2
2
 
3
+ ## 1.9.2-alpha.2
4
+
5
+ ## 1.9.2-alpha.1
6
+
7
+ ### Patch Changes
8
+
9
+ - 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))
10
+
3
11
  ## 1.9.2-alpha.0
4
12
 
5
13
  ## 1.9.1
package/dist/index.js CHANGED
@@ -15444,6 +15444,9 @@ var analyticsInstance = null;
15444
15444
  function getAnalytics() {
15445
15445
  return analyticsInstance;
15446
15446
  }
15447
+ function setAnalytics(instance) {
15448
+ analyticsInstance = instance;
15449
+ }
15447
15450
  var PosthogAnalytics = class {
15448
15451
  sessionId;
15449
15452
  client;
@@ -15778,7 +15781,7 @@ var PinoLogger = class _PinoLogger extends MastraLogger {
15778
15781
  };
15779
15782
 
15780
15783
  var package_default = {
15781
- version: "1.9.2-alpha.0"};
15784
+ version: "1.9.2-alpha.2"};
15782
15785
  var logger = createLogger(false);
15783
15786
  function createLogger(debug = false) {
15784
15787
  return new PinoLogger({
@@ -16624,7 +16627,20 @@ var create = async (args) => {
16624
16627
  needsInteractive
16625
16628
  });
16626
16629
  if (needsInteractive && result) {
16630
+ const analytics = getAnalytics();
16631
+ if (analytics && result?.llmProvider) {
16632
+ analytics.trackEvent("cli_model_provider_selected", {
16633
+ provider: result.llmProvider,
16634
+ selection_method: "interactive"
16635
+ });
16636
+ }
16627
16637
  const interactiveComponents = ["agents", "tools", "workflows", "scorers"];
16638
+ if (analytics) {
16639
+ analytics.trackEvent("cli_components_selected", {
16640
+ components: interactiveComponents,
16641
+ selection_method: "interactive"
16642
+ });
16643
+ }
16628
16644
  await init({
16629
16645
  ...result,
16630
16646
  llmApiKey: result?.llmApiKey,
@@ -16642,6 +16658,21 @@ var create = async (args) => {
16642
16658
  return;
16643
16659
  }
16644
16660
  const { components = [], llmProvider = "openai", addExample = false, llmApiKey } = args;
16661
+ const cliAnalytics = getAnalytics();
16662
+ if (cliAnalytics) {
16663
+ cliAnalytics.trackEvent("cli_model_provider_selected", {
16664
+ provider: llmProvider,
16665
+ selection_method: "cli_args"
16666
+ });
16667
+ cliAnalytics.trackEvent("cli_components_selected", {
16668
+ components,
16669
+ has_agents: components.includes("agents"),
16670
+ has_tools: components.includes("tools"),
16671
+ has_workflows: components.includes("workflows"),
16672
+ has_scorers: components.includes("scorers"),
16673
+ selection_method: "cli_args"
16674
+ });
16675
+ }
16645
16676
  await init({
16646
16677
  directory,
16647
16678
  components,
@@ -16902,6 +16933,7 @@ const analytics = new PosthogAnalytics({
16902
16933
  host: "https://us.posthog.com",
16903
16934
  version
16904
16935
  });
16936
+ setAnalytics(analytics);
16905
16937
  const program = new Command();
16906
16938
  program.version(`${version}`, "-v, --version").description(`create-mastra ${version}`).action(async () => {
16907
16939
  try {
@@ -16918,41 +16950,62 @@ program.name("create-mastra").description("Create a new Mastra project").argumen
16918
16950
  ).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
16951
  "--template [template-name]",
16920
16952
  "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/",
16953
+ ).option("--observe", "Enable Mastra Observe (writes MASTRA_CLOUD_ACCESS_TOKEN placeholder to .env)").option("--no-observe", "Do not enable Mastra Observe").action(
16954
+ async (projectNameArg, args) => analytics.trackCommandExecution({
16955
+ command: "create",
16956
+ args: {
16957
+ projectName: projectNameArg || args.projectName,
16958
+ components: args.components,
16959
+ llmProvider: args.llm,
16960
+ addExample: args.example,
16961
+ default: args.default,
16934
16962
  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);
16963
+ observability: args.observe
16964
+ },
16965
+ execution: async () => {
16966
+ const projectName = projectNameArg || args.projectName;
16967
+ const timeout = args?.timeout ? args?.timeout === true ? 6e4 : parseInt(args?.timeout, 10) : void 0;
16968
+ if (args.default) {
16969
+ await create({
16970
+ components: ["agents", "tools", "workflows", "scorers"],
16971
+ llmProvider: "openai",
16972
+ addExample: true,
16973
+ createVersionTag,
16974
+ timeout,
16975
+ projectName,
16976
+ mcpServer: args.mcp,
16977
+ directory: "src/",
16978
+ template: args.template,
16979
+ analytics,
16980
+ observability: args.observe
16981
+ });
16982
+ return;
16983
+ }
16984
+ await create({
16985
+ components: args.components ? args.components.split(",") : [],
16986
+ llmProvider: args.llm,
16987
+ addExample: args.example,
16988
+ llmApiKey: args.llmApiKey,
16989
+ createVersionTag,
16990
+ timeout,
16991
+ projectName,
16992
+ directory: args.dir,
16993
+ mcpServer: args.mcp,
16994
+ template: args.template,
16995
+ analytics,
16996
+ observability: args.observe
16997
+ });
16998
+ }
16999
+ })
17000
+ );
17001
+ try {
17002
+ await program.parseAsync(process.argv);
17003
+ } catch (err) {
17004
+ console.error(`Error: ${err instanceof Error ? err.message : String(err)}`);
17005
+ process.exitCode = 1;
17006
+ } finally {
17007
+ await analytics.shutdown(1e3);
17008
+ }
16956
17009
 
16957
17010
  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
17011
  //# sourceMappingURL=index.js.map