Skip to content

Commit

Permalink
Make token required and only use in example
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiaslins committed Sep 6, 2023
1 parent bf95d8b commit f3f32e3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions apps/nextjs/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
}): React.ReactNode {
return (
<html lang="en">
<SpeedInsights />
<SpeedInsights token="wAkFEOQVq9CTI5O4445EXoD5w1Y" />
<body>{children}</body>
</html>
);
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default function MyApp({ Component, pageProps }: AppProps) {
return (
<>
<Component {...pageProps} />
<SpeedInsights sampleRate={0.5} />
<SpeedInsights token="wAkFEOQVq9CTI5O4445EXoD5w1Y" sampleRate={0.5} />
</>
);
}
3 changes: 1 addition & 2 deletions packages/web/src/generic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ export function sendVitals(metrics: CollectedMetric[], dsn: string): void {
speed,
id: metric.id,
event_name: metric.name,
...(metric.dynamicPath && { dynamicPath: metric.dynamicPath }),
value,
href: window.location.href.replace('http://', 'https://'), // TODO: remove this
//...metric,
...(metric.dynamicPath && { dynamicPath: metric.dynamicPath }),
};

sendBeacon(vital);
Expand Down
4 changes: 2 additions & 2 deletions packages/web/src/nextjs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { CollectedMetric } from '../types';
import { useDynamicPath } from './utils';

interface SpeedInsightsProps {
token?: string;
token: string;
sampleRate?: number; // Only send a percentage of events to the server to reduce costs
}

Expand All @@ -22,7 +22,7 @@ export function SpeedInsights({ token, sampleRate }: SpeedInsightsProps): null {

// eslint-disable-next-line no-console -- ok for now
console.log('flushing', body);
sendVitals(body, token ?? 'wAkFEOQVq9CTI5O4445EXoD5w1Y');
sendVitals(body, token);

vitals.current = [];
}
Expand Down

0 comments on commit f3f32e3

Please sign in to comment.