File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed
Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,9 @@ module.exports = {
4343 // Default cache TTL set to 1 minute as property definitions rarely change
4444 // Can be configured via context.config.objectPropertiesCacheTTL if needed
4545 const objectPropertiesCacheTTL = context . config . objectPropertiesCacheTTL || ( 60 * 1000 ) ;
46- const cacheKeyPrefix = 'hubspot_properties_' + objectType ;
46+ // Use hub_id from context to differentiate between different HubSpot portals/users.
47+ const portalId = context . auth ?. profileInfo ?. hub_id || 'default' ;
48+ const cacheKeyPrefix = 'hubspot_properties_' + objectType + '_' + portalId ;
4749 let lock ;
4850 try {
4951 lock = await context . lock ( `hubspot_properties_${ objectType } ` ) ;
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ describe('commons.js', () => {
1212
1313 // Reset the context.
1414 context = testUtils . createMockContext ( ) ;
15+ context . auth = { profileInfo : { hub_id : '123456' } } ;
1516 context . messages = { in : { content : { } } } ;
1617 context . config = {
1718 objectPropertiesCacheTTL : 1
@@ -57,5 +58,9 @@ describe('commons.js', () => {
5758 assert ( properties . length > 0 ) ;
5859 assert . equal ( properties [ 0 ] . label , 'Jirka Notes [custom]' , 'Custom field should have [custom] suffix' ) ;
5960 assert . equal ( properties [ 1 ] . label , 'Job Title' , 'Non custom field should not have [custom] suffix' ) ;
61+
62+ // Should use `hub_id` from context to differentiate between different HubSpot portals/users.
63+ const setCacheArgs = context . staticCache . set . getCall ( 0 ) . args ;
64+ assert . equal ( setCacheArgs [ 0 ] , 'hubspot_properties_contacts_123456_all' , 'Cache key should contain hub_id' ) ;
6065 } ) ;
6166} ) ;
You can’t perform that action at this time.
0 commit comments