mirror of
https://github.com/hyperdxio/hyperdx
synced 2026-04-21 13:37:15 +00:00
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:
parent
89868d2670
commit
45755260d0
2 changed files with 31 additions and 22 deletions
5
.changeset/hdx-3800-fix-duplicate-demo-sources.md
Normal file
5
.changeset/hdx-3800-fix-duplicate-demo-sources.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"@hyperdx/app": patch
|
||||
---
|
||||
|
||||
fix: Prevent duplicate demo sources in Play Environment source select
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue