You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/browser/README.md
+18-1Lines changed: 18 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ HyperDX.init({
26
26
27
27
#### Options
28
28
29
-
-`apiKey` - Your HyperDX Ingestion API Key.
29
+
-`apiKey` - Your HyperDX Ingestion API Key. Can be a string or an async function that returns a string (useful for fetching the key from your backend).
30
30
-`service` - The service name events will show up as in HyperDX.
31
31
-`tracePropagationTargets` - A list of regex patterns to match against HTTP
32
32
requests to link frontend and backend traces, it will add an additional
@@ -56,6 +56,23 @@ HyperDX.init({
56
56
57
57
## Additional Configuration
58
58
59
+
### Async API Key
60
+
61
+
If you need to fetch the API key from your backend, you can pass an async function to the `apiKey` option:
62
+
63
+
```js
64
+
HyperDX.init({
65
+
apiKey:async () => {
66
+
constresponse=awaitfetch('/api/hyperdx-key');
67
+
constdata=awaitresponse.json();
68
+
returndata.apiKey;
69
+
},
70
+
service:'my-frontend-app',
71
+
});
72
+
```
73
+
74
+
**Note**: When using an async function for `apiKey`, any events that occur before the API key resolves will not be captured. The SDK initialization is deferred until the API key is available.
75
+
59
76
### Attach User Information or Metadata
60
77
61
78
Attaching user information will allow you to search/filter sessions and events
0 commit comments