Skip to content

Commit fe02020

Browse files
committed
fix broken links & logger dep
1 parent 282963d commit fe02020

File tree

4 files changed

+43
-67
lines changed

4 files changed

+43
-67
lines changed

apps/docs/app/api/ambassador/submit/route.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { createLogger } from "@databuddy/shared/logger";
1+
// import { createLogger } from "@databuddy/shared/logger";
22
import { type NextRequest, NextResponse } from "next/server";
33

4-
const logger = createLogger("ambassador-form");
4+
// const logger = createLogger("ambassador-form");
55
const SLACK_WEBHOOK_URL = process.env.SLACK_WEBHOOK_URL || "";
66
const SLACK_TIMEOUT_MS = 10_000;
77

@@ -207,7 +207,7 @@ async function sendToSlack(
207207
ip: string
208208
): Promise<void> {
209209
if (!SLACK_WEBHOOK_URL) {
210-
logger.warn(
210+
console.warn(
211211
{},
212212
"SLACK_WEBHOOK_URL not configured, skipping Slack notification"
213213
);
@@ -235,7 +235,7 @@ async function sendToSlack(
235235
const responseText = await response
236236
.text()
237237
.catch(() => "Unable to read response");
238-
logger.error(
238+
console.error(
239239
{
240240
status: response.status,
241241
statusText: response.statusText,
@@ -247,13 +247,13 @@ async function sendToSlack(
247247
} catch (fetchError) {
248248
clearTimeout(timeoutId);
249249
if (fetchError instanceof Error && fetchError.name === "AbortError") {
250-
logger.error({}, "Slack webhook request timed out after 10 seconds");
250+
console.error({}, "Slack webhook request timed out after 10 seconds");
251251
} else {
252252
throw fetchError;
253253
}
254254
}
255255
} catch (error) {
256-
logger.error(
256+
console.error(
257257
{
258258
error: error instanceof Error ? error.message : String(error),
259259
stack: error instanceof Error ? error.stack : undefined,
@@ -272,7 +272,7 @@ export async function POST(request: NextRequest) {
272272
try {
273273
formData = await request.json();
274274
} catch (jsonError) {
275-
logger.warn(
275+
console.warn(
276276
{
277277
ip: clientIP,
278278
userAgent,
@@ -290,7 +290,7 @@ export async function POST(request: NextRequest) {
290290
const validation = validateFormData(formData);
291291

292292
if (!validation.valid) {
293-
logger.info(
293+
console.info(
294294
{ errors: validation.errors, ip: clientIP },
295295
"Form submission failed validation"
296296
);
@@ -302,7 +302,7 @@ export async function POST(request: NextRequest) {
302302

303303
const ambassadorData = validation.data;
304304

305-
logger.info(
305+
console.info(
306306
{
307307
name: ambassadorData.name,
308308
email: ambassadorData.email,
@@ -319,7 +319,7 @@ export async function POST(request: NextRequest) {
319319
message: "Ambassador application submitted successfully",
320320
});
321321
} catch (error) {
322-
logger.error(
322+
console.error(
323323
{
324324
ip: clientIP,
325325
userAgent,

apps/docs/content/docs/dashboard.mdx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ Discover your global audience and optimize for different regions:
296296
derived from the user's IP address at the beginning of a session. This
297297
functionality is an integral part of session tracking. Ensure `trackSessions=
298298
{true}` (which is enabled by default) in your [SDK
299-
configuration](/docs/sdk#-configuration-options) to collect this data.
299+
configuration](/docs/sdk#configuration-options) to collect this data.
300300
</Callout>
301301

302302
## Technology Stack Analysis
@@ -358,9 +358,9 @@ Track and analyze your business-specific events with detailed property breakdown
358358
`db.track('your_event_name', {your_properties})` method. The more relevant and
359359
well-structured custom events you track, the more insightful this section will
360360
become. For detailed guidance on how to implement custom event tracking,
361-
please refer to the [SDK Methods Reference](/docs/sdk#-sdk-methods-reference)
361+
please refer to the [SDK Methods Reference](/docs/sdk#sdk-methods)
362362
and strategies in the [Custom Event
363-
Tracking](/docs/sdk#-custom-event-tracking) section of the SDK documentation.
363+
Tracking](/docs/sdk#custom-event-tracking) section of the SDK documentation.
364364
</Callout>
365365

366366
### Enhanced Event Interface
@@ -557,7 +557,7 @@ Monitor your website's technical health and user experience:
557557
The performance metrics, including Core Web Vitals, are populated when you
558558
enable `trackPerformance={true}` (enabled by default) and `trackWebVitals=
559559
{true}` (disabled by default, but recommended) in your [SDK
560-
configuration](/docs/sdk#-optional-tracking-features). Enabling these options
560+
configuration](/docs/sdk#optional-features). Enabling these options
561561
allows the SDK to collect detailed timing and performance data from the user's
562562
browser.
563563
</Callout>
@@ -641,11 +641,11 @@ Monitor and resolve issues affecting your users:
641641
<Callout type="tip" title="Enabling Error Data Collection">
642642
To populate the error tracking sections of the dashboard, ensure you have
643643
`trackErrors={true}` enabled in your [SDK
644-
configuration](/docs/sdk#-optional-tracking-features). This will automatically
644+
configuration](/docs/sdk#optional-features). This will automatically
645645
capture unhandled JavaScript errors and promise rejections. For more detailed
646646
context on specific handled errors, you can manually send error events using
647647
`db.track('error', {/* custom properties */})` as described in the [SDK
648-
Methods Reference](/docs/sdk#-sdk-methods-reference).
648+
Methods Reference](/docs/sdk#sdk-methods).
649649
</Callout>
650650

651651
### JavaScript Error Analytics
@@ -862,7 +862,7 @@ To populate funnel data, you need to:
862862
1. Define the steps of your funnel within the Databuddy dashboard settings.
863863
2. Ensure each step corresponds to a custom event (or page view) that you are tracking with the SDK. For example, a signup funnel might be defined by a sequence of events like `viewed_signup_page` (a screen view), `started_signup_form` (custom event), and `completed_signup` (custom event).
864864

865-
The sequence of these events for users will then build the funnel visualization. For more details on sending custom events, see the [SDK Methods Reference](/docs/sdk#-sdk-methods-reference) in the SDK documentation.
865+
The sequence of these events for users will then build the funnel visualization. For more details on sending custom events, see the [SDK Methods Reference](/docs/sdk#sdk-methods) in the SDK documentation.
866866

867867
</Callout>
868868

@@ -876,8 +876,8 @@ User journey visualization allows you to see the paths users take through your w
876876

877877
<Callout type="tip" title="Data for User Journeys">
878878
This feature relies on the comprehensive event data tracked by the SDK. The richness of the user journeys depends on:
879-
- Thorough `screen_view` tracking (often automatic via `trackScreenViews={true}` in the [SDK configuration](/docs/sdk#-configuration-options)).
880-
- Detailed custom event tracking (`db.track()`) for significant interactions as described in the [SDK Methods Reference](/docs/sdk#-sdk-methods-reference).
879+
- Thorough `screen_view` tracking (often automatic via `trackScreenViews={true}` in the [SDK configuration](/docs/sdk#configuration-options)).
880+
- Detailed custom event tracking (`db.track()`) for significant interactions as described in the [SDK Methods Reference](/docs/sdk#sdk-methods).
881881

882882
Each event is tied to a user's session, allowing the dashboard to reconstruct their path.
883883

@@ -896,9 +896,9 @@ Richer user profiles are developed when you consistently track custom events tha
896896

897897
Refer to these SDK documentation sections for more:
898898

899-
- [Custom Event Tracking](/docs/sdk#-custom-event-tracking) for strategy.
900-
- [Standard Event Reference](/docs/sdk#-standard-event-reference) for common event types.
901-
- [SDK Methods Reference](/docs/sdk#-sdk-methods-reference) for `db.track()` and `db.setGlobalProperties()`.
899+
- [Custom Event Tracking](/docs/sdk#custom-event-tracking) for strategy.
900+
- [Standard Event Reference](/docs/sdk#standard-events) for common event types.
901+
- [SDK Methods Reference](/docs/sdk#sdk-methods) for `db.track()` and `db.setGlobalProperties()`.
902902
- The `db.setGlobalProperties()` method can be particularly useful for adding persistent attributes to a user's profile.
903903
</Callout>
904904

apps/docs/content/docs/getting-started.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,15 +388,15 @@ function SignupForm() {
388388
<Card title="API Playground" href="/api">
389389
Test endpoints interactively and explore query types with real data
390390
</Card>
391-
<Card title="SDK Configuration Guide" href="/docs/sdk#-configuration-options">
391+
<Card title="SDK Configuration Guide" href="/docs/sdk#configuration-options">
392392
Explore all SDK configuration props and options
393393
</Card>
394394
<Card title="Dashboard Guide" href="/docs/dashboard">
395395
Learn to navigate your analytics dashboard and its features
396396
</Card>
397397
<Card
398398
title="Event Tracking Deep Dive"
399-
href="/docs/sdk#-sdk-methods-reference"
399+
href="/docs/sdk#sdk-methods"
400400
>
401401
Master custom event tracking, SDK methods, and standard event types
402402
</Card>

apps/docs/scripts/validate-links.ts

Lines changed: 19 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,35 @@ import {
77
} from "next-validate-link";
88
import { source } from "../lib/source";
99

10+
type Page = InferPageType<typeof source>;
11+
12+
const getHeadings = (page: Page): string[] =>
13+
page.data.toc?.map((item) => item.url.slice(1)) ?? [];
14+
15+
const getFiles = (): Promise<FileObject[]> =>
16+
Promise.all(
17+
source.getPages().map(async (page) => ({
18+
path: page.file.path,
19+
content: await page.data.getText("raw"),
20+
url: page.url,
21+
data: page.data,
22+
}))
23+
);
24+
1025
async function checkLinks() {
11-
console.log("🔍 Scanning URLs...");
26+
const pages = source.getPages();
1227

1328
const scanned = await scanURLs({
1429
preset: "next",
1530
populate: {
16-
"docs/[[...slug]]": source.getPages().map((page) => ({
17-
value: {
18-
slug: page.slugs,
19-
},
31+
"docs/[[...slug]]": pages.map((page) => ({
32+
value: { slug: page.slugs },
2033
hashes: getHeadings(page),
2134
})),
2235
},
2336
});
2437

25-
console.log(`📄 Found ${scanned.urls.size} URLs`);
26-
console.log("🔗 Validating links in content files...");
27-
28-
const files = await getFiles();
29-
console.log(`📁 Checking ${files.length} files`);
30-
31-
const errors = await validateFiles(files, {
38+
const errors = await validateFiles(await getFiles(), {
3239
scanned,
3340
markdown: {
3441
components: {
@@ -43,39 +50,8 @@ async function checkLinks() {
4350
printErrors(errors, true);
4451

4552
if (errors.length > 0) {
46-
console.log(`\n❌ Found ${errors.length} link error(s)`);
4753
process.exit(1);
4854
}
49-
50-
console.log("\n✅ All links are valid!");
51-
}
52-
53-
function getHeadings({ data }: InferPageType<typeof source>): string[] {
54-
if (!data.toc) {
55-
return [];
56-
}
57-
return data.toc.map((item) => item.url.slice(1));
58-
}
59-
60-
async function getFiles(): Promise<FileObject[]> {
61-
const pages = source.getPages();
62-
const files: FileObject[] = [];
63-
64-
for (const page of pages) {
65-
try {
66-
const content = await page.data.getText("raw");
67-
files.push({
68-
path: page.file.path,
69-
content,
70-
url: page.url,
71-
data: page.data,
72-
});
73-
} catch (error) {
74-
console.warn(`⚠️ Could not read content for ${page.url}:`, error);
75-
}
76-
}
77-
78-
return files;
7955
}
8056

8157
checkLinks().catch(console.error);

0 commit comments

Comments
 (0)