Skip to content

Commit

Permalink
added Datahog setup
Browse files Browse the repository at this point in the history
  • Loading branch information
radumojic committed Dec 4, 2024
1 parent 08e93e8 commit 04bd85c
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"explorer"
],
"dependencies": {
"@datadog/browser-rum": "5.32.0",
"@fortawesome/fontawesome-svg-core": "6.5.1",
"@fortawesome/free-brands-svg-icons": "6.5.1",
"@fortawesome/free-regular-svg-icons": "6.5.1",
Expand Down
1 change: 1 addition & 0 deletions src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export * from './useIsMainnet';
export * from './useIsNativeTokenSearched';
export * from './useIsSovereign';
export * from './useIsTestnet';
export * from './useInitDataDog';
export * from './useLoopManager';
export * from './useMatchPath';
export * from './useNetworkRoute';
Expand Down
32 changes: 32 additions & 0 deletions src/hooks/useInitDatadog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { useEffect } from 'react';
import { datadogRum } from '@datadog/browser-rum';

export const useInitDatadog = () => {
useEffect(() => {
if (window.location.origin !== 'https://explorer.multiversx.com') {
return;
}

try {
datadogRum.init({
applicationId: 'f0b5a015-e0da-479a-b92d-cbcb050fadec',
clientToken: 'pub784ed9eeb1278d0b8ce7466862ef82f0',
// `site` refers to the Datadog site parameter of your organization
// see https://docs.datadoghq.com/getting_started/site/
site: 'datadoghq.eu',
service: 'explorer',
env: 'prod',
// Specify a version number to identify the deployed version of your application in Datadog
// version: '1.0.0',
sessionSampleRate: 100,
sessionReplaySampleRate: 20,
trackUserInteractions: true,
trackResources: true,
trackLongTasks: true,
defaultPrivacyLevel: 'mask-user-input'
});
} catch (err) {
console.warn('Unable to load Datadog setup: ', err);
}
}, []);
};
4 changes: 3 additions & 1 deletion src/layouts/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
useNetworkRouter,
useLoopManager,
useCheckVersion,
useGetURLNetwork
useGetURLNetwork,
useInitDatadog
} from 'hooks';
import { activeNetworkSelector, defaultNetworkSelector } from 'redux/selectors';

Expand All @@ -37,6 +38,7 @@ export const Layout = () => {
useNetworkRouter();
useLoopManager();
useCheckVersion();
useInitDatadog();

const offline = !window.navigator.onLine;

Expand Down
20 changes: 20 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,26 @@
debug "^3.1.0"
lodash.once "^4.1.1"

"@datadog/[email protected]":
version "5.32.0"
resolved "https://registry.yarnpkg.com/@datadog/browser-core/-/browser-core-5.32.0.tgz#2b13051588db0b6f5616f7f28d59df4ff527ebec"
integrity sha512-+RnQZRda/XwjP2v8TZHIIbZItS1xlRYVs7OmueaA+/MItj0DiL8hZ4uIj7eLsNUXGS0qsiGHXWkaBZE2HfWuvQ==

"@datadog/[email protected]":
version "5.32.0"
resolved "https://registry.yarnpkg.com/@datadog/browser-rum-core/-/browser-rum-core-5.32.0.tgz#2c0aac18e80668fe70f70c9e367939ee36c83f3e"
integrity sha512-SJb8Qmixc82+m613kR3aO31qOD+EhbVY8eMEJ8hYMs1r0LrWGbmEWFWmA86239W5pD4QyRy9ruvs5O/I0S6c1A==
dependencies:
"@datadog/browser-core" "5.32.0"

"@datadog/[email protected]":
version "5.32.0"
resolved "https://registry.yarnpkg.com/@datadog/browser-rum/-/browser-rum-5.32.0.tgz#676690d74c1c9b42fd573695e4ffd73f5535387c"
integrity sha512-Okiu/zTV/sgglGsMAtznqcoy+iwXDjGQ3PkHwZw2jAY/clDcoLbaOPGXeIHXh15E/zk8YALHkC/RW58DFv29lg==
dependencies:
"@datadog/browser-core" "5.32.0"
"@datadog/browser-rum-core" "5.32.0"

"@emotion/babel-plugin@^11.12.0":
version "11.12.0"
resolved "https://registry.yarnpkg.com/@emotion/babel-plugin/-/babel-plugin-11.12.0.tgz#7b43debb250c313101b3f885eba634f1d723fcc2"
Expand Down

0 comments on commit 04bd85c

Please sign in to comment.