fix: Prevent duplicate demo sources in Play Environment source select (#1977)

## Summary

The cleanup logic only removed demo sources where connection === 'local', or the db != 'otel_v2'. Now removes all Demo/ClickPy sources by name before recreating them, and reuses an existing demo connection instead of creating duplicates.

### References

- Linear Issue: HDX-3800
This commit is contained in:
Aaron Knudtson 2026-03-24 10:29:07 -04:00 committed by GitHub
parent 89868d2670
commit 45755260d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 31 additions and 22 deletions

View file

@ -0,0 +1,5 @@
---
"@hyperdx/app": patch
---
fix: Prevent duplicate demo sources in Play Environment source select

View file

@ -597,11 +597,10 @@ function OnboardingModalComponent({
try {
if (sources) {
for (const source of sources) {
// Clean out old demo sources. All new ones use the otel_v2 database
// Clean out ALL existing demo and ClickPy sources to avoid duplicates
if (
source.connection === 'local' &&
source.name.startsWith('Demo') &&
source.from.databaseName !== 'otel_v2'
source.name.startsWith('Demo') ||
source.name.startsWith('ClickPy')
) {
await deleteSourceMutation.mutateAsync({
id: source.id,
@ -609,26 +608,30 @@ function OnboardingModalComponent({
}
}
}
let createdConnectionId = '';
await createConnectionMutation.mutateAsync(
{
connection: {
name: 'Demo',
host: 'https://sql-clickhouse.clickhouse.com',
username: 'otel_demo',
password: '',
// Reuse existing demo connection if available, otherwise create one
const existingDemoConnection = connections?.find(c => c.name === 'Demo');
let createdConnectionId = existingDemoConnection?.id ?? '';
if (!existingDemoConnection) {
await createConnectionMutation.mutateAsync(
{
connection: {
name: 'Demo',
host: 'https://sql-clickhouse.clickhouse.com',
username: 'otel_demo',
password: '',
},
},
},
{
onSuccess(data) {
createdConnectionId = data.id;
{
onSuccess(data) {
createdConnectionId = data.id;
},
onError(error) {
console.error('Failed to create demo connection: ', error);
return;
},
},
onError(error) {
console.error('Failed to create demo connection: ', error);
return;
},
},
);
);
}
await addOtelDemoSources({
connectionId: createdConnectionId,
@ -741,6 +744,7 @@ function OnboardingModalComponent({
}
}, [
brandName,
connections,
createSourceMutation,
createConnectionMutation,
updateSourceMutation,