From 4b553961806830f8bbd6e334c4a9612464d3e767 Mon Sep 17 00:00:00 2001 From: Daniel Bisgrove Date: Thu, 21 Sep 2023 09:10:27 -0400 Subject: [PATCH] Adding testing transaction --- src/app/analytics/analytics.factory.js | 10 +++++++++- .../productConfigForm/productConfigForm.component.js | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/app/analytics/analytics.factory.js b/src/app/analytics/analytics.factory.js index 98b6d00c0..87cc99df4 100644 --- a/src/app/analytics/analytics.factory.js +++ b/src/app/analytics/analytics.factory.js @@ -15,6 +15,10 @@ function suppressErrors (func) { } catch (e) { } } } + +const brandedState = { + testingTransaction: undefined +} // Generate a datalayer product object const generateProduct = suppressErrors(function (item, additionalData = {}) { const price = additionalData?.price || item.amount @@ -37,7 +41,8 @@ const generateProduct = suppressErrors(function (item, additionalData = {}) { currency: 'USD', price: price ? price.toString() : undefined, quantity: '1', - recurring_date: recurringDate + recurring_date: recurringDate, + testing_transaction: brandedState.testingTransaction || undefined } }) @@ -130,6 +135,9 @@ const analyticsFactory = /* @ngInject */ function ($window, $timeout, envService }) } }), + saveTestingTransaction: suppressErrors(function (testingTransaction) { + brandedState.testingTransaction = testingTransaction + }), cartAdd: suppressErrors(function (itemConfig, productData) { let siteSubSection const cart = { diff --git a/src/app/productConfig/productConfigForm/productConfigForm.component.js b/src/app/productConfig/productConfigForm/productConfigForm.component.js index 4d6e3a604..426309788 100644 --- a/src/app/productConfig/productConfigForm/productConfigForm.component.js +++ b/src/app/productConfig/productConfigForm/productConfigForm.component.js @@ -309,7 +309,9 @@ class ProductConfigFormController { this.onStateChange({ state: 'submitting' }) const comment = this.itemConfig['donation-services-comments'] - this.brandedAnalyticsFactory.saveTestingTransaction(comment ? comment.toLowerCase().includes('test') : false) + const isTestingTransaction = comment ? comment.toLowerCase().includes('test') : false + this.brandedAnalyticsFactory.saveTestingTransaction(isTestingTransaction) + this.analyticsFactory.saveTestingTransaction(isTestingTransaction) const data = this.productData.frequency === 'NA' ? omit(this.itemConfig, ['recurring-start-month', 'recurring-day-of-month']) : this.itemConfig