@valbuild/tanstack 0.150.16 → 0.150.18

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,41 @@
1
1
  # @valbuild/tanstack
2
2
 
3
+ ## 0.150.18
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`43f72c8`](https://github.com/valbuild/val/commit/43f72c85c2114fe9a0ce536204858d2d3c05f962)]:
8
+ - @valbuild/shared@0.150.18
9
+ - @valbuild/ui@0.150.18
10
+ - @valbuild/language-server@0.150.18
11
+ - @valbuild/mcp@0.150.18
12
+ - @valbuild/react@0.150.18
13
+ - @valbuild/server@0.150.18
14
+
15
+ ## 0.150.17
16
+
17
+ ### Patch Changes
18
+
19
+ - [#992](https://github.com/valbuild/val/pull/992) [`ea3bf9b`](https://github.com/valbuild/val/commit/ea3bf9bbacd22bbb5485fd798d6b3a2d5916be81) Thanks [@freekh](https://github.com/freekh)! - Content analytics now counts on self-hosted sites (Custom hosting), not only on sites Val hosts.
20
+
21
+ A self-hosted app's own Val server now hands each analytics beacon on to Val's ingest, which counts it. To turn it on:
22
+
23
+ - Run the app with Val's content service: `VAL_API_KEY`, `VAL_SECRET` and `VAL_PROJECT` set. Most deployed apps already do.
24
+ - Set `VAL_ANALYTICS=true`. In TanStack Start, read it in your layout's loader (`{ enabled: process.env.VAL_ANALYTICS === "true" }`) and pass the result to `<ValProvider analytics>`. A self-hosted site has no platform to pass it for you.
25
+ - Switch analytics on for the project in Val's admin. While it is off there, the script on your pages is told so and stops sending.
26
+
27
+ The server forwards only same-origin beacons from a browser. It passes on the visitor's User-Agent and, where your host provides one (Vercel, Cloudflare or CloudFront), their country. It never passes on their IP address. If the api key is not accepted, the server logs one warning naming `VAL_API_KEY` and `VAL_PROJECT`. Local development (fs mode) works as before and counts nothing.
28
+
29
+ `VAL_ANALYTICS_INGEST_URL` overrides where beacons are sent. You will normally not need it.
30
+
31
+ - Updated dependencies [[`ea3bf9b`](https://github.com/valbuild/val/commit/ea3bf9bbacd22bbb5485fd798d6b3a2d5916be81)]:
32
+ - @valbuild/server@0.150.17
33
+ - @valbuild/shared@0.150.17
34
+ - @valbuild/language-server@0.150.17
35
+ - @valbuild/mcp@0.150.17
36
+ - @valbuild/react@0.150.17
37
+ - @valbuild/ui@0.150.16
38
+
3
39
  ## 0.150.16
4
40
 
5
41
  ### Patch Changes
package/README.md CHANGED
@@ -400,7 +400,7 @@ does not 404 either.
400
400
 
401
401
  ## Content analytics
402
402
 
403
- Val can count which content your visitors see, on a site Val hosts. It is
403
+ Val can count which content your visitors see. On a site Val hosts it is
404
404
  **off by default**, and a setting of the hosted project rather than of the
405
405
  code: the owner turns it on in the project's settings, and Val's hosting hands
406
406
  it to the site as the `VAL_ANALYTICS` variable, along with the id of the
@@ -455,11 +455,33 @@ the content version, so a page can be compared before and after a publish. No
455
455
  cookies, no storage and no visitor IDs, and nothing is sent in draft mode, in
456
456
  the Studio or from an automated browser.
457
457
 
458
- A site Val does not host has nowhere to send counts yet, and nothing hands it
459
- the setting, so it stays off. To see the mode working in local development,
460
- pass `analytics` yourself -- `examples/tanstack/src/val/server.ts` reads
461
- `VAL_ANALYTICS` from `process.env`, which TanStack Start fills from
462
- `.env.development`.
458
+ To see the mode working in local development, set `VAL_ANALYTICS=true` in
459
+ `.env.development`: the development server reads it, and nothing else does.
460
+
461
+ ### On your own hosting
462
+
463
+ A site Val does not host is counted too, on the Custom hosting plan. Its own
464
+ Val server answers `/api/val/analytics` and forwards each beacon to Val, with
465
+ the `VAL_API_KEY` and `VAL_PROJECT` it already has for publishing. It needs
466
+ two things:
467
+
468
+ 1. Content analytics switched on in the project's settings on val.build,
469
+ under Analytics. Switched off there, Val answers the forwarded beacons
470
+ with a 410 and the script stops sending them.
471
+ 2. The layout passing `analytics`, since no hosting hands it the setting. Read
472
+ it on the server, so it is never baked into the browser bundle:
473
+
474
+ ```tsx
475
+ // src/routes/_site.tsx
476
+ const getValPage = createServerFn().handler(async () => ({
477
+ draft: await fetchValDraft(),
478
+ analytics: { enabled: process.env.VAL_ANALYTICS === "true" },
479
+ }));
480
+ ```
481
+
482
+ and set `VAL_ANALYTICS=true` where the site is deployed. The visitor's country
483
+ is read from the host's own header when there is one (`x-vercel-ip-country`,
484
+ `cf-ipcountry` or `cloudfront-viewer-country`); the IP address never is.
463
485
 
464
486
  ## Images
465
487
 
@@ -497,7 +519,7 @@ SDK of your choice. See [`@valbuild/mcp`](https://www.npmjs.com/package/@valbuil
497
519
  | `ValImage` wraps `next/image` | `ValImage` is an `<img>` |
498
520
  | `fetchVal` in a Server Component | hooks in components; `createServerFn` for loaders |
499
521
  | client hooks render published SSR | `ValProvider draft` renders the draft during SSR |
500
- | no content analytics yet | `ValProvider analytics` (hosted projects only) |
522
+ | no content analytics yet | `ValProvider analytics` |
501
523
 
502
524
  ## Schema reference
503
525
 
@@ -8,6 +8,10 @@
8
8
  * (`platformAnalytics.tsx`); a layout that wants to decide reads them in its
9
9
  * loader with `fetchValAnalytics()`, from the `val.server.ts` the platform
10
10
  * writes, and passes them.
11
+ *
12
+ * A self-hosted site has no platform handing it anything, so its layout reads
13
+ * `VAL_ANALYTICS` from its own environment and passes the result: see
14
+ * `analytics` on `<ValProvider>`.
11
15
  */
12
16
  export type ValAnalytics = {
13
17
  /** Off unless this says so. */
@@ -6,7 +6,7 @@ var asyncToGenerator = require('./asyncToGenerator-c3823d62.cjs.dev.js');
6
6
  var _typeof = require('./typeof-dd0246a1.cjs.dev.js');
7
7
  var core = require('@valbuild/core');
8
8
  var stega = require('@valbuild/react/stega');
9
- var version = require('./version-e51a4941.cjs.dev.js');
9
+ var version = require('./version-2e1fee7b.cjs.dev.js');
10
10
  var internal = require('@valbuild/react/internal');
11
11
  var ui = require('@valbuild/ui');
12
12
  var reactRouter = require('@tanstack/react-router');
@@ -6,7 +6,7 @@ var asyncToGenerator = require('./asyncToGenerator-8e5c36c8.cjs.prod.js');
6
6
  var _typeof = require('./typeof-8998e126.cjs.prod.js');
7
7
  var core = require('@valbuild/core');
8
8
  var stega = require('@valbuild/react/stega');
9
- var version = require('./version-b91ea183.cjs.prod.js');
9
+ var version = require('./version-e2fe8a55.cjs.prod.js');
10
10
  var internal = require('@valbuild/react/internal');
11
11
  var ui = require('@valbuild/ui');
12
12
  var reactRouter = require('@tanstack/react-router');
@@ -5,7 +5,7 @@ import * as core from '@valbuild/core';
5
5
  export { core as expr };
6
6
  export { GenericSelector, Schema, VAL_EXTENSION, derefPatch, modules } from '@valbuild/core';
7
7
  import { stegaEncode, stegaDecodeStrings, attrs, raw, isReactDevelopmentBuild, watchStegaLeaks, stegaLeakMessage, SET_AUTO_TAG_JSX_ENABLED, autoTagJSX } from '@valbuild/react/stega';
8
- import { r as readValEnableCookie, _ as _toConsumableArray, V as VERSION$1 } from './version-8f811c24.esm.js';
8
+ import { r as readValEnableCookie, _ as _toConsumableArray, V as VERSION$1 } from './version-1efaf325.esm.js';
9
9
  export { ValRichText } from '@valbuild/react/internal';
10
10
  import { VERSION, VAL_APP_PATH, VAL_OVERLAY_ID, VAL_APP_ID } from '@valbuild/ui';
11
11
  import { useRouter, useRouterState } from '@tanstack/react-router';
@@ -93,7 +93,7 @@ var packageJson = {
93
93
  "tanstack-router",
94
94
  "react"
95
95
  ],
96
- version: "0.150.16",
96
+ version: "0.150.18",
97
97
  scripts: {
98
98
  typecheck: "tsc --noEmit",
99
99
  test: "jest"
@@ -95,7 +95,7 @@ var packageJson = {
95
95
  "tanstack-router",
96
96
  "react"
97
97
  ],
98
- version: "0.150.16",
98
+ version: "0.150.18",
99
99
  scripts: {
100
100
  typecheck: "tsc --noEmit",
101
101
  test: "jest"
@@ -95,7 +95,7 @@ var packageJson = {
95
95
  "tanstack-router",
96
96
  "react"
97
97
  ],
98
- version: "0.150.16",
98
+ version: "0.150.18",
99
99
  scripts: {
100
100
  typecheck: "tsc --noEmit",
101
101
  test: "jest"
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "tanstack-router",
15
15
  "react"
16
16
  ],
17
- "version": "0.150.16",
17
+ "version": "0.150.18",
18
18
  "main": "dist/valbuild-tanstack.cjs.js",
19
19
  "module": "dist/valbuild-tanstack.esm.js",
20
20
  "exports": {
@@ -53,12 +53,12 @@
53
53
  },
54
54
  "dependencies": {
55
55
  "@valbuild/core": "0.150.3",
56
- "@valbuild/language-server": "0.150.16",
57
- "@valbuild/mcp": "0.150.16",
58
- "@valbuild/react": "0.150.16",
59
- "@valbuild/server": "0.150.16",
60
- "@valbuild/shared": "0.150.16",
61
- "@valbuild/ui": "0.150.16"
56
+ "@valbuild/language-server": "0.150.18",
57
+ "@valbuild/mcp": "0.150.18",
58
+ "@valbuild/react": "0.150.18",
59
+ "@valbuild/server": "0.150.18",
60
+ "@valbuild/shared": "0.150.18",
61
+ "@valbuild/ui": "0.150.18"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@tanstack/react-router": "^1.170.41",
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = require('../../dist/version-e51a4941.cjs.dev.js');
5
+ var version = require('../../dist/version-2e1fee7b.cjs.dev.js');
6
6
  var asyncToGenerator = require('../../dist/asyncToGenerator-c3823d62.cjs.dev.js');
7
7
  var core = require('@valbuild/core');
8
8
  var _typeof = require('../../dist/typeof-dd0246a1.cjs.dev.js');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = require('../../dist/version-b91ea183.cjs.prod.js');
5
+ var version = require('../../dist/version-e2fe8a55.cjs.prod.js');
6
6
  var asyncToGenerator = require('../../dist/asyncToGenerator-8e5c36c8.cjs.prod.js');
7
7
  var core = require('@valbuild/core');
8
8
  var _typeof = require('../../dist/typeof-8998e126.cjs.prod.js');
@@ -1,4 +1,4 @@
1
- import { V as VERSION, _ as _toConsumableArray, s as setValEnableCookieReader } from '../../dist/version-8f811c24.esm.js';
1
+ import { V as VERSION, _ as _toConsumableArray, s as setValEnableCookieReader } from '../../dist/version-1efaf325.esm.js';
2
2
  import { _ as _asyncToGenerator, a as _regenerator } from '../../dist/asyncToGenerator-500f022f.esm.js';
3
3
  import { Internal } from '@valbuild/core';
4
4
  import { _ as _objectSpread2, a as _slicedToArray, b as _createForOfIteratorHelper, g as _defineProperty, c as _typeof } from '../../dist/typeof-66e2d869.esm.js';