@alipay/ams-checkout 0.0.1733711101-dev.1 → 0.0.1733711101-dev.2
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/dist/umd/ams-checkout.min.js +1 -1
- package/esm/core/bus/index.d.ts +3 -3
- package/esm/core/bus/index.js +14 -14
- package/esm/core/component/appPreloadProcessing.js +2 -2
- package/esm/core/component/ckp/index.js +6 -3
- package/esm/core/component/index.js +6 -10
- package/esm/core/instance/index.js +3 -3
- package/esm/foundation/product-processor/easysafepay/index.js +12 -12
- package/esm/foundation/service/api-bus/busManager.d.ts +3 -3
- package/esm/foundation/service/api-bus/busManager.js +14 -14
- package/esm/foundation/service/log/index.d.ts +2 -2
- package/esm/foundation/service/log/index.js +23 -8
- package/esm/foundation/service/log/keys.d.ts +13 -0
- package/esm/foundation/service/log/keys.js +103 -0
- package/esm/foundation/service/log/processor.d.ts +9 -0
- package/esm/foundation/service/log/processor.js +138 -0
- package/esm/foundation/service/log/types.d.ts +1 -1
- package/esm/foundation/service/security/index.js +6 -8
- package/esm/foundation/utils/redirect_utils.js +1 -2
- package/esm/index.js +1 -1
- package/esm/plugin/applepay/component.js +10 -8
- package/esm/plugin/applepay/index.js +10 -6
- package/esm/plugin/applepay/service.js +24 -16
- package/esm/plugin/component/cashierApp.js +3 -3
- package/esm/plugin/component/index.js +28 -24
- package/esm/plugin/paypal/index.js +1 -1
- package/esm/service/index.js +4 -2
- package/esm/util/getBackScheme.js +1 -2
- package/esm/util/index.js +4 -8
- package/esm/util/logger.d.ts +3 -3
- package/esm/util/logger.js +49 -13
- package/esm/util/spm-map.d.ts +172 -0
- package/esm/util/spm-map.js +172 -0
- package/package.json +1 -1
package/esm/core/bus/index.d.ts
CHANGED
@@ -16,17 +16,17 @@ export declare enum BusLogEventEnum {
|
|
16
16
|
/**
|
17
17
|
* 查询是否订阅
|
18
18
|
* action:string
|
19
|
-
* sub: bool
|
19
|
+
* sub (processResult): bool
|
20
20
|
*/
|
21
21
|
sdk_event_busIsSubscribe = "sdk_event_busIsSubscribe",
|
22
22
|
/**
|
23
23
|
* 订阅协议
|
24
|
-
* actions: string[] , 用逗号拼接
|
24
|
+
* actions (actionNames): string[] , 用逗号拼接
|
25
25
|
*/
|
26
26
|
sdk_event_busSubscribe = "sdk_event_busSubscribe",
|
27
27
|
/**
|
28
28
|
* 退订协议
|
29
|
-
* actions: string[] , 用逗号拼接
|
29
|
+
* actions (actionNames): string[] , 用逗号拼接
|
30
30
|
*/
|
31
31
|
sdk_event_busUnsubscribe = "sdk_event_busUnsubscribe",
|
32
32
|
/**
|
package/esm/core/bus/index.js
CHANGED
@@ -140,7 +140,7 @@ export var BusManager = /*#__PURE__*/function () {
|
|
140
140
|
this.logger.logInfo({
|
141
141
|
title: title
|
142
142
|
}, _objectSpread({
|
143
|
-
|
143
|
+
eventSource: 'sdk'
|
144
144
|
}, optionalParams)).send();
|
145
145
|
}
|
146
146
|
}
|
@@ -154,7 +154,7 @@ export var BusManager = /*#__PURE__*/function () {
|
|
154
154
|
this.logger.logError({
|
155
155
|
title: title
|
156
156
|
}, _objectSpread({
|
157
|
-
|
157
|
+
eventSource: 'sdk'
|
158
158
|
}, optionalParams)).send();
|
159
159
|
}
|
160
160
|
}
|
@@ -187,7 +187,7 @@ export var BusManager = /*#__PURE__*/function () {
|
|
187
187
|
setTimeout(function () {
|
188
188
|
if (failed) {
|
189
189
|
BusManager.traceError(BusLogEventEnum.sdk_error_busPublishNoResult, {
|
190
|
-
|
190
|
+
actionName: message.getAction()
|
191
191
|
});
|
192
192
|
if ((config === null || config === void 0 ? void 0 : config.fallback) !== null) {
|
193
193
|
resolve(message.result(config === null || config === void 0 ? void 0 : config.fallback));
|
@@ -203,7 +203,7 @@ export var BusManager = /*#__PURE__*/function () {
|
|
203
203
|
value: function publish(message, callback) {
|
204
204
|
var _callBack = function _callBack(result) {
|
205
205
|
BusManager.traceLog(BusLogEventEnum.sdk_event_busPublishCallback, {
|
206
|
-
|
206
|
+
actionName: message.getAction()
|
207
207
|
});
|
208
208
|
if (callback) {
|
209
209
|
callback(result);
|
@@ -213,7 +213,7 @@ export var BusManager = /*#__PURE__*/function () {
|
|
213
213
|
var actionName = message.getAction();
|
214
214
|
var subscribers = BusManager.subscribersMap.get(actionName);
|
215
215
|
BusManager.traceLog(BusLogEventEnum.sdk_event_busPublishMessage, {
|
216
|
-
|
216
|
+
actionName: message.getAction()
|
217
217
|
});
|
218
218
|
if (subscribers) {
|
219
219
|
var _iterator = _createForOfIteratorHelper(subscribers),
|
@@ -225,8 +225,8 @@ export var BusManager = /*#__PURE__*/function () {
|
|
225
225
|
subscriber.onMessage(context, message);
|
226
226
|
} catch (e) {
|
227
227
|
BusManager.traceError(BusLogEventEnum.sdk_error_busPublishError, {
|
228
|
-
|
229
|
-
|
228
|
+
actionName: message.getAction(),
|
229
|
+
errorMessage: e
|
230
230
|
});
|
231
231
|
var _iterator2 = _createForOfIteratorHelper(BusManager.interceptors),
|
232
232
|
_step2;
|
@@ -266,7 +266,7 @@ export var BusManager = /*#__PURE__*/function () {
|
|
266
266
|
BusManager.publish(message, callback); // Re-publish the message
|
267
267
|
} else {
|
268
268
|
BusManager.traceError(BusLogEventEnum.sdk_error_busPublishUnsubscribeError, {
|
269
|
-
|
269
|
+
actionName: message.getAction()
|
270
270
|
});
|
271
271
|
}
|
272
272
|
}
|
@@ -275,7 +275,7 @@ export var BusManager = /*#__PURE__*/function () {
|
|
275
275
|
key: "subscribe",
|
276
276
|
value: function subscribe(subscriber) {
|
277
277
|
BusManager.traceLog(BusLogEventEnum.sdk_event_busSubscribe, {
|
278
|
-
|
278
|
+
actionNames: subscriber === null || subscriber === void 0 ? void 0 : subscriber.actionNames()
|
279
279
|
});
|
280
280
|
var _iterator4 = _createForOfIteratorHelper(subscriber.actionNames()),
|
281
281
|
_step4;
|
@@ -300,7 +300,7 @@ export var BusManager = /*#__PURE__*/function () {
|
|
300
300
|
key: "unsubscribe",
|
301
301
|
value: function unsubscribe(subscriber) {
|
302
302
|
BusManager.traceLog(BusLogEventEnum.sdk_event_busUnsubscribe, {
|
303
|
-
|
303
|
+
actionNames: subscriber === null || subscriber === void 0 ? void 0 : subscriber.actionNames()
|
304
304
|
});
|
305
305
|
var _iterator5 = _createForOfIteratorHelper(subscriber.actionNames()),
|
306
306
|
_step5;
|
@@ -327,8 +327,8 @@ export var BusManager = /*#__PURE__*/function () {
|
|
327
327
|
var subscribers = BusManager.subscribersMap.get(actionName);
|
328
328
|
if (subscribers && subscribers.length > 0) {
|
329
329
|
BusManager.traceLog(BusLogEventEnum.sdk_event_busIsSubscribe, {
|
330
|
-
|
331
|
-
|
330
|
+
actionName: actionName,
|
331
|
+
processResult: true
|
332
332
|
});
|
333
333
|
return true;
|
334
334
|
}
|
@@ -350,8 +350,8 @@ export var BusManager = /*#__PURE__*/function () {
|
|
350
350
|
return BusManager.subscribersMap.has(actionName);
|
351
351
|
}
|
352
352
|
BusManager.traceLog(BusLogEventEnum.sdk_event_busIsSubscribe, {
|
353
|
-
|
354
|
-
|
353
|
+
actionName: actionName,
|
354
|
+
processResult: false
|
355
355
|
});
|
356
356
|
return false;
|
357
357
|
}
|
@@ -39,8 +39,8 @@ function _loadChannelPneumaticControl() {
|
|
39
39
|
logger.logInfo({
|
40
40
|
title: 'load_channel_sdk_start'
|
41
41
|
}, {
|
42
|
-
|
43
|
-
|
42
|
+
eventMessage: JSON.stringify(frontModulesToBeLoaded),
|
43
|
+
requestId: paymentRequestId
|
44
44
|
});
|
45
45
|
frontModulesToBeLoaded.forEach(function (loadItem) {
|
46
46
|
var acquirerName = loadItem.acquirerName,
|
@@ -114,14 +114,16 @@ export var AMSCheckoutPage = /*#__PURE__*/function () {
|
|
114
114
|
function mountComponent(params, selector) {
|
115
115
|
if (params.sessionData === undefined || params.sessionData === '' || typeof params.sessionData !== 'string') {
|
116
116
|
this.logger.logError({
|
117
|
-
title: '
|
117
|
+
title: 'event_important_error',
|
118
|
+
msg: 'PARAMS_ERROR_INVALID_SESSION_DATA'
|
118
119
|
});
|
119
120
|
console.error('[antom-web-sdk] <antom-checkout-page> mountComponent: sessionData is required and must be a string');
|
120
121
|
throw new Error('PARAMS_ERROR_INVALID_SESSION_DATA');
|
121
122
|
}
|
122
123
|
if (document.querySelector(this.APP_IFRAME_ID)) {
|
123
124
|
this.logger.logError({
|
124
|
-
title: '
|
125
|
+
title: 'event_important_error',
|
126
|
+
msg: 'PARAMS_ERROR_ALREADY_MOUNTED'
|
125
127
|
});
|
126
128
|
console.error('[antom-web-sdk] <antom-checkout-page> mountComponent: already mounted, please unmount first');
|
127
129
|
throw new Error('PARAMS_ERROR_ALREADY_MOUNTED');
|
@@ -140,7 +142,8 @@ export var AMSCheckoutPage = /*#__PURE__*/function () {
|
|
140
142
|
wrapper.appendChild(iframe);
|
141
143
|
} else {
|
142
144
|
this.logger.logError({
|
143
|
-
title: '
|
145
|
+
title: 'event_important_error',
|
146
|
+
msg: 'PARAMS_ERROR_INVALID_SELECTOR'
|
144
147
|
});
|
145
148
|
console.error('[antom-web-sdk] <antom-checkout-page> mountComponent: invalid selector');
|
146
149
|
this.removeListener();
|
@@ -219,19 +219,15 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
219
219
|
this.logger.logInfo({
|
220
220
|
title: 'preload_match'
|
221
221
|
}, {
|
222
|
-
|
223
|
-
|
224
|
-
sessionDataChannel: channelType,
|
225
|
-
sessionDataVersion: productSceneVersion
|
222
|
+
eventMessage: channelType,
|
223
|
+
productSceneVersion: productSceneVersion
|
226
224
|
});
|
227
225
|
} else {
|
228
226
|
this.logger.logInfo({
|
229
227
|
title: 'preload_no_match'
|
230
228
|
}, {
|
231
|
-
|
232
|
-
|
233
|
-
sessionDataChannel: channelType,
|
234
|
-
sessionDataVersion: productSceneVersion
|
229
|
+
eventMessage: channelType,
|
230
|
+
productSceneVersion: productSceneVersion
|
235
231
|
});
|
236
232
|
}
|
237
233
|
var previousChannel = {
|
@@ -332,7 +328,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
332
328
|
_this4.logger.logInfo({
|
333
329
|
title: 'canMakePayments_error'
|
334
330
|
}, {
|
335
|
-
|
331
|
+
errorMessage: JSON.stringify(e)
|
336
332
|
});
|
337
333
|
resolve(false);
|
338
334
|
});
|
@@ -403,7 +399,7 @@ export var AMSComponent = /*#__PURE__*/function (_CoreInstance) {
|
|
403
399
|
this.logger.logError({
|
404
400
|
title: 'performance_optimization_channelType_error'
|
405
401
|
}, {
|
406
|
-
|
402
|
+
eventMessage: channelType
|
407
403
|
});
|
408
404
|
}
|
409
405
|
this.timer = setTimeout(function () {
|
@@ -163,7 +163,7 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
163
163
|
this.logger.logInfo({
|
164
164
|
title: 'sdk_event_securitySdkPreInit'
|
165
165
|
}, {
|
166
|
-
|
166
|
+
productScene: product
|
167
167
|
}).send();
|
168
168
|
var sdk = this._getSecuritySDKByProductScene({
|
169
169
|
product: product || scene
|
@@ -176,14 +176,14 @@ var AMSSDK = /*#__PURE__*/function () {
|
|
176
176
|
_this.logger.logInfo({
|
177
177
|
title: 'sdk_event_securitySdkPreInitSuccess'
|
178
178
|
}, {
|
179
|
-
|
179
|
+
productScene: product
|
180
180
|
}).send();
|
181
181
|
}, function (msg) {
|
182
182
|
_this.logger.logError({
|
183
183
|
title: 'sdk_error_securitySdkInitFailed',
|
184
184
|
msg: msg
|
185
185
|
}, {
|
186
|
-
|
186
|
+
productScene: product,
|
187
187
|
sign: 'Active initialization'
|
188
188
|
}).send();
|
189
189
|
});
|
@@ -117,12 +117,12 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
117
117
|
key: "buildWebAppPreloadUrl",
|
118
118
|
value: function buildWebAppPreloadUrl(initConfig, instanceId, sdkMetaData) {
|
119
119
|
var _this = this;
|
120
|
-
var previousProductInfo = ProductInfoCacheUtil.getPreviousProductInfo(ProductSceneEnum.EASY_PAY, function (
|
121
|
-
if (
|
120
|
+
var previousProductInfo = ProductInfoCacheUtil.getPreviousProductInfo(ProductSceneEnum.EASY_PAY, function (errorMsg) {
|
121
|
+
if (errorMsg) {
|
122
122
|
_this.logger.logError({
|
123
123
|
title: 'performance_optimization_get_previousChannel_error'
|
124
124
|
}, {
|
125
|
-
|
125
|
+
errorMessage: errorMsg
|
126
126
|
});
|
127
127
|
}
|
128
128
|
});
|
@@ -294,8 +294,8 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
294
294
|
this.logger.logInfo({
|
295
295
|
title: 'sdk_event_submitPay'
|
296
296
|
}, {
|
297
|
-
|
298
|
-
|
297
|
+
config: JSON.stringify(submitParams.paymentSessionConfig),
|
298
|
+
requestId: requestBizId
|
299
299
|
});
|
300
300
|
// 由渠道定制点来构建额外参数
|
301
301
|
extParams = ((_this$channelBehavior2 = this.channelBehavior) === null || _this$channelBehavior2 === void 0 || (_this$channelBehavior3 = _this$channelBehavior2.buildSubmitPayExtParams) === null || _this$channelBehavior3 === void 0 ? void 0 : _this$channelBehavior3.call(_this$channelBehavior2, {
|
@@ -336,9 +336,9 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
336
336
|
this.logger.logInfo({
|
337
337
|
title: 'sdk_event_submitPayEnd'
|
338
338
|
}, {
|
339
|
-
|
340
|
-
|
341
|
-
|
339
|
+
config: JSON.stringify(submitParams.paymentSessionConfig),
|
340
|
+
requestId: requestBizId,
|
341
|
+
rpcTraceId: res.traceId
|
342
342
|
});
|
343
343
|
return _context2.abrupt("return", res);
|
344
344
|
case 30:
|
@@ -347,10 +347,10 @@ export var EasySafePayProcessor = /*#__PURE__*/function () {
|
|
347
347
|
this.logger.logError({
|
348
348
|
title: 'sdk_event_submitPay_failed'
|
349
349
|
}, {
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
350
|
+
config: JSON.stringify(submitParams.paymentSessionConfig),
|
351
|
+
errorMessage: _context2.t7,
|
352
|
+
requestId: requestBizId,
|
353
|
+
rpcTraceId: _context2.t7 === null || _context2.t7 === void 0 ? void 0 : _context2.t7.traceId
|
354
354
|
});
|
355
355
|
throw _context2.t7;
|
356
356
|
case 34:
|
@@ -15,17 +15,17 @@ export declare enum BusLogEventEnum {
|
|
15
15
|
/**
|
16
16
|
* 查询是否订阅
|
17
17
|
* action:string
|
18
|
-
* sub: bool
|
18
|
+
* sub (processResult): bool
|
19
19
|
*/
|
20
20
|
sdk_event_busIsSubscribe = "sdk_event_busIsSubscribe",
|
21
21
|
/**
|
22
22
|
* 订阅协议
|
23
|
-
* actions: string[] , 用逗号拼接
|
23
|
+
* actions (actionNames): string[] , 用逗号拼接
|
24
24
|
*/
|
25
25
|
sdk_event_busSubscribe = "sdk_event_busSubscribe",
|
26
26
|
/**
|
27
27
|
* 退订协议
|
28
|
-
* actions: string[] , 用逗号拼接
|
28
|
+
* actions (actionNames): string[] , 用逗号拼接
|
29
29
|
*/
|
30
30
|
sdk_event_busUnsubscribe = "sdk_event_busUnsubscribe",
|
31
31
|
/**
|
@@ -147,7 +147,7 @@ export var BusManager = /*#__PURE__*/function () {
|
|
147
147
|
this.logger.logInfo({
|
148
148
|
title: title
|
149
149
|
}, _objectSpread({
|
150
|
-
|
150
|
+
eventSource: 'sdk'
|
151
151
|
}, optionalParams)).send();
|
152
152
|
}
|
153
153
|
}
|
@@ -161,7 +161,7 @@ export var BusManager = /*#__PURE__*/function () {
|
|
161
161
|
this.logger.logError({
|
162
162
|
title: title
|
163
163
|
}, _objectSpread({
|
164
|
-
|
164
|
+
eventSource: 'sdk'
|
165
165
|
}, optionalParams)).send();
|
166
166
|
}
|
167
167
|
}
|
@@ -194,7 +194,7 @@ export var BusManager = /*#__PURE__*/function () {
|
|
194
194
|
setTimeout(function () {
|
195
195
|
if (failed) {
|
196
196
|
_this.traceError(BusLogEventEnum.sdk_error_busPublishNoResult, {
|
197
|
-
|
197
|
+
actionName: message.getAction()
|
198
198
|
});
|
199
199
|
if ((config === null || config === void 0 ? void 0 : config.fallback) !== null) {
|
200
200
|
resolve(message.result(config === null || config === void 0 ? void 0 : config.fallback));
|
@@ -211,7 +211,7 @@ export var BusManager = /*#__PURE__*/function () {
|
|
211
211
|
var _this2 = this;
|
212
212
|
var _callBack = function _callBack(result) {
|
213
213
|
_this2.traceLog(BusLogEventEnum.sdk_event_busPublishCallback, {
|
214
|
-
|
214
|
+
actionName: message.getAction(),
|
215
215
|
instanceId: _this2.instanceId
|
216
216
|
});
|
217
217
|
if (callback) {
|
@@ -222,7 +222,7 @@ export var BusManager = /*#__PURE__*/function () {
|
|
222
222
|
var actionName = this.instanceId ? BusManager.getInstanceActionName(message.getAction(), this.instanceId) : message.getAction();
|
223
223
|
var subscribers = BusManager.subscribersMap.get(actionName);
|
224
224
|
this.traceLog(BusLogEventEnum.sdk_event_busPublishMessage, {
|
225
|
-
|
225
|
+
actionName: message.getAction(),
|
226
226
|
instanceId: this.instanceId
|
227
227
|
});
|
228
228
|
if (!subscribers && this.instanceId) {
|
@@ -239,9 +239,9 @@ export var BusManager = /*#__PURE__*/function () {
|
|
239
239
|
subscriber.onMessage(context, message);
|
240
240
|
} catch (e) {
|
241
241
|
this.traceError(BusLogEventEnum.sdk_error_busPublishError, {
|
242
|
-
|
242
|
+
actionName: message.getAction(),
|
243
243
|
instanceId: this.instanceId,
|
244
|
-
|
244
|
+
errorMessage: e
|
245
245
|
});
|
246
246
|
var _iterator2 = _createForOfIteratorHelper(BusManager.interceptors),
|
247
247
|
_step2;
|
@@ -280,7 +280,7 @@ export var BusManager = /*#__PURE__*/function () {
|
|
280
280
|
this.publish(message, callback); // Re-publish the message
|
281
281
|
} else {
|
282
282
|
this.traceError(BusLogEventEnum.sdk_error_busPublishUnsubscribeError, {
|
283
|
-
|
283
|
+
actionName: message.getAction(),
|
284
284
|
instanceId: this.instanceId
|
285
285
|
});
|
286
286
|
}
|
@@ -290,7 +290,7 @@ export var BusManager = /*#__PURE__*/function () {
|
|
290
290
|
key: "subscribe",
|
291
291
|
value: function subscribe(subscriber) {
|
292
292
|
this.traceLog(BusLogEventEnum.sdk_event_busSubscribe, {
|
293
|
-
|
293
|
+
actionNames: subscriber.actionNames(),
|
294
294
|
instanceId: this.instanceId
|
295
295
|
});
|
296
296
|
var _iterator4 = _createForOfIteratorHelper(subscriber.actionNames()),
|
@@ -317,7 +317,7 @@ export var BusManager = /*#__PURE__*/function () {
|
|
317
317
|
key: "unsubscribe",
|
318
318
|
value: function unsubscribe(subscriber) {
|
319
319
|
this.traceLog(BusLogEventEnum.sdk_event_busUnsubscribe, {
|
320
|
-
|
320
|
+
actionNames: subscriber.actionNames(),
|
321
321
|
instanceId: this.instanceId
|
322
322
|
});
|
323
323
|
var _iterator5 = _createForOfIteratorHelper(subscriber.actionNames()),
|
@@ -354,9 +354,9 @@ export var BusManager = /*#__PURE__*/function () {
|
|
354
354
|
}
|
355
355
|
if (subscribers && subscribers.length > 0) {
|
356
356
|
this.traceLog(BusLogEventEnum.sdk_event_busIsSubscribe, {
|
357
|
-
|
357
|
+
actionName: actionName,
|
358
358
|
instanceId: this.instanceId,
|
359
|
-
|
359
|
+
processResult: true
|
360
360
|
});
|
361
361
|
return true;
|
362
362
|
}
|
@@ -377,9 +377,9 @@ export var BusManager = /*#__PURE__*/function () {
|
|
377
377
|
return BusManager.subscribersMap.has(key);
|
378
378
|
}
|
379
379
|
this.traceLog(BusLogEventEnum.sdk_event_busIsSubscribe, {
|
380
|
-
|
380
|
+
actionName: actionName,
|
381
381
|
instanceId: this.instanceId,
|
382
|
-
|
382
|
+
processResult: false
|
383
383
|
});
|
384
384
|
return false;
|
385
385
|
}
|
@@ -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:
|
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
|
-
|
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
|
-
|
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:
|
121
|
-
extra: _objectSpread(_objectSpread({},
|
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',
|
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
|
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(
|
205
|
+
(_window4 = window) === null || _window4 === void 0 || _window4.iTracker.initiTracker(_this3.config);
|
191
206
|
setTimeout(function () {
|
192
|
-
|
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
|
+
}
|