Skip to content

Commit 2e5eaef

Browse files
feat: Return uptime_ms for deleted browser sessions
1 parent beb89a7 commit 2e5eaef

5 files changed

Lines changed: 40 additions & 3 deletions

File tree

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 101
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-e6e88da6e6fffe12873a108ca33ebfbd59b85232078ab0e4dca5c8273c131053.yml
3-
openapi_spec_hash: 4f22b8ec1d048cc74a751e3ab39b943c
4-
config_hash: 6bac5bbe5d5fc26e0912e33f646adb14
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-586ddc36cd621b3705138de66a0e7d28d1c1485064aa85ce09ce24edb50003ef.yml
3+
openapi_spec_hash: 8e8d4bd31e4920303e7ec9ce313fb1ec
4+
config_hash: 81f143f4bee47ae7b0b8357551babadf

api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ Response Types:
7676

7777
- <a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk#BrowserPersistence">BrowserPersistence</a>
7878
- <a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk#BrowserPoolRef">BrowserPoolRef</a>
79+
- <a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk#BrowserUsage">BrowserUsage</a>
7980
- <a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk#Profile">Profile</a>
8081
- <a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk#BrowserNewResponse">BrowserNewResponse</a>
8182
- <a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk">kernel</a>.<a href="https://pkg.go.dev/github.com/kernel/kernel-go-sdk#BrowserGetResponse">BrowserGetResponse</a>

browser.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,24 @@ func (r *BrowserPoolRef) UnmarshalJSON(data []byte) error {
222222
return apijson.UnmarshalRoot(data, r)
223223
}
224224

225+
// Session usage metrics.
226+
type BrowserUsage struct {
227+
// Time in milliseconds the session was actively running.
228+
UptimeMs int64 `json:"uptime_ms" api:"required"`
229+
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
230+
JSON struct {
231+
UptimeMs respjson.Field
232+
ExtraFields map[string]respjson.Field
233+
raw string
234+
} `json:"-"`
235+
}
236+
237+
// Returns the unmodified JSON received from the API
238+
func (r BrowserUsage) RawJSON() string { return r.JSON.raw }
239+
func (r *BrowserUsage) UnmarshalJSON(data []byte) error {
240+
return apijson.UnmarshalRoot(data, r)
241+
}
242+
225243
// Browser profile metadata.
226244
type Profile struct {
227245
// Unique identifier for the profile
@@ -284,6 +302,8 @@ type BrowserNewResponse struct {
284302
Profile Profile `json:"profile"`
285303
// ID of the proxy associated with this browser session, if any.
286304
ProxyID string `json:"proxy_id"`
305+
// Session usage metrics.
306+
Usage BrowserUsage `json:"usage"`
287307
// Initial browser window size in pixels with optional refresh rate. If omitted,
288308
// image defaults apply (1920x1080@25). Arbitrary viewport dimensions are accepted,
289309
// but the following configurations are known-good and fully tested: 2560x1440@10,
@@ -309,6 +329,7 @@ type BrowserNewResponse struct {
309329
Pool respjson.Field
310330
Profile respjson.Field
311331
ProxyID respjson.Field
332+
Usage respjson.Field
312333
Viewport respjson.Field
313334
ExtraFields map[string]respjson.Field
314335
raw string
@@ -353,6 +374,8 @@ type BrowserGetResponse struct {
353374
Profile Profile `json:"profile"`
354375
// ID of the proxy associated with this browser session, if any.
355376
ProxyID string `json:"proxy_id"`
377+
// Session usage metrics.
378+
Usage BrowserUsage `json:"usage"`
356379
// Initial browser window size in pixels with optional refresh rate. If omitted,
357380
// image defaults apply (1920x1080@25). Arbitrary viewport dimensions are accepted,
358381
// but the following configurations are known-good and fully tested: 2560x1440@10,
@@ -378,6 +401,7 @@ type BrowserGetResponse struct {
378401
Pool respjson.Field
379402
Profile respjson.Field
380403
ProxyID respjson.Field
404+
Usage respjson.Field
381405
Viewport respjson.Field
382406
ExtraFields map[string]respjson.Field
383407
raw string
@@ -422,6 +446,8 @@ type BrowserUpdateResponse struct {
422446
Profile Profile `json:"profile"`
423447
// ID of the proxy associated with this browser session, if any.
424448
ProxyID string `json:"proxy_id"`
449+
// Session usage metrics.
450+
Usage BrowserUsage `json:"usage"`
425451
// Initial browser window size in pixels with optional refresh rate. If omitted,
426452
// image defaults apply (1920x1080@25). Arbitrary viewport dimensions are accepted,
427453
// but the following configurations are known-good and fully tested: 2560x1440@10,
@@ -447,6 +473,7 @@ type BrowserUpdateResponse struct {
447473
Pool respjson.Field
448474
Profile respjson.Field
449475
ProxyID respjson.Field
476+
Usage respjson.Field
450477
Viewport respjson.Field
451478
ExtraFields map[string]respjson.Field
452479
raw string
@@ -491,6 +518,8 @@ type BrowserListResponse struct {
491518
Profile Profile `json:"profile"`
492519
// ID of the proxy associated with this browser session, if any.
493520
ProxyID string `json:"proxy_id"`
521+
// Session usage metrics.
522+
Usage BrowserUsage `json:"usage"`
494523
// Initial browser window size in pixels with optional refresh rate. If omitted,
495524
// image defaults apply (1920x1080@25). Arbitrary viewport dimensions are accepted,
496525
// but the following configurations are known-good and fully tested: 2560x1440@10,
@@ -516,6 +545,7 @@ type BrowserListResponse struct {
516545
Pool respjson.Field
517546
Profile respjson.Field
518547
ProxyID respjson.Field
548+
Usage respjson.Field
519549
Viewport respjson.Field
520550
ExtraFields map[string]respjson.Field
521551
raw string

browserpool.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ type BrowserPoolAcquireResponse struct {
260260
Profile Profile `json:"profile"`
261261
// ID of the proxy associated with this browser session, if any.
262262
ProxyID string `json:"proxy_id"`
263+
// Session usage metrics.
264+
Usage BrowserUsage `json:"usage"`
263265
// Initial browser window size in pixels with optional refresh rate. If omitted,
264266
// image defaults apply (1920x1080@25). Arbitrary viewport dimensions are accepted,
265267
// but the following configurations are known-good and fully tested: 2560x1440@10,
@@ -285,6 +287,7 @@ type BrowserPoolAcquireResponse struct {
285287
Pool respjson.Field
286288
Profile respjson.Field
287289
ProxyID respjson.Field
290+
Usage respjson.Field
288291
Viewport respjson.Field
289292
ExtraFields map[string]respjson.Field
290293
raw string

invocation.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,8 @@ type InvocationListBrowsersResponseBrowser struct {
567567
Profile Profile `json:"profile"`
568568
// ID of the proxy associated with this browser session, if any.
569569
ProxyID string `json:"proxy_id"`
570+
// Session usage metrics.
571+
Usage BrowserUsage `json:"usage"`
570572
// Initial browser window size in pixels with optional refresh rate. If omitted,
571573
// image defaults apply (1920x1080@25). Arbitrary viewport dimensions are accepted,
572574
// but the following configurations are known-good and fully tested: 2560x1440@10,
@@ -592,6 +594,7 @@ type InvocationListBrowsersResponseBrowser struct {
592594
Pool respjson.Field
593595
Profile respjson.Field
594596
ProxyID respjson.Field
597+
Usage respjson.Field
595598
Viewport respjson.Field
596599
ExtraFields map[string]respjson.Field
597600
raw string

0 commit comments

Comments
 (0)