Surface regulation and user agent across consent record API layers

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-05-07 14:59:00 +04:00
parent 806bd672ed
commit 5f4fd3c427
9 changed files with 74 additions and 26 deletions

View File

@@ -52,13 +52,13 @@ query($id: ID!, $first: Int, $after: CursorKey, $filter: CookieConsentRecordFilt
`
type consentRecord struct {
ID string `json:"id"`
VisitorID string `json:"visitorId"`
Action string `json:"action"`
SDKVersion string `json:"sdkVersion"`
Regulation string `json:"regulation"`
CountryCode string `json:"countryCode"`
CreatedAt string `json:"createdAt"`
ID string `json:"id"`
VisitorID string `json:"visitorId"`
Action string `json:"action"`
SDKVersion string `json:"sdkVersion"`
Regulation *string `json:"regulation"`
CountryCode *string `json:"countryCode"`
CreatedAt string `json:"createdAt"`
}
func NewCmdList(f *cmdutil.Factory) *cobra.Command {
@@ -154,7 +154,15 @@ func NewCmdList(f *cmdutil.Factory) *cobra.Command {
rows := make([][]string, 0, len(records))
for _, r := range records {
rows = append(rows, []string{r.ID, r.VisitorID, r.Action, r.SDKVersion, r.Regulation, r.CountryCode, r.CreatedAt})
regulation := "-"
if r.Regulation != nil {
regulation = *r.Regulation
}
countryCode := "-"
if r.CountryCode != nil {
countryCode = *r.CountryCode
}
rows = append(rows, []string{r.ID, r.VisitorID, r.Action, r.SDKVersion, regulation, countryCode, r.CreatedAt})
}
t := cmdutil.NewTable("ID", "VISITOR ID", "ACTION", "SDK VERSION", "REGULATION", "COUNTRY", "CREATED AT").Rows(rows...)

View File

@@ -54,8 +54,8 @@ type viewResponse struct {
ConsentData string `json:"consentData"`
Action string `json:"action"`
SdkVersion string `json:"sdkVersion"`
Regulation string `json:"regulation"`
CountryCode string `json:"countryCode"`
Regulation *string `json:"regulation"`
CountryCode *string `json:"countryCode"`
CreatedAt string `json:"createdAt"`
} `json:"node"`
}
@@ -119,8 +119,12 @@ func NewCmdView(f *cmdutil.Factory) *cobra.Command {
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Visitor ID:"), v.VisitorID)
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Action:"), v.Action)
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("SDK Version:"), v.SdkVersion)
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Regulation:"), v.Regulation)
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Country Code:"), v.CountryCode)
if v.Regulation != nil {
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Regulation:"), *v.Regulation)
}
if v.CountryCode != nil {
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Country Code:"), *v.CountryCode)
}
if v.IPAddress != nil && *v.IPAddress != "" {
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("IP Address:"), *v.IPAddress)
}