mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-16 20:35:57 +08:00
chore: add funnel validation while processing funnel steps
Signed-off-by: Shivanshu Raj Shrivastava <shivanshu1333@gmail.com>
This commit is contained in:
parent
03e50d3bc3
commit
6676832c71
@ -2,13 +2,14 @@ package tracefunnel
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"sort"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/SigNoz/signoz/pkg/errors"
|
"github.com/SigNoz/signoz/pkg/errors"
|
||||||
"github.com/SigNoz/signoz/pkg/types/authtypes"
|
"github.com/SigNoz/signoz/pkg/types/authtypes"
|
||||||
tracefunnel "github.com/SigNoz/signoz/pkg/types/tracefunnel"
|
tracefunnel "github.com/SigNoz/signoz/pkg/types/tracefunnel"
|
||||||
"github.com/SigNoz/signoz/pkg/valuer"
|
"github.com/SigNoz/signoz/pkg/valuer"
|
||||||
"net/http"
|
|
||||||
"sort"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ValidateTimestamp validates a timestamp
|
// ValidateTimestamp validates a timestamp
|
||||||
@ -102,6 +103,14 @@ func ConstructFunnelResponse(funnel *tracefunnel.Funnel, claims *authtypes.Claim
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ProcessFunnelSteps(steps []tracefunnel.FunnelStep) ([]tracefunnel.FunnelStep, error) {
|
func ProcessFunnelSteps(steps []tracefunnel.FunnelStep) ([]tracefunnel.FunnelStep, error) {
|
||||||
|
// First validate the steps
|
||||||
|
if err := ValidateFunnelSteps(steps); err != nil {
|
||||||
|
return nil, errors.Newf(errors.TypeInvalidInput,
|
||||||
|
errors.CodeInvalidInput,
|
||||||
|
"invalid funnel steps: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Then process the steps
|
||||||
for i := range steps {
|
for i := range steps {
|
||||||
if steps[i].Order < 1 {
|
if steps[i].Order < 1 {
|
||||||
steps[i].Order = int64(i + 1)
|
steps[i].Order = int64(i + 1)
|
||||||
@ -111,11 +120,5 @@ func ProcessFunnelSteps(steps []tracefunnel.FunnelStep) ([]tracefunnel.FunnelSte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := ValidateFunnelSteps(steps); err != nil {
|
|
||||||
return nil, errors.Newf(errors.TypeInvalidInput,
|
|
||||||
errors.CodeInvalidInput,
|
|
||||||
"invalid funnel steps: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return NormalizeFunnelSteps(steps), nil
|
return NormalizeFunnelSteps(steps), nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user