create-tina-app 0.0.0-d813ac1-20251210222143 → 0.0.0-db7231c-20251216055550

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 os from "node:os";
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,30 @@ 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
+ if (!opts.noTelemetry) {
744
+ console.log(`
745
+ ${TextStylesBold.bold("Telemetry Notice")}`);
746
+ console.log(
747
+ `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.
748
+ No personal or project-specific code is ever collected. You can opt out at any time by passing the --noTelemetry flag.
749
+ `
750
+ );
751
+ }
752
+ if (!opts.noTelemetry) {
753
+ posthogClient = await initializePostHog(
754
+ "https://identity-v2.tinajs.io/v2/posthog-token"
755
+ );
756
+ }
661
757
  const spinner = ora();
662
758
  preRunChecks(spinner);
663
- const opts = extractOptions(process.argv);
759
+ if (!opts.noTelemetry && posthogClient) {
760
+ postHogCapture(posthogClient, CreateTinaAppStartedEvent, {
761
+ "node-version": process.version,
762
+ "os-version": os.version(),
763
+ "os-platform": os.platform()
764
+ });
765
+ }
664
766
  const telemetry = new Telemetry({ disabled: opts?.noTelemetry });
665
767
  let template = null;
666
768
  if (opts.template) {
@@ -768,7 +870,6 @@ async function run() {
768
870
  exit(1);
769
871
  }
770
872
  try {
771
- await downloadTemplate(template, rootDir, spinner);
772
873
  if (themeChoice) {
773
874
  await updateThemeSettings(rootDir, themeChoice);
774
875
  }
@@ -841,13 +942,27 @@ async function run() {
841
942
  "https://tina.io/docs/tinacloud/"
842
943
  )}`
843
944
  );
945
+ if (!opts.noTelemetry && posthogClient) {
946
+ postHogCapture(posthogClient, CreateTinaAppFinishedEvent, {
947
+ template: template.value,
948
+ "package-manager": pkgManager,
949
+ "node-version": process.version,
950
+ "app-name": appName,
951
+ "os-version": os.version(),
952
+ "os-platform": os.platform()
953
+ });
954
+ }
844
955
  }
845
956
  run().catch((error) => {
846
957
  if (process.stdout.columns >= 60) {
847
958
  console.log(TextStyles.tinaOrange(`${errorArt}`));
848
959
  }
849
- console.error("Error running create-tina-app: \n", error);
960
+ console.error("Error running create-tina-app:", error);
850
961
  process.exit(1);
962
+ }).then(async () => {
963
+ if (posthogClient) {
964
+ await posthogClient.shutdown();
965
+ }
851
966
  });
852
967
  export {
853
968
  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-d813ac1-20251210222143",
3
+ "version": "0.0.0-db7231c-20251216055550",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -44,6 +44,7 @@
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",
48
49
  "tar": "7.4.0",
49
50
  "@tinacms/metrics": "2.0.1"