@databuddy/sdk 1.4.1 → 1.4.2

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/dist/Databuddy.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use client';
2
- import pkg from '../package.json';
3
2
  import { useEffect } from 'react';
3
+ import pkg from '../package.json' with { type: 'json' };
4
4
  /**
5
5
  * <Databuddy /> component for Next.js/React apps
6
6
  * Injects the databuddy.js script with all config as data attributes
@@ -8,12 +8,15 @@ import { useEffect } from 'react';
8
8
  */
9
9
  export function Databuddy(props) {
10
10
  useEffect(() => {
11
- if (typeof window === 'undefined')
11
+ if (typeof window === 'undefined') {
12
12
  return;
13
- if (props.disabled)
13
+ }
14
+ if (props.disabled) {
14
15
  return;
15
- if (document.querySelector('script[data-databuddy-injected]'))
16
+ }
17
+ if (document.querySelector('script[data-databuddy-injected]')) {
16
18
  return;
19
+ }
17
20
  const script = document.createElement('script');
18
21
  script.src = props.scriptUrl || 'https://cdn.databuddy.cc/databuddy.js';
19
22
  script.async = true;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export * from './Databuddy';
2
- export * from './types';
3
2
  export * from './tracker';
3
+ export * from './types';
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export * from './Databuddy';
2
- export * from './types';
3
2
  export * from './tracker';
3
+ export * from './types';
package/dist/tracker.js CHANGED
@@ -6,15 +6,15 @@
6
6
  * Check if the Databuddy tracker is available
7
7
  */
8
8
  export function isTrackerAvailable() {
9
- return typeof window !== 'undefined' &&
10
- (!!window.databuddy || !!window.db);
9
+ return typeof window !== 'undefined' && (!!window.databuddy || !!window.db);
11
10
  }
12
11
  /**
13
12
  * Get the Databuddy tracker instance
14
13
  */
15
14
  export function getTracker() {
16
- if (typeof window === 'undefined')
15
+ if (typeof window === 'undefined') {
17
16
  return null;
17
+ }
18
18
  return window.databuddy || null;
19
19
  }
20
20
  /**
@@ -33,8 +33,7 @@ export const track = async (eventName, properties) => {
33
33
  try {
34
34
  await tracker(eventName, properties);
35
35
  }
36
- catch (error) {
37
- }
36
+ catch (_error) { }
38
37
  };
39
38
  /**
40
39
  * Clear the current session
@@ -51,8 +50,7 @@ export function clear() {
51
50
  try {
52
51
  tracker();
53
52
  }
54
- catch (error) {
55
- }
53
+ catch (_error) { }
56
54
  }
57
55
  /**
58
56
  * Flush any queued events
@@ -69,8 +67,7 @@ export function flush() {
69
67
  try {
70
68
  tracker();
71
69
  }
72
- catch (error) {
73
- }
70
+ catch (_error) { }
74
71
  }
75
72
  /**
76
73
  * Track an error event
package/package.json CHANGED
@@ -1,27 +1,34 @@
1
- {
2
- "name": "@databuddy/sdk",
3
- "version": "1.4.1",
4
- "main": "dist/index.js",
5
- "devDependencies": {
6
- "@types/node": "^20.0.0",
7
- "typescript": "^5.0.0"
8
- },
9
- "exports": {
10
- ".": "./dist/index.js"
11
- },
12
- "description": "Official Databuddy Analytics SDK",
13
- "files": [
14
- "dist"
15
- ],
16
- "keywords": [
17
- "analytics",
18
- "tracking",
19
- "databuddy",
20
- "sdk"
21
- ],
22
- "license": "MIT",
23
- "private": false,
24
- "scripts": {
25
- "build": "tsc --project tsconfig.json"
26
- }
27
- }
1
+ {
2
+ "name": "@databuddy/sdk",
3
+ "version": "1.4.2",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "module": "dist/index.js",
7
+ "devDependencies": {
8
+ "@types/node": "^20.0.0",
9
+ "typescript": "catalog:"
10
+ },
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js",
15
+ "require": "./dist/index.js",
16
+ "default": "./dist/index.js"
17
+ }
18
+ },
19
+ "description": "Official Databuddy Analytics SDK",
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "keywords": [
24
+ "analytics",
25
+ "tracking",
26
+ "databuddy",
27
+ "sdk"
28
+ ],
29
+ "license": "MIT",
30
+ "private": false,
31
+ "scripts": {
32
+ "build": "tsc --project tsconfig.json"
33
+ }
34
+ }
@@ -1,8 +0,0 @@
1
- import type { DatabuddyConfig } from './types';
2
- /**
3
- * <Databuddy /> component for Next.js/React apps
4
- * Injects the databuddy.js script with all config as data attributes
5
- * Usage: <Databuddy clientId="..." trackScreenViews trackPerformance ... />
6
- */
7
- export declare function Databuddy(props: DatabuddyConfig): null;
8
- export default Databuddy;
@@ -1,31 +0,0 @@
1
- 'use client';
2
- import { useEffect } from 'react';
3
- /**
4
- * <Databuddy /> component for Next.js/React apps
5
- * Injects the databuddy.js script with all config as data attributes
6
- * Usage: <Databuddy clientId="..." trackScreenViews trackPerformance ... />
7
- */
8
- export function Databuddy(props) {
9
- useEffect(() => {
10
- if (typeof window === 'undefined')
11
- return;
12
- if (document.querySelector('script[data-databuddy-injected]'))
13
- return;
14
- const script = document.createElement('script');
15
- script.src = props.scriptUrl || 'https://app.databuddy.cc/databuddy.js';
16
- script.defer = true;
17
- script.setAttribute('data-databuddy-injected', 'true');
18
- for (const [key, value] of Object.entries(props)) {
19
- if (value !== undefined) {
20
- const dataKey = `data-${key.replace(/([A-Z])/g, '-$1').toLowerCase()}`;
21
- script.setAttribute(dataKey, String(value));
22
- }
23
- }
24
- document.head.appendChild(script);
25
- return () => {
26
- script.remove();
27
- };
28
- }, [props]);
29
- return null;
30
- }
31
- export default Databuddy;