Skip to content

Commit

Permalink
Remove commented-out code and obsolete tracking
Browse files Browse the repository at this point in the history
Signed-off-by: Janus Reith <[email protected]>
  • Loading branch information
janus-reith committed May 19, 2020
1 parent 2ba7439 commit 0ae583e
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 163 deletions.
72 changes: 7 additions & 65 deletions components/CheckoutActions/CheckoutActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,9 @@ import withAddressValidation from "containers/address/withAddressValidation";
import Dialog from "@material-ui/core/Dialog";
import PageLoading from "components/PageLoading";
import Router from "translations/i18nRouter";
// import track from "lib/tracking/track";
// import TRACKING from "lib/tracking/constants";
// import trackCheckout from "lib/tracking/trackCheckout";
// import trackOrder from "lib/tracking/trackOrder";
// import trackCheckoutStep from "lib/tracking/trackCheckoutStep";
import calculateRemainderDue from "lib/utils/calculateRemainderDue";
import { placeOrderMutation } from "../../hooks/orders/placeOrder.gql";

/*
const {
CHECKOUT_STARTED,
CHECKOUT_STEP_COMPLETED,
CHECKOUT_STEP_VIEWED,
ORDER_COMPLETED,
PAYMENT_INFO_ENTERED
} = TRACKING;
*/

const MessageDiv = styled.div`
${addTypographyStyles("NoPaymentMethodsMessage", "bodyText")}
`;
Expand Down Expand Up @@ -73,24 +58,6 @@ class CheckoutActions extends Component {
isPlacingOrder: false
};

componentDidMount() {
this._isMounted = true;
const { cart } = this.props;

// Track start of checkout process
// this.trackCheckoutStarted({ cart, action: CHECKOUT_STARTED });

const { checkout: { fulfillmentGroups } } = cart;
const [fulfillmentGroup] = fulfillmentGroups;

// Track the first step, "Enter a shipping address" when the page renders,
// as it will be expanded by default, only record this event when the
// shipping address has not yet been set.
if (!fulfillmentGroup.shippingAddress) {
// this.trackAction(this.buildData({ action: CHECKOUT_STEP_VIEWED, step: 1 }));
}
}

componentDidUpdate({ addressValidationResults: prevAddressValidationResults }) {
const { addressValidationResults } = this.props;
if (
Expand Down Expand Up @@ -129,20 +96,12 @@ class CheckoutActions extends Component {
delete address.isValid;
const { data, error } = await onSetShippingAddress(address);

if (data && !error) {
// track successfully setting a shipping address
// this.trackAction(this.buildData({ action: CHECKOUT_STEP_COMPLETED, step: 1 }));

// The next step will automatically be expanded, so lets track that
// this.trackAction(this.buildData({ action: CHECKOUT_STEP_VIEWED, step: 2 }));

if (this._isMounted) {
this.setState({
actionAlerts: {
1: {}
}
});
}
if (data && !error && this._isMounted) {
this.setState({
actionAlerts: {
1: {}
}
});
}
};

Expand All @@ -166,14 +125,7 @@ class CheckoutActions extends Component {
fulfillmentMethodId: shippingMethod.selectedFulfillmentOption.fulfillmentMethod._id
};

const { data, error } = await onSetFulfillmentOption(fulfillmentOption);
if (data && !error) {
// track successfully setting a shipping method
// this.trackAction(this.buildData({ action: CHECKOUT_STEP_COMPLETED, step: 2 }));

// The next step will automatically be expanded, so lets track that
// this.trackAction(this.buildData({ action: CHECKOUT_STEP_VIEWED, step: 3 }));
}
await onSetFulfillmentOption(fulfillmentOption);
};

handlePaymentSubmit = (paymentInput) => {
Expand All @@ -185,12 +137,6 @@ class CheckoutActions extends Component {
3: {}
}
});

// Track successfully setting a payment method
// this.trackAction(this.buildData({ action: PAYMENT_INFO_ENTERED, step: 3 }));

// The next step will automatically be expanded, so lets track that
// this.trackAction(this.buildData({ action: CHECKOUT_STEP_VIEWED, step: 4 }));
};

handlePaymentsReset = () => {
Expand Down Expand Up @@ -267,10 +213,6 @@ class CheckoutActions extends Component {

const { placeOrder: { orders, token } } = data;

// this.trackAction(this.buildData({ action: CHECKOUT_STEP_COMPLETED, step: 4 }));

// this.trackOrder({ action: ORDER_COMPLETED, orders });

// Send user to order confirmation page
Router.push(`/checkout/order?orderId=${orders[0].referenceId}${token ? `&token=${token}` : ""}`);
} catch (error) {
Expand Down
1 change: 0 additions & 1 deletion components/MediaGallery/MediaGallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { Component } from "react";
import PropTypes from "prop-types";
import Grid from "@material-ui/core/Grid";
import withStyles from "@material-ui/core/styles/withStyles";
// import ProgressiveImage from "@reactioncommerce/components/ProgressiveImage/v1";
import ProgressiveImage from "components/ProgressiveImage";
import MediaGalleryItem from "components/MediaGalleryItem";

Expand Down
3 changes: 1 addition & 2 deletions components/MediaGalleryItem/MediaGalleryItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { Component } from "react";
import PropTypes from "prop-types";
import ButtonBase from "@material-ui/core/ButtonBase";
import withStyles from "@material-ui/core/styles/withStyles";
// import ProgressiveImage from "@reactioncommerce/components/ProgressiveImage/v1";
import ProgressiveImage from "components/ProgressiveImage";

const styles = () => ({
Expand Down Expand Up @@ -40,7 +39,7 @@ class MediaGalleryItem extends Component {
};

static defaultProps = {
onClick: () => {}
onClick: () => { }
};

/**
Expand Down
22 changes: 2 additions & 20 deletions components/MiniCart/MiniCart.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ import Badge from "@material-ui/core/Badge";
import Popper from "@material-ui/core/Popper";
import Fade from "@material-ui/core/Fade";
import withCart from "containers/cart/withCart";
// import trackCartItems from "lib/tracking/trackCartItems";
// import track from "lib/tracking/track";
import variantById from "lib/utils/variantById";
// import TRACKING from "lib/tracking/constants";

// const { CART_VIEWED, PRODUCT_REMOVED } = TRACKING;

const styles = ({ palette, zIndex }) => ({
popper: {
Expand Down Expand Up @@ -86,11 +81,6 @@ class MiniCart extends Component {
handlePopperOpen = () => {
const { cart, uiStore: { openCart } } = this.props;
openCart();

// Track a cart view event, only if the cart contains items
if (cart && Array.isArray(cart.items) && cart.items.length) {
// this.trackAction({ cartItems: cart.items, cartId: cart._id, action: CART_VIEWED });
}
}

handleClick = () => Router.push("/");
Expand Down Expand Up @@ -128,16 +118,8 @@ class MiniCart extends Component {
}

handleRemoveItem = async (itemId) => {
const { cart: { items }, onRemoveCartItems } = this.props;
const { data, error } = await onRemoveCartItems(itemId);

if (data && !error) {
const { cart: { _id } } = data.removeCartItems;
const removedItem = { cart_id: _id, ...variantById(items, itemId) }; // eslint-disable-line camelcase

// Track removed item
// this.trackAction({ cartItems: removedItem, action: PRODUCT_REMOVED });
}
const { onRemoveCartItems } = this.props;
await onRemoveCartItems(itemId);
};

renderMiniCart() {
Expand Down
35 changes: 1 addition & 34 deletions components/ProductDetail/ProductDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { withStyles } from "@material-ui/core/styles";
import Grid from "@material-ui/core/Grid";
import withWidth, { isWidthUp, isWidthDown } from "@material-ui/core/withWidth";
import inject from "hocs/inject";
// import track from "lib/tracking/track";
import Breadcrumbs from "components/Breadcrumbs";
import ProductDetailAddToCart from "components/ProductDetailAddToCart";
import ProductDetailTitle from "components/ProductDetailTitle";
Expand All @@ -16,11 +15,6 @@ import MediaGallery from "components/MediaGallery";
import Router from "translations/i18nRouter";
import priceByCurrencyCode from "lib/utils/priceByCurrencyCode";
import variantById from "lib/utils/variantById";
// import trackProduct from "lib/tracking/trackProduct";
// import TRACKING from "lib/tracking/constants";
// import trackCartItems from "lib/tracking/trackCartItems";

// const { CART_VIEWED, PRODUCT_ADDED, PRODUCT_VIEWED } = TRACKING;

const styles = (theme) => ({
section: {
Expand Down Expand Up @@ -78,8 +72,6 @@ class ProductDetail extends Component {
selectOptionId = variant.options[0]._id;
}

// this.trackAction({ variant, optionId, action: PRODUCT_VIEWED });

uiStore.setPDPSelectedVariantId(variantId, selectOptionId);

Router.replace("/product/[...slugOrId]", `/product/${product.slug}/${selectOptionId || variantId}`);
Expand Down Expand Up @@ -124,7 +116,7 @@ class ProductDetail extends Component {
const price = priceByCurrencyCode(currencyCode, selectedVariantOrOption.pricing);

// Call addItemsToCart with an object matching the GraphQL `CartItemInput` schema
const { data } = await addItemsToCart([
await addItemsToCart([
{
price: {
amount: price.price,
Expand All @@ -137,31 +129,6 @@ class ProductDetail extends Component {
quantity
}
]);

// If no errors occurred, track action
if (data) {
// The response data will be in either `createCart` or `addCartItems` prop
// depending on the type of user, either authenticated or anonymous.
const { cart } = data.createCart || data.addCartItems;
const { edges: items } = cart.items;

/*
this.trackAction({
variant: {
...selectedVariant,
cart_id: cart._id, // eslint-disable-line camelcase
quantity
},
optionId: selectedOption ? selectedOption._id : null,
action: PRODUCT_ADDED
});
*/

// The mini cart popper will open automatically after adding an item to the cart,
// therefore, a CART_VIEWED event is published.
// debugger // eslint-disable-line
// this.trackCartItems({ cartItems: items, cartId: cart._id, action: CART_VIEWED }); // eslint-disable-line camelcase
}
}
if (isWidthUp("md", width)) {
// Open the cart, and close after a 3 second delay
Expand Down
2 changes: 0 additions & 2 deletions components/ProductGrid/ProductGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import PropTypes from "prop-types";
import Grid from "@material-ui/core/Grid";
import { withStyles } from "@material-ui/core/styles";
import CatalogGrid from "@reactioncommerce/components/CatalogGrid/v1";
// import track from "lib/tracking/track";
// import trackProductClicked from "lib/tracking/trackProductClicked";
import PageLoading from "components/PageLoading";
import PageStepper from "components/PageStepper";
import PageSizeSelector from "components/PageSizeSelector";
Expand Down
2 changes: 0 additions & 2 deletions custom/componentsContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import CartItemDetail from "@reactioncommerce/components/CartItemDetail/v1";
import CartItems from "@reactioncommerce/components/CartItems/v1";
import CartSummary from "@reactioncommerce/components/CartSummary/v1";
import CatalogGrid from "@reactioncommerce/components/CatalogGrid/v1";
// import CatalogGridItem from "@reactioncommerce/components/CatalogGridItem/v1";
import CatalogGridItem from "components/CatalogGridItem";
import Checkbox from "@reactioncommerce/components/Checkbox/v1";
import CheckoutAction from "@reactioncommerce/components/CheckoutAction/v1";
Expand All @@ -54,7 +53,6 @@ import MiniCartSummary from "@reactioncommerce/components/MiniCartSummary/v1";
import PhoneNumberInput from "@reactioncommerce/components/PhoneNumberInput/v1";
import Price from "@reactioncommerce/components/Price/v1";
import ProfileImage from "@reactioncommerce/components/ProfileImage/v1";
// import ProgressiveImage from "@reactioncommerce/components/ProgressiveImage/v1";
import ProgressiveImage from "components/ProgressiveImage";
import QuantityInput from "@reactioncommerce/components/QuantityInput/v1";
import RegionInput from "@reactioncommerce/components/RegionInput/v1";
Expand Down
24 changes: 2 additions & 22 deletions pages/[lang]/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ import Link from "components/Link";
import Layout from "components/Layout";
import Router from "translations/i18nRouter";
import PageLoading from "components/PageLoading";
// import track from "lib/tracking/track";
import variantById from "lib/utils/variantById";
// import trackCartItems from "lib/tracking/trackCartItems";
// import TRACKING from "lib/tracking/constants";
import { withApollo } from "lib/apollo/withApollo";

import { locales } from "translations/config";
Expand Down Expand Up @@ -77,15 +74,6 @@ class CartPage extends Component {
})
};

componentDidMount() {
const { cart } = this.props;

// Track a cart view event
if (cart && Array.isArray(cart.items) && cart.items.length) {
// this.trackAction({ cartItems: cart.items, cartId: cart._id, action: TRACKING.CART_VIEWED });
}
}

handleClick = () => Router.push("/");

handleItemQuantityChange = (quantity, cartItemId) => {
Expand All @@ -95,17 +83,9 @@ class CartPage extends Component {
};

handleRemoveItem = async (itemId) => {
const { cart: { items }, onRemoveCartItems } = this.props;

const { data, error } = await onRemoveCartItems(itemId);
const { onRemoveCartItems } = this.props;

if (data && !error) {
const { cart: { _id } } = data.removeCartItems;
const removedItem = { cart_id: _id, ...variantById(items, itemId) }; // eslint-disable-line camelcase

// Track removed item
// this.trackAction({ cartItems: removedItem, action: TRACKING.PRODUCT_REMOVED });
}
await onRemoveCartItems(itemId);
};

renderCartItems() {
Expand Down
8 changes: 0 additions & 8 deletions pages/[lang]/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Helmet from "react-helmet";
import withCatalogItems from "containers/catalog/withCatalogItems";
import ProductGrid from "components/ProductGrid";
import Layout from "components/Layout";
// import trackProductListViewed from "lib/tracking/trackProductListViewed";
import { inPageSizes } from "lib/utils/pageSizes";
import { withApollo } from "lib/apollo/withApollo";

Expand Down Expand Up @@ -33,18 +32,11 @@ class ProductGridPage extends Component {
})
};

// @trackProductListViewed()
componentDidMount() {
const { routingStore } = this.props;
routingStore.setTagId(null);
}

componentDidUpdate(prevProps) {
if (this.props.catalogItems !== prevProps.catalogItems) {
// this.trackEvent(this.props);
}
}

setPageSize = (pageSize) => {
this.props.routingStore.setSearch({ limit: pageSize });
this.props.uiStore.setPageSize(pageSize);
Expand Down
7 changes: 0 additions & 7 deletions pages/[lang]/tag/[slug].js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import ProductGridHero from "components/ProductGridHero";
import ProductGridTitle from "components/ProductGridTitle";
import Layout from "components/Layout";
import SharedPropTypes from "lib/utils/SharedPropTypes";
// import trackProductListViewed from "lib/tracking/trackProductListViewed";
import { withApollo } from "lib/apollo/withApollo";

import { locales } from "translations/config";
Expand Down Expand Up @@ -64,12 +63,6 @@ class TagGridPage extends Component {

state = {};

componentDidUpdate(prevProps) {
if (this.props.catalogItems !== prevProps.catalogItems) {
// this.trackEvent(this.props);
}
}

setPageSize = (pageSize) => {
this.props.routingStore.setSearch({ limit: pageSize });
this.props.uiStore.setPageSize(pageSize);
Expand Down

0 comments on commit 0ae583e

Please sign in to comment.