Skip to content

Commit 09503d4

Browse files
committed
fix(integrations): apply rollout to filter groups, require a panels array, map the alert rule UID
1 parent da6a7f9 commit 09503d4

6 files changed

Lines changed: 29 additions & 13 deletions

File tree

‎apps/docs/content/docs/integrations/posthog.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ Create a new feature flag in PostHog
822822
| `filters` | string | No | Feature flag filters as JSON string |
823823
| `active` | boolean | No | Whether the flag is active \(default: true\) |
824824
| `ensureExperienceContinuity` | boolean | No | Whether to ensure experience continuity \(default: false\) |
825-
| `rolloutPercentage` | number | No | Percentage of users \(0-100\) the flag is released to. Ignored when Filters is set; put rollout_percentage in its groups instead. |
825+
| `rolloutPercentage` | number | No | Percentage of users \(0-100\) the flag is released to. With Filters, applies to each group that sets no rollout_percentage of its own. |
826826

827827
#### Output
828828

‎apps/sim/blocks/blocks/grafana.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,7 @@ Return ONLY the JSON object - no explanations, no markdown, no extra text.`,
11861186
if (params.annotationType) result.type = params.annotationType
11871187
if (params.panelId) result.panelId = Number(params.panelId)
11881188
if (params.alertId) result.alertId = Number(params.alertId)
1189+
if (params.alertUid) result.alertUid = params.alertUid
11891190
if (params.userId) result.userId = Number(params.userId)
11901191
if (params.from) result.from = Number(params.from)
11911192
if (params.to) result.to = Number(params.to)

‎apps/sim/tools/generated/tool-metadata.ts‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎apps/sim/tools/grafana/create_dashboard.test.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ describe('grafana create dashboard panels', () => {
2121
)
2222
})
2323

24-
it('sends panels a tool call already passed as an array', () => {
24+
it('refuses panels JSON that is not an array', () => {
25+
expect(() => buildBody({ ...baseParams, panels: '{"type": "timeseries"}' })).toThrow(
26+
'panels must be a JSON array'
27+
)
28+
})
29+
30+
it('sends panels a block reference already resolved to an array', () => {
2531
const panels = [{ type: 'timeseries', title: 'Latency' }]
2632
const body = buildBody({ ...baseParams, panels: panels as unknown as string })
2733
expect(body.dashboard.panels).toEqual(panels)

‎apps/sim/tools/grafana/create_dashboard.ts‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,18 @@ export const createDashboardTool: ToolConfig<
112112
refresh: params.refresh || '',
113113
}
114114

115-
if (!params.panels) {
116-
dashboard.panels = []
117-
} else if (typeof params.panels === 'string') {
115+
let panels: unknown = params.panels || []
116+
if (typeof panels === 'string') {
118117
try {
119-
dashboard.panels = JSON.parse(params.panels)
118+
panels = JSON.parse(panels)
120119
} catch {
121120
throw new Error('Invalid JSON for panels parameter')
122121
}
123-
} else {
124-
dashboard.panels = params.panels
125122
}
123+
if (!Array.isArray(panels)) {
124+
throw new Error('panels must be a JSON array of panel objects')
125+
}
126+
dashboard.panels = panels
126127

127128
const body: Record<string, any> = {
128129
dashboard,

‎apps/sim/tools/posthog/create_feature_flag.ts‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export const createFeatureFlagTool: ToolConfig<
106106
required: false,
107107
visibility: 'user-or-llm',
108108
description:
109-
'Percentage of users (0-100) the flag is released to. Ignored when Filters is set; put rollout_percentage in its groups instead.',
109+
'Percentage of users (0-100) the flag is released to. With Filters, applies to each group that sets no rollout_percentage of its own.',
110110
},
111111
},
112112

@@ -142,9 +142,17 @@ export const createFeatureFlagTool: ToolConfig<
142142
body.ensure_experience_continuity = params.ensureExperienceContinuity
143143
}
144144

145-
if (params.rolloutPercentage !== undefined && body.filters === undefined) {
146-
body.filters = {
147-
groups: [{ properties: [], rollout_percentage: params.rolloutPercentage }],
145+
if (params.rolloutPercentage !== undefined) {
146+
if (body.filters === undefined) {
147+
body.filters = {
148+
groups: [{ properties: [], rollout_percentage: params.rolloutPercentage }],
149+
}
150+
} else if (Array.isArray(body.filters?.groups)) {
151+
for (const group of body.filters.groups) {
152+
if (group && group.rollout_percentage === undefined) {
153+
group.rollout_percentage = params.rolloutPercentage
154+
}
155+
}
148156
}
149157
}
150158

0 commit comments

Comments
 (0)