@@ -127,30 +127,34 @@ export class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> impl
127127 }
128128
129129 async init ( ) : Promise < void > {
130- log . debug ( 'Initializing personalization adapter...' , this . exportConfig ?. context ) ;
131- await authenticationHandler . getAuthDetails ( ) ;
132- const token = authenticationHandler . accessToken ;
133- log . debug (
134- `Authentication type: ${ authenticationHandler . isOauthEnabled ? 'OAuth' : 'Token' } ` ,
135- this . exportConfig ?. context ,
136- ) ;
137-
138- if ( authenticationHandler . isOauthEnabled ) {
139- log . debug ( 'Setting OAuth authorization header' , this . exportConfig ?. context ) ;
140- this . apiClient . headers ( { authorization : token } ) ;
141- if ( this . adapterConfig . cmaConfig ) {
142- log . debug ( 'Setting OAuth authorization header for CMA client' , this . exportConfig ?. context ) ;
143- this . cmaAPIClient ?. headers ( { authorization : token } ) ;
144- }
145- } else {
146- log . debug ( 'Setting authtoken header' , this . exportConfig ?. context ) ;
147- this . apiClient . headers ( { authtoken : token } ) ;
148- if ( this . adapterConfig . cmaConfig ) {
149- log . debug ( 'Setting authtoken header for CMA client' , this . exportConfig ?. context ) ;
150- this . cmaAPIClient ?. headers ( { authtoken : token } ) ;
130+ try {
131+ log . debug ( 'Initializing personalization adapter...' , this . exportConfig ?. context ) ;
132+ await authenticationHandler . getAuthDetails ( ) ;
133+ const token = authenticationHandler . accessToken ;
134+ log . debug (
135+ `Authentication type: ${ authenticationHandler . isOauthEnabled ? 'OAuth' : 'Token' } ` ,
136+ this . exportConfig ?. context ,
137+ ) ;
138+
139+ if ( authenticationHandler . isOauthEnabled ) {
140+ log . debug ( 'Setting OAuth authorization header' , this . exportConfig ?. context ) ;
141+ this . apiClient . headers ( { authorization : token } ) ;
142+ if ( this . adapterConfig . cmaConfig ) {
143+ log . debug ( 'Setting OAuth authorization header for CMA client' , this . exportConfig ?. context ) ;
144+ this . cmaAPIClient ?. headers ( { authorization : token } ) ;
145+ }
146+ } else {
147+ log . debug ( 'Setting authtoken header' , this . exportConfig ?. context ) ;
148+ this . apiClient . headers ( { authtoken : token } ) ;
149+ if ( this . adapterConfig . cmaConfig ) {
150+ log . debug ( 'Setting authtoken header for CMA client' , this . exportConfig ?. context ) ;
151+ this . cmaAPIClient ?. headers ( { authtoken : token } ) ;
152+ }
151153 }
154+ log . debug ( 'Personalization adapter initialization completed' , this . exportConfig ?. context ) ;
155+ } catch ( error : any ) {
156+ log . debug ( `Personalization adapter initialization failed: ${ error } ` , this . exportConfig ?. context ) ;
152157 }
153- log . debug ( 'Personalization adapter initialization completed' , this . exportConfig ?. context ) ;
154158 }
155159
156160 async projects ( options : GetProjectsParams ) : Promise < ProjectStruct [ ] > {
@@ -170,7 +174,7 @@ export class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> impl
170174
171175 return result ;
172176 } catch ( error : any ) {
173- this . updateProgress ( false , 'projects fetch' , error ?. message || ' Failed to fetch projects' , 'Projects' ) ;
177+ log . debug ( ` Failed to fetch projects: ${ error } ` , this . exportConfig ?. context ) ;
174178 throw error ;
175179 }
176180 }
@@ -226,7 +230,7 @@ export class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> impl
226230
227231 return result ;
228232 } catch ( error : any ) {
229- this . updateProgress ( false , 'experiences fetch' , error ?. message || ' Failed to fetch experiences' , 'Experiences' ) ;
233+ log . debug ( ` Failed to fetch experiences: ${ error } ` , this . exportConfig ?. context ) ;
230234 throw error ;
231235 }
232236 }
@@ -318,10 +322,16 @@ export class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> impl
318322
319323 async getEvents ( ) : Promise < EventStruct [ ] | void > {
320324 log . debug ( 'Fetching events from personalization API' , this . exportConfig ?. context ) ;
321- const data = await this . apiClient . get < EventStruct > ( '/events' ) ;
322- const result = ( await this . handleVariantAPIRes ( data ) ) as EventStruct [ ] ;
323- log . debug ( `Fetched ${ result ?. length || 0 } events` , this . exportConfig ?. context ) ;
324- return result ;
325+ try {
326+ const data = await this . apiClient . get < EventStruct > ( '/events' ) ;
327+ const result = ( await this . handleVariantAPIRes ( data ) ) as EventStruct [ ] ;
328+ log . debug ( `Fetched ${ result ?. length || 0 } events` , this . exportConfig ?. context ) ;
329+ return result ;
330+ } catch ( error : any ) {
331+ log . debug ( `Failed to fetch events: ${ error } ` , this . exportConfig ?. context ) ;
332+ // Return empty array instead of throwing to prevent spinner from hanging
333+ throw error ;
334+ }
325335 }
326336
327337 async createEvents ( event : CreateEventInput ) : Promise < void | EventStruct > {
@@ -333,18 +343,30 @@ export class PersonalizationAdapter<T> extends AdapterHelper<T, HttpClient> impl
333343
334344 async getAudiences ( ) : Promise < AudienceStruct [ ] | void > {
335345 log . debug ( 'Fetching audiences from personalization API' , this . exportConfig ?. context ) ;
336- const data = await this . apiClient . get < AudienceStruct > ( '/audiences' ) ;
337- const result = ( await this . handleVariantAPIRes ( data ) ) as AudienceStruct [ ] ;
338- log . debug ( `Fetched ${ result ?. length || 0 } audiences` , this . exportConfig ?. context ) ;
339- return result ;
346+ try {
347+ const data = await this . apiClient . get < AudienceStruct > ( '/audiences' ) ;
348+ const result = ( await this . handleVariantAPIRes ( data ) ) as AudienceStruct [ ] ;
349+ log . debug ( `Fetched ${ result ?. length || 0 } audiences` , this . exportConfig ?. context ) ;
350+ return result ;
351+ } catch ( error : any ) {
352+ log . debug ( `Failed to fetch audiences: ${ error } ` , this . exportConfig ?. context ) ;
353+ // Return empty array instead of throwing to prevent spinner from hanging
354+ throw error ;
355+ }
340356 }
341357
342358 async getAttributes ( ) : Promise < AttributeStruct [ ] | void > {
343359 log . debug ( 'Fetching attributes from personalization API' , this . exportConfig ?. context ) ;
344- const data = await this . apiClient . get < AttributeStruct > ( '/attributes' ) ;
345- const result = ( await this . handleVariantAPIRes ( data ) ) as AttributeStruct [ ] ;
346- log . debug ( `Fetched ${ result ?. length || 0 } attributes` , this . exportConfig ?. context ) ;
347- return result ;
360+ try {
361+ const data = await this . apiClient . get < AttributeStruct > ( '/attributes' ) ;
362+ const result = ( await this . handleVariantAPIRes ( data ) ) as AttributeStruct [ ] ;
363+ log . debug ( `Fetched ${ result ?. length || 0 } attributes` , this . exportConfig ?. context ) ;
364+ return result ;
365+ } catch ( error : any ) {
366+ log . debug ( `Failed to fetch attributes: ${ error } ` , this . exportConfig ?. context ) ;
367+ // Return empty array instead of throwing to prevent spinner from hanging
368+ throw error ;
369+ }
348370 }
349371
350372 /**
0 commit comments