@databuddy/sdk 2.0.0 → 2.1.0

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/@databuddy/sdk?style=flat-square)](https://www.npmjs.com/package/@databuddy/sdk)
4
4
  [![License](https://img.shields.io/npm/l/@databuddy/sdk?style=flat-square)](./LICENSE)
5
- [![Docs](https://img.shields.io/badge/docs-databuddy.cc-blue?style=flat-square)](https://docs.databuddy.cc)
5
+ [![Docs](https://img.shields.io/badge/docs-databuddy.cc-blue?style=flat-square)](https://www.databuddy.cc/docs)
6
6
 
7
7
  > **The easiest, privacy-first way to add analytics to your web app.**
8
8
 
@@ -16,6 +16,7 @@
16
16
  - 🧩 **Drop-in React/Next.js component: `<Databuddy />`**
17
17
  - 🛡️ **Privacy-first: anonymized by default, sampling, batching, and more**
18
18
  - 🛠️ **Type-safe config and autocompletion**
19
+ - 📋 **Observability: logging, error tracking, and distributed tracing**
19
20
 
20
21
  ---
21
22
 
@@ -120,7 +121,7 @@ A: In your [Databuddy dashboard](https://app.databuddy.cc).
120
121
 
121
122
  ## 📚 Documentation & Support
122
123
 
123
- - [Databuddy Docs](https://docs.databuddy.cc)
124
+ - [Databuddy Docs](https://www.databuddy.cc/docs)
124
125
  - [Dashboard](https://app.databuddy.cc)
125
126
  - [Contact Support](https://www.databuddy.cc/contact)
126
127
 
@@ -1,5 +1,11 @@
1
- import { D as DatabuddyConfig, a as DatabuddyTracker, T as TrackFunction, b as Databuddy$1 } from '../shared/@databuddy/sdk.Sqo9i0iN.mjs';
2
- export { B as BaseEventProperties, e as DataAttributes, d as EventName, E as EventProperties, c as EventTypeMap, P as PropertiesForEvent, S as ScreenViewFunction, f as SetGlobalPropertiesFunction } from '../shared/@databuddy/sdk.Sqo9i0iN.mjs';
1
+ import { D as DatabuddyConfig, a as DatabuddyTracker, T as TrackFunction, b as Databuddy$1 } from '../shared/@databuddy/sdk.ClgMzRh8.mjs';
2
+ export { B as BaseEventProperties, e as DataAttributes, d as EventName, E as EventProperties, c as EventTypeMap, P as PropertiesForEvent, S as ScreenViewFunction, f as SetGlobalPropertiesFunction } from '../shared/@databuddy/sdk.ClgMzRh8.mjs';
3
+
4
+ /**
5
+ * Auto-detect Databuddy client ID from environment variables
6
+ * Supports Next.js, Nuxt, and other frameworks
7
+ */
8
+ declare function detectClientId(providedClientId?: string): string | undefined;
3
9
 
4
10
  declare function isScriptInjected(): boolean;
5
11
  declare function createScript({ scriptUrl, sdkVersion, ...props }: DatabuddyConfig): HTMLScriptElement;
@@ -46,4 +52,4 @@ declare function trackError(message: string, properties?: {
46
52
  */
47
53
  declare const Databuddy: typeof Databuddy$1;
48
54
 
49
- export { Databuddy, DatabuddyConfig, DatabuddyTracker, TrackFunction, clear, createScript, flush, getTracker, isScriptInjected, isTrackerAvailable, track, trackError };
55
+ export { Databuddy, DatabuddyConfig, DatabuddyTracker, TrackFunction, clear, createScript, detectClientId, flush, getTracker, isScriptInjected, isTrackerAvailable, track, trackError };
@@ -1,5 +1,11 @@
1
- import { D as DatabuddyConfig, a as DatabuddyTracker, T as TrackFunction, b as Databuddy$1 } from '../shared/@databuddy/sdk.Sqo9i0iN.js';
2
- export { B as BaseEventProperties, e as DataAttributes, d as EventName, E as EventProperties, c as EventTypeMap, P as PropertiesForEvent, S as ScreenViewFunction, f as SetGlobalPropertiesFunction } from '../shared/@databuddy/sdk.Sqo9i0iN.js';
1
+ import { D as DatabuddyConfig, a as DatabuddyTracker, T as TrackFunction, b as Databuddy$1 } from '../shared/@databuddy/sdk.ClgMzRh8.js';
2
+ export { B as BaseEventProperties, e as DataAttributes, d as EventName, E as EventProperties, c as EventTypeMap, P as PropertiesForEvent, S as ScreenViewFunction, f as SetGlobalPropertiesFunction } from '../shared/@databuddy/sdk.ClgMzRh8.js';
3
+
4
+ /**
5
+ * Auto-detect Databuddy client ID from environment variables
6
+ * Supports Next.js, Nuxt, and other frameworks
7
+ */
8
+ declare function detectClientId(providedClientId?: string): string | undefined;
3
9
 
4
10
  declare function isScriptInjected(): boolean;
5
11
  declare function createScript({ scriptUrl, sdkVersion, ...props }: DatabuddyConfig): HTMLScriptElement;
@@ -46,4 +52,4 @@ declare function trackError(message: string, properties?: {
46
52
  */
47
53
  declare const Databuddy: typeof Databuddy$1;
48
54
 
49
- export { Databuddy, DatabuddyConfig, DatabuddyTracker, TrackFunction, clear, createScript, flush, getTracker, isScriptInjected, isTrackerAvailable, track, trackError };
55
+ export { Databuddy, DatabuddyConfig, DatabuddyTracker, TrackFunction, clear, createScript, detectClientId, flush, getTracker, isScriptInjected, isTrackerAvailable, track, trackError };
@@ -1,5 +1,6 @@
1
+ import { D as Databuddy$1 } from '../shared/@databuddy/sdk.B72MFYNj.mjs';
2
+ export { d as detectClientId } from '../shared/@databuddy/sdk.B72MFYNj.mjs';
1
3
  export { c as createScript, i as isScriptInjected } from '../shared/@databuddy/sdk.CtTNAIIE.mjs';
2
- import { Databuddy as Databuddy$1 } from '../react/index.mjs';
3
4
 
4
5
  function isTrackerAvailable() {
5
6
  return typeof window !== "undefined" && (!!window.databuddy || !!window.db);
@@ -1 +1 @@
1
- export { b as Databuddy } from '../shared/@databuddy/sdk.Sqo9i0iN.mjs';
1
+ export { b as Databuddy } from '../shared/@databuddy/sdk.ClgMzRh8.mjs';
@@ -1 +1 @@
1
- export { b as Databuddy } from '../shared/@databuddy/sdk.Sqo9i0iN.js';
1
+ export { b as Databuddy } from '../shared/@databuddy/sdk.ClgMzRh8.js';
@@ -1,13 +1,4 @@
1
1
  'use client';
2
2
 
3
- import { i as isScriptInjected, c as createScript } from '../shared/@databuddy/sdk.CtTNAIIE.mjs';
4
-
5
- function Databuddy(props) {
6
- if (typeof window !== "undefined" && !props.disabled && !isScriptInjected()) {
7
- const script = createScript(props);
8
- document.head.appendChild(script);
9
- }
10
- return null;
11
- }
12
-
13
- export { Databuddy };
3
+ export { D as Databuddy } from '../shared/@databuddy/sdk.B72MFYNj.mjs';
4
+ import '../shared/@databuddy/sdk.CtTNAIIE.mjs';
@@ -0,0 +1,44 @@
1
+ import { i as isScriptInjected, c as createScript } from './sdk.CtTNAIIE.mjs';
2
+
3
+ function detectClientId(providedClientId) {
4
+ if (providedClientId) {
5
+ return providedClientId;
6
+ }
7
+ if (typeof process !== "undefined" && process.env) {
8
+ return process.env.NEXT_PUBLIC_DATABUDDY_CLIENT_ID || process.env.NUXT_PUBLIC_DATABUDDY_CLIENT_ID || process.env.VITE_DATABUDDY_CLIENT_ID || process.env.REACT_APP_DATABUDDY_CLIENT_ID;
9
+ }
10
+ if (typeof window !== "undefined") {
11
+ const nextEnv = window.__NEXT_DATA__?.env?.NEXT_PUBLIC_DATABUDDY_CLIENT_ID;
12
+ if (nextEnv) {
13
+ return nextEnv;
14
+ }
15
+ const nuxtEnv = window.__NUXT__?.env?.NUXT_PUBLIC_DATABUDDY_CLIENT_ID;
16
+ if (nuxtEnv) {
17
+ return nuxtEnv;
18
+ }
19
+ const viteEnv = window.__VITE_ENV__?.VITE_DATABUDDY_CLIENT_ID;
20
+ if (viteEnv) {
21
+ return viteEnv;
22
+ }
23
+ }
24
+ return;
25
+ }
26
+
27
+ function Databuddy(props) {
28
+ const clientId = detectClientId(props.clientId);
29
+ if (!clientId) {
30
+ if (typeof window !== "undefined" && !props.disabled) {
31
+ console.warn(
32
+ "Databuddy: No client ID found. Please provide clientId prop or set NEXT_PUBLIC_DATABUDDY_CLIENT_ID environment variable."
33
+ );
34
+ }
35
+ return null;
36
+ }
37
+ if (typeof window !== "undefined" && !props.disabled && !isScriptInjected()) {
38
+ const script = createScript({ ...props, clientId });
39
+ document.head.appendChild(script);
40
+ }
41
+ return null;
42
+ }
43
+
44
+ export { Databuddy as D, detectClientId as d };
@@ -4,11 +4,12 @@
4
4
  */
5
5
  interface DatabuddyConfig {
6
6
  /**
7
- * Your Databuddy project client ID (required).
7
+ * Your Databuddy project client ID.
8
+ * If not provided, will automatically detect from NEXT_PUBLIC_DATABUDDY_CLIENT_ID environment variable.
8
9
  * Get this from your Databuddy dashboard.
9
10
  * Example: '3ed1fce1-5a56-4cbc-a917-66864f6d18e3'
10
11
  */
11
- clientId: string;
12
+ clientId?: string;
12
13
  /**
13
14
  * (Advanced) Your Databuddy client secret for server-side operations.
14
15
  * Not required for browser usage.
@@ -95,6 +96,34 @@ interface DatabuddyConfig {
95
96
  * Track JavaScript errors (default: false).
96
97
  */
97
98
  trackErrors?: boolean;
99
+ /**
100
+ * Enable observability features (logging, error tracking, tracing) (default: false).
101
+ */
102
+ enableObservability?: boolean;
103
+ /**
104
+ * Service name for observability events.
105
+ */
106
+ observabilityService?: string;
107
+ /**
108
+ * Environment for observability events.
109
+ */
110
+ observabilityEnvironment?: string;
111
+ /**
112
+ * Service version for observability events.
113
+ */
114
+ observabilityVersion?: string;
115
+ /**
116
+ * Enable structured logging (default: false).
117
+ */
118
+ enableLogging?: boolean;
119
+ /**
120
+ * Enable distributed tracing (default: false).
121
+ */
122
+ enableTracing?: boolean;
123
+ /**
124
+ * Enable error tracking (default: false).
125
+ */
126
+ enableErrorTracking?: boolean;
98
127
  /**
99
128
  * Sampling rate for events (0.0 to 1.0, default: 1.0).
100
129
  * Example: 0.5 = 50% of events sent.
@@ -301,6 +330,7 @@ type SetGlobalPropertiesFunction = (properties: EventProperties) => void;
301
330
  * <Databuddy /> component for Next.js/React apps
302
331
  * Injects the databuddy.js script with all config as data attributes
303
332
  * Usage: <Databuddy clientId="..." trackScreenViews trackPerformance ... />
333
+ * Or simply: <Databuddy /> (auto-detects clientId from environment variables)
304
334
  */
305
335
  declare function Databuddy(props: DatabuddyConfig): null;
306
336
 
@@ -4,11 +4,12 @@
4
4
  */
5
5
  interface DatabuddyConfig {
6
6
  /**
7
- * Your Databuddy project client ID (required).
7
+ * Your Databuddy project client ID.
8
+ * If not provided, will automatically detect from NEXT_PUBLIC_DATABUDDY_CLIENT_ID environment variable.
8
9
  * Get this from your Databuddy dashboard.
9
10
  * Example: '3ed1fce1-5a56-4cbc-a917-66864f6d18e3'
10
11
  */
11
- clientId: string;
12
+ clientId?: string;
12
13
  /**
13
14
  * (Advanced) Your Databuddy client secret for server-side operations.
14
15
  * Not required for browser usage.
@@ -95,6 +96,34 @@ interface DatabuddyConfig {
95
96
  * Track JavaScript errors (default: false).
96
97
  */
97
98
  trackErrors?: boolean;
99
+ /**
100
+ * Enable observability features (logging, error tracking, tracing) (default: false).
101
+ */
102
+ enableObservability?: boolean;
103
+ /**
104
+ * Service name for observability events.
105
+ */
106
+ observabilityService?: string;
107
+ /**
108
+ * Environment for observability events.
109
+ */
110
+ observabilityEnvironment?: string;
111
+ /**
112
+ * Service version for observability events.
113
+ */
114
+ observabilityVersion?: string;
115
+ /**
116
+ * Enable structured logging (default: false).
117
+ */
118
+ enableLogging?: boolean;
119
+ /**
120
+ * Enable distributed tracing (default: false).
121
+ */
122
+ enableTracing?: boolean;
123
+ /**
124
+ * Enable error tracking (default: false).
125
+ */
126
+ enableErrorTracking?: boolean;
98
127
  /**
99
128
  * Sampling rate for events (0.0 to 1.0, default: 1.0).
100
129
  * Example: 0.5 = 50% of events sent.
@@ -301,6 +330,7 @@ type SetGlobalPropertiesFunction = (properties: EventProperties) => void;
301
330
  * <Databuddy /> component for Next.js/React apps
302
331
  * Injects the databuddy.js script with all config as data attributes
303
332
  * Usage: <Databuddy clientId="..." trackScreenViews trackPerformance ... />
333
+ * Or simply: <Databuddy /> (auto-detects clientId from environment variables)
304
334
  */
305
335
  declare function Databuddy(props: DatabuddyConfig): null;
306
336
 
@@ -1,10 +1,10 @@
1
1
  import * as vue from 'vue';
2
2
 
3
3
  declare const Databuddy: vue.DefineComponent<{
4
- clientId: {
4
+ clientId?: {
5
5
  type: StringConstructor;
6
- required: true;
7
- };
6
+ required: false;
7
+ } | undefined;
8
8
  clientSecret?: {
9
9
  type: StringConstructor;
10
10
  required: false;
@@ -85,6 +85,34 @@ declare const Databuddy: vue.DefineComponent<{
85
85
  type: BooleanConstructor;
86
86
  required: false;
87
87
  } | undefined;
88
+ enableObservability?: {
89
+ type: BooleanConstructor;
90
+ required: false;
91
+ } | undefined;
92
+ observabilityService?: {
93
+ type: StringConstructor;
94
+ required: false;
95
+ } | undefined;
96
+ observabilityEnvironment?: {
97
+ type: StringConstructor;
98
+ required: false;
99
+ } | undefined;
100
+ observabilityVersion?: {
101
+ type: StringConstructor;
102
+ required: false;
103
+ } | undefined;
104
+ enableLogging?: {
105
+ type: BooleanConstructor;
106
+ required: false;
107
+ } | undefined;
108
+ enableTracing?: {
109
+ type: BooleanConstructor;
110
+ required: false;
111
+ } | undefined;
112
+ enableErrorTracking?: {
113
+ type: BooleanConstructor;
114
+ required: false;
115
+ } | undefined;
88
116
  samplingRate?: {
89
117
  type: NumberConstructor;
90
118
  required: false;
@@ -113,13 +141,12 @@ declare const Databuddy: vue.DefineComponent<{
113
141
  type: NumberConstructor;
114
142
  required: false;
115
143
  } | undefined;
116
- }, () => null, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, Record<string, any>, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<{
117
- clientId: string;
118
- } & {
144
+ }, () => null, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, Record<string, any>, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<{} & {
145
+ sdk?: string | undefined;
146
+ clientId?: string | undefined;
119
147
  clientSecret?: string | undefined;
120
148
  apiUrl?: string | undefined;
121
149
  scriptUrl?: string | undefined;
122
- sdk?: string | undefined;
123
150
  sdkVersion?: string | undefined;
124
151
  disabled?: boolean | undefined;
125
152
  waitForProfile?: boolean | undefined;
@@ -136,6 +163,13 @@ declare const Databuddy: vue.DefineComponent<{
136
163
  trackPerformance?: boolean | undefined;
137
164
  trackWebVitals?: boolean | undefined;
138
165
  trackErrors?: boolean | undefined;
166
+ enableObservability?: boolean | undefined;
167
+ observabilityService?: string | undefined;
168
+ observabilityEnvironment?: string | undefined;
169
+ observabilityVersion?: string | undefined;
170
+ enableLogging?: boolean | undefined;
171
+ enableTracing?: boolean | undefined;
172
+ enableErrorTracking?: boolean | undefined;
139
173
  samplingRate?: number | undefined;
140
174
  enableRetries?: boolean | undefined;
141
175
  maxRetries?: number | undefined;
@@ -1,10 +1,10 @@
1
1
  import * as vue from 'vue';
2
2
 
3
3
  declare const Databuddy: vue.DefineComponent<{
4
- clientId: {
4
+ clientId?: {
5
5
  type: StringConstructor;
6
- required: true;
7
- };
6
+ required: false;
7
+ } | undefined;
8
8
  clientSecret?: {
9
9
  type: StringConstructor;
10
10
  required: false;
@@ -85,6 +85,34 @@ declare const Databuddy: vue.DefineComponent<{
85
85
  type: BooleanConstructor;
86
86
  required: false;
87
87
  } | undefined;
88
+ enableObservability?: {
89
+ type: BooleanConstructor;
90
+ required: false;
91
+ } | undefined;
92
+ observabilityService?: {
93
+ type: StringConstructor;
94
+ required: false;
95
+ } | undefined;
96
+ observabilityEnvironment?: {
97
+ type: StringConstructor;
98
+ required: false;
99
+ } | undefined;
100
+ observabilityVersion?: {
101
+ type: StringConstructor;
102
+ required: false;
103
+ } | undefined;
104
+ enableLogging?: {
105
+ type: BooleanConstructor;
106
+ required: false;
107
+ } | undefined;
108
+ enableTracing?: {
109
+ type: BooleanConstructor;
110
+ required: false;
111
+ } | undefined;
112
+ enableErrorTracking?: {
113
+ type: BooleanConstructor;
114
+ required: false;
115
+ } | undefined;
88
116
  samplingRate?: {
89
117
  type: NumberConstructor;
90
118
  required: false;
@@ -113,13 +141,12 @@ declare const Databuddy: vue.DefineComponent<{
113
141
  type: NumberConstructor;
114
142
  required: false;
115
143
  } | undefined;
116
- }, () => null, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, Record<string, any>, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<{
117
- clientId: string;
118
- } & {
144
+ }, () => null, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, Record<string, any>, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<{} & {
145
+ sdk?: string | undefined;
146
+ clientId?: string | undefined;
119
147
  clientSecret?: string | undefined;
120
148
  apiUrl?: string | undefined;
121
149
  scriptUrl?: string | undefined;
122
- sdk?: string | undefined;
123
150
  sdkVersion?: string | undefined;
124
151
  disabled?: boolean | undefined;
125
152
  waitForProfile?: boolean | undefined;
@@ -136,6 +163,13 @@ declare const Databuddy: vue.DefineComponent<{
136
163
  trackPerformance?: boolean | undefined;
137
164
  trackWebVitals?: boolean | undefined;
138
165
  trackErrors?: boolean | undefined;
166
+ enableObservability?: boolean | undefined;
167
+ observabilityService?: string | undefined;
168
+ observabilityEnvironment?: string | undefined;
169
+ observabilityVersion?: string | undefined;
170
+ enableLogging?: boolean | undefined;
171
+ enableTracing?: boolean | undefined;
172
+ enableErrorTracking?: boolean | undefined;
139
173
  samplingRate?: number | undefined;
140
174
  enableRetries?: boolean | undefined;
141
175
  maxRetries?: number | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@databuddy/sdk",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Official Databuddy Analytics SDK",
5
5
  "main": "./dist/core/index.mjs",
6
6
  "types": "./dist/core/index.d.ts",