-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AC-2507] Add Datadog monitoring hook (#151)
* Add datadog monitoring hook * Address @bang9 comment
- Loading branch information
1 parent
c26dba2
commit 2c5c0cf
Showing
13 changed files
with
96 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { datadogRum } from '@datadog/browser-rum'; | ||
import { useEffect } from 'react'; | ||
|
||
import { useConstantState } from '../context/ConstantContext'; | ||
|
||
const DATADOG_APP_ID = import.meta.env.VITE_CHAT_AI_WIDGET_DATADOG_APP_ID; | ||
const DATADOG_CLIENT_TOKEN = import.meta.env | ||
.VITE_CHAT_AI_WIDGET_DATADOG_CLIENT_TOKEN; | ||
const isProd = import.meta.env.PROD ? 'prod' : 'dev'; | ||
|
||
const useDatadogRum = () => { | ||
const { serviceName } = useConstantState(); | ||
useEffect(() => { | ||
if (DATADOG_APP_ID != null && DATADOG_CLIENT_TOKEN != null) { | ||
datadogRum.init({ | ||
applicationId: DATADOG_APP_ID, | ||
clientToken: DATADOG_CLIENT_TOKEN, | ||
site: 'datadoghq.com', | ||
sessionSampleRate: 100, | ||
sessionReplaySampleRate: 100, | ||
trackResources: true, | ||
trackLongTasks: true, | ||
trackUserInteractions: true, | ||
service: serviceName || 'genai-chatbot-widget', | ||
version: APP_VERSION, | ||
env: isProd ? 'production' : 'development', | ||
}); | ||
|
||
datadogRum.startSessionReplayRecording(); | ||
} | ||
|
||
return () => { | ||
datadogRum.stopSessionReplayRecording(); | ||
}; | ||
}, []); | ||
}; | ||
|
||
export default useDatadogRum; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
/// <reference types="vite/client" /> | ||
declare const APP_VERSION: string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters