@echoteam/signoz-react 1.0.2 → 1.0.4

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 CODR Team
3
+ Copyright (c) 2024 echoteam
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -30,6 +30,7 @@ REACT_APP_SIGNOZ_SERVICE_VERSION=1.0.0
30
30
  REACT_APP_SIGNOZ_ENV=production
31
31
  REACT_APP_SIGNOZ_SERVICE_NAMESPACE=frontend
32
32
  REACT_APP_SIGNOZ_URL=https://your-signoz-instance.com/v1/traces
33
+ REACT_APP_SIGNOZ_TRACE_SAMPLE_RATE=1.0
33
34
  ```
34
35
 
35
36
  ### Inisialisasi
@@ -49,7 +50,8 @@ initializeSignOzTracing({
49
50
  url: 'https://your-signoz-instance.com/v1/traces',
50
51
  headers: {
51
52
  'Authorization': 'Bearer your-token'
52
- }
53
+ },
54
+ traceSampleRate: 0.5 // Sampling 50% trace
53
55
  });
54
56
  ```
55
57
 
@@ -199,6 +201,8 @@ Inisialisasi SignOz tracing untuk aplikasi React.
199
201
  - `serviceNamespace`: Namespace layanan
200
202
  - `url`: URL endpoint SignOz
201
203
  - `headers`: Headers tambahan untuk request
204
+ - `traceSampleRate`: Sampling rate tracing (0.0 - 1.0, default: 1.0 jika tidak diisi)
205
+ - Bisa juga diatur lewat environment variable `REACT_APP_SIGNOZ_TRACE_SAMPLE_RATE`
202
206
 
203
207
  ### `ErrorBoundary`
204
208
 
@@ -0,0 +1,186 @@
1
+ # Troubleshooting Guide
2
+
3
+ ## Error: Can't resolve 'perf_hooks'
4
+
5
+ ### Masalah
6
+ Jika Anda mendapatkan error seperti ini:
7
+ ```
8
+ ERROR in ./node_modules/@echoteam/signoz-react/dist/index.esm.js 1:0-58
9
+ Module not found: Error: Can't resolve 'perf_hooks' in '/path/to/node_modules/@echoteam/signoz-react/dist'
10
+ ```
11
+
12
+ ### Penyebab
13
+ Error ini terjadi karena library OpenTelemetry mencoba mengimpor modul Node.js (`perf_hooks`) yang tidak tersedia di browser. Library ini dirancang untuk berjalan di browser, bukan di Node.js.
14
+
15
+ ### Solusi
16
+
17
+ #### 1. Pastikan menggunakan versi terbaru
18
+ Library ini sudah diperbaiki untuk menangani masalah ini. Pastikan Anda menggunakan versi terbaru:
19
+
20
+ ```bash
21
+ yarn add @echoteam/signoz-react@latest
22
+ ```
23
+
24
+ #### 2. Konfigurasi Webpack (jika menggunakan Webpack)
25
+ Tambahkan konfigurasi berikut di `webpack.config.js`:
26
+
27
+ ```javascript
28
+ module.exports = {
29
+ // ... konfigurasi lainnya
30
+ resolve: {
31
+ fallback: {
32
+ "perf_hooks": false,
33
+ "fs": false,
34
+ "path": false,
35
+ "os": false,
36
+ "crypto": false,
37
+ "stream": false,
38
+ "util": false,
39
+ "events": false,
40
+ "assert": false,
41
+ "buffer": false,
42
+ "querystring": false,
43
+ "url": false,
44
+ "http": false,
45
+ "https": false,
46
+ "zlib": false,
47
+ "tty": false,
48
+ "domain": false,
49
+ "dns": false,
50
+ "dgram": false,
51
+ "child_process": false,
52
+ "cluster": false,
53
+ "module": false,
54
+ "net": false,
55
+ "readline": false,
56
+ "repl": false,
57
+ "string_decoder": false,
58
+ "sys": false,
59
+ "timers": false,
60
+ "tls": false,
61
+ "v8": false,
62
+ "vm": false,
63
+ "worker_threads": false
64
+ }
65
+ }
66
+ };
67
+ ```
68
+
69
+ #### 3. Konfigurasi Vite (jika menggunakan Vite)
70
+ Tambahkan konfigurasi berikut di `vite.config.js`:
71
+
72
+ ```javascript
73
+ import { defineConfig } from 'vite';
74
+
75
+ export default defineConfig({
76
+ // ... konfigurasi lainnya
77
+ define: {
78
+ global: 'globalThis',
79
+ },
80
+ resolve: {
81
+ alias: {
82
+ 'perf_hooks': false,
83
+ 'fs': false,
84
+ 'path': false,
85
+ 'os': false,
86
+ 'crypto': false,
87
+ 'stream': false,
88
+ 'util': false,
89
+ 'events': false,
90
+ 'assert': false,
91
+ 'buffer': false,
92
+ 'querystring': false,
93
+ 'url': false,
94
+ 'http': false,
95
+ 'https': false,
96
+ 'zlib': false,
97
+ 'tty': false,
98
+ 'domain': false,
99
+ 'dns': false,
100
+ 'dgram': false,
101
+ 'child_process': false,
102
+ 'cluster': false,
103
+ 'module': false,
104
+ 'net': false,
105
+ 'readline': false,
106
+ 'repl': false,
107
+ 'string_decoder': false,
108
+ 'sys': false,
109
+ 'timers': false,
110
+ 'tls': false,
111
+ 'v8': false,
112
+ 'vm': false,
113
+ 'worker_threads': false
114
+ }
115
+ }
116
+ });
117
+ ```
118
+
119
+ #### 4. Konfigurasi Create React App
120
+ Jika menggunakan Create React App, Anda mungkin perlu menggunakan `react-app-rewired` untuk mengoverride konfigurasi webpack:
121
+
122
+ 1. Install react-app-rewired:
123
+ ```bash
124
+ yarn add --dev react-app-rewired
125
+ ```
126
+
127
+ 2. Buat file `config-overrides.js` di root proyek:
128
+ ```javascript
129
+ module.exports = function override(config, env) {
130
+ config.resolve.fallback = {
131
+ ...config.resolve.fallback,
132
+ "perf_hooks": false,
133
+ "fs": false,
134
+ "path": false,
135
+ "os": false,
136
+ "crypto": false,
137
+ "stream": false,
138
+ "util": false,
139
+ "events": false,
140
+ "assert": false,
141
+ "buffer": false,
142
+ "querystring": false,
143
+ "url": false,
144
+ "http": false,
145
+ "https": false,
146
+ "zlib": false,
147
+ "tty": false,
148
+ "domain": false,
149
+ "dns": false,
150
+ "dgram": false,
151
+ "child_process": false,
152
+ "cluster": false,
153
+ "module": false,
154
+ "net": false,
155
+ "readline": false,
156
+ "repl": false,
157
+ "string_decoder": false,
158
+ "sys": false,
159
+ "timers": false,
160
+ "tls": false,
161
+ "v8": false,
162
+ "vm": false,
163
+ "worker_threads": false
164
+ };
165
+ return config;
166
+ };
167
+ ```
168
+
169
+ 3. Update script di `package.json`:
170
+ ```json
171
+ {
172
+ "scripts": {
173
+ "start": "react-app-rewired start",
174
+ "build": "react-app-rewired build",
175
+ "test": "react-app-rewired test"
176
+ }
177
+ }
178
+ ```
179
+
180
+ ### Catatan Penting
181
+ - Library ini dirancang untuk berjalan di browser, bukan di Node.js
182
+ - Polyfill sudah disertakan untuk menangani modul Node.js yang tidak tersedia di browser
183
+ - Pastikan environment variables untuk SignOz sudah dikonfigurasi dengan benar
184
+
185
+ ### Masalah Lainnya
186
+ Jika Anda masih mengalami masalah, silakan buat issue di repository ini dengan detail error yang lengkap.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@echoteam/signoz-react",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "SignOz React JS - Library untuk monitoring dan tracing aplikasi React menggunakan OpenTelemetry dan SignOz",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -10,7 +10,8 @@
10
10
  "files": [
11
11
  "dist",
12
12
  "README.md",
13
- "LICENSE"
13
+ "LICENSE",
14
+ "TROUBLESHOOTING.md"
14
15
  ],
15
16
  "scripts": {
16
17
  "build": "rollup -c",
@@ -85,4 +86,4 @@
85
86
  "node": ">=14.0.0",
86
87
  "npm": ">=6.0.0"
87
88
  }
88
- }
89
+ }