<commit_before>import React from "react";
import PropTypes from "prop-types";
import { Button, StyleSheet, View } from "react-native";
// eslint-disable-next-line import/no-extraneous-dependencies
import { action } from "@storybook/addon-actions";
// eslint-disable-next-line import/no-extraneous-dependencies
import { storiesOf } from "@storybook/react-native";
import {
  withTrackRender,
  withTrackingContext,
  withTrackEvents
} from "./tracking";

const storybookReporter = action("analytics-event");

const styles = StyleSheet.create({
  box: {
    borderWidth: 2,
    borderColor: "black",
    borderStyle: "solid",
    height: 200,
    width: 200
  }
});
const Box = props => (
  <View style={[styles.box, { backgroundColor: props.color }]} />
);
Box.propTypes = {
  color: PropTypes.string.isRequired
};

const BoxWithButtons = props => (
  <View style={[styles.box, { backgroundColor: props.color }]}>
    <Button onPress={() => props.onPress("button 1")} title="Press me" />
    <Button
      color="limegreen"
      onPress={() => props.onPress("button 2")}
      title="Or me"
    />
  </View>
);
BoxWithButtons.propTypes = {
  color: PropTypes.string.isRequired,
  onPress: PropTypes.func.isRequired
};

storiesOf("Tracking", module)
  .add("Render tracking", () => {
    const BoxWithTrackingAndContext = withTrackingContext(
      withTrackRender(Box, {
        trackingName: "ColoredBox",
        getAttrs: props => ({ color: props.color })
      }),
      { trackingObject: "TrackRenderStory" }
    );

    return (
      <BoxWithTrackingAndContext
        analyticsStream={storybookReporter}
        color="red"
      />
    );
  })
  .add("Event tracking", () => {
    const BoxWithPressTrackingAndContext = withTrackingContext(
      withTrackEvents(BoxWithButtons, {
        analyticsEvents: [
          {
            eventName: "onPress",
            actionName: "Pressed",
            trackingName: "ColoredBox",
            getAttrs: (props, eventArgs) => ({ button: eventArgs[0] })
          }
        ]
      }),
      { trackingObject: "TrackRenderStory" }
    );

    return (
      <BoxWithPressTrackingAndContext
        analyticsStream={storybookReporter}
        color="red"
        onPress={() => {}}
      />
    );
  });<commit_msg>chore: remove track render story (#368)<commit_after>import React from "react";
import PropTypes from "prop-types";
import { Button, StyleSheet, View } from "react-native";
// eslint-disable-next-line import/no-extraneous-dependencies
import { action } from "@storybook/addon-actions";
// eslint-disable-next-line import/no-extraneous-dependencies
import { storiesOf } from "@storybook/react-native";
import { withTrackingContext, withTrackEvents } from "./tracking";

const storybookReporter = action("analytics-event");

const styles = StyleSheet.create({
  box: {
    borderWidth: 2,
    borderColor: "black",
    borderStyle: "solid",
    height: 200,
    width: 200
  }
});
const Box = props => (
  <View style={[styles.box, { backgroundColor: props.color }]} />
);
Box.propTypes = {
  color: PropTypes.string.isRequired
};

const BoxWithButtons = props => (
  <View style={[styles.box, { backgroundColor: props.color }]}>
    <Button onPress={() => props.onPress("button 1")} title="Press me" />
    <Button
      color="limegreen"
      onPress={() => props.onPress("button 2")}
      title="Or me"
    />
  </View>
);
BoxWithButtons.propTypes = {
  color: PropTypes.string.isRequired,
  onPress: PropTypes.func.isRequired
};

const BoxWithTrackingContext = withTrackingContext(Box, {
  trackingObject: "TrackRenderStory",
  getAttrs: props => ({ color: props.color })
});

const BoxWithPressTrackingAndContext = withTrackingContext(
  withTrackEvents(BoxWithButtons, {
    analyticsEvents: [
      {
        eventName: "onPress",
        actionName: "Pressed",
        trackingName: "ColoredBox",
        getAttrs: (props, eventArgs) => ({ button: eventArgs[0] })
      }
    ]
  }),
  { trackingObject: "TrackRenderStory" }
);

storiesOf("Tracking", module)
  .add("Page tracking", () => (
    <BoxWithTrackingContext analyticsStream={storybookReporter} color="red" />
  ))
  .add("Event tracking", () => (
    <BoxWithPressTrackingAndContext
      analyticsStream={storybookReporter}
      color="red"
      onPress={() => {}}
    />
  ));
{'fraction_non_alphanumeric': 0.14844835572024084, 'fraction_numerical': 0.0053265400648448355, 'mean_word_length': 3.3582240161453076, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4807581', 'n_tokens_mistral': 1339, 'n_tokens_neox': 1333, 'n_words': 259}