@paypal/checkout-components 5.0.289 → 5.0.290

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.289",
3
+ "version": "5.0.290",
4
4
  "description": "PayPal Checkout components, for integrating checkout products.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -6,7 +6,9 @@ import {
6
6
  getClientMetadataID,
7
7
  getUserIDToken,
8
8
  getLogger,
9
+ getDebug,
9
10
  } from "@paypal/sdk-client/src";
11
+ import { FPTI_KEY } from "@paypal/sdk-constants";
10
12
 
11
13
  import { sendCountMetric } from "./sendCountMetric";
12
14
 
@@ -20,6 +22,7 @@ export const getConnectComponent = async (merchantProps) => {
20
22
  const cmid = getClientMetadataID();
21
23
  const clientID = getClientID();
22
24
  const userIdToken = getUserIDToken();
25
+ const debugEnabled = getDebug() || false;
23
26
  const { metadata } = merchantProps;
24
27
 
25
28
  let loadResult = {};
@@ -27,7 +30,7 @@ export const getConnectComponent = async (merchantProps) => {
27
30
  loadResult = await loadAxo({
28
31
  platform: "PPCP",
29
32
  btSdkVersion: "3.97.3-connect-alpha.6.1",
30
- minified: true,
33
+ minified: !debugEnabled,
31
34
  metadata,
32
35
  });
33
36
  } catch (error) {
@@ -39,7 +42,14 @@ export const getConnectComponent = async (merchantProps) => {
39
42
  },
40
43
  });
41
44
 
42
- getLogger().error("load_axo_error", { err: stringifyError(error) });
45
+ getLogger()
46
+ .track({
47
+ [FPTI_KEY.CONTEXT_TYPE]: "CMID",
48
+ [FPTI_KEY.CONTEXT_ID]: cmid,
49
+ [FPTI_KEY.EVENT_NAME]: `ppcp_axo_failure`,
50
+ })
51
+ .error("load_connect_error", { err: stringifyError(error) })
52
+ .flush();
43
53
 
44
54
  throw new Error(error);
45
55
  }
@@ -52,10 +62,16 @@ export const getConnectComponent = async (merchantProps) => {
52
62
  platform: "PPCP",
53
63
  userIdToken,
54
64
  clientID,
55
- clientMetadataID: cmid,
65
+ clientMetadataId: cmid,
56
66
  },
57
67
  });
58
-
68
+ getLogger()
69
+ .track({
70
+ [FPTI_KEY.CONTEXT_TYPE]: "CMID",
71
+ [FPTI_KEY.CONTEXT_ID]: cmid,
72
+ [FPTI_KEY.EVENT_NAME]: `ppcp_connect_success`,
73
+ })
74
+ .flush();
59
75
  sendCountMetric({
60
76
  name: "pp.app.paypal_sdk.connect.init.success.count",
61
77
  event: "success",
@@ -72,7 +88,14 @@ export const getConnectComponent = async (merchantProps) => {
72
88
  },
73
89
  });
74
90
 
75
- getLogger().error("init_axo_error", { err: stringifyError(error) });
91
+ getLogger()
92
+ .track({
93
+ [FPTI_KEY.CONTEXT_TYPE]: "CMID",
94
+ [FPTI_KEY.CONTEXT_ID]: cmid,
95
+ [FPTI_KEY.EVENT_NAME]: `ppcp_connect_failure`,
96
+ })
97
+ .error("init_connect_error", { err: stringifyError(error) })
98
+ .flush();
76
99
 
77
100
  throw new Error(error);
78
101
  }
@@ -16,6 +16,7 @@ vi.mock("@paypal/sdk-client/src", () => {
16
16
  getClientID: vi.fn(() => "mock-client-id"),
17
17
  getClientMetadataID: vi.fn(() => "mock-cmid"),
18
18
  getUserIDToken: vi.fn(() => "mock-uid"),
19
+ getDebug: vi.fn(() => false),
19
20
  getLogger: vi.fn(() => ({ metric: vi.fn(), error: vi.fn() })),
20
21
  };
21
22
  });
@@ -86,4 +87,14 @@ describe("getConnectComponent: returns ConnectComponent", () => {
86
87
  );
87
88
  expect(sendCountMetric).toBeCalledTimes(2);
88
89
  });
90
+
91
+ test("minified is set according to debug value", async () => {
92
+ await getConnectComponent(mockProps);
93
+ expect(loadAxo).toHaveBeenCalledWith({
94
+ minified: true,
95
+ btSdkVersion: "3.97.3-connect-alpha.6.1",
96
+ metadata: undefined,
97
+ platform: "PPCP",
98
+ });
99
+ });
89
100
  });