tinacms 3.5.0 → 3.5.1

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
@@ -63,11 +63,11 @@ import { DayPicker } from "react-day-picker";
63
63
  import * as SelectPrimitive from "@radix-ui/react-select";
64
64
  import { formatDistanceToNow } from "date-fns";
65
65
  import { useReactTable, getCoreRowModel, getSortedRowModel, flexRender } from "@tanstack/react-table";
66
+ import posthog from "posthog-js";
66
67
  import { TinaSchema, addNamespaceToSchema, parseURL, resolveForm, normalizePath, canonicalPath, validateSchema } from "@tinacms/schema-tools";
67
68
  import { NAMER, resolveField } from "@tinacms/schema-tools";
68
69
  import gql from "graphql-tag";
69
70
  import { useLocation, NavLink, useNavigate, useParams, Link as Link$1, HashRouter, Routes, Route } from "react-router-dom";
70
- import posthog from "posthog-js";
71
71
  import { serializeMDX } from "@tinacms/mdx";
72
72
  const ModalProvider = ({ children }) => {
73
73
  const [modalRootContainerRef, setModalRootContainerRef] = useState(
@@ -43934,6 +43934,91 @@ const TableCaption = React.forwardRef(({ className, ...props }, ref) => /* @__PU
43934
43934
  }
43935
43935
  ));
43936
43936
  TableCaption.displayName = "TableCaption";
43937
+ let posthogClient = null;
43938
+ let isInitialized = false;
43939
+ let initializationPromise = null;
43940
+ const POSTHOG_CONFIG_ENDPOINT = "https://identity-v2.tinajs.io/v2/posthog-token";
43941
+ async function fetchPostHogConfig() {
43942
+ try {
43943
+ const response = await fetch(POSTHOG_CONFIG_ENDPOINT, {
43944
+ method: "GET",
43945
+ headers: {
43946
+ "Content-Type": "application/json"
43947
+ }
43948
+ });
43949
+ if (!response.ok) {
43950
+ console.warn(`Failed to fetch PostHog config: ${response.statusText}`);
43951
+ return {};
43952
+ }
43953
+ return await response.json();
43954
+ } catch (error2) {
43955
+ console.warn(
43956
+ "Failed to fetch PostHog config:",
43957
+ error2 instanceof Error ? error2.message : "Unknown error"
43958
+ );
43959
+ return {};
43960
+ }
43961
+ }
43962
+ async function initializePostHog(mode = "anonymous") {
43963
+ if (isInitialized) {
43964
+ return posthogClient;
43965
+ }
43966
+ if (initializationPromise) {
43967
+ return initializationPromise;
43968
+ }
43969
+ if (mode === "disabled") {
43970
+ isInitialized = true;
43971
+ return null;
43972
+ }
43973
+ if (process.env.TINA_DEV === "true") {
43974
+ isInitialized = true;
43975
+ return null;
43976
+ }
43977
+ initializationPromise = (async () => {
43978
+ const config = await fetchPostHogConfig();
43979
+ if (!config.api_key) {
43980
+ console.warn(
43981
+ "PostHog API key not found. PostHog tracking will be disabled."
43982
+ );
43983
+ isInitialized = true;
43984
+ return null;
43985
+ }
43986
+ posthog.init(config.api_key, {
43987
+ api_host: config.host || "https://us.i.posthog.com",
43988
+ persistence: "localStorage",
43989
+ autocapture: false,
43990
+ capture_pageview: false,
43991
+ disable_session_recording: true,
43992
+ disable_compression: true
43993
+ });
43994
+ posthogClient = posthog;
43995
+ isInitialized = true;
43996
+ return posthogClient;
43997
+ })();
43998
+ return initializationPromise;
43999
+ }
44000
+ function captureEvent(event, properties2) {
44001
+ if (!posthogClient) {
44002
+ return;
44003
+ }
44004
+ try {
44005
+ posthogClient.capture(event, {
44006
+ ...properties2,
44007
+ system: "tinacms/tinacms"
44008
+ });
44009
+ } catch (error2) {
44010
+ console.error("Error capturing PostHog event:", error2);
44011
+ }
44012
+ }
44013
+ const BranchSwitchedEvent = "branch-switched";
44014
+ const BranchSwitcherOpenedEvent = "branch-switcher-opened";
44015
+ const BranchSwitcherSearchEvent = "branch-switcher-search";
44016
+ const BranchSwitcherDropDownEvent = "branch-switcher-dropdown";
44017
+ const BranchSwitcherPRClickedEvent = "branch-switcher-pr-clicked";
44018
+ const TinaCMSStartedEvent = "tina-cms-started";
44019
+ const CollectionListPageItemClickedEvent = "collection-list-page-item-clicked";
44020
+ const CollectionListPageSortEvent = "collection-list-page-sort";
44021
+ const CollectionListPageSearchEvent = "collection-list-page-search";
43937
44022
  const IndexStatus$1 = ({ indexingStatus }) => {
43938
44023
  const styles = {
43939
44024
  complete: {
@@ -43975,6 +44060,7 @@ function BranchSelectorTable({
43975
44060
  var _a2, _b, _c, _d, _e;
43976
44061
  const [filter2, setFilter] = React.useState("content");
43977
44062
  const [search, setSearch] = React.useState("");
44063
+ const searchEventFired = React.useRef(false);
43978
44064
  const [sorting, setSorting] = React.useState([]);
43979
44065
  const [selectedBranch, setSelectedBranch] = React.useState(
43980
44066
  null
@@ -44091,7 +44177,13 @@ function BranchSelectorTable({
44091
44177
  {
44092
44178
  placeholder: "Branch name or PR #",
44093
44179
  value: search,
44094
- onChange: (e3) => setSearch(e3.target.value)
44180
+ onChange: (e3) => {
44181
+ if (e3.target.value && !searchEventFired.current) {
44182
+ searchEventFired.current = true;
44183
+ captureEvent(BranchSwitcherSearchEvent, {});
44184
+ }
44185
+ setSearch(e3.target.value);
44186
+ }
44095
44187
  }
44096
44188
  ), search === "" ? /* @__PURE__ */ React.createElement(BiSearch, { className: "absolute right-3 top-1/2 -translate-y-1/2 w-5 h-auto text-blue-500 opacity-70 group-hover:opacity-100 transition-all ease-out duration-150" }) : /* @__PURE__ */ React.createElement(
44097
44189
  "button",
@@ -44117,7 +44209,12 @@ function BranchSelectorTable({
44117
44209
  id: "branch-type",
44118
44210
  name: "branch-type",
44119
44211
  value: filter2,
44120
- onChange: (e3) => setFilter(e3.target.value)
44212
+ onChange: (e3) => {
44213
+ setFilter(e3.target.value);
44214
+ captureEvent(BranchSwitcherDropDownEvent, {
44215
+ option: e3.target.value
44216
+ });
44217
+ }
44121
44218
  },
44122
44219
  options: [
44123
44220
  {
@@ -44216,6 +44313,7 @@ const PullRequestCell = ({
44216
44313
  const [creatingPR, setCreatingPR] = React.useState(false);
44217
44314
  const handleCreatePullRequest = async (e3) => {
44218
44315
  e3.stopPropagation();
44316
+ captureEvent(BranchSwitcherPRClickedEvent, { type: "Create PR" });
44219
44317
  if (creatingPR)
44220
44318
  return;
44221
44319
  setCreatingPR(true);
@@ -44254,6 +44352,9 @@ const PullRequestCell = ({
44254
44352
  variant: "white",
44255
44353
  size: "custom",
44256
44354
  onClick: () => {
44355
+ captureEvent(BranchSwitcherPRClickedEvent, {
44356
+ type: "Open Git Pull Request"
44357
+ });
44257
44358
  window.open(branch.githubPullRequestUrl, "_blank");
44258
44359
  },
44259
44360
  className: "cursor-pointer h-9 px-2 flex items-center gap-1",
@@ -46849,7 +46950,7 @@ const NavProvider = ({
46849
46950
  const name = "tinacms";
46850
46951
  const type = "module";
46851
46952
  const typings = "dist/index.d.ts";
46852
- const version$1 = "3.5.0";
46953
+ const version$1 = "3.5.1";
46853
46954
  const main = "dist/index.js";
46854
46955
  const module = "./dist/index.js";
46855
46956
  const exports = {
@@ -49344,7 +49445,10 @@ const BranchButton = ({ className = "" }) => {
49344
49445
  "pointer-events-auto px-3 py-3 flex shrink gap-1 items-center justify-between max-w-sm",
49345
49446
  className
49346
49447
  ),
49347
- onClick: () => setOpen(true),
49448
+ onClick: () => {
49449
+ setOpen(true);
49450
+ captureEvent(BranchSwitcherOpenedEvent, {});
49451
+ },
49348
49452
  title: currentBranch
49349
49453
  },
49350
49454
  isProtected ? /* @__PURE__ */ React.createElement(BiLockAlt, { className: "flex-shrink-0 h-6 w-auto opacity-70" }) : /* @__PURE__ */ React.createElement(BiGitBranch, { className: "flex-shrink-0 h-6 w-auto opacity-70 text-zinc-400" }),
@@ -121032,6 +121136,15 @@ const TinaCloudProvider = (props) => {
121032
121136
  } else {
121033
121137
  cms.api.tina.setBranch(currentBranch);
121034
121138
  }
121139
+ const previousBranchRef = React__default.useRef(currentBranch);
121140
+ useEffect(() => {
121141
+ if (previousBranchRef.current !== currentBranch) {
121142
+ captureEvent(BranchSwitchedEvent, {
121143
+ branchSwitchedTo: currentBranch
121144
+ });
121145
+ previousBranchRef.current = currentBranch;
121146
+ }
121147
+ }, [currentBranch]);
121035
121148
  useEffect(() => {
121036
121149
  var _a3, _b2, _c2, _d, _e, _f, _g, _h;
121037
121150
  let searchClient;
@@ -122342,6 +122455,13 @@ const CollectionListPage = () => {
122342
122455
  name: "sort",
122343
122456
  value: sortKey,
122344
122457
  onChange: (e3) => {
122458
+ captureEvent(
122459
+ CollectionListPageSortEvent,
122460
+ {
122461
+ sortKey: e3.target.value,
122462
+ collectionName
122463
+ }
122464
+ );
122345
122465
  const val = JSON.parse(
122346
122466
  e3.target.value
122347
122467
  );
@@ -122365,7 +122485,9 @@ const CollectionListPage = () => {
122365
122485
  search,
122366
122486
  setSearch,
122367
122487
  searchInput,
122368
- setSearchInput
122488
+ setSearchInput: (searchInput2) => {
122489
+ setSearchInput(searchInput2);
122490
+ }
122369
122491
  }
122370
122492
  ) : /* @__PURE__ */ React__default.createElement("div", { className: "flex flex-col gap-2 items-start w-full md:w-auto" }, /* @__PURE__ */ React__default.createElement("div", { className: "block font-sans text-xs font-semibold opacity-0" }, " "), /* @__PURE__ */ React__default.createElement(Callout, { calloutStyle: "info" }, " ", "You have not configured search.", " ", /* @__PURE__ */ React__default.createElement(
122371
122493
  "a",
@@ -122496,6 +122618,14 @@ const CollectionListPage = () => {
122496
122618
  {
122497
122619
  className: "text-blue-600 flex items-center gap-3 cursor-pointer truncate",
122498
122620
  onClick: () => {
122621
+ captureEvent(
122622
+ CollectionListPageItemClickedEvent,
122623
+ {
122624
+ itemType: "folder",
122625
+ itemName: document2.node.name,
122626
+ collectionName
122627
+ }
122628
+ );
122499
122629
  navigate(
122500
122630
  `/${[
122501
122631
  "collections",
@@ -122542,6 +122672,14 @@ const CollectionListPage = () => {
122542
122672
  {
122543
122673
  className: "text-blue-600 flex items-center gap-3 cursor-pointer truncate",
122544
122674
  onClick: () => {
122675
+ captureEvent(
122676
+ CollectionListPageItemClickedEvent,
122677
+ {
122678
+ itemType: "document",
122679
+ itemName: document2.node._sys.basename,
122680
+ collectionName
122681
+ }
122682
+ );
122545
122683
  handleNavigate(
122546
122684
  navigate,
122547
122685
  cms,
@@ -122710,6 +122848,9 @@ const SearchInput = ({
122710
122848
  e3.preventDefault();
122711
122849
  if (searchInput.trim()) {
122712
122850
  setSearch(searchInput);
122851
+ captureEvent(CollectionListPageSearchEvent, {
122852
+ searchQuery: searchInput
122853
+ });
122713
122854
  setSearchLoaded(false);
122714
122855
  }
122715
122856
  };
@@ -123690,70 +123831,6 @@ const ScreenPage = () => {
123690
123831
  } })));
123691
123832
  });
123692
123833
  };
123693
- const TinaCMSStartedEvent = "tina-cms-started";
123694
- let posthogClient = null;
123695
- let isInitialized = false;
123696
- let initializationPromise = null;
123697
- const POSTHOG_CONFIG_ENDPOINT = "https://identity-v2.tinajs.io/v2/posthog-token";
123698
- async function fetchPostHogConfig() {
123699
- try {
123700
- const response = await fetch(POSTHOG_CONFIG_ENDPOINT, {
123701
- method: "GET",
123702
- headers: {
123703
- "Content-Type": "application/json"
123704
- }
123705
- });
123706
- if (!response.ok) {
123707
- console.warn(`Failed to fetch PostHog config: ${response.statusText}`);
123708
- return {};
123709
- }
123710
- return await response.json();
123711
- } catch (error2) {
123712
- console.warn(
123713
- "Failed to fetch PostHog config:",
123714
- error2 instanceof Error ? error2.message : "Unknown error"
123715
- );
123716
- return {};
123717
- }
123718
- }
123719
- async function initializePostHog(mode = "anonymous") {
123720
- if (isInitialized) {
123721
- return posthogClient;
123722
- }
123723
- if (initializationPromise) {
123724
- return initializationPromise;
123725
- }
123726
- if (mode === "disabled") {
123727
- isInitialized = true;
123728
- return null;
123729
- }
123730
- if (process.env.TINA_DEV === "true") {
123731
- isInitialized = true;
123732
- return null;
123733
- }
123734
- initializationPromise = (async () => {
123735
- const config = await fetchPostHogConfig();
123736
- if (!config.api_key) {
123737
- console.warn(
123738
- "PostHog API key not found. PostHog tracking will be disabled."
123739
- );
123740
- isInitialized = true;
123741
- return null;
123742
- }
123743
- posthog.init(config.api_key, {
123744
- api_host: config.host || "https://us.i.posthog.com",
123745
- persistence: "localStorage",
123746
- autocapture: false,
123747
- capture_pageview: false,
123748
- disable_session_recording: true,
123749
- disable_compression: true
123750
- });
123751
- posthogClient = posthog;
123752
- isInitialized = true;
123753
- return posthogClient;
123754
- })();
123755
- return initializationPromise;
123756
- }
123757
123834
  const getBackendType = (client) => {
123758
123835
  var _a2, _b, _c;
123759
123836
  if (!client)
@@ -1,6 +1,18 @@
1
1
  export declare const BranchSwitchedEvent: string;
2
2
  export type BranchSwitchedPayload = {
3
- branchName: string;
3
+ branchSwitchedTo: string;
4
+ };
5
+ export declare const BranchSwitcherOpenedEvent: string;
6
+ export type BranchSwitcherOpenedPayload = Record<string, never>;
7
+ export declare const BranchSwitcherSearchEvent: string;
8
+ export type BranchSwitcherSearchPayload = {
9
+ option: string;
10
+ };
11
+ export declare const BranchSwitcherDropDownEvent: string;
12
+ export type BranchSwitcherDropDownPayload = Record<string, never>;
13
+ export declare const BranchSwitcherPRClickedEvent: string;
14
+ export type BranchSwitcherPRClickedPayload = {
15
+ type: 'Open Git Pull Request' | 'Create PR';
4
16
  };
5
17
  export declare const SavedContentEvent: string;
6
18
  export type SavedContentPayload = {
@@ -27,7 +39,16 @@ export type TinaCMSStartedPayload = {
27
39
  export declare const CollectionListPageItemClickedEvent: string;
28
40
  export type CollectionListPageItemClickedPayload = {
29
41
  itemName: string;
30
- itemType: 'collection' | 'folder' | 'document';
42
+ itemType: 'folder' | 'document';
43
+ collectionName: string;
44
+ };
45
+ export declare const CollectionListPageSortEvent: string;
46
+ export type CollectionListPageSortPayload = {
47
+ sortKey: string;
48
+ collectionName: string;
31
49
  };
32
50
  export declare const CollectionListPageSearchEvent: string;
51
+ export type CollectionListPageSearchPayload = {
52
+ searchQuery: string;
53
+ };
33
54
  export declare const EventLogPageViewedEvent: string;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "tinacms",
3
3
  "type": "module",
4
4
  "typings": "dist/index.d.ts",
5
- "version": "3.5.0",
5
+ "version": "3.5.1",
6
6
  "main": "dist/index.js",
7
7
  "module": "./dist/index.js",
8
8
  "exports": {
@@ -113,8 +113,8 @@
113
113
  "yup": "^1.6.1",
114
114
  "zod": "^3.24.2",
115
115
  "@tinacms/mdx": "2.0.6",
116
- "@tinacms/schema-tools": "2.6.0",
117
- "@tinacms/search": "1.2.3"
116
+ "@tinacms/search": "1.2.4",
117
+ "@tinacms/schema-tools": "2.6.0"
118
118
  },
119
119
  "devDependencies": {
120
120
  "@graphql-tools/utils": "^10.8.1",