Skip to content

Commit 2c139e3

Browse files
committed
sdk cleanup
1 parent 660be81 commit 2c139e3

File tree

9 files changed

+29
-26
lines changed

9 files changed

+29
-26
lines changed

apps/dashboard/app/(main)/websites/[id]/_components/utils/code-generators.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export function generateNpmCode(
7676
const propsString =
7777
meaningfulProps.length > 0 ? `\n${meaningfulProps.join('\n')}\n ` : '';
7878

79-
return `import { Databuddy } from '@databuddy/sdk';
79+
return `import { Databuddy } from '@databuddy/sdk/react';
8080
8181
function AppLayout({ children }) {
8282
return (

apps/docs/content/blogs/we-are-gdpr-compliant.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ Getting started with GDPR-compliant analytics takes less than 2 minutes:
340340

341341
<Tab value="React/Next.js">
342342
```javascript title="React/Next.js Component"
343-
import { Databuddy } from '@databuddy/sdk';
343+
import { Databuddy } from '@databuddy/sdk/react';
344344

345345
// ✅ Privacy-first analytics component
346346
function MyApp() {

apps/docs/content/docs/Integrations/nextjs.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ yarn add @databuddy/sdk
2525

2626
```tsx
2727
// app/layout.tsx
28-
import { Databuddy } from '@databuddy/sdk';
28+
import { Databuddy } from '@databuddy/sdk/react';
2929

3030
export default function RootLayout({
3131
children,
@@ -81,7 +81,7 @@ Then add to your root layout:
8181

8282
```tsx
8383
// app/layout.tsx
84-
import { Databuddy } from '@databuddy/sdk';
84+
import { Databuddy } from '@databuddy/sdk/react';
8585
import { Analytics } from './analytics';
8686

8787
export default function RootLayout({
@@ -111,7 +111,7 @@ export default function RootLayout({
111111
```tsx
112112
// pages/_app.tsx
113113
import type { AppProps } from 'next/app';
114-
import { Databuddy } from '@databuddy/sdk';
114+
import { Databuddy } from '@databuddy/sdk/react';
115115
import { useRouter } from 'next/router';
116116
import { useEffect } from 'react';
117117
import { track } from '@databuddy/sdk';
@@ -279,7 +279,7 @@ You can configure Databuddy with various options:
279279

280280
```tsx
281281
// app/layout.tsx
282-
import { Databuddy } from '@databuddy/sdk';
282+
import { Databuddy } from '@databuddy/sdk/react';
283283

284284
export default function RootLayout({
285285
children,
@@ -326,7 +326,7 @@ Only load in production:
326326

327327
```tsx
328328
// app/layout.tsx
329-
import { Databuddy } from '@databuddy/sdk';
329+
import { Databuddy } from '@databuddy/sdk/react';
330330

331331
export default function RootLayout({
332332
children,
@@ -361,7 +361,7 @@ Replace Vercel Analytics with Databuddy for better privacy:
361361
import { Analytics } from '@vercel/analytics/react';
362362

363363
// After (with Databuddy)
364-
import { Databuddy } from '@databuddy/sdk';
364+
import { Databuddy } from '@databuddy/sdk/react';
365365
```
366366

367367
### Environment Variables on Vercel

apps/docs/content/docs/Integrations/react.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ Add the `<Databuddy />` component to inject the tracking script:
2727

2828
```tsx
2929
// App.tsx
30-
import { Databuddy } from '@databuddy/sdk';
30+
import { Databuddy } from '@databuddy/sdk/react';
3131

3232
function App() {
3333
return (
3434
<>
3535
<Databuddy
36-
clientId="YOUR_SITE_ID"
36+
clientId="YOUR_SITE_ID"
3737
trackScreenViews={true}
3838
trackAttributes={true}
3939
/>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Add the `<Databuddy />` component to your root layout:
7979
<CodeBlock
8080
language="tsx"
8181
filename="app/layout.tsx"
82-
code={`import { Databuddy } from "@databuddy/sdk";
82+
code={`import { Databuddy } from "@databuddy/sdk/react";
8383
8484
export default function RootLayout({
8585
children,

apps/docs/content/docs/security.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Databuddy is **compliant by default** - no consent banners or cookie notices req
6464

6565
<CodeBlock
6666
language="tsx"
67-
code={`import { Databuddy } from "@databuddy/sdk";
67+
code={`import { Databuddy } from "@databuddy/sdk/react";
6868
6969
function App() {
7070
return (

packages/sdk/build.config.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ export default defineBuildConfig({
1818
},
1919
hooks: {
2020
'build:done': async () => {
21-
const file = await readFile('./dist/react/index.mjs', 'utf-8');
22-
await writeFile('./dist/react/index.mjs', `'use client';\n\n${file}`);
21+
try {
22+
const file = await readFile('./dist/react/index.mjs', 'utf-8');
23+
await writeFile('./dist/react/index.mjs', `'use client';\n\n${file}`);
24+
} catch (error) {
25+
console.error('Failed to add "use client" directive:', error);
26+
}
2327
},
2428
},
2529
});

packages/sdk/src/core/index.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,3 @@ export * from './flags';
33
export * from './script';
44
export * from './tracker';
55
export * from './types';
6-
7-
import { Databuddy as DatabuddyReact } from '@/react/Databuddy';
8-
9-
/**
10-
* @deprecated Use Databuddy from `@databuddy/sdk/react` instead
11-
*/
12-
export const Databuddy = DatabuddyReact;

packages/sdk/src/core/tracker.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ export const track: TrackFunction = async <T extends EventName>(
4646
}
4747

4848
try {
49-
await tracker(eventName, properties as any);
50-
} catch (_error) {}
49+
await tracker(eventName, properties);
50+
} catch (error) {
51+
console.error('Databuddy tracking error:', error);
52+
}
5153
};
5254
/**
5355
* Clear the current session
@@ -65,7 +67,9 @@ export function clear(): void {
6567

6668
try {
6769
tracker();
68-
} catch (_error) {}
70+
} catch (error) {
71+
console.error('Databuddy clear error:', error);
72+
}
6973
}
7074

7175
/**
@@ -84,7 +88,9 @@ export function flush(): void {
8488

8589
try {
8690
tracker();
87-
} catch (_error) {}
91+
} catch (error) {
92+
console.error('Databuddy flush error:', error);
93+
}
8894
}
8995

9096
/**
@@ -98,7 +104,7 @@ export function trackError(
98104
colno?: number;
99105
stack?: string;
100106
error_type?: string;
101-
[key: string]: any;
107+
[key: string]: string | number | boolean | null | undefined;
102108
}
103109
): Promise<void> {
104110
return track('error', { message, ...properties });

0 commit comments

Comments
 (0)