diff --git a/packages/lib/src/components/Card/Card.tsx b/packages/lib/src/components/Card/Card.tsx index 1c04e917e7..60c2ccd578 100644 --- a/packages/lib/src/components/Card/Card.tsx +++ b/packages/lib/src/components/Card/Card.tsx @@ -14,10 +14,17 @@ import ClickToPayWrapper from './components/ClickToPayWrapper'; import { ComponentFocusObject, PayButtonFunctionProps, UIElementStatus } from '../types'; import SRPanelProvider from '../../core/Errors/SRPanelProvider'; import PayButton from '../internal/PayButton'; -import { ANALYTICS_FOCUS_STR, ANALYTICS_CONFIGURED_STR, ANALYTICS_UNFOCUS_STR, ANALYTICS_VALIDATION_ERROR_STR } from '../../core/Analytics/constants'; +import { + ANALYTICS_FOCUS_STR, + ANALYTICS_CONFIGURED_STR, + ANALYTICS_UNFOCUS_STR, + ANALYTICS_VALIDATION_ERROR_STR, + ANALYTICS_RENDERED_STR +} from '../../core/Analytics/constants'; import { ALL_SECURED_FIELDS, ENCRYPTED } from '../internal/SecuredFields/lib/configuration/constants'; import { camelCaseToSnakeCase } from '../../utils/textUtils'; -import { FieldErrorAnalyticsObject } from '../../core/Analytics/types'; +import { FieldErrorAnalyticsObject, SendAnalyticsObject } from '../../core/Analytics/types'; +import { hasOwnProperty } from '../../utils/hasOwnProperty'; export class CardElement extends UIElement { public static type = 'scheme'; @@ -166,6 +173,22 @@ export class CardElement extends UIElement { } } + protected submitAnalytics(analyticsObj: SendAnalyticsObject) { + const { type } = analyticsObj; + + if (type === ANALYTICS_RENDERED_STR || type === ANALYTICS_CONFIGURED_STR) { + // Check if it's a storedCard + if (this.constructor['type'] === 'scheme') { + if (hasOwnProperty(this.props, 'supportedShopperInteractions')) { + analyticsObj.isStoredPaymentMethod = true; + analyticsObj.brand = this.props.brand; + } + } + } + + super.submitAnalytics(analyticsObj); + } + private fieldTypeToSnakeCase(fieldType) { let str = camelCaseToSnakeCase(fieldType); // SFs need their fieldType mapped to what the endpoint expects diff --git a/packages/lib/src/components/ThreeDS2/components/Challenge/types.ts b/packages/lib/src/components/ThreeDS2/components/Challenge/types.ts index a1f01570eb..f0950411dd 100644 --- a/packages/lib/src/components/ThreeDS2/components/Challenge/types.ts +++ b/packages/lib/src/components/ThreeDS2/components/Challenge/types.ts @@ -7,7 +7,6 @@ export interface DoChallenge3DS2Props extends ChallengeData { onCompleteChallenge: (resolveObject: ThreeDS2FlowObject) => void; onErrorChallenge: (rejectObject: ThreeDS2FlowObject) => void; onActionHandled: (rtnObj: ActionHandledReturnObject) => void; - onFormSubmit: (w) => void; } export interface DoChallenge3DS2State { diff --git a/packages/lib/src/components/ThreeDS2/components/DeviceFingerprint/types.ts b/packages/lib/src/components/ThreeDS2/components/DeviceFingerprint/types.ts index 25fb2f1220..f5b8d8ffd3 100644 --- a/packages/lib/src/components/ThreeDS2/components/DeviceFingerprint/types.ts +++ b/packages/lib/src/components/ThreeDS2/components/DeviceFingerprint/types.ts @@ -8,7 +8,6 @@ export interface DoFingerprint3DS2Props extends FingerPrintData { onErrorFingerprint: (rejectObject: ThreeDS2FlowObject) => void; showSpinner: boolean; onActionHandled: (rtnObj: ActionHandledReturnObject) => void; - onFormSubmit: (w) => void; } export interface DoFingerprint3DS2State { diff --git a/packages/lib/src/components/ThreeDS2/components/Form/ThreeDS2Form.tsx b/packages/lib/src/components/ThreeDS2/components/Form/ThreeDS2Form.tsx index 3dc9d9f9d9..fbc74717c9 100644 --- a/packages/lib/src/components/ThreeDS2/components/Form/ThreeDS2Form.tsx +++ b/packages/lib/src/components/ThreeDS2/components/Form/ThreeDS2Form.tsx @@ -7,7 +7,7 @@ interface ThreeDS2FormProps { target: string; inputName: string; inputValue: string; - onFormSubmit: (w) => void; + onFormSubmit: (msg: string) => void; } export default class ThreeDS2Form extends Component { diff --git a/packages/lib/src/components/ThreeDS2/types.ts b/packages/lib/src/components/ThreeDS2/types.ts index 3d12980cfe..797cbc3d32 100644 --- a/packages/lib/src/components/ThreeDS2/types.ts +++ b/packages/lib/src/components/ThreeDS2/types.ts @@ -18,6 +18,7 @@ export interface ChallengeData { cReqData: CReqData; iframeSizeArr: string[]; postMessageDomain: string; + onFormSubmit: (msg: string) => void; } export interface ResultObject { @@ -58,6 +59,7 @@ export interface FingerPrintData { threeDSMethodURL: string; threeDSMethodNotificationURL: string; postMessageDomain: string; + onFormSubmit: (msg: string) => void; } export type ThreeDS2FingerprintResponse = { diff --git a/packages/lib/src/components/UIElement.tsx b/packages/lib/src/components/UIElement.tsx index 3180bfe873..c7de4d24b2 100644 --- a/packages/lib/src/components/UIElement.tsx +++ b/packages/lib/src/components/UIElement.tsx @@ -11,7 +11,7 @@ import { hasOwnProperty } from '../utils/hasOwnProperty'; import DropinElement from './Dropin'; import { CoreOptions } from '../core/types'; import Core from '../core'; -import { ANALYTICS_CONFIGURED_STR, ANALYTICS_RENDERED_STR, ANALYTICS_SUBMIT_STR } from '../core/Analytics/constants'; +import { ANALYTICS_SUBMIT_STR } from '../core/Analytics/constants'; import { AnalyticsInitialEvent, SendAnalyticsObject } from '../core/Analytics/types'; export class UIElement

extends BaseElement

implements IUIElement { @@ -76,18 +76,6 @@ export class UIElement

extends BaseElement

im component = this.constructor['type'] === 'scheme' || this.constructor['type'] === 'bcmc' ? this.constructor['type'] : this.props.type; } - const { type } = analyticsObj; - - if (type === ANALYTICS_RENDERED_STR || type === ANALYTICS_CONFIGURED_STR) { - // Check if it's a storedCard - if (component === 'scheme') { - if (hasOwnProperty(this.props, 'supportedShopperInteractions')) { - analyticsObj.isStoredPaymentMethod = true; - analyticsObj.brand = this.props.brand; - } - } - } - this.props.modules?.analytics.sendAnalytics(component, analyticsObj); }