Skip to content

Commit 21bd5f4

Browse files
authored
feat: add insights data collection (#1148)
1 parent d0645a9 commit 21bd5f4

File tree

8 files changed

+577
-524
lines changed

8 files changed

+577
-524
lines changed

apps/website/q-insights.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"manual":{"s2g3ySl4oC0":"bundle_kka83r","8k0QF0kHOh4":"bundle_kka83r","qZdJbomELRE":"bundle_kka83r","GDdQTzyqtL4":"bundle_kka83r","Cj001qTgb0Q":"bundle_kka83r","Ls6XITa7SAc":"bundle_kka83r","vx1zEYLlXuU":"bundle_kka83r","tYnx64EilWs":"bundle_kka83r","edpUY02B90s":"bundle_kka83r","uhY2tomah6c":"bundle_kka83r","eMvF2HKX9WM":"bundle_kka83r","4DmzQtoIVPA":"bundle_vanl6a","UHm20YTnam8":"bundle_vanl6a","yV34xs7eOGc":"bundle_vanl6a","mYe5pDrsVJg":"bundle_vanl6a","2EREqIr6Kd0":"bundle_vanl6a","wkdINL10t1M":"bundle_vanl6a","aKkAwjSyqBQ":"bundle_vanl6a","Ygej0BjMiic":"bundle_456zph"},"prefetch":[{"route":"docs/styled/accordion/","symbols":["2EREqIr6Kd0","aKkAwjSyqBQ","yV34xs7eOGc","8k0QF0kHOh4","Cj001qTgb0Q","GDdQTzyqtL4","Ls6XITa7SAc","Ygej0BjMiic","eMvF2HKX9WM","edpUY02B90s","mYe5pDrsVJg","qZdJbomELRE","s2g3ySl4oC0","tYnx64EilWs","uhY2tomah6c","vx1zEYLlXuU","wkdINL10t1M","4DmzQtoIVPA","UHm20YTnam8"]}],"type":"smart"}

apps/website/src/entry.cloudflare-pages.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@ import {
1212
type PlatformCloudflarePages,
1313
} from '@builder.io/qwik-city/middleware/cloudflare-pages';
1414
import qwikCityPlan from '@qwik-city-plan';
15-
import { manifest } from '@qwik-client-manifest';
1615
import render from './entry.ssr';
1716

1817
declare global {
19-
interface QwikCityPlatform extends PlatformCloudflarePages {}
18+
type QwikCityPlatform = PlatformCloudflarePages;
2019
}
2120

22-
const fetch = createQwikCity({ render, qwikCityPlan, manifest });
21+
const fetch = createQwikCity({ render, qwikCityPlan });
2322

2423
export { fetch };

apps/website/src/entry.preview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
*
1212
*/
1313
import { createQwikCity } from '@builder.io/qwik-city/middleware/node';
14-
import render from './entry.ssr';
1514
import qwikCityPlan from '@qwik-city-plan';
15+
import render from './entry.ssr';
1616

1717
/**
1818
* The default export is the QwikCity adaptor used by Vite preview.

apps/website/src/entry.ssr.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ import Root from './root';
1616

1717
export default function (opts: RenderToStreamOptions) {
1818
return renderToStream(<Root />, {
19-
preloader: {
20-
ssrPreloads: 20,
21-
maxIdlePreloads: 25,
22-
},
2319
manifest,
2420
...opts,
2521
// Use container attributes to set attributes on the html tag.

apps/website/src/root.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { component$, useContextProvider, useStore, useStyles$ } from '@builder.io/qwik';
22
import { QwikCityProvider, RouterOutlet } from '@builder.io/qwik-city';
3+
import { Insights } from '@builder.io/qwik-labs';
34

45
import { APP_STATE_CONTEXT_ID } from './_state/app-state-context-id';
56
import { AppState } from './_state/app-state.type';
@@ -43,6 +44,8 @@ export default component$(() => {
4344
<meta charset="utf-8" />
4445
<link rel="manifest" href="/manifest.json" />
4546
<RouterHead />
47+
<script dangerouslySetInnerHTML={`(${collectSymbols})()`} />
48+
<Insights publicApiKey={'1uelfebvo7l'} />
4649
</head>
4750
<body lang="en">
4851
<ThemeProvider
@@ -72,3 +75,10 @@ export default component$(() => {
7275
</QwikCityProvider>
7376
);
7477
});
78+
79+
export function collectSymbols() {
80+
(window as any).symbols = [];
81+
document.addEventListener('qsymbol', (e) =>
82+
(window as any).symbols.push((e as any).detail.symbol),
83+
);
84+
}

apps/website/vite.config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { recmaProvideComponents } from './recma-provide-components';
66
import autoAPI from './auto-api';
77
import { ShikiTransformer } from 'shiki';
88
import tailwindcss from '@tailwindcss/vite';
9+
import { qwikInsights } from '@builder.io/qwik-labs/vite';
10+
import basicSsl from '@vitejs/plugin-basic-ssl';
911

1012
export default defineConfig(async () => {
1113
const { default: shikiRehype } = await import('@shikijs/rehype');
@@ -36,7 +38,7 @@ export default defineConfig(async () => {
3638
}),
3739
qwikVite({
3840
lint: false,
39-
debug: false,
41+
debug: true,
4042
tsconfigFileNames: ['tsconfig.app.json'],
4143
client: {
4244
outDir: '../../dist/apps/website/client',
@@ -49,6 +51,8 @@ export default defineConfig(async () => {
4951
// Uncomment for debugging preview with http2 via https
5052
// basicSsl(),
5153
tailwindcss(),
54+
// qwikInsights({ publicApiKey: '1uelfebvo7l' }),
55+
basicSsl(),
5256
],
5357

5458
server: {

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@
4949
"packageManager": "[email protected]",
5050
"devDependencies": {
5151
"@axe-core/playwright": "^4.10.2",
52-
"@builder.io/qwik": "1.16.1",
53-
"@builder.io/qwik-city": "1.16.1",
52+
"@builder.io/qwik": "https://pkg.pr.new/@builder.io/qwik@dc830b4",
53+
"@builder.io/qwik-city": "https://pkg.pr.new/@builder.io/qwik-city@dc830b4",
54+
"@builder.io/qwik-labs": "github:QwikDev/qwik-labs-build#main",
5455
"@changesets/cli": "^2.29.7",
5556
"@changesets/get-github-info": "^0.6.0",
5657
"@changesets/types": "^6.1.0",
@@ -117,6 +118,7 @@
117118
"prettier-plugin-tailwindcss": "^0.6.14",
118119
"pretty-quick": "^4.2.2",
119120
"qwik-nx": "^3.2.1",
121+
"rollup": "4.52.3",
120122
"sass": "^1.93.2",
121123
"shiki": "^3.13.0",
122124
"simple-git-hooks": "2.11.1",

0 commit comments

Comments
 (0)