@paypal/checkout-components 5.0.209-alpha.0 → 5.0.210

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paypal/checkout-components",
3
- "version": "5.0.209-alpha.0",
3
+ "version": "5.0.210",
4
4
  "description": "PayPal Checkout components, for integrating checkout products.",
5
5
  "main": "index.js",
6
6
  "engines": {
@@ -69,7 +69,6 @@
69
69
  "conventional-changelog-cli": "^2.0.34",
70
70
  "flow-bin": "0.155.0",
71
71
  "fs-extra": "^10.0.0",
72
- "grumbler-scripts": "^5.0.1",
73
72
  "husky": "^7.0.4",
74
73
  "imagemagick": "^0.1.3",
75
74
  "imgur": "^0.3.1",
@@ -82,7 +81,7 @@
82
81
  "pixelmatch": "^5.2.1",
83
82
  "pngjs": "^6.0.0",
84
83
  "prettier": "^2.5.1",
85
- "prettier-plugin-sh": "^0.8.1",
84
+ "prettier-plugin-sh": "^0.10.0",
86
85
  "puppeteer": "^1.20.0",
87
86
  "serve": "^13.0.0"
88
87
  },
@@ -13,11 +13,4 @@ export const ATTRIBUTE = {
13
13
  PAY_NOW: ('data-pay-now' : 'data-pay-now')
14
14
  };
15
15
 
16
- export const FPTI_CPL_KEY = {
17
- PAGE_NAME: ('page_name' : 'page_name'),
18
- CPL_COMP_METRICS: ('cpl_comp_metrics' : 'cpl_comp_metrics'),
19
- CPL_CHUNK_METRICS: ('cpl_chunk_metrics' : 'cpl_chunk_metrics'),
20
- CPL_QUERY_METRICS: ('cpl_query_metrics' : 'cpl_query_metrics')
21
- };
22
-
23
16
  export const DEFAULT = ('default' : 'default');
package/src/lib/index.js CHANGED
@@ -4,4 +4,3 @@ export * from './errors';
4
4
  export * from './isRTLLanguage';
5
5
  export * from './security';
6
6
  export * from './session';
7
- export * from './cpl';
@@ -184,18 +184,15 @@ export type Personalization = {|
184
184
  |}
185
185
  |};
186
186
 
187
- export type ApplePayErrorCode = 'shippingContactInvalid' | 'billingContactInvalid' | 'addressUnserviceable' | 'unknown';
188
- export type ApplePayContactField = 'phoneNumber' | 'emailAddress' | 'givenName' | 'familyName' | 'phoneticGivenName' | 'phoneticFamilyName' | 'addressLines' | 'subLocality' | 'locality' | 'postalCode' | 'subAdministrativeArea' | 'administrativeArea' | 'country' | 'countryCode';
189
-
187
+ // https://developer.apple.com/documentation/apple_pay_on_the_web/applepayerror/2970147-applepayerror
190
188
  export type ApplePayError = {|
191
- code : ApplePayErrorCode,
192
- contactField : ApplePayContactField,
193
- message : string
189
+ code : string, // https://developer.apple.com/documentation/apple_pay_on_the_web/applepayerrorcode
190
+ contactField : string, // https://developer.apple.com/documentation/apple_pay_on_the_web/applepayerrorcontactfield
191
+ message : string // custom error message
194
192
  |};
195
193
 
196
- export type ApplePayLineItemType = 'final' | 'pending';
197
194
  export type ApplePayLineItem = {|
198
- type? : ApplePayLineItemType,
195
+ type? : string, // 'final' | 'pending'
199
196
  label? : string,
200
197
  amount? : string
201
198
  |};
@@ -13,7 +13,7 @@ import { uniqueID, memoize, isApplePaySupported, supportsPopups as userAgentSupp
13
13
  import { FUNDING, FUNDING_BRAND_LABEL, QUERY_BOOL, ENV, FPTI_KEY } from '@paypal/sdk-constants/src';
14
14
  import { node, dom } from '@krakenjs/jsx-pragmatic/src';
15
15
 
16
- import { getSessionID, storageState, sessionState, logCPLPhase } from '../../lib';
16
+ import { getSessionID, storageState, sessionState } from '../../lib';
17
17
  import { normalizeButtonStyle, type ButtonProps } from '../../ui/buttons/props';
18
18
  import { isFundingEligible } from '../../funding';
19
19
  import { EXPERIENCE } from '../../constants';
@@ -262,7 +262,6 @@ export const getButtonsComponent : () => ButtonsComponent = memoize(() => {
262
262
  required: false,
263
263
  default: () => noop,
264
264
  decorate: ({ props, value = noop }) => {
265
- logCPLPhase(props.buttonSessionID, 'first_render', 'comp', true);
266
265
  return (...args) => {
267
266
  const { fundingSource } = props;
268
267
  const venmoExperiment = createVenmoExperiment();
@@ -12,7 +12,6 @@ import type { ZoidProps } from '@krakenjs/zoid/src';
12
12
  import { DEFAULT_POPUP_SIZE } from '../checkout';
13
13
  import { Buttons } from '../../ui';
14
14
  import { type ButtonProps } from '../../ui/buttons/props';
15
- import { logCPLPhase, triggerInitialCPLEvent } from '../../lib';
16
15
 
17
16
  type PrerenderedButtonsProps = {|
18
17
  nonce : ?string,
@@ -67,8 +66,7 @@ export function PrerenderedButtons({ nonce, onRenderCheckout, props } : Prerende
67
66
  onRenderCheckout({ fundingSource, card });
68
67
  }
69
68
  };
70
- logCPLPhase(props.buttonSessionID, 'first_render', 'comp');
71
- triggerInitialCPLEvent(props.buttonSessionID);
69
+
72
70
  return (
73
71
  <html>
74
72
  <body>
package/src/lib/cpl.js DELETED
@@ -1,96 +0,0 @@
1
- /* @flow */
2
- import { getLogger } from '@paypal/sdk-client/src';
3
- import { FPTI_KEY } from '@paypal/sdk-constants/src';
4
-
5
- import { FPTI_CPL_KEY } from '../constants';
6
-
7
- /* To Track time spent in each phase(cdn download, chunks download, etc)
8
- logCPLPhase('first_interactable_render')
9
- logCPLPhase('html_body', 'comp', true);
10
- logCPLPhase('html_body', 'comp');
11
- */
12
- const cplPhases = {};
13
- export const logCPLPhase = (buttonID : string, phase : string, category : string, isStart : ?boolean) => {
14
- try {
15
- // to remove Query from phase
16
- phase = phase.replace(/Query/g, '');
17
- if (!cplPhases[buttonID]) {
18
- cplPhases[buttonID] = {
19
- query: {},
20
- chunk: {},
21
- comp: {}
22
- };
23
- }
24
- const epochNow = Date.now();
25
- if (category && cplPhases[buttonID][category] && phase) {
26
- if (isStart && !cplPhases[buttonID][category][phase]) {
27
- cplPhases[buttonID][category][phase] = {
28
- start: epochNow
29
- };
30
- } else if (cplPhases[buttonID][category][phase]) {
31
- if (
32
- cplPhases[buttonID][category][phase].start &&
33
- !cplPhases[buttonID][category][phase].tt
34
- ) {
35
- cplPhases[buttonID][category][phase].tt =
36
- epochNow - cplPhases[buttonID][category][phase].start;
37
- }
38
- } else {
39
- getLogger().info('CPL_LOG_PHASE_UNHANDLED_CONDITION').track({
40
- phase,
41
- category,
42
- isStart
43
- }).flush();
44
- }
45
- } else if (phase && !cplPhases[buttonID][category][phase]) {
46
- if (performance && performance.timing) {
47
- cplPhases[buttonID][category][phase] = epochNow - performance.timing.fetchStart;
48
- }
49
- }
50
- } catch (err) {
51
- getLogger().info('CPL_LOG_PHASE_ERROR').track({
52
- phase,
53
- category,
54
- isStart,
55
- err: err.message || 'CPL_LOG_PHASE_ERROR',
56
- details: err.details,
57
- stack: JSON.stringify(err.stack || err)
58
- }).flush();
59
- }
60
- };
61
-
62
- const _store = {
63
- triggerInitialCPLEvent: true,
64
- hasContingencies: false
65
- };
66
-
67
- const triggerCPLLatencyMetricsFPTI = (buttonId : string) => {
68
- const cplLatencyMetrics = {
69
- [FPTI_KEY.STATE]: 'CPL_LATENCY_METRICS',
70
- [FPTI_KEY.TRANSITION]: 'process_client_metrics',
71
- [FPTI_CPL_KEY.PAGE_NAME]: `main:xo:paypal-components:smart-payment-buttons`,
72
- [FPTI_CPL_KEY.CPL_COMP_METRICS]: JSON.stringify(cplPhases?.[buttonId]?.comp || {}),
73
- [FPTI_CPL_KEY.CPL_QUERY_METRICS]: JSON.stringify(cplPhases?.[buttonId]?.query || {}),
74
- [FPTI_CPL_KEY.CPL_CHUNK_METRICS]: JSON.stringify(cplPhases?.[buttonId]?.chunk || {})
75
- };
76
-
77
- getLogger().info('CPL_LATENCY_METRICS_FIRST_RENDER').track(cplLatencyMetrics).flush();
78
- };
79
-
80
- export const updateTriggerInitialCPLEvent = (state : boolean) => {
81
- getLogger().info(`CPL_UPDATE_TRIGGER_INITIAL_CPL_EVENT_TO_${ state.toString() }`).flush();
82
- _store.triggerInitialCPLEvent = state;
83
- };
84
-
85
- export const shouldTriggerInitialCPLEvent = () : boolean => {
86
- return _store.triggerInitialCPLEvent;
87
- };
88
-
89
- export const triggerInitialCPLEvent = (buttonId : string) => {
90
- if (shouldTriggerInitialCPLEvent()) {
91
- // Set the flag to false so that CPL call is not triggered again
92
- updateTriggerInitialCPLEvent(false);
93
- // Trigger FPTI event to capture the time spent on different phases.
94
- triggerCPLLatencyMetricsFPTI(buttonId);
95
- }
96
- };