@alipay/ams-checkout 0.0.1732700846-dev.1 → 0.0.1732700846-dev.11

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.
Files changed (63) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/component/channel.js +1 -1
  3. package/esm/component/component.popup.style.d.ts +2 -0
  4. package/esm/component/component.popup.style.js +15 -2
  5. package/esm/config/index.d.ts +7 -7
  6. package/esm/config/index.js +7 -7
  7. package/esm/constant/index.d.ts +17 -0
  8. package/esm/constant/index.js +18 -0
  9. package/esm/core/bus/index.d.ts +3 -3
  10. package/esm/core/bus/index.js +14 -14
  11. package/esm/core/component/appPreloadProcessing.js +2 -2
  12. package/esm/core/component/ckp/index.js +6 -3
  13. package/esm/core/component/element/index.d.ts +1 -0
  14. package/esm/core/component/element/index.js +79 -70
  15. package/esm/core/component/element/mock.d.ts +2 -0
  16. package/esm/core/component/element/mock.js +129 -53
  17. package/esm/core/component/element/type.d.ts +5 -4
  18. package/esm/core/component/element/type.js +3 -2
  19. package/esm/core/component/index.js +8 -12
  20. package/esm/core/instance/index.js +3 -3
  21. package/esm/foundation/core/index.d.ts +2 -0
  22. package/esm/foundation/core/index.js +50 -20
  23. package/esm/foundation/product-processor/easysafepay/index.js +17 -16
  24. package/esm/foundation/service/api-bus/busManager.d.ts +3 -3
  25. package/esm/foundation/service/api-bus/busManager.js +14 -14
  26. package/esm/foundation/service/container/index.d.ts +2 -0
  27. package/esm/foundation/service/container/index.js +33 -1
  28. package/esm/foundation/service/event-center.d.ts +9 -3
  29. package/esm/foundation/service/event-center.js +41 -10
  30. package/esm/foundation/service/log/index.d.ts +2 -2
  31. package/esm/foundation/service/log/index.js +23 -8
  32. package/esm/foundation/service/log/keys.d.ts +13 -0
  33. package/esm/foundation/service/log/keys.js +103 -0
  34. package/esm/foundation/service/log/processor.d.ts +9 -0
  35. package/esm/foundation/service/log/processor.js +148 -0
  36. package/esm/foundation/service/log/types.d.ts +1 -1
  37. package/esm/foundation/service/requester/requester.js +3 -0
  38. package/esm/foundation/service/security/index.js +6 -8
  39. package/esm/foundation/utils/redirect_utils.js +1 -2
  40. package/esm/index.d.ts +1 -0
  41. package/esm/index.js +6 -1
  42. package/esm/plugin/applepay/component.js +10 -8
  43. package/esm/plugin/applepay/index.js +10 -6
  44. package/esm/plugin/applepay/interface.d.ts +2 -2
  45. package/esm/plugin/applepay/service.js +24 -16
  46. package/esm/plugin/component/cashierApp.js +3 -3
  47. package/esm/plugin/component/channel.d.ts +41 -1
  48. package/esm/plugin/component/channel.js +590 -2
  49. package/esm/plugin/component/component.popup.style.d.ts +8 -0
  50. package/esm/plugin/component/component.popup.style.js +22 -2
  51. package/esm/plugin/component/index.d.ts +3 -1
  52. package/esm/plugin/component/index.js +136 -68
  53. package/esm/plugin/paypal/index.js +1 -1
  54. package/esm/service/index.js +4 -2
  55. package/esm/types/index.d.ts +32 -2
  56. package/esm/types/index.js +3 -2
  57. package/esm/util/getBackScheme.js +1 -2
  58. package/esm/util/index.js +4 -8
  59. package/esm/util/logger.d.ts +3 -3
  60. package/esm/util/logger.js +49 -13
  61. package/esm/util/spm-map.d.ts +172 -0
  62. package/esm/util/spm-map.js +172 -0
  63. package/package.json +1 -1
@@ -9,7 +9,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
9
9
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
10
  import { v4 as uuid } from 'uuid';
11
11
  import { ERRORMESSAGE } from "../../constant";
12
- import { EventPayload, MessageName } from "../../types";
12
+ import { MessageName } from "../../types";
13
13
  import { isJsonString } from "../../util";
14
14
  import { getIframeOrigin, registerSystemEvents, unRegisterSystemEvents } from "../utils/system_events";
15
15
 
@@ -72,6 +72,15 @@ export var EventCenter = /*#__PURE__*/function () {
72
72
  origin: getIframeOrigin(iframe)
73
73
  });
74
74
  }
75
+
76
+ /**
77
+ * Cleans iframes when web app close
78
+ */
79
+ }, {
80
+ key: "cleanIFrames",
81
+ value: function cleanIFrames() {
82
+ this.iframes = [];
83
+ }
75
84
  }, {
76
85
  key: "removeIFrame",
77
86
  value: function removeIFrame(iframe) {
@@ -99,15 +108,35 @@ export var EventCenter = /*#__PURE__*/function () {
99
108
  }
100
109
  var isJson = isJsonString(e.data);
101
110
  if (isJson) {
102
- var _EventPayload = JSON.parse(e.data);
103
- if (_EventPayload.name !== MessageName.APP_TO_SDK) {
111
+ var _eventPayload = JSON.parse(e.data);
112
+ if (!this.checkEventCompliant(_eventPayload)) {
104
113
  return;
105
114
  }
106
- this._handleAppMessage(_EventPayload);
115
+ this._handleAppMessage(_eventPayload);
107
116
  } else {
108
117
  console.error(ERRORMESSAGE.NOT_JSON_FORMAT);
109
118
  }
110
119
  }
120
+ }, {
121
+ key: "checkEventCompliant",
122
+ value: function checkEventCompliant(eventPayload) {
123
+ // connect element场景下,多子iframes共用AntomCore中生成的instanceId,此时将发送事件方instanceId与iframes中instanceId做比较看是否在其中
124
+ // 非connect场景下,直接将发送事件方instanceId与AntomCore的instanceId做比较
125
+ if (eventPayload.name !== MessageName.APP_TO_SDK) {
126
+ return false;
127
+ }
128
+ var iframesInstanceIds = this.iframes.map(function (iframe) {
129
+ var _iframe$ref;
130
+ if (!new URL((_iframe$ref = iframe.ref) === null || _iframe$ref === void 0 ? void 0 : _iframe$ref.src)) {
131
+ return;
132
+ }
133
+ return new URL(iframe.ref.src).searchParams.get('instanceId');
134
+ }).filter(Boolean);
135
+ if (eventPayload.instanceId !== this.instanceId && !iframesInstanceIds.includes(eventPayload.instanceId)) {
136
+ return false;
137
+ }
138
+ return true;
139
+ }
111
140
 
112
141
  /**
113
142
  * Processes the application message and emits the associated event.
@@ -115,22 +144,24 @@ export var EventCenter = /*#__PURE__*/function () {
115
144
  */
116
145
  }, {
117
146
  key: "_handleAppMessage",
118
- value: function _handleAppMessage(EventPayload) {
119
- var context = EventPayload.context;
147
+ value: function _handleAppMessage(eventPayload) {
148
+ var context = eventPayload.context;
120
149
  var event = context.event,
121
150
  data = context.data;
122
- this.emit(event, data, EventPayload);
151
+ this.emit(event, data, eventPayload);
123
152
  }
124
153
 
125
154
  /**
126
155
  * Listens to an event by adding a callback function.
127
156
  * @param name - The name of the event to listen for.
128
157
  * @param func - The callback function to execute when the event is emitted.
158
+ * @param isAppend - Append to event handlers as chain, default value is false
129
159
  */
130
160
  }, {
131
161
  key: "listen",
132
162
  value: function listen(name, func) {
133
- var eventList = this.events.get(name) || [];
163
+ var isAppend = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
164
+ var eventList = isAppend ? this.events.get(name) || [] : [];
134
165
  eventList.push({
135
166
  func: func
136
167
  });
@@ -165,11 +196,11 @@ export var EventCenter = /*#__PURE__*/function () {
165
196
  */
166
197
  }, {
167
198
  key: "emit",
168
- value: function emit(name, data, EventPayload) {
199
+ value: function emit(name, data, eventPayload) {
169
200
  if (this.events.has(name)) {
170
201
  var eventList = this.events.get(name);
171
202
  eventList.forEach(function (item) {
172
- item.func(data, EventPayload);
203
+ item.func(data, eventPayload);
173
204
  });
174
205
  }
175
206
  }
@@ -30,9 +30,9 @@ export declare class LogService implements Service {
30
30
  destroy(): void;
31
31
  setMetaData(metaData: LogMetaData): void;
32
32
  getLogConfig(): Config;
33
- logError(error: LogPayload, extra?: LogExtra): LogService;
33
+ logError(error: LogPayload, extra?: LogExtra, enableExtractCompliance?: boolean): LogService;
34
34
  logInfo(info: LogPayload, extra?: LogExtra): LogService;
35
- log(type: string, payload: any, extra?: LogExtra): LogService;
35
+ log(type: string, payload: LogPayload, extra?: LogExtra, enableExtractCompliance?: boolean): LogService;
36
36
  private reportLogs;
37
37
  private loadScript;
38
38
  private initTracker;
@@ -8,8 +8,10 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
8
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
9
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
10
  import { EnvironmentEnum } from "../../../types";
11
+ import { LogComplianceProcessor } from "./processor";
11
12
  import { isPC } from "../../../util";
12
13
  import { getStorageString, setStorageString } from "../../../util/storage";
14
+ import { SPM_MAP } from "../../../util/spm-map";
13
15
 
14
16
  /**
15
17
  * @author 谦彧 <zhangmian.zm@alipay.com>
@@ -44,7 +46,7 @@ export var LogService = /*#__PURE__*/function () {
44
46
  this.setMetaData({
45
47
  instanceId: instanceId,
46
48
  // use to identify a device, named from deprecated SDK
47
- storageId: deviceId,
49
+ deviceId: deviceId,
48
50
  sdkVersion: sdkMetaData.sdkVersion,
49
51
  webAppVersion: sdkMetaData.webAppVersion,
50
52
  productScene: sdkMetaData.productScene,
@@ -103,7 +105,8 @@ export var LogService = /*#__PURE__*/function () {
103
105
  }, {
104
106
  key: "logError",
105
107
  value: function logError(error, extra) {
106
- return this.log('error', error, extra);
108
+ var enableExtractCompliance = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
109
+ return this.log('error', error, extra, enableExtractCompliance);
107
110
  }
108
111
  }, {
109
112
  key: "logInfo",
@@ -113,18 +116,30 @@ export var LogService = /*#__PURE__*/function () {
113
116
  }, {
114
117
  key: "log",
115
118
  value: function log(type, payload, extra) {
119
+ var _this2 = this;
120
+ var enableExtractCompliance = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
121
+ var newExtra = enableExtractCompliance ? LogComplianceProcessor.extractComplianceParams(payload.title, extra !== null && extra !== void 0 ? extra : {}, function (error, ext) {
122
+ _this2.logError(error, ext, false);
123
+ }) : extra !== null && extra !== void 0 ? extra : {};
116
124
  var now = Date.now();
117
125
  var fsDuration = now - this.componentStartTime;
126
+ var newPayload = _objectSpread({}, payload);
127
+ var oldTitle = payload === null || payload === void 0 ? void 0 : payload.title;
128
+ if (SPM_MAP[oldTitle]) {
129
+ newPayload.title = SPM_MAP[oldTitle];
130
+ }
131
+ newExtra.eventSource = 'sdk';
132
+ newExtra.eventAlias = extra !== null && extra !== void 0 && extra.eventAlias ? extra === null || extra === void 0 ? void 0 : extra.eventAlias : oldTitle;
118
133
  this.logs.push({
119
134
  type: type,
120
- logPayload: payload,
121
- extra: _objectSpread(_objectSpread({}, extra), {}, {
135
+ logPayload: newPayload,
136
+ extra: _objectSpread(_objectSpread({}, newExtra), {}, {
122
137
  fsDuration: fsDuration,
123
138
  timeStamp: now
124
139
  })
125
140
  });
126
141
  if (this.debug) {
127
- console.log('[web-sdk] Log', payload, extra);
142
+ console.log('[web-sdk] Log', newPayload, newExtra);
128
143
  }
129
144
  this.send();
130
145
  return this;
@@ -180,16 +195,16 @@ export var LogService = /*#__PURE__*/function () {
180
195
  }, {
181
196
  key: "initTracker",
182
197
  value: function initTracker() {
183
- var _this2 = this;
198
+ var _this3 = this;
184
199
  if (this.isLoaded) return;
185
200
  this.isLoaded = true;
186
201
  try {
187
202
  if (typeof localStorage !== 'undefined') {
188
203
  this.loadScript(this.config.scriptUrl, function () {
189
204
  var _window4;
190
- (_window4 = window) === null || _window4 === void 0 || _window4.iTracker.initiTracker(_this2.config);
205
+ (_window4 = window) === null || _window4 === void 0 || _window4.iTracker.initiTracker(_this3.config);
191
206
  setTimeout(function () {
192
- _this2.reportLogs();
207
+ _this3.reportLogs();
193
208
  }, 80);
194
209
  });
195
210
  }
@@ -0,0 +1,13 @@
1
+ export declare class LogComplianceExtendKeys {
2
+ static complianceExtParams: Record<string, string>;
3
+ }
4
+ export declare const KEYS: {
5
+ EVENT_SDK_ON_ABNORMAL_EVENT_NAME: {
6
+ spmId: string;
7
+ alias: string;
8
+ };
9
+ EVENT_SDK_ON_ABNORMAL_EVENT_EXT_INFO: {
10
+ spmId: string;
11
+ alias: string;
12
+ };
13
+ };
@@ -0,0 +1,103 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
3
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ export var LogComplianceExtendKeys = /*#__PURE__*/_createClass(function LogComplianceExtendKeys() {
9
+ _classCallCheck(this, LogComplianceExtendKeys);
10
+ });
11
+ // 静态常量字典,用于存储合规扩展参数
12
+ // c 辅助排查问题的内容,通常是字符串类型
13
+ // m 是 number 类型,通常用于数学计算,比如求平均数
14
+ // d 是维度,比如城市,就是维度信息,典型的用法就是按照维度计算 m 值,比如求上海人年龄的平均数,那么,上海这个城市信息,上报的时候就放在 d 字段,每个人的年龄信息,就应该放在 m 字段
15
+ _defineProperty(LogComplianceExtendKeys, "complianceExtParams", {
16
+ // C 字符串类型
17
+ requestSeq: 'C',
18
+ firstLogTime: 'C',
19
+ sessionData: 'C',
20
+ isPreload: 'C',
21
+ disableAccelerate: 'C',
22
+ deviceId: 'C',
23
+ url: 'C',
24
+ errorName: 'C',
25
+ isPrerender: 'C',
26
+ loadWebAppType: 'C',
27
+ rpcTraceId: 'C',
28
+ timezone: 'C',
29
+ userPath: 'C',
30
+ previousEventName: 'C',
31
+ containerCacheFileCount: 'C',
32
+ containerTotalFileCount: 'C',
33
+ containerMissedFiles: 'C',
34
+ containerOfflinePkgId: 'C',
35
+ containerTotalPkgCount: 'C',
36
+ webAppUrl: 'C',
37
+ edcDeviceRequest: 'C',
38
+ config: 'C',
39
+ initOptions: 'C',
40
+ edcDeviceId: 'C',
41
+ instanceId: 'C',
42
+ trackId: 'C',
43
+ errorMessage: 'C',
44
+ timestamp: 'C',
45
+ eventMessage: 'C',
46
+ checkoutUrl: 'C',
47
+ redirectInfo: 'C',
48
+ riskSdkInfo: 'C',
49
+ actionName: 'C',
50
+ requestId: 'C',
51
+ callbackData: 'C',
52
+ callbackId: 'C',
53
+ actionNames: 'C',
54
+ // D 维度信息
55
+ operationType: 'D',
56
+ jsApi: 'D',
57
+ extSdkError: 'D',
58
+ processResult: 'D',
59
+ iterationVersion: 'D',
60
+ OperationType: 'D',
61
+ edcVendor: 'D',
62
+ platform: 'D',
63
+ sdkVersion: 'D',
64
+ eventSource: 'D',
65
+ productScene: 'D',
66
+ paymentMethodCategoryType: 'D',
67
+ productSceneVersion: 'D',
68
+ merchantId: 'D',
69
+ eventName: 'D',
70
+ paymentMethodType: 'D',
71
+ containerVersion: 'D',
72
+ locale: 'D',
73
+ renderDisplayType: 'D',
74
+ webAppVersion: 'D',
75
+ eventCode: 'D',
76
+ containerType: 'D',
77
+ logVersion: 'D',
78
+ httpCode: 'D',
79
+ openType: 'D',
80
+ isCrashTack: 'D',
81
+ isCrashTrackOverride: 'D',
82
+ appUpgradeVersion: 'D',
83
+ fromFastSdk: 'D',
84
+ terminalType: 'D',
85
+ eventAlias: 'D',
86
+ // 用来标记事件别名
87
+ success: 'D',
88
+ // 用来标记行为是否成功
89
+ // M 数字类型
90
+ timeCost: 'M',
91
+ pageLoadProgress: 'M',
92
+ fsDuration: 'M'
93
+ });
94
+ export var KEYS = {
95
+ EVENT_SDK_ON_ABNORMAL_EVENT_NAME: {
96
+ spmId: 'a3753.b101271.c388193.d513345',
97
+ alias: 'sdk_event_onAbnormalEventName'
98
+ },
99
+ EVENT_SDK_ON_ABNORMAL_EVENT_EXT_INFO: {
100
+ spmId: 'a3753.b101271.c388193.d513391',
101
+ alias: 'sdk_event_onAbnormalKeys'
102
+ }
103
+ };
@@ -0,0 +1,9 @@
1
+ import { LogExtra, LogPayload } from './types';
2
+ export declare class LogComplianceProcessor {
3
+ private static abnormalEventNameSet;
4
+ private static nonComplianceEventKeys;
5
+ static extractComplianceParams(eventName: string, params: Record<string, any>, errorLogCallback?: (error: LogPayload, extra?: LogExtra) => void): Record<string, string>;
6
+ private static reportHasAbnormalEventName;
7
+ private static reportHasIllegalExtendInfoKey;
8
+ static flushAbnormalInfo(errorLogCallback?: (error: LogPayload, extra?: LogExtra) => void): void;
9
+ }
@@ -0,0 +1,148 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
4
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
+ import { LogComplianceExtendKeys, KEYS } from "./keys";
9
+ export var LogComplianceProcessor = /*#__PURE__*/function () {
10
+ function LogComplianceProcessor() {
11
+ _classCallCheck(this, LogComplianceProcessor);
12
+ }
13
+ _createClass(LogComplianceProcessor, null, [{
14
+ key: "extractComplianceParams",
15
+ value: function extractComplianceParams(eventName, params, errorLogCallback) {
16
+ var _this = this;
17
+ try {
18
+ // 触发防抖上报
19
+ logDebounceTracker.track(function () {
20
+ _this.flushAbnormalInfo(errorLogCallback);
21
+ });
22
+ // 事件名检测
23
+ var isSpmId = eventName ? eventName.includes('.') : false;
24
+ if (!isSpmId) {
25
+ // 非SPM,说明是未做映射的,需要加到埋点里面
26
+ this.reportHasAbnormalEventName(eventName);
27
+ }
28
+ var newParams = {};
29
+ // 逐个字段检查
30
+ for (var _i = 0, _Object$keys = Object.keys(params); _i < _Object$keys.length; _i++) {
31
+ var key = _Object$keys[_i];
32
+ // 如果当前字段不在合规表中,说明是未合规字段,剔除并且上报异常
33
+ if (key in LogComplianceExtendKeys.complianceExtParams) {
34
+ newParams[key] = "".concat(params[key]);
35
+ } else {
36
+ // 如果当前字段不在合规表中,说明是未合规字段,剔除并且上报异常
37
+ this.reportHasIllegalExtendInfoKey(eventName, key);
38
+ }
39
+ }
40
+ return newParams;
41
+ } catch (error) {
42
+ console.error(error);
43
+ return {};
44
+ }
45
+ }
46
+ }, {
47
+ key: "reportHasAbnormalEventName",
48
+ value: function reportHasAbnormalEventName(eventName) {
49
+ this.abnormalEventNameSet.add(eventName);
50
+ }
51
+ }, {
52
+ key: "reportHasIllegalExtendInfoKey",
53
+ value: function reportHasIllegalExtendInfoKey(eventName, key) {
54
+ if (!this.nonComplianceEventKeys[eventName]) {
55
+ this.nonComplianceEventKeys[eventName] = new Set();
56
+ }
57
+ this.nonComplianceEventKeys[eventName].add(key);
58
+ }
59
+ }, {
60
+ key: "flushAbnormalInfo",
61
+ value: function flushAbnormalInfo(errorLogCallback) {
62
+ try {
63
+ var _this$abnormalEventNa;
64
+ if (((_this$abnormalEventNa = this.abnormalEventNameSet) === null || _this$abnormalEventNa === void 0 ? void 0 : _this$abnormalEventNa.size) > 0) {
65
+ // 不正常的事件名按|分割
66
+ // Abnormal event use event name with divider "|"
67
+ var abnormalEventNames = Array.from(this.abnormalEventNameSet).join('|');
68
+ errorLogCallback && errorLogCallback({
69
+ title: KEYS.EVENT_SDK_ON_ABNORMAL_EVENT_NAME.spmId
70
+ }, {
71
+ eventAlias: KEYS.EVENT_SDK_ON_ABNORMAL_EVENT_NAME.alias,
72
+ errorMessage: abnormalEventNames
73
+ });
74
+ this.abnormalEventNameSet.clear();
75
+ }
76
+ // process nonComplianceEventKeys
77
+ // eg: if sdk_event_createComponent has key1,key2,key3
78
+ // sdk_event_createComponent>key1+key2+key3|otherEventName>key1+key2+key3
79
+ var nonComplianceEventKeysList = [];
80
+ if (Object.keys(this.nonComplianceEventKeys).length === 0) {
81
+ return;
82
+ }
83
+ for (var eventName in this.nonComplianceEventKeys) {
84
+ var keys = this.nonComplianceEventKeys[eventName];
85
+ var keyStr = "".concat(eventName, ">").concat(Array.from(keys).join('+'));
86
+ nonComplianceEventKeysList.push(keyStr);
87
+ }
88
+ var nonComplianceEventKeysLogString = nonComplianceEventKeysList.join('|');
89
+ errorLogCallback && errorLogCallback({
90
+ title: KEYS.EVENT_SDK_ON_ABNORMAL_EVENT_EXT_INFO.spmId
91
+ }, {
92
+ eventAlias: KEYS.EVENT_SDK_ON_ABNORMAL_EVENT_EXT_INFO.alias,
93
+ errorMessage: nonComplianceEventKeysLogString
94
+ });
95
+ this.nonComplianceEventKeys = {};
96
+ } catch (error) {
97
+ console.error(error);
98
+ }
99
+ }
100
+ }]);
101
+ return LogComplianceProcessor;
102
+ }();
103
+ // 记录不正常的事件名
104
+ _defineProperty(LogComplianceProcessor, "abnormalEventNameSet", new Set());
105
+ // 记录不合规的扩展字段,KEY是事件名,VALUE是非合规扩展字段列表
106
+ _defineProperty(LogComplianceProcessor, "nonComplianceEventKeys", {});
107
+ var LogDebounceTracker = /*#__PURE__*/function () {
108
+ function LogDebounceTracker() {
109
+ var debounceTime = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 5000;
110
+ _classCallCheck(this, LogDebounceTracker);
111
+ _defineProperty(this, "timeoutId", void 0);
112
+ _defineProperty(this, "debounceTime", void 0);
113
+ this.timeoutId = null;
114
+ this.debounceTime = debounceTime;
115
+ }
116
+ _createClass(LogDebounceTracker, [{
117
+ key: "track",
118
+ value: function track(callback) {
119
+ this.debounce(callback);
120
+ }
121
+
122
+ // 防抖实现
123
+ }, {
124
+ key: "debounce",
125
+ value: function debounce(callback) {
126
+ var _this2 = this;
127
+ if (this.timeoutId) {
128
+ clearTimeout(this.timeoutId);
129
+ }
130
+ this.timeoutId = setTimeout(function () {
131
+ _this2.report(callback);
132
+ _this2.reset();
133
+ }, this.debounceTime);
134
+ }
135
+ }, {
136
+ key: "report",
137
+ value: function report(callback) {
138
+ callback && callback();
139
+ }
140
+ }, {
141
+ key: "reset",
142
+ value: function reset() {
143
+ this.timeoutId = null;
144
+ }
145
+ }]);
146
+ return LogDebounceTracker;
147
+ }();
148
+ var logDebounceTracker = new LogDebounceTracker();
@@ -20,7 +20,7 @@ export interface LogMetaData {
20
20
  firstLogTime?: number;
21
21
  fsDuration?: number;
22
22
  instanceId?: string;
23
- storageId?: string;
23
+ deviceId?: string;
24
24
  renderDisplayType?: string;
25
25
  merchantId?: string;
26
26
  productScene?: string;
@@ -80,6 +80,7 @@ export var RequesterService = /*#__PURE__*/function () {
80
80
  errorMessage = (resData === null || resData === void 0 ? void 0 : resData.errorMessage) || (handleGetWayError === null || handleGetWayError === void 0 ? void 0 : handleGetWayError.errorMessage);
81
81
  errorCode = handleGetWayError === null || handleGetWayError === void 0 ? void 0 : handleGetWayError.errorCode;
82
82
  this.reportRequestTimeCost({
83
+ title: 'a3753.b101271.c388193.d521387',
83
84
  name: options === null || options === void 0 ? void 0 : options['Operation-Type'],
84
85
  label: 'request',
85
86
  time: Date.now() - startTime,
@@ -95,6 +96,7 @@ export var RequesterService = /*#__PURE__*/function () {
95
96
  }));
96
97
  case 20:
97
98
  this.reportRequestTimeCost({
99
+ title: 'a3753.b101271.c388193.d521387',
98
100
  name: options === null || options === void 0 ? void 0 : options['Operation-Type'],
99
101
  label: 'request',
100
102
  time: Date.now() - startTime,
@@ -116,6 +118,7 @@ export var RequesterService = /*#__PURE__*/function () {
116
118
  timeoutCode = _context.t0 !== null && _context.t0 !== void 0 && (_error$message = _context.t0.message) !== null && _error$message !== void 0 && _error$message.includes('timeout') ? errorEnum.TIMEOUT : '';
117
119
  _errorCode = (_error === null || _error === void 0 ? void 0 : _error.errorCode) || timeoutCode;
118
120
  this.reportRequestTimeCost({
121
+ title: 'a3753.b101271.c388193.d521387',
119
122
  name: options === null || options === void 0 ? void 0 : options['Operation-Type'],
120
123
  label: 'request',
121
124
  time: Date.now() - startTime,
@@ -169,8 +169,8 @@ export var SecurityService = /*#__PURE__*/function () {
169
169
  _this2.logger.logError({
170
170
  title: 'sdk_error_securitySdkInitTimeout'
171
171
  }, {
172
- product: _this2.productScene,
173
- sign: isPre ? 'Active initialization' : 'SDK internal initialization'
172
+ productScene: _this2.productScene,
173
+ eventMessage: isPre ? 'Active initialization' : 'SDK internal initialization'
174
174
  }).send();
175
175
  reject();
176
176
  }, timeout);
@@ -182,7 +182,7 @@ export var SecurityService = /*#__PURE__*/function () {
182
182
  _this2.logger.logInfo({
183
183
  title: "sdk_event_securitySdk".concat(sdkAction, "Success")
184
184
  }, isPre ? {
185
- product: _this2.productScene
185
+ productScene: _this2.productScene
186
186
  } : undefined).send();
187
187
  resolve();
188
188
  }, function (msg) {
@@ -190,7 +190,7 @@ export var SecurityService = /*#__PURE__*/function () {
190
190
  title: 'sdk_error_securitySdkInitFailed',
191
191
  msg: msg || undefined
192
192
  }, {
193
- product: _this2.productScene,
193
+ productScene: _this2.productScene,
194
194
  sign: isPre ? 'Active initialization' : 'SDK internal initialization'
195
195
  }).send();
196
196
  reject();
@@ -215,15 +215,13 @@ export var SecurityService = /*#__PURE__*/function () {
215
215
  this.logger.logInfo({
216
216
  title: 'sdk_event_securitySdkGetTokenSuccess'
217
217
  }, {
218
- deviceId: deviceId,
219
- time: time
218
+ eventMessage: time
220
219
  }).send();
221
220
  } else {
222
221
  this.logger.logInfo({
223
222
  title: 'sdk_error_securitySdkGetTokenFailed'
224
223
  }, {
225
- deviceId: deviceId,
226
- time: time
224
+ eventMessage: time
227
225
  }).send();
228
226
  }
229
227
  }
@@ -240,8 +240,7 @@ function logBackScheme(logger, userAgent, scheme) {
240
240
  logger.logInfo({
241
241
  title: 'a3753.b101271.c377460'
242
242
  }, {
243
- userAgent: userAgent,
244
- backScheme: scheme
243
+ eventMessage: scheme
245
244
  });
246
245
  }
247
246
  }
package/esm/index.d.ts CHANGED
@@ -33,4 +33,5 @@ export declare class AMSEasyPay {
33
33
  private core;
34
34
  constructor(options: IoptionsParams);
35
35
  createComponent(params: IcreateComponent): void;
36
+ unmount(): void;
36
37
  }
package/esm/index.js CHANGED
@@ -98,7 +98,7 @@ export var AMSCashierPayment = /*#__PURE__*/function (_AMSCheckout3) {
98
98
  logger.logError({
99
99
  title: 'performance_optimization_get_previousChannel_error'
100
100
  }, {
101
- error: error
101
+ errorMessage: error
102
102
  });
103
103
  }
104
104
  return _super4.call(this, _options, currentChannelType);
@@ -181,6 +181,11 @@ export var AMSEasyPay = /*#__PURE__*/function () {
181
181
  isAppWebview: params.isAppWebview
182
182
  });
183
183
  }
184
+ }, {
185
+ key: "unmount",
186
+ value: function unmount() {
187
+ this.core.destroy();
188
+ }
184
189
  }]);
185
190
  return AMSEasyPay;
186
191
  }();
@@ -82,13 +82,15 @@ var ApplePayComponent = /*#__PURE__*/function () {
82
82
  name: 'APPLE_PAY',
83
83
  title: ApplePayComponentEvent.sdk_event_applePaymentResult
84
84
  }, {
85
- biz: 'sdk',
86
- type: 'funnel',
87
- success: eventCodeEnum.SDK_PAYMENT_SUCCESSFUL === (state === null || state === void 0 ? void 0 : state.code),
85
+ eventSource: 'sdk',
86
+ processResult: eventCodeEnum.SDK_PAYMENT_SUCCESSFUL === (state === null || state === void 0 ? void 0 : state.code),
88
87
  code: state === null || state === void 0 ? void 0 : state.code,
89
- errorCode: state === null || state === void 0 || (_state$result = state.result) === null || _state$result === void 0 ? void 0 : _state$result.errorCode,
88
+ extSdkError: state === null || state === void 0 || (_state$result = state.result) === null || _state$result === void 0 ? void 0 : _state$result.errorCode,
90
89
  errorMessage: state === null || state === void 0 || (_state$result2 = state.result) === null || _state$result2 === void 0 ? void 0 : _state$result2.errorMessage,
91
- recurring: this.isRecurring
90
+ eventMessage: JSON.stringify({
91
+ type: 'funnel',
92
+ recurring: this.isRecurring
93
+ })
92
94
  }).send();
93
95
  (_this$_options = this._options) === null || _this$_options === void 0 || _this$_options.onEventCallback(state);
94
96
  }
@@ -118,7 +120,7 @@ var ApplePayComponent = /*#__PURE__*/function () {
118
120
  msg: 'Abnormal paymentSessionData'
119
121
  }, {
120
122
  type: 'error',
121
- biz: 'sdk'
123
+ eventSource: 'sdk'
122
124
  }).send();
123
125
  return;
124
126
  }
@@ -259,7 +261,7 @@ var ApplePayComponent = /*#__PURE__*/function () {
259
261
  title: 'submitPayStatus',
260
262
  msg: res === null || res === void 0 ? void 0 : res.errorStatus
261
263
  }, {
262
- biz: 'sdk'
264
+ eventSource: 'sdk'
263
265
  }).send();
264
266
  if (res !== null && res !== void 0 && res.success || (res === null || res === void 0 ? void 0 : res.errorStatus) === 'U') {
265
267
  return Promise.resolve(res);
@@ -302,7 +304,7 @@ var ApplePayComponent = /*#__PURE__*/function () {
302
304
  msg: error
303
305
  }, {
304
306
  type: 'error',
305
- biz: 'sdk'
307
+ eventSource: 'sdk'
306
308
  }).send();
307
309
  if (_this._isFinish) {
308
310
  return;