create-tina-app 0.0.0-e1eb9ad-20251211011556 → 0.0.0-e2db315-20251216223244

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/dist/index.js CHANGED
@@ -20,6 +20,16 @@ var TextStyles = {
20
20
  err: chalk.red,
21
21
  bold: chalk.bold
22
22
  };
23
+ var TextStylesBold = {
24
+ tinaOrange: chalk.hex("#EC4816").bold,
25
+ link: (url) => `\x1B]8;;${url}\x07${chalk.cyan.underline(url)}\x1B]8;;\x07`,
26
+ cmd: chalk.bgBlackBright.bold.white,
27
+ info: chalk.blue,
28
+ success: chalk.green,
29
+ warn: chalk.yellow,
30
+ err: chalk.red,
31
+ bold: chalk.bold
32
+ };
23
33
 
24
34
  // src/util/fileUtil.ts
25
35
  async function isWriteable(directory) {
@@ -631,6 +641,77 @@ var THEMES = [
631
641
  ];
632
642
 
633
643
  // src/index.ts
644
+ import { PostHog } from "posthog-node";
645
+
646
+ // src/util/posthog.ts
647
+ var CreateTinaAppStartedEvent = "create-tina-app-started";
648
+ var CreateTinaAppFinishedEvent = "create-tina-app-finished";
649
+ function postHogCapture(client, event, properties) {
650
+ if (process.env.TINA_DEV === "true") return;
651
+ if (!client) {
652
+ console.error(`PostHog client not initialized`);
653
+ return;
654
+ }
655
+ try {
656
+ client.capture({
657
+ distinctId: "create-tina-app",
658
+ event,
659
+ properties: {
660
+ ...properties,
661
+ system: "tinacms/create-tina-app"
662
+ }
663
+ });
664
+ } catch (error) {
665
+ console.error("Error capturing event:", error);
666
+ }
667
+ }
668
+
669
+ // src/util/fetchPosthogConfig.tsx
670
+ async function fetchPostHogConfig(endpointUrl) {
671
+ try {
672
+ const response = await fetch(endpointUrl, {
673
+ method: "GET",
674
+ headers: {
675
+ "Content-Type": "application/json"
676
+ }
677
+ });
678
+ if (!response.ok) {
679
+ throw new Error(`Failed to fetch PostHog config: ${response.statusText}`);
680
+ }
681
+ const config = await response.json();
682
+ return {
683
+ POSTHOG_API_KEY: config.api_key,
684
+ POSTHOG_ENDPOINT: config.host
685
+ };
686
+ } catch (error) {
687
+ console.warn(
688
+ `Failed to fetch PostHog config from endpoint: ${error instanceof Error ? error.message : "Unknown error"}`
689
+ );
690
+ return {};
691
+ }
692
+ }
693
+
694
+ // src/index.ts
695
+ import * as sys from "systeminformation";
696
+ var posthogClient = null;
697
+ async function initializePostHog(configEndpoint) {
698
+ let apiKey;
699
+ let endpoint;
700
+ if (configEndpoint) {
701
+ const config = await fetchPostHogConfig(configEndpoint);
702
+ apiKey = config.POSTHOG_API_KEY;
703
+ endpoint = config.POSTHOG_ENDPOINT;
704
+ }
705
+ if (!apiKey) {
706
+ console.warn(
707
+ "PostHog API key not found. PostHog tracking will be disabled."
708
+ );
709
+ return null;
710
+ }
711
+ return new PostHog(apiKey, {
712
+ host: endpoint
713
+ });
714
+ }
634
715
  function formatTemplateChoice(template) {
635
716
  let description = template.description || "";
636
717
  if (template.features && template.features.length > 0) {
@@ -658,9 +739,31 @@ async function run() {
658
739
  const require2 = createRequire(import.meta.url);
659
740
  const version2 = require2("../package.json").version;
660
741
  console.log(`Create Tina App v${version2}`);
742
+ const opts = extractOptions(process.argv);
743
+ const osInfo2 = await sys.osInfo();
744
+ if (!opts.noTelemetry) {
745
+ console.log(`
746
+ ${TextStylesBold.bold("Telemetry Notice")}`);
747
+ console.log(
748
+ `To help the TinaCMS team improve the developer experience, create-tina-app collects anonymous usage statistics. This data helps us understand which environments and features are most important to support. Usage analytics may include: Operating system and version, package manager name and version (local only), Node.js version (local only), and the selected TinaCMS starter template.
749
+ No personal or project-specific code is ever collected. You can opt out at any time by passing the --noTelemetry flag.
750
+ `
751
+ );
752
+ }
753
+ if (!opts.noTelemetry) {
754
+ posthogClient = await initializePostHog(
755
+ "https://identity-v2.tinajs.io/v2/posthog-token"
756
+ );
757
+ }
661
758
  const spinner = ora();
662
759
  preRunChecks(spinner);
663
- const opts = extractOptions(process.argv);
760
+ if (!opts.noTelemetry && posthogClient) {
761
+ postHogCapture(posthogClient, CreateTinaAppStartedEvent, {
762
+ "node-version": process.version,
763
+ "os-distro": osInfo2.distro,
764
+ "os-release": osInfo2.release
765
+ });
766
+ }
664
767
  const telemetry = new Telemetry({ disabled: opts?.noTelemetry });
665
768
  let template = null;
666
769
  if (opts.template) {
@@ -768,7 +871,6 @@ async function run() {
768
871
  exit(1);
769
872
  }
770
873
  try {
771
- await downloadTemplate(template, rootDir, spinner);
772
874
  if (themeChoice) {
773
875
  await updateThemeSettings(rootDir, themeChoice);
774
876
  }
@@ -841,13 +943,27 @@ async function run() {
841
943
  "https://tina.io/docs/tinacloud/"
842
944
  )}`
843
945
  );
946
+ if (!opts.noTelemetry && posthogClient) {
947
+ postHogCapture(posthogClient, CreateTinaAppFinishedEvent, {
948
+ template: template.value,
949
+ "package-manager": pkgManager,
950
+ "node-version": process.version,
951
+ "app-name": appName,
952
+ "os-distro": osInfo2.distro,
953
+ "os-release": osInfo2.release
954
+ });
955
+ }
844
956
  }
845
957
  run().catch((error) => {
846
958
  if (process.stdout.columns >= 60) {
847
959
  console.log(TextStyles.tinaOrange(`${errorArt}`));
848
960
  }
849
- console.error("Error running create-tina-app: \n", error);
961
+ console.error("Error running create-tina-app:", error);
850
962
  process.exit(1);
963
+ }).then(async () => {
964
+ if (posthogClient) {
965
+ await posthogClient.shutdown();
966
+ }
851
967
  });
852
968
  export {
853
969
  run
@@ -0,0 +1,5 @@
1
+ export interface PostHogConfig {
2
+ POSTHOG_API_KEY?: string;
3
+ POSTHOG_ENDPOINT?: string;
4
+ }
5
+ export default function fetchPostHogConfig(endpointUrl: string): Promise<PostHogConfig>;
@@ -0,0 +1,4 @@
1
+ import { PostHog } from 'posthog-node';
2
+ export declare const CreateTinaAppStartedEvent: string;
3
+ export declare const CreateTinaAppFinishedEvent: string;
4
+ export declare function postHogCapture(client: PostHog, event: string, properties: Record<string, any>): void;
@@ -8,3 +8,13 @@ export declare const TextStyles: {
8
8
  err: import("chalk").ChalkInstance;
9
9
  bold: import("chalk").ChalkInstance;
10
10
  };
11
+ export declare const TextStylesBold: {
12
+ tinaOrange: import("chalk").ChalkInstance;
13
+ link: (url: string) => string;
14
+ cmd: import("chalk").ChalkInstance;
15
+ info: import("chalk").ChalkInstance;
16
+ success: import("chalk").ChalkInstance;
17
+ warn: import("chalk").ChalkInstance;
18
+ err: import("chalk").ChalkInstance;
19
+ bold: import("chalk").ChalkInstance;
20
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-tina-app",
3
- "version": "0.0.0-e1eb9ad-20251211011556",
3
+ "version": "0.0.0-e2db315-20251216223244",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -44,7 +44,9 @@
44
44
  "cross-spawn": "^7.0.6",
45
45
  "fs-extra": "^11.3.0",
46
46
  "ora": "^8.2.0",
47
+ "posthog-node": "^5.17.2",
47
48
  "prompts": "^2.4.2",
49
+ "systeminformation": "^5.27.13",
48
50
  "tar": "7.4.0",
49
51
  "@tinacms/metrics": "2.0.1"
50
52
  },