@@ -9,25 +9,27 @@ import FEATURES from 'src/features';
99
1010export async function checkResponseSchema ( userId : string , endpointData : Tables < 'endpoints' > , responseSchema : any ) {
1111 try {
12- const saveSchema = async ( oldSchema : any , newSchema : any ) => {
12+ const saveSchema = async ( oldSchema : any , newSchema : any , saveIncident : boolean = false ) => {
1313 await supabase
1414 . from ( 'endpoints_response_schema_history' )
1515 . insert ( {
1616 endpoint_id : endpointData . id ,
1717 schema : responseSchema
1818 } ) ;
1919
20- await supabase
21- . from ( 'incidents' )
22- . insert ( {
23- endpoint_id : endpointData . id ,
24- type : 'SCHEMA_CHANGED' ,
25- title : 'Response schema changed' ,
26- details : {
27- oldSchema,
28- newSchema
29- }
30- } ) ;
20+ if ( saveIncident ) {
21+ await supabase
22+ . from ( 'incidents' )
23+ . insert ( {
24+ endpoint_id : endpointData . id ,
25+ type : 'SCHEMA_CHANGED' ,
26+ title : 'Response schema changed' ,
27+ details : {
28+ oldSchema,
29+ newSchema
30+ }
31+ } ) ;
32+ }
3133 }
3234
3335 const latestSchemaResponse = await supabase
@@ -50,7 +52,7 @@ export async function checkResponseSchema(userId: string, endpointData: Tables<'
5052 }
5153 catch ( e : unknown ) {
5254 if ( e instanceof AssertionError ) {
53- await saveSchema ( latestSchema , responseSchema ) ;
55+ await saveSchema ( latestSchema , responseSchema , true ) ;
5456
5557 if ( FEATURES . EMAILS ) {
5658 const userData = await supabase . auth . admin . getUserById ( userId ) ;
0 commit comments