11import React , { useEffect , useState } from "react" ;
22import ContentstackAppSdk from "@contentstack/app-sdk" ;
3- import constants from "../../common/constants" ;
3+ import constants , { eventNames } from "../../common/constants" ;
44import { isEmpty } from "../../common/utils" ;
55import { TypeSDKData } from "../../common/types" ;
66import "./styles.scss" ;
7+ import useAnalytics from "../../hooks/useAnalytics" ;
78import JSONEditor from "../../components/jsoneditor" ;
89
910const CustomField : React . FC = function ( ) {
@@ -13,7 +14,10 @@ const CustomField: React.FC = function () {
1314 appSdkInitialized : false ,
1415 } ) ;
1516 const [ jsonData , setJsonData ] = useState < Array < any > > ( [ { } ] ) ;
17+ const { trackEvent } = useAnalytics ( ) ;
1618 const [ saveJsonData , setSaveJsonData ] = useState < Array < any > > ( [ { } ] ) ;
19+ const { APP_INITIALIZE_SUCCESS , APP_INITIALIZE_FAILURE } = eventNames ;
20+
1721 let isStringified : any ;
1822
1923 const toStringify = ( localConfig : any , globalConfig : any ) => {
@@ -62,9 +66,11 @@ const CustomField: React.FC = function () {
6266 [ JSON . stringify ( jsonVal [ 0 ] ) ]
6367 : jsonVal
6468 ) ;
69+ trackEvent ( APP_INITIALIZE_SUCCESS )
6570 } )
6671 . catch ( ( error ) => {
6772 console . error ( constants . appSdkError , error ) ;
73+ trackEvent ( APP_INITIALIZE_FAILURE )
6874 } ) ;
6975 } , [ ] ) ;
7076
0 commit comments