@@ -3,7 +3,7 @@ import { getErrorMessage, toError } from '@sim/utils/errors'
33import { RootlyIcon } from '@/components/icons'
44import { fetchWithRetry , VALIDATE_RETRY_OPTIONS } from '@/lib/knowledge/documents/utils'
55import type { ConnectorConfig , ExternalDocument , ExternalDocumentList } from '@/connectors/types'
6- import { joinTagArray , parseTagDate } from '@/connectors/utils'
6+ import { joinTagArray , parseMultiValue , parseTagDate } from '@/connectors/utils'
77
88const logger = createLogger ( 'RootlyConnector' )
99
@@ -17,8 +17,9 @@ const MAX_TIMELINE_EVENTS = 200
1717 * JSON:API relationships to embed inline within each incident's `attributes`.
1818 * Rootly omits these unless requested via `include`, so both the list (stub) and
1919 * detail requests pass them to ensure tag metadata is identical on either path.
20- * Scoped to exactly the relationships this connector reads (services, teams,
21- * environments) to avoid fetching unused relationship payloads on every incident.
20+ * Scoped to exactly the relationships this connector reads — `environments`,
21+ * `services`, and `groups` (Rootly's API token for teams) — to avoid fetching
22+ * unused relationship payloads on every incident.
2223 */
2324const INCIDENT_INCLUDE = 'environments,services,groups'
2425
@@ -388,9 +389,39 @@ export const rootlyConnector: ConnectorConfig = {
388389 type : 'short-input' ,
389390 required : false ,
390391 mode : 'advanced' ,
391- placeholder : 'e.g. SEV0 (default: all)' ,
392+ placeholder : 'e.g. sev0 (default: all)' ,
392393 description :
393- 'Only sync incidents with this severity name. Leave blank to sync all severities.' ,
394+ 'Only sync incidents with this severity slug (e.g. sev0, sev1). Leave blank to sync all severities.' ,
395+ } ,
396+ {
397+ id : 'services' ,
398+ title : 'Filter by Services' ,
399+ type : 'short-input' ,
400+ required : false ,
401+ mode : 'advanced' ,
402+ multi : true ,
403+ placeholder : 'Service slugs (comma-separated, default: all)' ,
404+ description : 'Only sync incidents affecting these service slugs.' ,
405+ } ,
406+ {
407+ id : 'teams' ,
408+ title : 'Filter by Teams' ,
409+ type : 'short-input' ,
410+ required : false ,
411+ mode : 'advanced' ,
412+ multi : true ,
413+ placeholder : 'Team slugs (comma-separated, default: all)' ,
414+ description : 'Only sync incidents owned by these team slugs.' ,
415+ } ,
416+ {
417+ id : 'environments' ,
418+ title : 'Filter by Environments' ,
419+ type : 'short-input' ,
420+ required : false ,
421+ mode : 'advanced' ,
422+ multi : true ,
423+ placeholder : 'Environment slugs (comma-separated, default: all)' ,
424+ description : 'Only sync incidents in these environment slugs.' ,
394425 } ,
395426 {
396427 id : 'maxIncidents' ,
@@ -411,6 +442,9 @@ export const rootlyConnector: ConnectorConfig = {
411442 const maxIncidents = parseMaxIncidents ( sourceConfig )
412443 const status = typeof sourceConfig . status === 'string' ? sourceConfig . status . trim ( ) : ''
413444 const severity = typeof sourceConfig . severity === 'string' ? sourceConfig . severity . trim ( ) : ''
445+ const services = parseMultiValue ( sourceConfig . services )
446+ const teams = parseMultiValue ( sourceConfig . teams )
447+ const environments = parseMultiValue ( sourceConfig . environments )
414448 const pageNumber = cursor ? Number ( cursor ) : 1
415449 const startPage = Number . isFinite ( pageNumber ) && pageNumber > 0 ? pageNumber : 1
416450
@@ -420,6 +454,9 @@ export const rootlyConnector: ConnectorConfig = {
420454 queryParams . set ( 'include' , INCIDENT_INCLUDE )
421455 if ( status ) queryParams . set ( 'filter[status]' , status )
422456 if ( severity ) queryParams . set ( 'filter[severity]' , severity )
457+ if ( services . length > 0 ) queryParams . set ( 'filter[services]' , services . join ( ',' ) )
458+ if ( teams . length > 0 ) queryParams . set ( 'filter[teams]' , teams . join ( ',' ) )
459+ if ( environments . length > 0 ) queryParams . set ( 'filter[environments]' , environments . join ( ',' ) )
423460
424461 if ( lastSyncAt ) {
425462 queryParams . set ( 'filter[updated_at][gt]' , lastSyncAt . toISOString ( ) )
0 commit comments