diff --git a/services/graphql/src/definitions/customer.js b/services/graphql/src/definitions/customer.js index aa2e1bd..c170202 100644 --- a/services/graphql/src/definitions/customer.js +++ b/services/graphql/src/definitions/customer.js @@ -295,6 +295,8 @@ input RapidCustomerIdentificationBehaviorInput { id: Int! "The date the behavior occurred." date: DateTime + "An optional promo code to associate with this specific behavior. Falls back to the top-level promoCode if not set." + behaviorPromoCode: String "An array of pre-defined key-values to send with the behavior." attributes: [RapidCustomerIdentificationBehaviorAttributeInput!]! = [] } diff --git a/services/graphql/src/resolvers/customer.js b/services/graphql/src/resolvers/customer.js index bb460cd..23eb951 100644 --- a/services/graphql/src/resolvers/customer.js +++ b/services/graphql/src/resolvers/customer.js @@ -469,9 +469,17 @@ module.exports = { })), }), ...(behaviors.length && { - CustomerBehaviors: behaviors.map(({ id, date, attributes }) => ({ + CustomerBehaviors: behaviors.map(({ + id, + date, + behaviorPromoCode, + attributes, + }) => ({ BehaviorId: id, BehaviorDate: dayjs(date || new Date()).format('YYYY-MM-DD HH:mm:ss'), + ...((behaviorPromoCode || promoCode) && { + BehaviorPromoCode: behaviorPromoCode || promoCode, + }), ...(attributes.length && { BehaviorAttributes: attributes.map((attr) => { if (!attr.valueId && !attr.value) throw new UserInputError('One of `valueId` or `value` must be specified for behavior attribute!');