Skip to content

Commit b01c8a5

Browse files
committed
Consolidate ECARD suppression in DataLayer (asset)
1 parent f67a589 commit b01c8a5

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

packages/scripts/dist/data-layer.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class DataLayer {
3535
"receiptNumber",
3636
"recurring",
3737
"transactionId",
38-
"transactionType"
38+
"transactionType",
3939
];
4040
this.excludedFields = [
4141
// Credit Card
@@ -115,22 +115,25 @@ export class DataLayer {
115115
onLoad() {
116116
// Collect all data layer variables to push at once
117117
const dataLayerData = {};
118+
const suppressEcardData = ENGrid.getPageType() === "ECARD" &&
119+
ENGrid.getOption("SuppressPurchaseEcard");
118120
if (ENGrid.getGiftProcess()) {
119121
// EN will chain together gift process data on the page json when redirecting from a completed donation to an ecard.
120-
// Since the ecard page can be embedded on the thank you page of a donation, this can cause confusion in the data layer with events
122+
// Since the ecard page can be embedded on the thank you page of a donation, this can cause confusion in the data layer with events
121123
// firing for both the donation and the ecard on the same page.
122-
if (ENGrid.getPageType() === "ECARD" && ENGrid.getOption("SuppressPurchaseEcard")) {
124+
if (suppressEcardData) {
123125
this.logger.log("⛔ Gift process was detected BUT suppressing EN_SUCCESSFUL_DONATION event due to SuppressPurchaseEcard option enabled");
126+
window.sessionStorage.removeItem(this.endOfGiftProcessStorageKey);
124127
}
125128
else {
126129
this.logger.log("EN_SUCCESSFUL_DONATION");
127130
this.addEndOfGiftProcessEventsToDataLayer();
128131
}
129132
}
130133
if (window.pageJson) {
131-
let pageJson = window.pageJson;
134+
const pageJson = window.pageJson;
132135
for (const property in pageJson) {
133-
if (ENGrid.getPageType() === "ECARD" && ENGrid.getOption("SuppressPurchaseEcard") && this.giftFields.includes(property)) {
136+
if (suppressEcardData && this.giftFields.includes(property)) {
134137
continue;
135138
}
136139
const key = `EN_PAGEJSON_${property.toUpperCase()}`;

0 commit comments

Comments
 (0)