Download next.js/crates/next-core/src/next_telemetry.rs from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 2.47 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/crates/next-core/src/next_telemetry.rs
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/crates/next-core/src/next_telemetry.rs
-
curl -L -o next_telemetry.rs https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/crates/next-core/src/next_telemetry.rs
2.47 kB
| use turbo_rcstr::{RcStr, rcstr}; | |
| use turbo_tasks::{Vc, fxindexmap}; | |
| use turbopack_core::diagnostics::{Diagnostic, DiagnosticPayload}; | |
| /// A structure that keeps track of whether a particular Next.js feature is | |
| /// enabled for the telemetry. | |
| /// | |
| /// The original implementation code can be found | |
| /// [here](https://github.com/vercel/next.js/blob/9da305fe320b89ee2f8c3cfb7ecbf48856368913/packages/next/src/build/webpack-config.ts#L2516). | |
| 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, | |
| } | |
| } | |
| } | |
| impl Diagnostic for NextFeatureTelemetry { | |
| fn category(&self) -> Vc<RcStr> { | |
| Vc::cell(rcstr!("NextFeatureTelemetry_category_tbd")) | |
| } | |
| fn name(&self) -> Vc<RcStr> { | |
| Vc::cell(self.event_name.clone()) | |
| } | |
| fn payload(&self) -> Vc<DiagnosticPayload> { | |
| Vc::cell(fxindexmap! { | |
| self.feature_name.clone() => | |
| self.enabled.to_string().into(), | |
| }) | |
| } | |
| } | |
| /// A struct represent telemetry event for the feature usage, | |
| /// referred as `importing` a certain module. (i.e importing @next/image) | |
| 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, | |
| } | |
| } | |
| } | |
| impl Diagnostic for ModuleFeatureTelemetry { | |
| fn category(&self) -> Vc<RcStr> { | |
| Vc::cell(rcstr!("ModuleFeatureTelemetry_category_tbd")) | |
| } | |
| fn name(&self) -> Vc<RcStr> { | |
| Vc::cell(self.event_name.clone()) | |
| } | |
| fn payload(&self) -> Vc<DiagnosticPayload> { | |
| Vc::cell(fxindexmap! { | |
| self.feature_name.clone() => | |
| self.invocation_count.to_string().into(), | |
| }) | |
| } | |
| } | |