Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: dynamicall update the tracePropagationTargets (from api url)
  • Loading branch information
wrn14897 committed Sep 22, 2023
commit 59252abd25b22d75a6c46dc53e2a0874cddf885d
11 changes: 10 additions & 1 deletion packages/app/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,24 @@ export default function MyApp({ Component, pageProps }: AppProps) {
.then(res => res.json())
.then(_jsonData => {
if (_jsonData?.apiKey) {
let hostname;
try {
const url = new URL(_jsonData.apiServerUrl);
hostname = url.hostname;
} catch (err) {
// console.log(err);
}
HyperDX.init({
apiKey: _jsonData.apiKey,
consoleCapture: true,
maskAllInputs: true,
maskAllText: true,
service: _jsonData.serviceName,
tracePropagationTargets: [/localhost/i, /hyperdx\.io/i],
tracePropagationTargets: [new RegExp(hostname ?? 'localhost', 'i')],
url: _jsonData.collectorUrl,
});
} else {
console.warn('No API key found');
}
})
.catch(err => {
Expand Down
3 changes: 3 additions & 0 deletions packages/app/pages/api/config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import type { NextApiRequest, NextApiResponse } from 'next';

import {
API_SERVER_URL,
HDX_API_KEY,
HDX_COLLECTOR_URL,
HDX_SERVICE_NAME,
} from '../../src/config';

type ResponseData = {
apiKey: string;
apiServerUrl: string;
collectorUrl: string;
serviceName: string;
};
Expand All @@ -18,6 +20,7 @@ export default function handler(
) {
res.status(200).json({
apiKey: HDX_API_KEY,
apiServerUrl: API_SERVER_URL,
collectorUrl: HDX_COLLECTOR_URL,
serviceName: HDX_SERVICE_NAME,
});
Expand Down