Analytics integration for Redux and ngrx/store
If you're using Redux or ngrx/store to manage your app's state, you can useRedux Beacon to tap into your dispatched actions and map them to events that areconsumable by an analytics service (e.g. Google Analytics). With Redux Beaconyour entire global state life-cycle becomes trackable.
Redux Beacon is lightweight. The core Redux Beacon module is tiny (~ 1KB), and each target, extension, andutil, is either around the same size or smaller.
You can use Redux Beacon with any framework. Redux Beacon doesn't depend on anyframework, you can use Redux Beacon with React, Angular, React Native, Vue orjust plain JavaScript.
You can send analytics anywhere. We have prebuilt targets for the mostpopular analytics services, you can also build your own custom targets if youneed to.
You can track analytics offline. Redux Beacon providesextensions for tracking analytics during intermittent outages inconnectivity. These extensions save events in a persistent store when offline(e.g indexedDB). When back online, the extensions purge the store and passthe events off to a target. Read more about offline event collection in thedocs.
Version | Package | |
---|---|---|
redux-beacon-matomo-tag-manager | ||
redux-beacon-react-native-appsflyer |
If you don't see your analytics target listed it might be worth a shot doing a quick search on npmjs.org. If all else fails you can always build and provide your own custom Targets!
Integration | Integrates with | Description |
---|---|---|
redux-dynamic-modules-beacon | redux-dynamic-modules | Redux Dynamic Modules is a library that allows to modularize redux code. With help of this extension events do not have to be defined in one central location but can be defined for each module individually. |
Step 1. Pick out a target (see above)
Step 2. Pick out some events you want to track from your target's Event Definitions section
Step 3. Match the events to action types (see below)
Track a page view on each ROUTE_CHANGED
action
const eventsMap = {
'ROUTE_CHANGED': trackPageView(action => ({
page: action.payload.routerState.url,
})),
}
Track an event on each VIDEO_SELECTED
action, use the state before the actionand the state after the action to hydrate the analytics event
const eventsMap = {
'VIDEO_SELECTED': trackEvent((action, prevState, nextState) => ({
category: 'Videos',
action: action.type,
label: prevState.videos.currentCampaign,
value: nextState.videos.numVideosSelected,
}))
}
Track an event on every action using the special '*' key
const eventsMap = {
'*': trackEvent(action => ({
category: 'redux',
action: action.type,
})),
}
Track multiple events on each VIDEO_PLAYED
action using the combineEvents
util
const eventsMap = {
'VIDEO_PLAYED': combineEvents(
trackTiming(action => ({
category: 'Videos',
action: 'load',
value: action.payload.loadTime,
}))
trackEvent(() => ({
category: 'Videos',
action: 'play'
})),
),
}
Track an event on each 'VIDEO_SEARCHED' action, but throttle it with the debounceEvent util so it doesn't fire as often
const eventsMap = {
'VIDEO_SEARCHED': debounceEvent(300,
trackEvent(action => ({
category: 'Videos',
action: 'search',
label: action.payload.searchTerm,
}))
),
}
The trackPageView
, trackEvent
, and trackTiming
functions used above arecalled eventDefinitions
and are what you use to create events that areconsumable by an analytics service (a.k.a "target"). Each target will have itsown set of eventDefinitions
that you can use and customize.
Don't like the idea of using an object to map actions?
You can use a function...
const pageView = trackPageView(action => ({
page: action.payload.routerState.url,
}));
const videoLoadTime = trackTiming(action => ({
category: 'Videos',
action: 'load',
value: action.payload.loadTime,
}));
const videoPlayed = trackEvent(() => ({
category: 'Videos',
action: 'play'
}));
const eventsMapper = (action) => {
switch(action.type) {
case 'ROUTE_CHANGED':
return pageView;
case 'VIDEO_PLAYED':
return [videoLoadTime, videoPlayed]
default:
return [];
}
}
Version | Package | |
---|---|---|
|
@redux-beacon/logger | |
|
@redux-beacon/combine-events | |
|
@redux-beacon/ensure | |
|
@redux-beacon/debounce-event | |
|
@redux-beacon/offline-web | |
|
@redux-beacon/offline-react-native |
Redux中间件与异步操作 Redux的使用方式是用户发出 Action,Reducer 函数算出新的 State,View 重新渲染。但是应该考虑到异步操作怎么执行,Action 发出以后,Reducer 立即算出 State,这叫做同步;Action 发出以后,过一段时间再执行 Reducer,这就是异步。这时就需要使用中间件(middleware)进行异步操作。 中间件就是一个函数,对sto
React-Redux的介绍与使用 React-Redux是为了方便使用Redux而封装的一个react库,你可以使用它将组建分为UI组件(只负责渲染页面),和容器组件(负责管理数据,业务逻辑)。 1.Provider Provider的作用是把store提供给子组件,让其子组件能获取到store import React from 'react'; import ReactDOM from 'r
问题内容: 我正在使用React + Flux。我们的团队计划从助焊剂转变为还原剂。Redux对于来自助焊剂世界的我非常困惑。在 磁通控制中, 从 **组件- 操作->存储和存储更新返回组件 很** 简单。它很简单,也很清楚。 但在redux中令人困惑。这里没有商店,是的,有些例子没有使用商店。我经历了一些教程,看来每个人都有自己的实现风格。有些正在使用容器,有些则没有。(我不知道这个Contai
对于如何使用React路由器的。 换句话说,如果您使用Redux的连接一个组件,那么如何放置应该在调度特定操作后触发的按钮? 为了澄清这个问题,这里是我的一个实验片段。。。 如您所见,一旦通过将帖子添加到Redux的状态,页面就需要通过历史记录移动到。推 根据Redux的文档,容器用于更新状态(以及获取数据)。因此,哑组件不应该放置任何类似。 有什么方法比上面的代码更好? 如有任何建议,将不胜感激
Dan Abramov 在 React Europe 2015 上作了一场令人印象深刻的演示 Hot Reloading with Time Travel,之后 Redux 迅速成为最受人关注的 Flux 实现之一。 Redux 把自己标榜为一个“可预测的状态容器”,其实也是 Flux 里面“单向数据流”的思想,只是它充分利用函数式的特性,让整个实现更加优雅纯粹,使用起来也更简单。 Redux(o
Redux 是 JavaScript 应用程序的可预测状态容器。(不要与WordPress框架——Redux框架混淆。) 它可以帮助您编写行为一致、在不同环境(客户机、服务器和本机)中运行且易于测试的应用程序。除此之外,它还提供了很好的开发体验,例如实时代码编辑和时间旅行调试器的结合。 您可以将 Redux 与 React 一起使用,或与任何其他视图库一起使用。 Actions: // Still
本文向大家介绍redux Redux-thunk:基础知识,包括了redux Redux-thunk:基础知识的使用技巧和注意事项,需要的朋友参考一下 示例 虽然redux本身是完全同步的,但是您可以使用中间件redux-thunk来处理异步操作。 “ thunk”是回调的另一个名称。该函数通常作为参数传递,以便以后调用。 要使用,请将中间件应用于您的redux存储: 这使您可以将thunk传递给
本文向大家介绍一篇文章介绍redux、react-redux、redux-saga总结,包括了一篇文章介绍redux、react-redux、redux-saga总结的使用技巧和注意事项,需要的朋友参考一下 本篇主要将react全家桶的产品非常精炼的提取了核心内容,精华程度堪比精油。各位大人,既然来了,客官您坐,来人,给客官看茶~~ redux 前言 首先,本篇文章要求您对js,react等知识有
目录 为何组件没有被重新渲染、或者 mapStateToProps 没有运行? 为何组件频繁的重新渲染? 怎样使 mapStateToProps 执行更快? 为何不在被连接的组件中使用 this.props.dispatch ? 应该只连接到顶层组件吗,或者可以在组件树中连接到不同组件吗? React Redux 为何组件没有被重新渲染、或者 mapStateToProps 没有运行? 目前来看,
An implementation of the @handsontable/react component with a readOnly toggle switch and the Redux state manager implemented.import React from 'react'; import ReactDOM from 'react-dom'; import {create