@@ -45,7 +45,7 @@ export default class Experiences extends PersonalizationAdapter<ImportConfig> {
4545 const conf : APIConfig = {
4646 config,
4747 baseURL : config . modules . personalize . baseURL [ config . region . name ] ,
48- headers : { 'X-Project-Uid' : config . modules . personalize . project_id } ,
48+ headers : { 'X-Project-Uid' : config . modules . personalize . project_id } ,
4949 cmaConfig : {
5050 baseURL : config . region . cma + `/v3` ,
5151 headers : { api_key : config . apiKey } ,
@@ -141,8 +141,11 @@ export default class Experiences extends PersonalizationAdapter<ImportConfig> {
141141 const jobRes = await this . validateVariantGroupAndVariantsCreated ( ) ;
142142 fsUtil . writeFile ( this . cmsVariantPath , this . cmsVariants ) ;
143143 fsUtil . writeFile ( this . cmsVariantGroupPath , this . cmsVariantGroups ) ;
144- if ( jobRes )
144+ if ( jobRes ) {
145145 this . log ( this . config , this . $t ( this . messages . CREATE_SUCCESS , { module : 'Variant & Variant groups' } ) , 'info' ) ;
146+ } else {
147+ this . personalizeConfig . importData = false ;
148+ }
146149
147150 if ( this . personalizeConfig . importData ) {
148151 this . log ( this . config , this . messages . UPDATING_CT_IN_EXP , 'info' ) ;
@@ -162,7 +165,11 @@ export default class Experiences extends PersonalizationAdapter<ImportConfig> {
162165 * function import experience versions from a JSON file and creates them in the project.
163166 */
164167 async importExperienceVersions ( experience : ExperienceStruct , oldExperienceUid : string ) {
165- const versionsPath = resolve ( sanitizePath ( this . experiencesDirPath ) , 'versions' , `${ sanitizePath ( oldExperienceUid ) } .json` ) ;
168+ const versionsPath = resolve (
169+ sanitizePath ( this . experiencesDirPath ) ,
170+ 'versions' ,
171+ `${ sanitizePath ( oldExperienceUid ) } .json` ,
172+ ) ;
166173
167174 if ( ! existsSync ( versionsPath ) ) {
168175 return ;
@@ -231,7 +238,7 @@ export default class Experiences extends PersonalizationAdapter<ImportConfig> {
231238 try {
232239 const promises = this . pendingVariantAndVariantGrpForExperience . map ( async ( expUid ) => {
233240 const expRes = await this . getExperience ( expUid ) ;
234- if ( expRes ?. _cms ) {
241+ if ( expRes ?. _cms && expRes ?. _cms ?. variantGroup && Object . keys ( expRes . _cms . variants ) . length > 0 ) {
235242 this . cmsVariants [ expUid ] = expRes . _cms ?. variants ?? { } ;
236243 this . cmsVariantGroups [ expUid ] = expRes . _cms ?. variantGroup ?? { } ;
237244 return expUid ; // Return the expUid for filtering later
0 commit comments