Skip to content

Commit 2e8c24f

Browse files
fix(app-rfi): ga track default disabled for pii
1 parent 0670ba3 commit 2e8c24f

File tree

10 files changed

+64
-12
lines changed

10 files changed

+64
-12
lines changed

packages/app-rfi/src/components/AsuRfi/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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,

packages/app-rfi/src/components/AsuRfi/story.helper.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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",

packages/app-rfi/src/components/steps/questions/Country.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import React, { useEffect, useState } from "react";
22

3-
import { gaEventPropTypes, trackGAEvent } from "../../../../../../shared";
43
import { fetchCountries } from "../../../core/utils/fetchCountries";
54
import { useRfiContext } from "../../../core/utils/rfiContext";
5+
import {
6+
gaEventPropTypes,
7+
useTryGAEvent,
8+
} from "../../../core/utils/useDataLayer";
69
import { 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,

packages/app-rfi/src/components/steps/questions/EmailAddress.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import React from "react";
22

3-
import { gaEventPropTypes, trackGAEvent } from "../../../../../../shared";
3+
import {
4+
gaEventPropTypes,
5+
useTryGAEvent,
6+
} from "../../../core/utils/useDataLayer";
47
import { 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,

packages/app-rfi/src/components/steps/questions/FirstName.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import React from "react";
22

3-
import { gaEventPropTypes, trackGAEvent } from "../../../../../../shared";
3+
import {
4+
gaEventPropTypes,
5+
useTryGAEvent,
6+
} from "../../../core/utils/useDataLayer";
47
import { 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,

packages/app-rfi/src/components/steps/questions/LastName.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import React from "react";
22

3-
import { gaEventPropTypes, trackGAEvent } from "../../../../../../shared";
3+
import {
4+
gaEventPropTypes,
5+
useTryGAEvent,
6+
} from "../../../core/utils/useDataLayer";
47
import { 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,

packages/app-rfi/src/components/steps/questions/Phone.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import React from "react";
22

3-
import { gaEventPropTypes, trackGAEvent } from "../../../../../../shared";
3+
import {
4+
gaEventPropTypes,
5+
useTryGAEvent,
6+
} from "../../../core/utils/useDataLayer";
47
import { 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,

packages/app-rfi/src/components/steps/questions/ZipCode.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import React, { useEffect } from "react";
22

3-
import { gaEventPropTypes, trackGAEvent } from "../../../../../../shared";
43
import { KEY } from "../../../core/utils/constants";
54
import { useRfiContext } from "../../../core/utils/rfiContext";
5+
import {
6+
gaEventPropTypes,
7+
useTryGAEvent,
8+
} from "../../../core/utils/useDataLayer";
69
import { 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,

packages/app-rfi/src/core/types/rfi-types.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
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]
@@ -46,6 +47,7 @@
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]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
};

0 commit comments

Comments
 (0)