diff --git a/proto/autogenerated/client.md b/proto/autogenerated/client.md index e648b2b6..277807ee 100644 --- a/proto/autogenerated/client.md +++ b/proto/autogenerated/client.md @@ -1343,6 +1343,7 @@ The nostr server will send back a message response, and inside the body there wi - __app_id__: _string_ - __metrics_name__: _string_ - __page__: _number_ + - __request_id__: _number_ *this field is optional ### UpdateChannelPolicyRequest - __policy__: _[ChannelPolicy](#ChannelPolicy)_ diff --git a/proto/autogenerated/go/types.go b/proto/autogenerated/go/types.go index b4479edb..11158b1b 100644 --- a/proto/autogenerated/go/types.go +++ b/proto/autogenerated/go/types.go @@ -559,6 +559,7 @@ type SingleUsageMetricReq struct { App_id string `json:"app_id"` Metrics_name string `json:"metrics_name"` Page int64 `json:"page"` + Request_id int64 `json:"request_id"` } type UpdateChannelPolicyRequest struct { Policy *ChannelPolicy `json:"policy"` diff --git a/proto/autogenerated/ts/types.ts b/proto/autogenerated/ts/types.ts index 042ebb35..76655f9a 100644 --- a/proto/autogenerated/ts/types.ts +++ b/proto/autogenerated/ts/types.ts @@ -3191,13 +3191,16 @@ export type SingleUsageMetricReq = { app_id: string metrics_name: string page: number + request_id?: number } -export const SingleUsageMetricReqOptionalFields: [] = [] +export type SingleUsageMetricReqOptionalField = 'request_id' +export const SingleUsageMetricReqOptionalFields: SingleUsageMetricReqOptionalField[] = ['request_id'] export type SingleUsageMetricReqOptions = OptionsBaseMessage & { - checkOptionalsAreSet?: [] + checkOptionalsAreSet?: SingleUsageMetricReqOptionalField[] app_id_CustomCheck?: (v: string) => boolean metrics_name_CustomCheck?: (v: string) => boolean page_CustomCheck?: (v: number) => boolean + request_id_CustomCheck?: (v?: number) => boolean } export const SingleUsageMetricReqValidate = (o?: SingleUsageMetricReq, opts: SingleUsageMetricReqOptions = {}, path: string = 'SingleUsageMetricReq::root.'): Error | null => { if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message') @@ -3212,6 +3215,9 @@ export const SingleUsageMetricReqValidate = (o?: SingleUsageMetricReq, opts: Sin if (typeof o.page !== 'number') return new Error(`${path}.page: is not a number`) if (opts.page_CustomCheck && !opts.page_CustomCheck(o.page)) return new Error(`${path}.page: custom check failed`) + if ((o.request_id || opts.allOptionalsAreSet || opts.checkOptionalsAreSet?.includes('request_id')) && typeof o.request_id !== 'number') return new Error(`${path}.request_id: is not a number`) + if (opts.request_id_CustomCheck && !opts.request_id_CustomCheck(o.request_id)) return new Error(`${path}.request_id: custom check failed`) + return null } diff --git a/proto/service/structs.proto b/proto/service/structs.proto index 4fa295e8..2e74b8fa 100644 --- a/proto/service/structs.proto +++ b/proto/service/structs.proto @@ -45,6 +45,7 @@ message SingleUsageMetricReq { string app_id = 1; string metrics_name = 2; int64 page = 3; + optional int64 request_id = 4; } message UsageMetric { diff --git a/src/services/webRTC/index.ts b/src/services/webRTC/index.ts index 5bdf2ba6..74c8b655 100644 --- a/src/services/webRTC/index.ts +++ b/src/services/webRTC/index.ts @@ -89,7 +89,7 @@ export default class webRTC { return } const res = await this.storage.metricsEventStorage.LoadRawMetricsFile(j.app_id, j.metrics_name, j.page) - const id = Math.floor(Math.random() * 2_000_000_000) + const id = j.request_id || Math.floor(Math.random() * 2_000_000_000) let i = 0 const packets: Buffer[] = [] while (i < res.length) {