Skip to content

Commit

Permalink
Add datadog logging for genie (#5020)
Browse files Browse the repository at this point in the history
  • Loading branch information
alisman authored Oct 13, 2024
1 parent f3125f8 commit 50c71b7
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/appBootstrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ superagent.Request.prototype.end = function(callback) {
});
};

function enableDataDogTracking() {
function enableDataDogTracking(store: AppStore) {
datadogLogs.init({
clientToken: 'pub9a94ebb002f105ff44d8e427b6549775',
site: 'datadoghq.com',
Expand Down Expand Up @@ -246,17 +246,25 @@ function enableDataDogTracking() {
const oldRequest = (internalClient as any).request;
(internalClient as any).request = function(...args: any) {
try {
const url = args[1];
let url = args[1];

if (Object.keys(args[4]).length) {
url = url + '?' + $.param(args[4]);
}

const data = args[2];

const studyIds = data.studyIds || data.studyViewFilter.studyIds;

const appName = store.serverConfig.app_name;

if (studyIds.length < 4 && _.some(match, re => re.test(url))) {
const hash = hashString(url + JSON.stringify(toJS(data)));
datadogLogs.logger.info('study view request', {
url,
data,
hash,
appName,
});
}
} catch (ex) {
Expand Down Expand Up @@ -363,10 +371,12 @@ $(document).ready(async () => {
initializeAppStore(stores.appStore);

if (
stores.appStore.serverConfig.app_name === 'public-portal' &&
['genie-public-portal', 'public-portal'].includes(
stores.appStore.serverConfig.app_name!
) &&
!isWebdriver()
) {
enableDataDogTracking();
enableDataDogTracking(stores.appStore);
}

await loadCustomJs();
Expand Down

0 comments on commit 50c71b7

Please sign in to comment.