@alipay/ams-checkout 0.0.1715248982-dev.0 → 0.0.1716363774-dev.0

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.
@@ -152,9 +152,6 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
152
152
  key: "pluginAppendIframe",
153
153
  value: function pluginAppendIframe(appendParams) {
154
154
  try {
155
- this.logger.logInfo({
156
- title: 'sdk_event_createComponent'
157
- }).send();
158
155
  return this._componentApp.appendIframeNodes(appendParams.componentSign, appendParams.iframeNodesParams);
159
156
  } catch (error) {
160
157
  return Promise.reject(error);
@@ -311,6 +308,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
311
308
  value: function createComponent(params) {
312
309
  var _this4 = this;
313
310
  this.clearPreloadIframe();
311
+ this.logger.setComponentStartTime(Date.now());
314
312
  return this.parameterInitAndCheck({
315
313
  params: params,
316
314
  renderDisplayType: renderDisplayTypeEnum.popup
@@ -401,6 +399,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
401
399
  value: function mountComponent(params, selector) {
402
400
  var _this6 = this;
403
401
  this.clearPreloadIframe();
402
+ this.logger.setComponentStartTime(Date.now());
404
403
  return this.parameterInitAndCheck({
405
404
  params: params,
406
405
  renderDisplayType: renderDisplayTypeEnum.inline,
@@ -1,5 +1,5 @@
1
1
  import { componentSignEnum, Ianalytics, renderDisplayTypeEnum } from '../../types';
2
- export declare const getAppPath: (environment: string, appVersion: string, componentSign: componentSignEnum, productScene: string, productSceneVersion: string, extendInfo: string, mid: string) => any;
2
+ export declare const getAppPath: (environment: string, appVersion: string, componentSign: componentSignEnum, productScene: string, productSceneVersion: string, extendInfo: string, mid: string, sendLog?: boolean) => any;
3
3
  export declare const getAppDomain: (domainParams: {
4
4
  environment: string;
5
5
  appVersion: string;
@@ -12,28 +12,31 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
12
12
  import { marmotMap, sdkVersion } from "../../config/index";
13
13
  import { componentSignEnum } from "../../types";
14
14
  import { isDebugLog } from "../../util/debug";
15
- import { getViewPort, queryParse, serialize } from "../../util/index";
15
+ import { queryParse, serialize } from "../../util/index";
16
16
  import { Logger } from "../../util/logger";
17
17
  import { getLastAppVersion, getMatchAppVersion, setLastAppVersion } from "../../util/upgrade";
18
18
  var getAppVersion = function getAppVersion(_extendInfo, productScene, mid) {
19
+ var sendLog = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
19
20
  try {
20
- var _Logger$getInstance;
21
21
  var appVersion = getMatchAppVersion(_extendInfo, {
22
22
  sdkVersion: sdkVersion,
23
23
  productScene: productScene,
24
24
  mid: mid
25
25
  });
26
- // 有sessionData加载时
27
- (_Logger$getInstance = Logger.getInstance()) === null || _Logger$getInstance === void 0 || _Logger$getInstance.logInfo({
28
- title: 'sdk_event_appUpgradeInfo'
29
- }, {
30
- appUpgradeVersion: appVersion,
31
- appUpgraded: appVersion ? true : false,
32
- isPreload: _extendInfo ? false : true,
33
- extendInfo: _extendInfo,
34
- productScene: productScene,
35
- mid: mid
36
- });
26
+ if (sendLog) {
27
+ var _Logger$getInstance;
28
+ (_Logger$getInstance = Logger.getInstance()) === null || _Logger$getInstance === void 0 || _Logger$getInstance.logInfo({
29
+ title: 'sdk_event_appUpgradeInfo'
30
+ }, {
31
+ appUpgradeVersion: appVersion,
32
+ appUpgraded: appVersion ? true : false,
33
+ isPreload: _extendInfo ? false : true,
34
+ extendInfo: _extendInfo,
35
+ productScene: productScene,
36
+ mid: mid
37
+ });
38
+ }
39
+
37
40
  // 没有匹配到版本,查询上次的加载版本
38
41
  if (!appVersion) {
39
42
  appVersion = getLastAppVersion(productScene);
@@ -66,9 +69,10 @@ export var getAppPath = function getAppPath() {
66
69
  var productSceneVersion = arguments.length > 4 ? arguments[4] : undefined;
67
70
  var extendInfo = arguments.length > 5 ? arguments[5] : undefined;
68
71
  var mid = arguments.length > 6 ? arguments[6] : undefined;
72
+ var sendLog = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
69
73
  var _ref = queryParse() || {},
70
74
  urlTestHost = _ref.host;
71
- var upgradeAppVersion = getAppVersion(extendInfo, productScene, mid);
75
+ var upgradeAppVersion = getAppVersion(extendInfo, productScene, mid, sendLog);
72
76
  var finalAppVersion = upgradeAppVersion || appVersion;
73
77
  // 当有升级版本时,更新到全局字段
74
78
  if (upgradeAppVersion) {
@@ -120,14 +124,12 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
120
124
  hostSign = _iframeParams$hostSig === void 0 ? '' : _iframeParams$hostSig,
121
125
  _iframeParams$mid = iframeParams.mid,
122
126
  mid = _iframeParams$mid === void 0 ? '' : _iframeParams$mid;
123
- var path = getAppPath(environment, appVersion, componentSign, productScene, productSceneVersion, extendInfo || '', mid);
127
+ var path = getAppPath(environment, appVersion, componentSign, productScene, productSceneVersion, extendInfo || '', mid, true);
124
128
  var appMatched = getMatchAppVersion(extendInfo, {
125
129
  sdkVersion: sdkVersion,
126
130
  productScene: productScene,
127
131
  mid: mid
128
132
  }) ? 'true' : 'false';
129
- var initialScale = 1;
130
- var scale = getViewPort('initial-scale') || initialScale;
131
133
  var _queryParse = queryParse(),
132
134
  _sandbox = _queryParse._sandbox,
133
135
  _light_sandbox = _queryParse._light_sandbox,
@@ -140,7 +142,6 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
140
142
  var urlParams = Object.assign({}, {
141
143
  displayType: renderDisplayType,
142
144
  locale: locale,
143
- scale: scale,
144
145
  instanceId: instanceId,
145
146
  appMatched: appMatched,
146
147
  analyticsEnabled: (analytics === null || analytics === void 0 ? void 0 : analytics.enabled) === false ? 'false' : 'true',
@@ -156,7 +157,6 @@ export var getIframeUrl = function getIframeUrl(iframeParams) {
156
157
  if (environment === 'light_sandbox' || _light_sandbox === 'true') urlParams.sandbox = 'true';
157
158
  if (environment === 'sandbox' || _sandbox === 'true') urlParams.shadow = 'true';
158
159
  if (_displayType) urlParams.displayType = _displayType;
159
- if (isPreload) urlParams.isPreload = isPreload;
160
160
  var locationSearch = serialize(urlParams);
161
161
  if (isDebugLog()) {
162
162
  console.log('appUpgrade#getIframeUrl#appMatched', appMatched);
@@ -97,7 +97,7 @@ export default class ComponentApp {
97
97
  */
98
98
  dispatchToApp(payload: {
99
99
  context: eventPayloadContext;
100
- }, targetElement?: any, sendLog?: boolean): any;
100
+ }, targetElement?: any): any;
101
101
  /**
102
102
  * @description Subscribe to messages from SDK
103
103
  */
@@ -55,7 +55,7 @@ var ComponentApp = /*#__PURE__*/function () {
55
55
  _defineProperty(this, "_multipleCallbackEvents", void 0);
56
56
  _defineProperty(this, "_merchantAppointParam", void 0);
57
57
  _defineProperty(this, "_webAppHeartBeatTimeoutFn", void 0);
58
- this._appVersion = '1.14.0.0';
58
+ this._appVersion = '1.15.0';
59
59
  this._isInitComponent = false;
60
60
  this._selector = "#".concat(COMPONENT_SECTION_ID);
61
61
  this.createIframeNode = function () {
@@ -112,7 +112,7 @@ var ComponentApp = /*#__PURE__*/function () {
112
112
  productSceneVersion: paymentSessionConfig === null || paymentSessionConfig === void 0 ? void 0 : paymentSessionConfig.productSceneVersion,
113
113
  paymentMethodType: paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa = paymentSessionMetaData.paymentMethodInfoView) === null || _paymentSessionMetaDa === void 0 ? void 0 : _paymentSessionMetaDa.paymentMethodType,
114
114
  paymentMethodCategoryType: paymentSessionConfig === null || paymentSessionConfig === void 0 ? void 0 : paymentSessionConfig.paymentMethodCategoryType,
115
- requestSeq: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.paymentSessionData,
115
+ requestSeq: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.sessionData,
116
116
  trackId: (_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.sessionData
117
117
  });
118
118
  }
@@ -1348,20 +1348,12 @@ var ComponentApp = /*#__PURE__*/function () {
1348
1348
  key: "dispatchToApp",
1349
1349
  value: function dispatchToApp(payload) {
1350
1350
  var targetElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
1351
- var sendLog = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1352
1351
  var data = Object.assign({}, payload, {
1353
1352
  name: messageName.SDK_TO_APP,
1354
1353
  mode: this.AMSSDK.options.mode,
1355
1354
  appId: COMPONENTPLUGINID,
1356
1355
  instanceId: this.AMSSDK._instanceId
1357
1356
  });
1358
- if (sendLog) {
1359
- this.AMSSDK.logger.logInfo({
1360
- title: 'sdk_event_send_message_to_web'
1361
- }, {
1362
- event: data === null || data === void 0 ? void 0 : data.context.event
1363
- }).send();
1364
- }
1365
1357
  if (targetElement && targetElement.contentWindow) {
1366
1358
  return targetElement.contentWindow.postMessage(JSON.stringify(data), '*');
1367
1359
  }
@@ -1450,7 +1442,7 @@ var ComponentApp = /*#__PURE__*/function () {
1450
1442
  })
1451
1443
  }
1452
1444
  }
1453
- }, null, true);
1445
+ }, null);
1454
1446
  this.AMSSDK.logger.logInfo({
1455
1447
  title: 'sdk_event_renderComponent'
1456
1448
  });
@@ -1489,9 +1481,6 @@ var ComponentApp = /*#__PURE__*/function () {
1489
1481
  var _document$getElementB4,
1490
1482
  _this9 = this;
1491
1483
  var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1492
- this.AMSSDK.logger.logInfo({
1493
- title: 'sdk_event_clean_component'
1494
- }).send();
1495
1484
  (_document$getElementB4 = document.getElementById(LOADING_ID)) === null || _document$getElementB4 === void 0 || _document$getElementB4.remove();
1496
1485
  this.hideComponentAnimation();
1497
1486
  var mockup = document.getElementById(MOCKUP_ID);
@@ -84,7 +84,7 @@ export interface IappendIframeNodesParams extends IcreateComponent {
84
84
  paypalConfiguration?: IPaypalConfiguration;
85
85
  }
86
86
  export interface IPaypalConfiguration {
87
- style?: Object;
87
+ style?: object;
88
88
  blockPayPalCreditButton?: boolean;
89
89
  blockPayPalPayLaterButton?: boolean;
90
90
  displayPayPalPayLaterButtonOnly?: boolean;
package/esm/util/debug.js CHANGED
@@ -1,9 +1,9 @@
1
- import { queryParse } from ".";
1
+ import { queryParse } from '.';
2
2
  export var isDebugLog = function isDebugLog() {
3
3
  var _ref = queryParse() || {},
4
4
  environment = _ref.environment;
5
5
  if (!environment) {
6
6
  return false;
7
7
  }
8
- return environment !== 'prod';
8
+ return environment === 'dev';
9
9
  };
@@ -43,10 +43,15 @@ export var Logger = /*#__PURE__*/function () {
43
43
  }, {
44
44
  key: "logError",
45
45
  value: function logError(error, extra) {
46
+ var now = Date.now();
47
+ var fsDuration = now - this.componentStartTime;
46
48
  this.logs.push({
47
49
  type: 'error',
48
50
  logPayload: error,
49
- extra: extra
51
+ extra: _objectSpread(_objectSpread({}, extra), {}, {
52
+ fsDuration: fsDuration,
53
+ timeStamp: now
54
+ })
50
55
  });
51
56
  if (this.debug) {
52
57
  console.error(error);
@@ -57,10 +62,15 @@ export var Logger = /*#__PURE__*/function () {
57
62
  }, {
58
63
  key: "logInfo",
59
64
  value: function logInfo(info, extra) {
65
+ var now = Date.now();
66
+ var fsDuration = now - this.componentStartTime;
60
67
  this.logs.push({
61
68
  type: 'info',
62
69
  logPayload: info,
63
- extra: extra
70
+ extra: _objectSpread(_objectSpread({}, extra), {}, {
71
+ fsDuration: fsDuration,
72
+ timeStamp: now
73
+ })
64
74
  });
65
75
  if (this.debug) {
66
76
  console.log(info);
@@ -71,10 +81,15 @@ export var Logger = /*#__PURE__*/function () {
71
81
  }, {
72
82
  key: "reportRPC",
73
83
  value: function reportRPC(rpcData, extra) {
84
+ var now = Date.now();
85
+ var fsDuration = now - this.componentStartTime;
74
86
  this.logs.push({
75
87
  type: 'rpc',
76
88
  logPayload: rpcData,
77
- extra: extra
89
+ extra: _objectSpread(_objectSpread({}, extra), {}, {
90
+ fsDuration: fsDuration,
91
+ timeStamp: now
92
+ })
78
93
  });
79
94
  if (this.debug) {
80
95
  console.log(rpcData);
@@ -94,32 +109,24 @@ export var Logger = /*#__PURE__*/function () {
94
109
  logInfo = _window$iTracker.logInfo,
95
110
  reportRPC = _window$iTracker.reportRPC;
96
111
  var logs = this.logs;
97
- var now = Date.now();
98
- var fsDuration = now - this.componentStartTime;
99
112
  while (logs.length > 0) {
100
113
  try {
101
114
  var log = logs.pop();
102
115
  if (log.type === 'error') {
103
116
  var _log$logPayload;
104
117
  logError(log.logPayload, _objectSpread({
105
- fsDuration: fsDuration,
106
- timeStamp: now,
107
118
  trackId: this.trackId,
108
119
  title: (_log$logPayload = log.logPayload) === null || _log$logPayload === void 0 ? void 0 : _log$logPayload.title
109
120
  }, log === null || log === void 0 ? void 0 : log.extra));
110
121
  } else if (log.type === 'info') {
111
122
  var _log$logPayload2;
112
123
  logInfo(log.logPayload, _objectSpread({
113
- fsDuration: fsDuration,
114
- timeStamp: now,
115
124
  trackId: this.trackId,
116
125
  title: (_log$logPayload2 = log.logPayload) === null || _log$logPayload2 === void 0 ? void 0 : _log$logPayload2.title
117
126
  }, log === null || log === void 0 ? void 0 : log.extra));
118
127
  } else if (log.type === 'rpc') {
119
128
  var _log$logPayload3;
120
129
  reportRPC(log.logPayload, _objectSpread({
121
- fsDuration: fsDuration,
122
- timeStamp: now,
123
130
  trackId: this.trackId,
124
131
  title: (_log$logPayload3 = log.logPayload) === null || _log$logPayload3 === void 0 ? void 0 : _log$logPayload3.title
125
132
  }, log === null || log === void 0 ? void 0 : log.extra));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/ams-checkout",
3
- "version": "0.0.1715248982-dev.0",
3
+ "version": "0.0.1716363774-dev.0",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "esm/index.js",