Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
react-i13n
Advanced tools
React I13n provides a performant and scalable solution to application instrumentation.
react-i13n
provides a performant, scalable and pluggable approach to instrumenting your React application.
Typically, you have to manually add instrumentation code throughout your application, e.g., hooking up onClick
handlers to the links you want to track. react-i13n
provides a simplified approach by letting you define the data model you want to track and handling the beaconing for you.
react-i13n
does this by building an instrumentation tree that mirrors your applications React component hierarchy. All you have to do is leverage our React component or mixin to denote which components should fire the tracking events.
i13nModel
) can be a plain JS object or custom function. This means you can dynamically change tracking data without causing unnecessary re-renders.I13nNode
. Which means that data will only be beaconed when the node is in the viewport. This reduces the network usage for the user and provides better tracking details.dangerouslySetInnerHTML
. We scan the tags you define on client side, track them and build nodes for them in i13n tree.npm install react-i13n --save
var React = require('react');
var ReactI13n = require('react-i13n').ReactI13n;
var setupI13n = require('react-i13n').setupI13n;
var somePlugin = require('some-i13n-plugin'); // a plugin for a certain instrumentation mechanism
// create a i13n anchor for link tracking
// or you can use the mixin to track an existing component
var createI13nNode = require('react-i13n').createI13nNode;
var I13nAnchor = createI13nNode('a', {
isLeafNode: true,
bindClickEvent: true,
follow: true
});
var DemoApp = React.createClass({
componentWillMount: function () {
this.props.i13n.executeEvent('pageview', {}); // fire a custom event
},
render: function () {
...
<I13nAnchor href="http://foo.bar" i13nModel={{action: 'click', label: 'foo'}}>...</I13nAnchor>
// this link will be tracked, and the click event handlers provided by the plugin will get the model data as
// {site: 'foo', action: 'click', label: 'foo'}
}
});
var I13nDempApp = setupI13n(DemoApp, {
rootModelData: {site: 'foo'},
isViewportEnabled: true
}, [somePlugin]);
// then you could use I13nDemoApp to render you app
Or follow our guide and create your own.
react-i13n
builds the instrumentation tree by leveraging the undocumented React context
feature and the componentWillMount
life cycle event. Each component can define a i13nModel
prop that defines the data it needs to track. This approach is more performant, as it means you do not need additional DOM manipulation when you want to collect the tracking data values for sending out beacons.
Since the i13n data is defined at each level. Whenever you want to get the i13nModel
for a certain node, react-i13n
will traverse back up the tree to merge all the i13nModel
information in the hierarchy. Since the tree is already built, you do not need extra DOM access, which is cheap and efficient.
Take a look at Rafael Martins' slides from a recent React meetup to understand more.
Add i13n_debug=1
to the request url, you will get the i13n model for each i13n node
directly shown on the page. It shows the information for each model data and where the data inherits from.
react-i13n
with it.react-i13n
and react-i13n-ga.We check process.env.NODE_ENV !== 'production'
to determine if we should do some action like print out warning massage, that means it's recommended to use tools like envify
as part of your build process to strip out non-production code for production build.
Use DefinePlugin
to define the value for process.env
.
Example of the webpack configuration:
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
}),
...
]
Similar to webpack, you can also use envify
to set process.env.NODE_ENV to the desired environment
$ browserify index.js -t [ envify --NODE_ENV production ] | uglifyjs -c > bundle.js
grunt unit
to run unit testsgrunt cover
to generate the istanbul coverage reportgrunt functional-debug
http://127.0.0.1:9999/tests/functional/page.html
saucelabs
:
grunt functional
This software is free to use under the Yahoo Inc. BSD license. See the LICENSE file for license text and copyright information.
FAQs
React I13n provides a performant and scalable solution to application instrumentation.
We found that react-i13n demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.