11/* Import React modules */
22/* eslint-disable */
33import React , { useState , useEffect } from "react" ;
4+ import { get } from "lodash" ;
45/* Import other node modules */
56
67import VenusHelp from "../../components/venus-help" ;
@@ -11,6 +12,7 @@ import tippy from "tippy.js";
1112import localeTexts from "../../common/locale/en-us" ;
1213import constants from "../../common/constants" ;
1314import { mergeObjects } from "../../common/utils" ;
15+ import getAppLocation from "../../common/utils/function" ;
1416import { TypeAppSdkConfigState } from "../../common/types" ;
1517
1618/* Import node module CSS */
@@ -23,12 +25,10 @@ import { useAppSdk } from "../../hooks/useAppSdk";
2325import useAnalytics from "../../hooks/useAnalytics" ;
2426
2527const ConfigScreen : React . FC = function ( ) {
26-
2728 // error tracking hooks
28- const { addMetadata , trackError } = useJsErrorTracker ( ) ;
29+ const { setErrorsMetaData , trackError } = useJsErrorTracker ( ) ;
2930 const { trackEvent } = useAnalytics ( ) ;
3031 const [ appSdk ] = useAppSdk ( ) ;
31-
3232
3333 const [ state , setState ] = useState < TypeAppSdkConfigState > ( {
3434 installationData : {
@@ -45,28 +45,30 @@ const ConfigScreen: React.FC = function () {
4545 } ,
4646 appSdkInitialized : false ,
4747 } ) ;
48- const [ isStringified , setIsStringified ] = useState ( false ) ;
48+ const [ isStringified , setIsStringified ] = useState ( false ) ;
4949
5050 useEffect ( ( ) => {
5151 ContentstackAppSdk . init ( )
5252 . then ( async ( appSdk ) => {
5353 const sdkConfigData = appSdk ?. location ?. AppConfigWidget ?. installation ;
5454 if ( sdkConfigData ) {
55- const installationDataFromSDK =
56- await sdkConfigData ?. getInstallationData ( ) ;
55+ const installationDataFromSDK = await sdkConfigData ?. getInstallationData ( ) ;
5756 const setInstallationDataOfSDK = sdkConfigData ?. setInstallationData ;
5857 setState ( {
5958 ...state ,
60- installationData : mergeObjects (
61- state ?. installationData ,
62- installationDataFromSDK
63- ) ,
59+ installationData : mergeObjects ( state ?. installationData , installationDataFromSDK ) ,
6460 setInstallationData : setInstallationDataOfSDK ,
6561 appSdkInitialized : true ,
6662 } ) ;
67- setIsStringified (
68- state ?. installationData ?. configuration ?. isStringified
69- ) ;
63+ setIsStringified ( state ?. installationData ?. configuration ?. isStringified ) ;
64+ const appLocation : string = getAppLocation ( appSdk ) ;
65+ let properties = {
66+ Stack : appSdk ?. stack . _data . api_key ,
67+ Organization : appSdk ?. currentUser . defaultOrganization ,
68+ "App Location" : appLocation ,
69+ "User Id" : get ( appSdk , "stack._data.collaborators.0.uid" , "" ) , //first uuid from collaborators
70+ } ;
71+ setErrorsMetaData ( properties ) ; // set global event data for errors
7072 }
7173 } )
7274 . catch ( ( error ) => {
@@ -117,60 +119,26 @@ const ConfigScreen: React.FC = function () {
117119 < div className = "page-wrapper" >
118120 < form data-testid = "cs-form" className = "config-wrapper" >
119121 < div className = "Form__item" >
120- < div
121- className = "Field Field--full json-field"
122- data-testid = "cs-field"
123- >
124- < label
125- className = "FieldLabel"
126- htmlFor = "isStringified"
127- data-testid = "cs-field-label"
128- >
122+ < div className = "Field Field--full json-field" data-testid = "cs-field" >
123+ < label className = "FieldLabel" htmlFor = "isStringified" data-testid = "cs-field-label" >
129124 { localeTexts . configFields . entrySaveRadioButton . label }
130125 < span className = "FieldLabel__required-text" >
131126 < span className = "" > *</ span >
132127 </ span >
133128 </ label >
134- < div
135- className = "tippy-wrapper"
136- id = "help-text"
137- data-testid = "cs-tooltip"
138- >
129+ < div className = "tippy-wrapper" id = "help-text" data-testid = "cs-tooltip" >
139130 < VenusHelp />
140131 </ div >
141132 < div className = "Radio-wrapper" >
142133 < label data-testid = "cs-radio-one" className = "Radio label-text" >
143- < input
144- id = "jsonObject"
145- type = "radio"
146- name = "isStringified"
147- required
148- value = "false"
149- checked = { ! isStringified }
150- onChange = { updateCustomJSON }
151- />
134+ < input id = "jsonObject" type = "radio" name = "isStringified" required value = "false" checked = { ! isStringified } onChange = { updateCustomJSON } />
152135 < span className = "Radio__box" > </ span >
153- < span className = "Radio__label" >
154- { localeTexts . configFields . entrySaveRadioButton . jsonObject }
155- </ span >
136+ < span className = "Radio__label" > { localeTexts . configFields . entrySaveRadioButton . jsonObject } </ span >
156137 </ label >
157138 < label data-testid = "cs-radio-two" className = "Radio label-text" >
158- < input
159- id = "stringified"
160- type = "radio"
161- name = "isStringified"
162- required
163- value = "true"
164- checked = { isStringified }
165- onChange = { updateCustomJSON }
166- />
139+ < input id = "stringified" type = "radio" name = "isStringified" required value = "true" checked = { isStringified } onChange = { updateCustomJSON } />
167140 < span className = "Radio__box" > </ span >
168- < span className = "Radio__label" >
169- {
170- localeTexts . configFields . entrySaveRadioButton
171- . jsonStringified
172- }
173- </ span >
141+ < span className = "Radio__label" > { localeTexts . configFields . entrySaveRadioButton . jsonStringified } </ span >
174142 </ label >
175143 </ div >
176144 < p className = "InstructionText" data-testid = "cs-instruction-text" >
0 commit comments