| use turbo_rcstr::{RcStr, rcstr}; |
| use turbo_tasks::{Vc, fxindexmap}; |
| use turbopack_core::diagnostics::{Diagnostic, DiagnosticPayload}; |
|
|
| |
| |
| |
| |
| |
| #[turbo_tasks::value(shared)] |
| pub struct NextFeatureTelemetry { |
| pub event_name: RcStr, |
| pub feature_name: RcStr, |
| pub enabled: bool, |
| } |
|
|
| impl NextFeatureTelemetry { |
| pub fn new(feature_name: RcStr, enabled: bool) -> Self { |
| NextFeatureTelemetry { |
| event_name: rcstr!("EVENT_BUILD_FEATURE_USAGE"), |
| feature_name, |
| enabled, |
| } |
| } |
| } |
|
|
| #[turbo_tasks::value_impl] |
| impl Diagnostic for NextFeatureTelemetry { |
| #[turbo_tasks::function] |
| fn category(&self) -> Vc<RcStr> { |
| Vc::cell(rcstr!("NextFeatureTelemetry_category_tbd")) |
| } |
|
|
| #[turbo_tasks::function] |
| fn name(&self) -> Vc<RcStr> { |
| Vc::cell(self.event_name.clone()) |
| } |
|
|
| #[turbo_tasks::function] |
| fn payload(&self) -> Vc<DiagnosticPayload> { |
| Vc::cell(fxindexmap! { |
| self.feature_name.clone() => |
| self.enabled.to_string().into(), |
| }) |
| } |
| } |
|
|
| |
| |
| #[turbo_tasks::value(shared)] |
| pub struct ModuleFeatureTelemetry { |
| pub event_name: RcStr, |
| pub feature_name: RcStr, |
| pub invocation_count: usize, |
| } |
|
|
| impl ModuleFeatureTelemetry { |
| pub fn new(feature_name: RcStr, invocation_count: usize) -> Self { |
| ModuleFeatureTelemetry { |
| event_name: rcstr!("EVENT_BUILD_FEATURE_USAGE"), |
| feature_name, |
| invocation_count, |
| } |
| } |
| } |
|
|
| #[turbo_tasks::value_impl] |
| impl Diagnostic for ModuleFeatureTelemetry { |
| #[turbo_tasks::function] |
| fn category(&self) -> Vc<RcStr> { |
| Vc::cell(rcstr!("ModuleFeatureTelemetry_category_tbd")) |
| } |
|
|
| #[turbo_tasks::function] |
| fn name(&self) -> Vc<RcStr> { |
| Vc::cell(self.event_name.clone()) |
| } |
|
|
| #[turbo_tasks::function] |
| fn payload(&self) -> Vc<DiagnosticPayload> { |
| Vc::cell(fxindexmap! { |
| self.feature_name.clone() => |
| self.invocation_count.to_string().into(), |
| }) |
| } |
| } |
|
|