Skip to content

Commit

Permalink
Merge branch 'adding-data-onto-datalayer-tracking' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-bizz committed Sep 21, 2023
2 parents e8ac4ba + 4b55396 commit d33d53e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/app/analytics/analytics.factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
})

Expand Down Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,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

Expand Down

0 comments on commit d33d53e

Please sign in to comment.