/** * Copyright 2013 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * @providesModule AnalyticsEventPluginFactory * * This module provides a factory method to create the AnalyticsEventPlugin that * can be used to track the usage of React components that are of interest to * the user. * * In order to enable a component for analytics tracking, you need to specify * two additional attributes to the component when you describe the structure of * your component in the render() method: * * 1. 'data-analytics-id': This represents a unique ID that the analytics module * will use to identify this component in all the analytics data. Note that * this is independent of the ref or the DOM id of the element. Over the * lifetime of the product, even if the component id or ref needs to be * changed, as long as you can ensure the analytics ID doesnt change, the * historical data can be correlated. Also note that React does NOT do * anything to guarantee or enforce uniqueness of this ID. If its not unique * the analytics data reported will be incorrect. * * 2. 'data-analytics-events': This is a comma separated list of DOM events that * you want analytics on. React currently supports tracking only on a * distinct set of events (See topLevelTypesToAnalyticsEvent). * If the list contains an event that React does not recognize for analytics * tracking, in __DEV__, an error will be thrown. Note that it is case * sensitive and space sensitive. * * By default the AnalyticsEventPlugin is NOT enabled in React. To use it, you * need to create the plugin using the factory method and add it to the list of * Plugins maintained in the EventPluginHub before your component is rendered. * As creation parameters you can specify two arguments: * * 1. callback: This is a required parameter. In __DEV__, an error will be * thrown if this param is missing. The callback will be called with the * analyticsData as an argument. The analyticsData will contain one property * per every React component, identified by its data-analytics-id. The value * of this property will be an object containing properties corresponding to * each of the comma separated events specified in data-analytics-events. * * For example, if you have: *