Skip to content

Commit

Permalink
Rename URLGroups to URLOverrides
Browse files Browse the repository at this point in the history
  • Loading branch information
ankur22 committed Oct 7, 2024
1 parent a07fc63 commit 31050eb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion browser/metric_event_mapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func mapMetricEvent(vu moduleVU, cm *common.MetricEvent) (mapping, error) {
}

return mapping{
"Tag": func(urls common.URLGroups) error {
"Tag": func(urls common.URLOverrides) error {
callback := func(pattern, url string) (bool, error) {
js := fmt.Sprintf(`_k6BrowserURLGroupingTest(%s, '%s')`, pattern, url)

Expand Down
22 changes: 11 additions & 11 deletions common/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,14 +421,14 @@ type MetricEvent struct {
name *string
}

// URLGroups will contain all the URL groupings.
type URLGroups struct {
URLs []URLGroup `js:"urls"`
// URLOverrides will contain all the URL groupings.
type URLOverrides struct {
URLs []URLOverride `js:"urls"`
}

// URLGroup contains the single url regex and the name to give to the metric
// URLOverride contains the single url regex and the name to give to the metric
// if a match is found.
type URLGroup struct {
type URLOverride struct {
// This is a regex.
URL string
// The name to send back to the caller of the handler.
Expand All @@ -437,18 +437,18 @@ type URLGroup struct {

type regexCallback func(pattern, url string) (bool, error)

// Tag will find the first match given the URLGroups and the URL from
// Tag will find the first match given the URLOverrides and the URL from
// the metric tag and update the name field.
func (e *MetricEvent) Tag(callBack regexCallback, groups URLGroups) error {
for _, g := range groups.URLs {
name := strings.TrimSpace(g.Name)
func (e *MetricEvent) Tag(callBack regexCallback, overrides URLOverrides) error {
for _, o := range overrides.URLs {
name := strings.TrimSpace(o.Name)
if name == "" {
return fmt.Errorf("name %q is invalid", g.Name)
return fmt.Errorf("name %q is invalid", o.Name)
}

// callback is a function that will perform the regex test in the Sobek
// runtime.
val, err := callBack(g.URL, e.urlTag)
val, err := callBack(o.URL, e.urlTag)
if err != nil {
return err
}
Expand Down

0 comments on commit 31050eb

Please sign in to comment.