File tree Expand file tree Collapse file tree 3 files changed +38
-1
lines changed
Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change 77 "@types/node" : " ^12.20.37" ,
88 "@types/react" : " ^17.0.35" ,
99 "@types/react-dom" : " ^17.0.11" ,
10+ "@datadog/browser-rum" : " ^4.25.0" ,
1011 "ajv" : " ^8.8.2" ,
1112 "brace" : " ^0.11.1" ,
1213 "jsoneditor" : " ^9.5.8" ,
Original file line number Diff line number Diff line change 22/* eslint-disable react/destructuring-assignment */
33import React from "react" ;
44import TrackJS from "../../trackjs" ;
5+ import { datadogRum } from '@datadog/browser-rum' ;
56
6- interface MyProps { }
7+ interface MyProps {
8+ children : React . ReactElement ;
9+ }
710
811interface MyState {
912 hasError : boolean ;
1013}
1114
15+ //datadog-rum Installation
16+ datadogRum . init ( {
17+ applicationId : `${ process . env . REACT_APP_DATADOG_RUM_APPLICATION_ID } ` ,
18+ clientToken : `${ process . env . REACT_APP_DATADOG_RUM_CLIENT_TOKEN } ` ,
19+ site : `${ process . env . REACT_APP_DATADOG_RUM_SITE } ` ,
20+ service : `${ process . env . REACT_APP_DATADOG_RUM_SERVICE } ` ,
21+ sampleRate : 100 ,
22+ sessionReplaySampleRate : 20 ,
23+ trackInteractions : true ,
24+ trackResources : true ,
25+ trackLongTasks : true ,
26+ defaultPrivacyLevel : 'mask-user-input' ,
27+ useCrossSiteSessionCookie : true ,
28+ } ) ;
29+
30+ //sending MetaData to Datadog RUM
31+ datadogRum . setGlobalContextProperty ( 'Application Type' , 'Marketplace' ) ;
32+ datadogRum . setGlobalContextProperty ( 'Application Name' , 'JSON Editor App' ) ;
33+
1234class ErrorBoundary extends React . Component < MyProps , MyState > {
1335 constructor ( props : any ) {
1436 super ( props ) ;
Original file line number Diff line number Diff line change @@ -19,7 +19,13 @@ import "tippy.js/dist/tippy.css";
1919/* Import our CSS */
2020import "./styles.scss" ;
2121
22+ import useJsErrorTracker from "../../hooks/useJsErrorTracker" ;
23+
2224const ConfigScreen : React . FC = function ( ) {
25+
26+ // error tracking hooks
27+ const { addMetadata, trackError } = useJsErrorTracker ( ) ;
28+
2329 const [ state , setState ] = useState < TypeAppSdkConfigState > ( {
2430 installationData : {
2531 configuration : {
@@ -60,9 +66,17 @@ const ConfigScreen: React.FC = function () {
6066 setIsStringified (
6167 state ?. installationData ?. configuration ?. isStringified
6268 ) ;
69+
70+ // setting metadata for js error tracker
71+ addMetadata ( "stack" , `${ appSdk ?. stack . _data . name } ` ) ;
72+ addMetadata ( "organization" , `${ appSdk ?. currentUser . defaultOrganization } ` ) ;
73+ addMetadata ( "api_key" , `${ stackKey } ` ) ;
74+ addMetadata ( "user_uid" , `${ appSdk ?. stack . _data . collaborators [ 0 ] . uid } ` ) ;
75+
6376 }
6477 } )
6578 . catch ( ( error ) => {
79+ trackError ( error ) ;
6680 console . error ( constants . appSdkError , error ) ;
6781 } ) ;
6882 } , [ ] ) ;
You can’t perform that action at this time.
0 commit comments