Skip to content

Commit 1180b74

Browse files
authored
Merge pull request #63 from joincivil/nickreynolds/stripe-ga
fix: add GA for stripe payment flow
2 parents faae996 + 98a0304 commit 1180b74

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

src/react/boosts/payments/BoostPayFormStripe.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
CardCvcElement,
99
} from "react-stripe-elements";
1010
import styled from "styled-components";
11-
import { colors, fonts, mediaQueries, FullScreenModal } from "@joincivil/components";
11+
import { colors, fonts, mediaQueries, FullScreenModal, CivilContext, ICivilContext } from "@joincivil/components";
1212
import { isValidEmail } from "@joincivil/utils";
1313
import {
1414
BoostFlexStart,
@@ -170,6 +170,8 @@ export interface BoostPayFormStripeStates {
170170
}
171171

172172
class BoostPayFormStripe extends React.Component<BoostPayFormStripeProps, BoostPayFormStripeStates> {
173+
public static contextType: React.Context<ICivilContext> = CivilContext;
174+
public context!: React.ContextType<typeof CivilContext>;
173175
constructor(props: any) {
174176
super(props);
175177
this.state = {
@@ -423,6 +425,12 @@ class BoostPayFormStripe extends React.Component<BoostPayFormStripeProps, BoostP
423425
this.setState({ paymentProcessing: true });
424426
if (this.props.stripe) {
425427
try {
428+
this.context.fireAnalyticsEvent(
429+
"boosts",
430+
"start submit CC support",
431+
this.props.boostId,
432+
this.props.usdToSpend,
433+
);
426434
const token = await this.props.stripe.createToken({
427435
name: this.state.name,
428436
address_country: this.state.country,

src/react/boosts/payments/BoostPayOptions.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ export class BoostPayOptions extends React.Component<BoostPayOptionsProps, Boost
216216
this.setState({ paymentType: PAYMENT_TYPE.ETH, etherToSpend, usdToSpend });
217217
};
218218

219-
private handleStripeNext = () => {
219+
private handleStripeNext = (usdToSpend: number) => {
220+
this.context.fireAnalyticsEvent("boosts", "continue CC support", this.props.boostId, usdToSpend);
220221
this.setState({ paymentType: PAYMENT_TYPE.STRIPE });
221222
};
222223

src/react/boosts/payments/BoostPayStripe.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export interface BoostPayStripeProps {
1616
paymentType: string;
1717
optionLabel: string | JSX.Element;
1818
paymentStarted?: boolean;
19-
handleNext(): void;
19+
handleNext(usdToSpend: number): void;
2020
handlePaymentSelected?(paymentType: string): void;
2121
handlePaymentSuccess(): void;
2222
}
@@ -63,7 +63,9 @@ export class BoostPayStripe extends React.Component<BoostPayStripeProps, BoostPa
6363
</a>
6464
.
6565
</p>
66-
{this.props.selected && <BoostButton onClick={() => this.props.handleNext()}>Next</BoostButton>}
66+
{this.props.selected && (
67+
<BoostButton onClick={() => this.props.handleNext(this.props.usdToSpend)}>Next</BoostButton>
68+
)}
6769
</BoostFlexCenter>
6870
</BoostPayCardDetails>
6971
</BoostPayOption>

0 commit comments

Comments
 (0)