Được TopGit lập chỉ mục từ metadata GitHub: nfl/react-metrics có 615 sao, viết chủ yếu bằng JavaScript. An analytics module for React
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
React Metrics depends on Promise to be available in browser. If your application support the browser which doesn't support Promise, please include the polyfill.
Getting Started
1. Configure Metrics
Refer to the docs for more information on configuration.
// Application.js
import {metrics} from "react-metrics";
const config = {
vendors: [{
name: "Google Analytics",
api: new GoogleAnalytics({
trackingId: "UA-********-*"
})
}],
pageViewEvent: "pageLoad",
pageDefaults: () => {
return {
siteName: "My Web Site",
...
};
}
}
2. Wrap Application Level Component
Compose your top level application component with metrics in order to provide metrics to all components and automatically enable page view tracking.
react-metrics does not automatically supply any vendor analytics. You need to integrate with an analytics vendor to actually track something for reporting.
Refer to Vendor Examples for Omniture, Google Analytics and other implementations.
Also check out the awesome segmentio library which provides a lot of third party analytics vendors.
Advanced Usage
Override Default Page View Tracking
Use the @exposeMetrics decorator and willTrackPageView() methods on a route-handling component to override the default page view tracking behavior and pageDefaults data.
// PageComponent.js
// Must be a "route handling" component: <Route path="my-page" component={PageComponent}/>
import {exposeMetrics, PropTypes} from "react-metrics";
@exposeMetrics
class PageComponent extends React.Component {
static contextTypes = {
metrics: PropTypes.metrics
}
static willTrackPageView() {
// first, suppress the automatic call.
return false;
}
componentDidMount() {
const {value1, value2} = this.props;
this.context.metrics.pageView({value1, value2});
}
render () {
...
}
}
Example: add custom data to automatic page view tracking.
// PageComponent.js "route-handler
// A route handling component: <Route path="my-page" component={PageComponent}/>
import {exposeMetrics} from "react-metrics";
@exposeMetrics
class PageComponent extends React.Component {
static willTrackPageView(routeState) {
// return a promise that resolves to custom data.
return yourPromise.then(data => {
// data gets merged with `pageDefaults` object
return data;
});
}
render () {
...
}
}
Imperative Custom Event Tracking
Use this.context.metrics.track() to trigger custom event tracking as an alternative to declarative custom link tracking.
Define metrics as a contextType in your component and trigger custom track events using metrics.track().
react-metrics provides a low level factory API; this is convenient for exposing an instance of the metrics API outside of a React component.
Use createMetrics to create a metrics instance and expose the metrics.api.
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/nfl/react-metrics là nguồn chính thức.
nfl/react-metrics có phải mã nguồn mở không?
Có — nfl/react-metrics phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/nfl/react-metrics.
nfl/react-metrics có website riêng không?
TopGit chưa ghi nhận URL trang chủ cho nfl/react-metrics. Phần README ở tab phía trên thường có link demo, hoặc xem mô tả GitHub của repo.
nfl/react-metrics dùng license gì?
nfl/react-metrics phát hành theo license MIT. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
nfl/react-metrics là gì?
nfl/react-metrics (nfl/react-metrics) là dự án JavaScript trên GitHub. Theo mô tả gốc: An analytics module for React
Đọc đầy đủ README ở tab phía trên.
Chưa chắc react-metrics có hợp với bạn?
Để ChatGPT, Claude hoặc Perplexity tìm hiểu giúp — bấm bên dưới và xem AI nói gì về react-metrics.