import {
  raiseEvent
} from "./chunk-XP2QYGFD.js";
import {
  countResources,
  serializeCounts
} from "./chunk-4UVFXLPI.js";
import {
  getEventCatalogConfigFile,
  verifyRequiredFieldsAreInCatalogConfigFile
} from "./chunk-5T63CXKU.js";

// src/analytics/log-build.js
var getFeatures = async (configFile) => {
  return {
    llmsTxt: configFile.llmsTxt?.enabled || false,
    rss: configFile.rss?.enabled || false,
    chat: configFile.chat?.enabled || false,
    output: configFile.output || "static"
  };
};
var main = async (projectDir, { isEventCatalogStarterEnabled, isEventCatalogScaleEnabled, isBackstagePluginEnabled }) => {
  if (process.env.NODE_ENV === "CI") return;
  try {
    await verifyRequiredFieldsAreInCatalogConfigFile(projectDir);
    const configFile = await getEventCatalogConfigFile(projectDir);
    const { cId, organizationName, generators = [] } = configFile;
    let generatorNames = generators.length > 0 ? generators.map((generator) => generator[0]) : ["none"];
    if (isEventCatalogStarterEnabled) {
      generatorNames.push("@eventcatalog/eventcatalog-starter");
    }
    if (isEventCatalogScaleEnabled) {
      generatorNames.push("@eventcatalog/eventcatalog-scale");
    }
    if (isBackstagePluginEnabled) {
      generatorNames.push("@eventcatalog/backstage-plugin-eventcatalog");
    }
    const features = await getFeatures(configFile);
    const resourceCounts = await countResources(projectDir);
    await raiseEvent({
      command: "build",
      org: organizationName,
      cId,
      generators: generatorNames.toString(),
      features: Object.keys(features).map((feature) => `${feature}:${features[feature]}`).join(","),
      resources: serializeCounts(resourceCounts)
    });
  } catch (error) {
  }
};
var log_build_default = main;

export {
  log_build_default
};
