@@ -72,56 +72,30 @@ export default {
7272 async getContactDetails ( contactIds ) {
7373 if ( ! contactIds . length ) return { } ;
7474
75- const uniqueContactIds = [
76- ...new Set ( contactIds ) ,
77- ] ;
78-
7975 const { properties = [ ] } = this ;
8076 const allProperties = [
81- ...new Set ( [
82- ...DEFAULT_CONTACT_PROPERTIES ,
83- ...properties ,
84- ] ) ,
77+ ...DEFAULT_CONTACT_PROPERTIES ,
78+ ...properties ,
8579 ] ;
8680
87- const chunks = [ ] ;
88- const chunkSize = 100 ;
89- for ( let i = 0 ; i < uniqueContactIds . length ; i += chunkSize ) {
90- chunks . push ( uniqueContactIds . slice ( i , i + chunkSize ) ) ;
91- }
92-
93- const contactMap = { } ;
94-
95- const chunkPromises = chunks . map ( async ( chunk ) => {
96- try {
97- const { results } = await this . hubspot . batchGetObjects ( {
98- objectType : "contacts" ,
99- data : {
100- inputs : chunk . map ( ( id ) => ( {
101- id,
102- } ) ) ,
103- properties : allProperties ,
104- } ,
105- } ) ;
106- return results ;
107- } catch ( error ) {
108- console . warn ( "Error fetching contact details for chunk:" , error ) ;
109- return [ ] ;
110- }
111- } ) ;
112-
11381 try {
114- const chunkResults = await Promise . all ( chunkPromises ) ;
115-
116- chunkResults . forEach ( ( results ) => {
117- results . forEach ( ( contact ) => {
118- contactMap [ contact . id ] = contact ;
119- } ) ;
82+ const { results } = await this . hubspot . batchGetObjects ( {
83+ objectType : "contacts" ,
84+ data : {
85+ inputs : contactIds . map ( ( id ) => ( {
86+ id,
87+ } ) ) ,
88+ properties : allProperties ,
89+ } ,
12090 } ) ;
12191
92+ const contactMap = { } ;
93+ results . forEach ( ( contact ) => {
94+ contactMap [ contact . id ] = contact ;
95+ } ) ;
12296 return contactMap ;
12397 } catch ( error ) {
124- console . warn ( "Error processing contact details:" , error ) ;
98+ console . warn ( "Error fetching contact details:" , error ) ;
12599 return { } ;
126100 }
127101 } ,
0 commit comments