File tree Expand file tree Collapse file tree 10 files changed +64
-12
lines changed Expand file tree Collapse file tree 10 files changed +64
-12
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ const AsuRfi = props => {
4444 country,
4545 stateProvince,
4646 successMsg,
47+ dataLayerEnabled,
4748 test,
4849 dataSourceDegreeSearch,
4950 dataSourceAsuOnline,
@@ -99,6 +100,7 @@ const AsuRfi = props => {
99100 country,
100101 stateProvince,
101102 successMsg,
103+ dataLayerEnabled,
102104 test,
103105 dataSourceDegreeSearch,
104106 dataSourceAsuOnline,
@@ -150,6 +152,7 @@ AsuRfi.defaultProps = {
150152 country : undefined ,
151153 stateProvince : undefined ,
152154 successMsg : undefined ,
155+ dataLayerEnabled : false ,
153156 test : false ,
154157 dataSourceDegreeSearch : DATA_SOURCE . DEGREE_SEARCH ,
155158 dataSourceAsuOnline : DATA_SOURCE . ASU_ONLINE ,
@@ -175,6 +178,7 @@ AsuRfi.propTypes = {
175178 country : PropTypes . string ,
176179 stateProvince : PropTypes . string ,
177180 successMsg : PropTypes . string ,
181+ dataLayerEnabled : PropTypes . bool ,
178182 test : PropTypes . bool ,
179183 dataSourceDegreeSearch : PropTypes . string ,
180184 dataSourceAsuOnline : PropTypes . string ,
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ export const defaultArgs = {
2323 country : undefined ,
2424 stateProvince : undefined , // Only US states or CA provinces - use full name.
2525 successMsg : undefined ,
26+ dataLayerEnabled : false ,
2627 test : false ,
2728 dataSourceDegreeSearch : undefined , // "https://degrees.apps.asu.edu/t5/service",
2829 dataSourceAsuOnline : undefined , // "https://cms.asuonline.asu.edu/lead-submissions-v3.5/programs",
Original file line number Diff line number Diff line change 11import React , { useEffect , useState } from "react" ;
22
3- import { gaEventPropTypes , trackGAEvent } from "../../../../../../shared" ;
43import { fetchCountries } from "../../../core/utils/fetchCountries" ;
54import { useRfiContext } from "../../../core/utils/rfiContext" ;
5+ import {
6+ gaEventPropTypes ,
7+ useTryGAEvent ,
8+ } from "../../../core/utils/useDataLayer" ;
69import { RfiSelect } from "../../controls" ;
710
811// Options
@@ -45,14 +48,16 @@ export const Country = ({ gaData }) => {
4548 } ) ;
4649 } , [ ] ) ; // Run only once
4750
51+ const tryGAEvent = useTryGAEvent ( ) ;
52+
4853 return (
4954 < RfiSelect
5055 label = { label }
5156 id = { name }
5257 name = { name }
5358 options = { countryOptions }
5459 onBlur = { e =>
55- trackGAEvent ( {
60+ tryGAEvent ( {
5661 ...gaData ,
5762 event : "select" ,
5863 type : label ,
Original file line number Diff line number Diff line change 11import React from "react" ;
22
3- import { gaEventPropTypes , trackGAEvent } from "../../../../../../shared" ;
3+ import {
4+ gaEventPropTypes ,
5+ useTryGAEvent ,
6+ } from "../../../core/utils/useDataLayer" ;
47import { RfiEmailInput } from "../../controls" ;
58
69/**
@@ -10,6 +13,8 @@ export const EmailAddress = ({ gaData }) => {
1013 const label = "Email Address" ;
1114 const name = "EmailAddress" ;
1215
16+ const tryGAEvent = useTryGAEvent ( ) ;
17+
1318 return (
1419 < RfiEmailInput
1520 label = { label }
@@ -18,7 +23,7 @@ export const EmailAddress = ({ gaData }) => {
1823 requiredIcon
1924 required
2025 onBlur = { e =>
21- trackGAEvent ( {
26+ tryGAEvent ( {
2227 ...gaData ,
2328 type : label ,
2429 text : e . target . value ,
Original file line number Diff line number Diff line change 11import React from "react" ;
22
3- import { gaEventPropTypes , trackGAEvent } from "../../../../../../shared" ;
3+ import {
4+ gaEventPropTypes ,
5+ useTryGAEvent ,
6+ } from "../../../core/utils/useDataLayer" ;
47import { RfiTextInput } from "../../controls" ;
58
69/**
@@ -10,6 +13,8 @@ export const FirstName = ({ gaData }) => {
1013 const label = "First name" ;
1114 const name = "FirstName" ;
1215
16+ const tryGAEvent = useTryGAEvent ( ) ;
17+
1318 return (
1419 < RfiTextInput
1520 label = { label }
@@ -18,7 +23,7 @@ export const FirstName = ({ gaData }) => {
1823 requiredIcon
1924 required
2025 onBlur = { e =>
21- trackGAEvent ( {
26+ tryGAEvent ( {
2227 ...gaData ,
2328 type : label ,
2429 text : e . target . value ,
Original file line number Diff line number Diff line change 11import React from "react" ;
22
3- import { gaEventPropTypes , trackGAEvent } from "../../../../../../shared" ;
3+ import {
4+ gaEventPropTypes ,
5+ useTryGAEvent ,
6+ } from "../../../core/utils/useDataLayer" ;
47import { RfiTextInput } from "../../controls" ;
58
69/**
@@ -10,6 +13,8 @@ export const LastName = ({ gaData }) => {
1013 const label = "Last name" ;
1114 const name = "LastName" ;
1215
16+ const tryGAEvent = useTryGAEvent ( ) ;
17+
1318 return (
1419 < RfiTextInput
1520 label = { label }
@@ -18,7 +23,7 @@ export const LastName = ({ gaData }) => {
1823 requiredIcon
1924 required
2025 onBlur = { e =>
21- trackGAEvent ( {
26+ tryGAEvent ( {
2227 ...gaData ,
2328 type : label ,
2429 text : e . target . value ,
Original file line number Diff line number Diff line change 11import React from "react" ;
22
3- import { gaEventPropTypes , trackGAEvent } from "../../../../../../shared" ;
3+ import {
4+ gaEventPropTypes ,
5+ useTryGAEvent ,
6+ } from "../../../core/utils/useDataLayer" ;
47import { RfiPhone } from "../../controls" ;
58
69/**
@@ -10,6 +13,8 @@ export const Phone = ({ gaData }) => {
1013 const label = "Phone" ;
1114 const name = "Phone" ;
1215
16+ const tryGAEvent = useTryGAEvent ( ) ;
17+
1318 return (
1419 < RfiPhone
1520 label = { label }
@@ -18,7 +23,7 @@ export const Phone = ({ gaData }) => {
1823 requiredIcon
1924 required
2025 onBlur = { e =>
21- trackGAEvent ( {
26+ tryGAEvent ( {
2227 ...gaData ,
2328 type : label ,
2429 text : e . target . value ,
Original file line number Diff line number Diff line change 11import React , { useEffect } from "react" ;
22
3- import { gaEventPropTypes , trackGAEvent } from "../../../../../../shared" ;
43import { KEY } from "../../../core/utils/constants" ;
54import { useRfiContext } from "../../../core/utils/rfiContext" ;
5+ import {
6+ gaEventPropTypes ,
7+ useTryGAEvent ,
8+ } from "../../../core/utils/useDataLayer" ;
69import { RfiTextInput } from "../../controls" ;
710
811/**
@@ -31,6 +34,8 @@ export const ZipCode = ({ gaData }) => {
3134 return < > </ > ;
3235 }
3336
37+ const tryGAEvent = useTryGAEvent ( ) ;
38+
3439 return (
3540 < RfiTextInput
3641 label = { label }
@@ -39,7 +44,7 @@ export const ZipCode = ({ gaData }) => {
3944 requiredIcon
4045 required
4146 onBlur = { e =>
42- trackGAEvent ( {
47+ tryGAEvent ( {
4348 ...gaData ,
4449 type : label ,
4550 text : e . target . value ,
Original file line number Diff line number Diff line change 1717 * @property {string } [country]
1818 * @property {string } [stateProvince]
1919 * @property {string } [successMsg]
20+ * @property {boolean } [dataLayerEnabled]
2021 * @property {boolean } [test]
2122 * @property {string } [dataSourceDegreeSearch]
2223 * @property {string } [dataSourceAsuOnline]
4647 * @property {string } [country]
4748 * @property {string } [stateProvince]
4849 * @property {string } [successMsg]
50+ * @property {boolean } [dataLayerEnabled]
4951 * @property {boolean } [test]
5052 * @property {string } [dataSourceDegreeSearch]
5153 * @property {string } [dataSourceAsuOnline]
Original file line number Diff line number Diff line change 1+ // @ts -check
2+ import { trackGAEvent as fn } from "../../../../../shared" ;
3+ import { useRfiContext } from "./rfiContext" ;
4+
5+ export { gaEventPropTypes } from "../../../../../shared" ;
6+
7+ export const useTryGAEvent = ( ) => {
8+ const { dataLayerEnabled } = useRfiContext ( ) ;
9+
10+ if ( dataLayerEnabled ) {
11+ return fn ;
12+ }
13+ // return NOOP function
14+ return ( ) => { } ;
15+ } ;
You can’t perform that action at this time.
0 commit comments