@datarangers/sdk-javascript 0.1.3 → 0.1.4
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/es/index-base.min.js +676 -265
- package/es/index.min.js +676 -271
- package/lib/index-base.min.js +676 -265
- package/lib/index.min.js +676 -271
- package/package.json +1 -1
package/es/index-base.min.js
CHANGED
|
@@ -406,7 +406,10 @@ var cookie = createCommonjsModule(function (module, exports) {
|
|
|
406
406
|
});
|
|
407
407
|
|
|
408
408
|
// Copyright 2022 Beijing Volcanoengine Technology Ltd. All Rights Reserved.
|
|
409
|
-
|
|
409
|
+
/**
|
|
410
|
+
* cacheStorage
|
|
411
|
+
*/
|
|
412
|
+
var Memory = /** @class */function () {
|
|
410
413
|
function Memory() {
|
|
411
414
|
this.cache = {};
|
|
412
415
|
}
|
|
@@ -419,36 +422,26 @@ var Memory$1 = /** @class */function () {
|
|
|
419
422
|
Memory.prototype.removeItem = function (cacheKey) {
|
|
420
423
|
this.cache[cacheKey] = undefined;
|
|
421
424
|
};
|
|
422
|
-
Memory.prototype.getCookie = function (name) {
|
|
423
|
-
this.getItem(name);
|
|
424
|
-
};
|
|
425
|
-
Memory.prototype.setCookie = function (key, value) {
|
|
426
|
-
this.setItem(key, value);
|
|
427
|
-
};
|
|
428
425
|
return Memory;
|
|
429
426
|
}();
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
} catch (e) {
|
|
437
|
-
return false;
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
function isSupportSession() {
|
|
441
|
-
try {
|
|
442
|
-
sessionStorage.setItem('_ranger-test-key', 'hi');
|
|
443
|
-
sessionStorage.getItem('_ranger-test-key');
|
|
444
|
-
sessionStorage.removeItem('_ranger-test-key');
|
|
445
|
-
return true;
|
|
446
|
-
} catch (e) {
|
|
447
|
-
return false;
|
|
427
|
+
/**
|
|
428
|
+
* localStorage
|
|
429
|
+
*/
|
|
430
|
+
var Local = /** @class */function () {
|
|
431
|
+
function Local() {
|
|
432
|
+
this.support = this.isSupportLS();
|
|
448
433
|
}
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
434
|
+
Local.prototype.isSupportLS = function () {
|
|
435
|
+
try {
|
|
436
|
+
localStorage.setItem('_applogtest-test-key', 'hi');
|
|
437
|
+
localStorage.getItem('_applogtest-test-key');
|
|
438
|
+
localStorage.removeItem('_applogtest-test-key');
|
|
439
|
+
return true;
|
|
440
|
+
} catch (e) {
|
|
441
|
+
return false;
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
Local.prototype.getItem = function (key) {
|
|
452
445
|
try {
|
|
453
446
|
var value = localStorage.getItem(key);
|
|
454
447
|
var ret = value;
|
|
@@ -460,42 +453,38 @@ var local = {
|
|
|
460
453
|
return ret || {};
|
|
461
454
|
} catch (e) {}
|
|
462
455
|
return {};
|
|
463
|
-
}
|
|
464
|
-
setItem
|
|
456
|
+
};
|
|
457
|
+
Local.prototype.setItem = function (key, value) {
|
|
465
458
|
try {
|
|
466
459
|
var stringValue = typeof value === 'string' ? value : JSON.stringify(value);
|
|
467
460
|
localStorage.setItem(key, stringValue);
|
|
468
461
|
} catch (e) {}
|
|
469
|
-
}
|
|
470
|
-
removeItem
|
|
462
|
+
};
|
|
463
|
+
Local.prototype.removeItem = function (key) {
|
|
471
464
|
try {
|
|
472
465
|
localStorage.removeItem(key);
|
|
473
466
|
} catch (e) {}
|
|
474
|
-
}
|
|
475
|
-
|
|
467
|
+
};
|
|
468
|
+
return Local;
|
|
469
|
+
}();
|
|
470
|
+
/**
|
|
471
|
+
* sessionStorage
|
|
472
|
+
*/
|
|
473
|
+
var Session$1 = /** @class */function () {
|
|
474
|
+
function Session() {
|
|
475
|
+
this.support = this.isSupportSession();
|
|
476
|
+
}
|
|
477
|
+
Session.prototype.isSupportSession = function () {
|
|
476
478
|
try {
|
|
477
|
-
|
|
478
|
-
|
|
479
|
+
sessionStorage.setItem('_applogtest-test-key', 'hi');
|
|
480
|
+
sessionStorage.getItem('_applogtest-test-key');
|
|
481
|
+
sessionStorage.removeItem('_applogtest-test-key');
|
|
482
|
+
return true;
|
|
479
483
|
} catch (e) {
|
|
480
|
-
return
|
|
484
|
+
return false;
|
|
481
485
|
}
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
try {
|
|
485
|
-
var _domain = domain || document.domain;
|
|
486
|
-
var timestamp = +new Date();
|
|
487
|
-
var furureTimestamp = timestamp + expiresTime; // 3年
|
|
488
|
-
cookie.set(name, value, {
|
|
489
|
-
expires: new Date(furureTimestamp),
|
|
490
|
-
path: '/',
|
|
491
|
-
domain: _domain
|
|
492
|
-
});
|
|
493
|
-
} catch (e) {}
|
|
494
|
-
},
|
|
495
|
-
isSupportLS: isSupportLS()
|
|
496
|
-
};
|
|
497
|
-
var session = {
|
|
498
|
-
getItem: function getItem(key) {
|
|
486
|
+
};
|
|
487
|
+
Session.prototype.getItem = function (key) {
|
|
499
488
|
try {
|
|
500
489
|
var value = sessionStorage.getItem(key);
|
|
501
490
|
var ret = value;
|
|
@@ -507,56 +496,92 @@ var session = {
|
|
|
507
496
|
return ret || {};
|
|
508
497
|
} catch (e) {}
|
|
509
498
|
return {};
|
|
510
|
-
}
|
|
511
|
-
setItem
|
|
499
|
+
};
|
|
500
|
+
Session.prototype.setItem = function (key, value) {
|
|
512
501
|
try {
|
|
513
502
|
var stringValue = typeof value === 'string' ? value : JSON.stringify(value);
|
|
514
503
|
sessionStorage.setItem(key, stringValue);
|
|
515
504
|
} catch (e) {}
|
|
516
|
-
}
|
|
517
|
-
removeItem
|
|
505
|
+
};
|
|
506
|
+
Session.prototype.removeItem = function (key) {
|
|
518
507
|
try {
|
|
519
508
|
sessionStorage.removeItem(key);
|
|
520
509
|
} catch (e) {}
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
this.
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
var Storage = /** @class */function () {
|
|
531
|
-
function Storage(isCache, type) {
|
|
532
|
-
if (type && type === 'session') {
|
|
533
|
-
this._storage = session;
|
|
534
|
-
} else {
|
|
535
|
-
this._storage = !isCache && local.isSupportLS ? local : new Memory$1();
|
|
536
|
-
}
|
|
510
|
+
};
|
|
511
|
+
return Session;
|
|
512
|
+
}();
|
|
513
|
+
var StorageManager = /** @class */function () {
|
|
514
|
+
function StorageManager() {
|
|
515
|
+
this.defaultExpireTime = 7 * 1000 * 60 * 60 * 24;
|
|
516
|
+
this.local = new Local();
|
|
517
|
+
this.session = new Session$1();
|
|
518
|
+
this.cache = new Memory();
|
|
537
519
|
}
|
|
538
|
-
|
|
539
|
-
return this.
|
|
520
|
+
StorageManager.prototype.getLocalItem = function (key) {
|
|
521
|
+
return this.local.getItem(key);
|
|
522
|
+
};
|
|
523
|
+
StorageManager.prototype.setLocalItem = function (key, value) {
|
|
524
|
+
this.local.setItem(key, value);
|
|
525
|
+
};
|
|
526
|
+
StorageManager.prototype.removeLocalItem = function (key) {
|
|
527
|
+
this.local.removeItem(key);
|
|
528
|
+
};
|
|
529
|
+
StorageManager.prototype.getSessionItem = function (key) {
|
|
530
|
+
return this.session.getItem(key);
|
|
531
|
+
};
|
|
532
|
+
StorageManager.prototype.setSessionItem = function (key, value) {
|
|
533
|
+
this.session.setItem(key, value);
|
|
540
534
|
};
|
|
541
|
-
|
|
542
|
-
this.
|
|
535
|
+
StorageManager.prototype.removeSessionItem = function (key) {
|
|
536
|
+
this.session.removeItem(key);
|
|
543
537
|
};
|
|
544
|
-
|
|
545
|
-
return this.
|
|
538
|
+
StorageManager.prototype.getCacheItem = function (key) {
|
|
539
|
+
return this.cache.getItem(key);
|
|
546
540
|
};
|
|
547
|
-
|
|
548
|
-
this.
|
|
541
|
+
StorageManager.prototype.setCacheItem = function (key, value) {
|
|
542
|
+
this.cache.setItem(key, value);
|
|
549
543
|
};
|
|
550
|
-
|
|
551
|
-
this.
|
|
544
|
+
StorageManager.prototype.removeCacheItem = function (key) {
|
|
545
|
+
this.cache.removeItem(key);
|
|
552
546
|
};
|
|
553
|
-
|
|
547
|
+
StorageManager.prototype.getCookie = function (key, domain) {
|
|
548
|
+
try {
|
|
549
|
+
// const _matches = Cookies.get(name, { domain: domain || document.domain })
|
|
550
|
+
var _matches = cookie.get(key);
|
|
551
|
+
return _matches;
|
|
552
|
+
} catch (e) {
|
|
553
|
+
return '';
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
StorageManager.prototype.setCookie = function (key, value, expiresTime, domain) {
|
|
557
|
+
if (expiresTime === void 0) {
|
|
558
|
+
expiresTime = this.defaultExpireTime;
|
|
559
|
+
}
|
|
560
|
+
try {
|
|
561
|
+
var _domain = domain || document.domain;
|
|
562
|
+
var timestamp = +new Date();
|
|
563
|
+
var furureTimestamp = timestamp + expiresTime;
|
|
564
|
+
cookie.set(key, value, {
|
|
565
|
+
expires: new Date(furureTimestamp),
|
|
566
|
+
path: '/',
|
|
567
|
+
domain: _domain
|
|
568
|
+
});
|
|
569
|
+
} catch (e) {}
|
|
570
|
+
};
|
|
571
|
+
StorageManager.prototype.removeCookie = function (key, domain) {
|
|
572
|
+
try {
|
|
573
|
+
cookie.remove(key, {
|
|
574
|
+
path: '/',
|
|
575
|
+
domain: domain || ''
|
|
576
|
+
});
|
|
577
|
+
} catch (e) {}
|
|
578
|
+
};
|
|
579
|
+
return StorageManager;
|
|
554
580
|
}();
|
|
555
581
|
|
|
556
582
|
// Copyright 2022 Beijing Volcanoengine Technology Ltd. All Rights Reserved.
|
|
557
583
|
var UTM = function UTM(app_id, urlQueryObj, domain, cookie_expire) {
|
|
558
|
-
var storage = new
|
|
559
|
-
var session = new Storage(false, 'session');
|
|
584
|
+
var storage = new StorageManager();
|
|
560
585
|
var cacheKey = app_id ? "_tea_utm_cache_" + app_id : '_tea_utm_cache';
|
|
561
586
|
var sourceKey = app_id ? "_$utm_from_url_" + app_id : '_$utm_from_url';
|
|
562
587
|
var utmObj = {};
|
|
@@ -594,7 +619,7 @@ var UTM = function UTM(app_id, urlQueryObj, domain, cookie_expire) {
|
|
|
594
619
|
}
|
|
595
620
|
if (utmFromUrl) {
|
|
596
621
|
// 发现url上有则更新缓存,并上报
|
|
597
|
-
|
|
622
|
+
storage.setSessionItem(sourceKey, '1');
|
|
598
623
|
storage.setCookie(cacheKey, JSON.stringify(utmObj), cookie_expire, domain);
|
|
599
624
|
} else {
|
|
600
625
|
// url没有则取缓存
|
|
@@ -603,7 +628,7 @@ var UTM = function UTM(app_id, urlQueryObj, domain, cookie_expire) {
|
|
|
603
628
|
utmObj = JSON.parse(cache);
|
|
604
629
|
}
|
|
605
630
|
}
|
|
606
|
-
if (
|
|
631
|
+
if (storage.getSessionItem(sourceKey)) {
|
|
607
632
|
if (!utmObj.hasOwnProperty('tracer_data')) {
|
|
608
633
|
utmObj['tracer_data'] = {};
|
|
609
634
|
}
|
|
@@ -910,180 +935,6 @@ var Client = /** @class */function () {
|
|
|
910
935
|
return Client;
|
|
911
936
|
}();
|
|
912
937
|
|
|
913
|
-
// Copyright 2022 Beijing Volcanoengine Technology Ltd. All Rights Reserved.
|
|
914
|
-
/**
|
|
915
|
-
* cacheStorage
|
|
916
|
-
*/
|
|
917
|
-
var Memory = /** @class */function () {
|
|
918
|
-
function Memory() {
|
|
919
|
-
this.cache = {};
|
|
920
|
-
}
|
|
921
|
-
Memory.prototype.setItem = function (cacheKey, data) {
|
|
922
|
-
this.cache[cacheKey] = data;
|
|
923
|
-
};
|
|
924
|
-
Memory.prototype.getItem = function (cacheKey) {
|
|
925
|
-
return this.cache[cacheKey];
|
|
926
|
-
};
|
|
927
|
-
Memory.prototype.removeItem = function (cacheKey) {
|
|
928
|
-
this.cache[cacheKey] = undefined;
|
|
929
|
-
};
|
|
930
|
-
return Memory;
|
|
931
|
-
}();
|
|
932
|
-
/**
|
|
933
|
-
* localStorage
|
|
934
|
-
*/
|
|
935
|
-
var Local = /** @class */function () {
|
|
936
|
-
function Local() {
|
|
937
|
-
this.support = this.isSupportLS();
|
|
938
|
-
}
|
|
939
|
-
Local.prototype.isSupportLS = function () {
|
|
940
|
-
try {
|
|
941
|
-
localStorage.setItem('_applogtest-test-key', 'hi');
|
|
942
|
-
localStorage.getItem('_applogtest-test-key');
|
|
943
|
-
localStorage.removeItem('_applogtest-test-key');
|
|
944
|
-
return true;
|
|
945
|
-
} catch (e) {
|
|
946
|
-
return false;
|
|
947
|
-
}
|
|
948
|
-
};
|
|
949
|
-
Local.prototype.getItem = function (key) {
|
|
950
|
-
try {
|
|
951
|
-
var value = localStorage.getItem(key);
|
|
952
|
-
var ret = value;
|
|
953
|
-
try {
|
|
954
|
-
if (value && typeof value === 'string') {
|
|
955
|
-
ret = JSON.parse(value);
|
|
956
|
-
}
|
|
957
|
-
} catch (e) {}
|
|
958
|
-
return ret || {};
|
|
959
|
-
} catch (e) {}
|
|
960
|
-
return {};
|
|
961
|
-
};
|
|
962
|
-
Local.prototype.setItem = function (key, value) {
|
|
963
|
-
try {
|
|
964
|
-
var stringValue = typeof value === 'string' ? value : JSON.stringify(value);
|
|
965
|
-
localStorage.setItem(key, stringValue);
|
|
966
|
-
} catch (e) {}
|
|
967
|
-
};
|
|
968
|
-
Local.prototype.removeItem = function (key) {
|
|
969
|
-
try {
|
|
970
|
-
localStorage.removeItem(key);
|
|
971
|
-
} catch (e) {}
|
|
972
|
-
};
|
|
973
|
-
return Local;
|
|
974
|
-
}();
|
|
975
|
-
/**
|
|
976
|
-
* sessionStorage
|
|
977
|
-
*/
|
|
978
|
-
var Session$1 = /** @class */function () {
|
|
979
|
-
function Session() {
|
|
980
|
-
this.support = this.isSupportSession();
|
|
981
|
-
}
|
|
982
|
-
Session.prototype.isSupportSession = function () {
|
|
983
|
-
try {
|
|
984
|
-
sessionStorage.setItem('_applogtest-test-key', 'hi');
|
|
985
|
-
sessionStorage.getItem('_applogtest-test-key');
|
|
986
|
-
sessionStorage.removeItem('_applogtest-test-key');
|
|
987
|
-
return true;
|
|
988
|
-
} catch (e) {
|
|
989
|
-
return false;
|
|
990
|
-
}
|
|
991
|
-
};
|
|
992
|
-
Session.prototype.getItem = function (key) {
|
|
993
|
-
try {
|
|
994
|
-
var value = sessionStorage.getItem(key);
|
|
995
|
-
var ret = value;
|
|
996
|
-
try {
|
|
997
|
-
if (value && typeof value === 'string') {
|
|
998
|
-
ret = JSON.parse(value);
|
|
999
|
-
}
|
|
1000
|
-
} catch (e) {}
|
|
1001
|
-
return ret || {};
|
|
1002
|
-
} catch (e) {}
|
|
1003
|
-
return {};
|
|
1004
|
-
};
|
|
1005
|
-
Session.prototype.setItem = function (key, value) {
|
|
1006
|
-
try {
|
|
1007
|
-
var stringValue = typeof value === 'string' ? value : JSON.stringify(value);
|
|
1008
|
-
sessionStorage.setItem(key, stringValue);
|
|
1009
|
-
} catch (e) {}
|
|
1010
|
-
};
|
|
1011
|
-
Session.prototype.removeItem = function (key) {
|
|
1012
|
-
try {
|
|
1013
|
-
sessionStorage.removeItem(key);
|
|
1014
|
-
} catch (e) {}
|
|
1015
|
-
};
|
|
1016
|
-
return Session;
|
|
1017
|
-
}();
|
|
1018
|
-
var StorageManager = /** @class */function () {
|
|
1019
|
-
function StorageManager() {
|
|
1020
|
-
this.defaultExpireTime = 7 * 1000 * 60 * 60 * 24;
|
|
1021
|
-
this.local = new Local();
|
|
1022
|
-
this.session = new Session$1();
|
|
1023
|
-
this.cache = new Memory();
|
|
1024
|
-
}
|
|
1025
|
-
StorageManager.prototype.getLocalItem = function (key) {
|
|
1026
|
-
return this.local.getItem(key);
|
|
1027
|
-
};
|
|
1028
|
-
StorageManager.prototype.setLocalItem = function (key, value) {
|
|
1029
|
-
this.local.setItem(key, value);
|
|
1030
|
-
};
|
|
1031
|
-
StorageManager.prototype.removeLocalItem = function (key) {
|
|
1032
|
-
this.local.removeItem(key);
|
|
1033
|
-
};
|
|
1034
|
-
StorageManager.prototype.getSessionItem = function (key) {
|
|
1035
|
-
return this.session.getItem(key);
|
|
1036
|
-
};
|
|
1037
|
-
StorageManager.prototype.setSessionItem = function (key, value) {
|
|
1038
|
-
this.session.setItem(key, value);
|
|
1039
|
-
};
|
|
1040
|
-
StorageManager.prototype.removeSessionItem = function (key) {
|
|
1041
|
-
this.session.removeItem(key);
|
|
1042
|
-
};
|
|
1043
|
-
StorageManager.prototype.getCacheItem = function (key) {
|
|
1044
|
-
return this.cache.getItem(key);
|
|
1045
|
-
};
|
|
1046
|
-
StorageManager.prototype.setCacheItem = function (key, value) {
|
|
1047
|
-
this.cache.setItem(key, value);
|
|
1048
|
-
};
|
|
1049
|
-
StorageManager.prototype.removeCacheItem = function (key) {
|
|
1050
|
-
this.cache.removeItem(key);
|
|
1051
|
-
};
|
|
1052
|
-
StorageManager.prototype.getCookie = function (key, domain) {
|
|
1053
|
-
try {
|
|
1054
|
-
// const _matches = Cookies.get(name, { domain: domain || document.domain })
|
|
1055
|
-
var _matches = cookie.get(key);
|
|
1056
|
-
return _matches;
|
|
1057
|
-
} catch (e) {
|
|
1058
|
-
return '';
|
|
1059
|
-
}
|
|
1060
|
-
};
|
|
1061
|
-
StorageManager.prototype.setCookie = function (key, value, expiresTime, domain) {
|
|
1062
|
-
if (expiresTime === void 0) {
|
|
1063
|
-
expiresTime = this.defaultExpireTime;
|
|
1064
|
-
}
|
|
1065
|
-
try {
|
|
1066
|
-
var _domain = domain || document.domain;
|
|
1067
|
-
var timestamp = +new Date();
|
|
1068
|
-
var furureTimestamp = timestamp + expiresTime;
|
|
1069
|
-
cookie.set(key, value, {
|
|
1070
|
-
expires: new Date(furureTimestamp),
|
|
1071
|
-
path: '/',
|
|
1072
|
-
domain: _domain
|
|
1073
|
-
});
|
|
1074
|
-
} catch (e) {}
|
|
1075
|
-
};
|
|
1076
|
-
StorageManager.prototype.removeCookie = function (key, domain) {
|
|
1077
|
-
try {
|
|
1078
|
-
cookie.remove(key, {
|
|
1079
|
-
path: '/',
|
|
1080
|
-
domain: domain || ''
|
|
1081
|
-
});
|
|
1082
|
-
} catch (e) {}
|
|
1083
|
-
};
|
|
1084
|
-
return StorageManager;
|
|
1085
|
-
}();
|
|
1086
|
-
|
|
1087
938
|
// Copyright 2022 Beijing Volcanoengine Technology Ltd. All Rights Reserved.
|
|
1088
939
|
var LOG;
|
|
1089
940
|
LOG = {
|
|
@@ -1093,7 +944,14 @@ LOG = {
|
|
|
1093
944
|
};
|
|
1094
945
|
// CN: https://mcs.volceapplog.com VA: https://mcs.itobsnssdk.com SG: https://mcs.tobsnssdk.com
|
|
1095
946
|
var LOG_URL = LOG;
|
|
1096
|
-
var SDK_VERSION = '0.1.
|
|
947
|
+
var SDK_VERSION = '0.1.4';
|
|
948
|
+
var SDK_USE_TYPE = 'npm';
|
|
949
|
+
var SDK_TYPE = SDK_USE_TYPE;
|
|
950
|
+
var AB_DOMAINS = {
|
|
951
|
+
cn: '1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az1az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k',
|
|
952
|
+
va: '1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az1gz22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k',
|
|
953
|
+
sg: '1fz22z22z1nz21z4mz4bz4bz22z1mz19z1jz1mz1ez4az22z1mz19z21z1lz21z21z1bz1iz4az1az1mz1k'
|
|
954
|
+
};
|
|
1097
955
|
|
|
1098
956
|
// Copyright 2022 Beijing Volcanoengine Technology Ltd. All Rights Reserved.
|
|
1099
957
|
var EventCheck = /** @class */function () {
|
|
@@ -2929,6 +2787,559 @@ var RequestManager = /** @class */function () {
|
|
|
2929
2787
|
return RequestManager;
|
|
2930
2788
|
}();
|
|
2931
2789
|
|
|
2790
|
+
// Copyright 2022 Beijing Volcanoengine Technology Ltd. All Rights Reserved.
|
|
2791
|
+
// debugger icon的可拖拽
|
|
2792
|
+
var DraggableButton = /** @class */function () {
|
|
2793
|
+
function DraggableButton(element) {
|
|
2794
|
+
var _this = this;
|
|
2795
|
+
this.onMove = function (e) {
|
|
2796
|
+
if (!_this.isDragging) return;
|
|
2797
|
+
// 判断是否达到拖拽阈值
|
|
2798
|
+
var currentX = e.clientX || e.touches[0].clientX;
|
|
2799
|
+
var currentY = e.clientY || e.touches[0].clientY;
|
|
2800
|
+
if (_this.clickAllowed) {
|
|
2801
|
+
var deltaX = Math.abs(currentX - _this.initialX);
|
|
2802
|
+
var deltaY = Math.abs(currentY - _this.initialY);
|
|
2803
|
+
if (deltaX > _this.dragThreshold || deltaY > _this.dragThreshold) {
|
|
2804
|
+
_this.clickAllowed = false;
|
|
2805
|
+
}
|
|
2806
|
+
}
|
|
2807
|
+
// 节流处理
|
|
2808
|
+
if (_this.animationFrameId) {
|
|
2809
|
+
cancelAnimationFrame(_this.animationFrameId);
|
|
2810
|
+
}
|
|
2811
|
+
_this.animationFrameId = requestAnimationFrame(function () {
|
|
2812
|
+
var clientX = e.touches ? e.touches[0].clientX : e.clientX;
|
|
2813
|
+
var clientY = e.touches ? e.touches[0].clientY : e.clientY;
|
|
2814
|
+
// 计算新位置
|
|
2815
|
+
var newX = clientX - _this.offsetX;
|
|
2816
|
+
var newY = clientY - _this.offsetY;
|
|
2817
|
+
// 边界限制
|
|
2818
|
+
var maxX = window.innerWidth - _this.element.offsetWidth;
|
|
2819
|
+
var maxY = window.innerHeight - _this.element.offsetHeight;
|
|
2820
|
+
newX = Math.max(0, Math.min(newX, maxX));
|
|
2821
|
+
newY = Math.max(0, Math.min(newY, maxY));
|
|
2822
|
+
// 直接应用transform(不修改left/top)
|
|
2823
|
+
_this.element.style.transform = "translate(\n " + (newX - _this.initialX) + "px, \n " + (newY - _this.initialY) + "px\n )";
|
|
2824
|
+
});
|
|
2825
|
+
};
|
|
2826
|
+
this.onEnd = function () {
|
|
2827
|
+
if (!_this.isDragging) return;
|
|
2828
|
+
_this.isDragging = false;
|
|
2829
|
+
// 将最终位置同步到left/top
|
|
2830
|
+
var matrix = new DOMMatrix(getComputedStyle(_this.element).transform);
|
|
2831
|
+
var finalX = _this.initialX + matrix.m41;
|
|
2832
|
+
var finalY = _this.initialY + matrix.m42;
|
|
2833
|
+
_this.element.style.left = finalX + "px";
|
|
2834
|
+
_this.element.style.top = finalY + "px";
|
|
2835
|
+
_this.element.style.transform = 'none';
|
|
2836
|
+
// 更新初始位置记录
|
|
2837
|
+
_this.initialX = finalX;
|
|
2838
|
+
_this.initialY = finalY;
|
|
2839
|
+
// 清理事件监听
|
|
2840
|
+
document.removeEventListener('mousemove', _this.onMove);
|
|
2841
|
+
document.removeEventListener('mouseup', _this.onEnd);
|
|
2842
|
+
document.removeEventListener('touchmove', _this.onMove);
|
|
2843
|
+
document.removeEventListener('touchend', _this.onEnd);
|
|
2844
|
+
setTimeout(function () {
|
|
2845
|
+
_this.clickAllowed = true;
|
|
2846
|
+
}, 50);
|
|
2847
|
+
};
|
|
2848
|
+
this.element = element;
|
|
2849
|
+
this.isDragging = false;
|
|
2850
|
+
this.enableClick = false;
|
|
2851
|
+
this.animationFrameId = null;
|
|
2852
|
+
this.lastX = 0;
|
|
2853
|
+
this.lastY = 0;
|
|
2854
|
+
this.initialX = 0; // 元素初始X坐标
|
|
2855
|
+
this.initialY = 0; // 元素初始Y坐标
|
|
2856
|
+
this.offsetX = 0;
|
|
2857
|
+
this.offsetY = 0;
|
|
2858
|
+
this.clickAllowed = true;
|
|
2859
|
+
this.dragThreshold = 1; // 移动超过5px视为拖拽
|
|
2860
|
+
this.initPosition();
|
|
2861
|
+
this.bindEvents();
|
|
2862
|
+
this.bindClickHandler();
|
|
2863
|
+
}
|
|
2864
|
+
// 初始化元素定位方式
|
|
2865
|
+
DraggableButton.prototype.initPosition = function () {
|
|
2866
|
+
var rect = this.element.getBoundingClientRect();
|
|
2867
|
+
this.element.style.position = 'fixed';
|
|
2868
|
+
this.element.style.left = rect.left + "px";
|
|
2869
|
+
this.element.style.top = rect.top + "px";
|
|
2870
|
+
this.element.style.transform = 'translate(0, 0)';
|
|
2871
|
+
};
|
|
2872
|
+
DraggableButton.prototype.bindEvents = function () {
|
|
2873
|
+
this.element.addEventListener('mousedown', this.onStart.bind(this));
|
|
2874
|
+
this.element.addEventListener('touchstart', this.onStart.bind(this));
|
|
2875
|
+
};
|
|
2876
|
+
DraggableButton.prototype.onStart = function (e) {
|
|
2877
|
+
e.preventDefault();
|
|
2878
|
+
this.initialX = e.clientX || e.touches[0].clientX;
|
|
2879
|
+
this.initialY = e.clientY || e.touches[0].clientY;
|
|
2880
|
+
var clientX = e.touches ? e.touches[0].clientX : e.clientX;
|
|
2881
|
+
var clientY = e.touches ? e.touches[0].clientY : e.clientY;
|
|
2882
|
+
// 获取元素当前实际位置(包含transform)
|
|
2883
|
+
var rect = this.element.getBoundingClientRect();
|
|
2884
|
+
this.initialX = rect.left;
|
|
2885
|
+
this.initialY = rect.top;
|
|
2886
|
+
// 计算点击位置偏移量
|
|
2887
|
+
this.offsetX = clientX - this.initialX;
|
|
2888
|
+
this.offsetY = clientY - this.initialY;
|
|
2889
|
+
this.clickAllowed = true;
|
|
2890
|
+
this.isDragging = true;
|
|
2891
|
+
document.addEventListener('mousemove', this.onMove);
|
|
2892
|
+
document.addEventListener('mouseup', this.onEnd);
|
|
2893
|
+
document.addEventListener('touchmove', this.onMove);
|
|
2894
|
+
document.addEventListener('touchend', this.onEnd);
|
|
2895
|
+
};
|
|
2896
|
+
// 修改后的点击事件绑定方式
|
|
2897
|
+
DraggableButton.prototype.bindClickHandler = function () {
|
|
2898
|
+
var _this = this;
|
|
2899
|
+
this.element.addEventListener('click', function (e) {
|
|
2900
|
+
if (!_this.enableClick) return;
|
|
2901
|
+
if (!_this.clickAllowed) {
|
|
2902
|
+
e.stopImmediatePropagation();
|
|
2903
|
+
e.preventDefault();
|
|
2904
|
+
return;
|
|
2905
|
+
}
|
|
2906
|
+
// 原有的点击处理逻辑
|
|
2907
|
+
window && window.postMessage({
|
|
2908
|
+
type: 'devtool:web:open-draw'
|
|
2909
|
+
}, location.origin);
|
|
2910
|
+
});
|
|
2911
|
+
};
|
|
2912
|
+
DraggableButton.prototype.enable = function () {
|
|
2913
|
+
this.enableClick = true;
|
|
2914
|
+
this.element.style.cursor = 'pointer';
|
|
2915
|
+
this.element.style.opacity = '1';
|
|
2916
|
+
};
|
|
2917
|
+
return DraggableButton;
|
|
2918
|
+
}();
|
|
2919
|
+
|
|
2920
|
+
// Copyright 2022 Beijing Volcanoengine Technology Ltd. All Rights Reserved.
|
|
2921
|
+
var Debugger = /** @class */function () {
|
|
2922
|
+
function Debugger(collect, config) {
|
|
2923
|
+
this.devToolReady = false;
|
|
2924
|
+
this.devToolOrigin = '*';
|
|
2925
|
+
this.sendAlready = false;
|
|
2926
|
+
this.trackEnabled = true;
|
|
2927
|
+
if (config.disable_debug) return;
|
|
2928
|
+
if (collect.configManager.get('browser') === 'Microsoft Internet Explorer') return;
|
|
2929
|
+
this.collect = collect;
|
|
2930
|
+
this.config = config;
|
|
2931
|
+
this.app_id = config.app_id;
|
|
2932
|
+
this.trackEnabled = config.track_enabled ? true : false;
|
|
2933
|
+
this.cacheStorgae = new StorageManager();
|
|
2934
|
+
this.currentAppKey = "__applog_load_devtool_web_" + this.app_id;
|
|
2935
|
+
this.loadUrl = config.devtool_url || 'https://lf-static.applogcdn.com/obj/applog-sdk-static/log-sdk/collect/devtool/debug-web.v2.0.1.js';
|
|
2936
|
+
this.filterEvent = new Set(['__bav_page', '__bav_beat', '__bav_page_statistics', '__bav_click', '__bav_page_exposure', 'bav2b_page', 'bav2b_beat', 'bav2b_page_statistics', 'bav2b_click', 'bav2b_page_exposure', '_be_active', 'predefine_pageview', '__profile_set', '__profile_set_once', '__profile_increment', '__profile_unset', '__profile_append', 'predefine_page_alive', 'predefine_page_close', 'abtest_exposure']);
|
|
2937
|
+
this.load();
|
|
2938
|
+
}
|
|
2939
|
+
Debugger.prototype.loadScript = function (src) {
|
|
2940
|
+
var _this = this;
|
|
2941
|
+
try {
|
|
2942
|
+
var script = document.createElement('script');
|
|
2943
|
+
script.src = src;
|
|
2944
|
+
script.onerror = function () {
|
|
2945
|
+
console.log('load DevTool render fail');
|
|
2946
|
+
};
|
|
2947
|
+
script.onload = function () {
|
|
2948
|
+
_this.enableDebugButton();
|
|
2949
|
+
console.log('load DevTool render success');
|
|
2950
|
+
};
|
|
2951
|
+
document.getElementsByTagName('body')[0].appendChild(script);
|
|
2952
|
+
} catch (e) {
|
|
2953
|
+
console.log("devTool load fail, " + e.message);
|
|
2954
|
+
}
|
|
2955
|
+
};
|
|
2956
|
+
Debugger.prototype.parseUrl = function () {
|
|
2957
|
+
var params = {};
|
|
2958
|
+
try {
|
|
2959
|
+
var url = window.location.href;
|
|
2960
|
+
var hash = url.split('?')[1].split('&');
|
|
2961
|
+
if (hash.length) {
|
|
2962
|
+
hash.forEach(function (h) {
|
|
2963
|
+
var parts = h.split('=');
|
|
2964
|
+
params[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]);
|
|
2965
|
+
});
|
|
2966
|
+
}
|
|
2967
|
+
} catch (e) {}
|
|
2968
|
+
return params;
|
|
2969
|
+
};
|
|
2970
|
+
Debugger.prototype.load = function () {
|
|
2971
|
+
try {
|
|
2972
|
+
var queryObj = this.parseUrl();
|
|
2973
|
+
if (queryObj['open_devtool_web'] == false) {
|
|
2974
|
+
this.cacheStorgae.removeLocalItem("__applog_open_devtool_web");
|
|
2975
|
+
return;
|
|
2976
|
+
}
|
|
2977
|
+
if (queryObj['open_devtool_web'] && queryObj['app_id']) {
|
|
2978
|
+
if (parseInt(queryObj['app_id']) !== this.app_id) return;
|
|
2979
|
+
} else {
|
|
2980
|
+
if (!this.getStorage()) return;
|
|
2981
|
+
}
|
|
2982
|
+
this.loadBaseInfo();
|
|
2983
|
+
this.loadHook();
|
|
2984
|
+
this.setStorage();
|
|
2985
|
+
this.addLintener();
|
|
2986
|
+
this.loadDevTool();
|
|
2987
|
+
} catch (e) {
|
|
2988
|
+
console.log("debug fail, " + e.message);
|
|
2989
|
+
}
|
|
2990
|
+
};
|
|
2991
|
+
Debugger.prototype.getStorage = function () {
|
|
2992
|
+
var storage_appid = this.cacheStorgae.getLocalItem("__applog_open_devtool_web");
|
|
2993
|
+
return storage_appid && parseInt(storage_appid) === this.app_id;
|
|
2994
|
+
};
|
|
2995
|
+
Debugger.prototype.setStorage = function () {
|
|
2996
|
+
this.cacheStorgae.setLocalItem('__applog_open_devtool_web', this.app_id);
|
|
2997
|
+
this.cacheStorgae.setLocalItem('__applog_devtool_web_track_enable', this.trackEnabled);
|
|
2998
|
+
};
|
|
2999
|
+
Debugger.prototype.loadDevTool = function () {
|
|
3000
|
+
var currentAppHasLoad = this.cacheStorgae.getLocalItem(this.currentAppKey) == 1;
|
|
3001
|
+
if (currentAppHasLoad) {
|
|
3002
|
+
console.warn("your appid: " + this.app_id + " has load web devtools already, maybe your page has more than two applogsdk and use one appid");
|
|
3003
|
+
return;
|
|
3004
|
+
}
|
|
3005
|
+
this.loadDebuggerModule();
|
|
3006
|
+
this.loadScript(this.loadUrl);
|
|
3007
|
+
};
|
|
3008
|
+
Debugger.prototype.loadBaseInfo = function () {
|
|
3009
|
+
this.log = [];
|
|
3010
|
+
this.event = [];
|
|
3011
|
+
this.info = [{
|
|
3012
|
+
title: '基本信息',
|
|
3013
|
+
key: 'base',
|
|
3014
|
+
type: 1,
|
|
3015
|
+
content: [{
|
|
3016
|
+
name: 'app_id',
|
|
3017
|
+
desc: 'APP_ID',
|
|
3018
|
+
value: this.config.app_id
|
|
3019
|
+
}, {
|
|
3020
|
+
name: 'channel',
|
|
3021
|
+
desc: 'CHANNEL',
|
|
3022
|
+
value: this.config.channel
|
|
3023
|
+
}, {
|
|
3024
|
+
name: 'domain',
|
|
3025
|
+
desc: '上报域名',
|
|
3026
|
+
value: this.collect.configManager.getDomain()
|
|
3027
|
+
}, {
|
|
3028
|
+
name: 'sdk_version',
|
|
3029
|
+
desc: 'SDK版本',
|
|
3030
|
+
value: SDK_VERSION
|
|
3031
|
+
}, {
|
|
3032
|
+
name: 'sdk_type',
|
|
3033
|
+
desc: 'SDK引入方式',
|
|
3034
|
+
value: SDK_TYPE
|
|
3035
|
+
}]
|
|
3036
|
+
}, {
|
|
3037
|
+
title: '用户信息',
|
|
3038
|
+
key: 'user',
|
|
3039
|
+
type: 2,
|
|
3040
|
+
content: [{
|
|
3041
|
+
name: 'uuid',
|
|
3042
|
+
desc: 'UUID',
|
|
3043
|
+
value: this.collect.configManager.get('user').user_unique_id || ''
|
|
3044
|
+
}, {
|
|
3045
|
+
name: 'web_id',
|
|
3046
|
+
desc: 'WEB_ID',
|
|
3047
|
+
value: this.collect.configManager.get('user').web_id || ''
|
|
3048
|
+
}]
|
|
3049
|
+
}, {
|
|
3050
|
+
title: '公共参数信息',
|
|
3051
|
+
type: 2,
|
|
3052
|
+
key: 'common',
|
|
3053
|
+
content: [{
|
|
3054
|
+
name: 'browser',
|
|
3055
|
+
desc: '浏览器',
|
|
3056
|
+
value: this.collect.configManager.get('browser')
|
|
3057
|
+
}, {
|
|
3058
|
+
name: 'browser_version',
|
|
3059
|
+
desc: '浏览器版本',
|
|
3060
|
+
value: this.collect.configManager.get('browser_version')
|
|
3061
|
+
}, {
|
|
3062
|
+
name: 'platform',
|
|
3063
|
+
desc: '平台',
|
|
3064
|
+
value: this.collect.configManager.get('platform')
|
|
3065
|
+
}, {
|
|
3066
|
+
name: 'device_model',
|
|
3067
|
+
desc: '设备型号',
|
|
3068
|
+
value: this.collect.configManager.get('device_model')
|
|
3069
|
+
}, {
|
|
3070
|
+
name: 'os_name',
|
|
3071
|
+
desc: '操作系统',
|
|
3072
|
+
value: this.collect.configManager.get('os_name')
|
|
3073
|
+
}, {
|
|
3074
|
+
name: 'os_version',
|
|
3075
|
+
desc: '操作系统版本',
|
|
3076
|
+
value: this.collect.configManager.get('os_version')
|
|
3077
|
+
}, {
|
|
3078
|
+
name: 'resolution',
|
|
3079
|
+
desc: '屏幕分辨率',
|
|
3080
|
+
value: this.collect.configManager.get('resolution')
|
|
3081
|
+
}, {
|
|
3082
|
+
name: 'referrer',
|
|
3083
|
+
desc: '来源',
|
|
3084
|
+
value: this.collect.configManager.get('referrer')
|
|
3085
|
+
}, {
|
|
3086
|
+
name: 'custom',
|
|
3087
|
+
desc: '自定义信息',
|
|
3088
|
+
value: JSON.stringify(this.collect.configManager.get('custom'))
|
|
3089
|
+
}]
|
|
3090
|
+
}, {
|
|
3091
|
+
title: '配置信息',
|
|
3092
|
+
key: 'config',
|
|
3093
|
+
type: 3,
|
|
3094
|
+
content: [{
|
|
3095
|
+
name: 'autotrack',
|
|
3096
|
+
desc: '全埋点',
|
|
3097
|
+
value: this.config.autotrack ? true : false
|
|
3098
|
+
}, {
|
|
3099
|
+
name: 'stay',
|
|
3100
|
+
desc: '停留时长',
|
|
3101
|
+
value: this.config.enable_stay_duration ? true : false
|
|
3102
|
+
}]
|
|
3103
|
+
}, {
|
|
3104
|
+
title: 'A/B配置信息',
|
|
3105
|
+
key: 'ab',
|
|
3106
|
+
type: 4,
|
|
3107
|
+
content: [{
|
|
3108
|
+
name: 'ab',
|
|
3109
|
+
desc: 'A/B实验',
|
|
3110
|
+
value: this.config.enable_ab_test ? true : false
|
|
3111
|
+
}]
|
|
3112
|
+
}];
|
|
3113
|
+
if (this.config.enable_ab_test) {
|
|
3114
|
+
var ab = this.getInfo('ab');
|
|
3115
|
+
var content = [{
|
|
3116
|
+
name: 'ab',
|
|
3117
|
+
desc: 'A/B实验',
|
|
3118
|
+
value: this.config.enable_ab_test ? true : false
|
|
3119
|
+
}, {
|
|
3120
|
+
name: 'vid',
|
|
3121
|
+
desc: '已曝光VID',
|
|
3122
|
+
value: this.collect.configManager.getAbVersion()
|
|
3123
|
+
}, {
|
|
3124
|
+
name: 'ab_domain',
|
|
3125
|
+
desc: 'A/B域名',
|
|
3126
|
+
value: this.config.ab_channel_domain || decodeUrl(AB_DOMAINS[this.config.channel])
|
|
3127
|
+
}, {
|
|
3128
|
+
name: 'all_values',
|
|
3129
|
+
desc: '全部配置',
|
|
3130
|
+
value: this.collect.configManager.getAbCache()
|
|
3131
|
+
}];
|
|
3132
|
+
ab.content = content;
|
|
3133
|
+
this.setInfo('ab', ab);
|
|
3134
|
+
}
|
|
3135
|
+
if (this.config.enable_native || this.config.Native) {
|
|
3136
|
+
var _native = {
|
|
3137
|
+
title: '客户端信息',
|
|
3138
|
+
type: 3,
|
|
3139
|
+
content: [{
|
|
3140
|
+
name: 'native',
|
|
3141
|
+
desc: '是否打通',
|
|
3142
|
+
value: this.collect.bridgeReport ? true : false
|
|
3143
|
+
}]
|
|
3144
|
+
};
|
|
3145
|
+
this.setInfo('native', _native);
|
|
3146
|
+
}
|
|
3147
|
+
if (SDK_VERSION.includes('tob')) {
|
|
3148
|
+
var user = this.getInfo('user');
|
|
3149
|
+
user.content.push({
|
|
3150
|
+
name: 'sid',
|
|
3151
|
+
desc: 'DISS'.split('').reverse().join(''),
|
|
3152
|
+
value: '点击获取'
|
|
3153
|
+
});
|
|
3154
|
+
this.setInfo('user', user);
|
|
3155
|
+
}
|
|
3156
|
+
};
|
|
3157
|
+
Debugger.prototype.getInfo = function (key) {
|
|
3158
|
+
var current = null;
|
|
3159
|
+
this.info.forEach(function (item) {
|
|
3160
|
+
if (item.key === key) {
|
|
3161
|
+
current = item;
|
|
3162
|
+
}
|
|
3163
|
+
});
|
|
3164
|
+
return current;
|
|
3165
|
+
};
|
|
3166
|
+
Debugger.prototype.setInfo = function (key, data) {
|
|
3167
|
+
var hasKey = false;
|
|
3168
|
+
this.info.forEach(function (item) {
|
|
3169
|
+
if (item.key === key) {
|
|
3170
|
+
hasKey = true;
|
|
3171
|
+
item = data;
|
|
3172
|
+
}
|
|
3173
|
+
});
|
|
3174
|
+
if (!hasKey) {
|
|
3175
|
+
this.info.push(data);
|
|
3176
|
+
}
|
|
3177
|
+
};
|
|
3178
|
+
Debugger.prototype.getSecondInfo = function (key, valueKey) {
|
|
3179
|
+
var data = this.getInfo(key);
|
|
3180
|
+
var current = null;
|
|
3181
|
+
data.content.forEach(function (item) {
|
|
3182
|
+
if (item.name === valueKey) {
|
|
3183
|
+
current = item;
|
|
3184
|
+
}
|
|
3185
|
+
});
|
|
3186
|
+
return current;
|
|
3187
|
+
};
|
|
3188
|
+
Debugger.prototype.setSecondInfo = function (key, valueKey, value) {
|
|
3189
|
+
var data = this.getInfo(key);
|
|
3190
|
+
var contentHasKey = false;
|
|
3191
|
+
data.content.forEach(function (item) {
|
|
3192
|
+
if (item.name === valueKey) {
|
|
3193
|
+
item.value = value;
|
|
3194
|
+
contentHasKey = true;
|
|
3195
|
+
}
|
|
3196
|
+
});
|
|
3197
|
+
if (!contentHasKey) {
|
|
3198
|
+
var newContent = {
|
|
3199
|
+
name: valueKey,
|
|
3200
|
+
value: value,
|
|
3201
|
+
desc: valueKey.toLocaleUpperCase()
|
|
3202
|
+
};
|
|
3203
|
+
data.content.push(newContent);
|
|
3204
|
+
}
|
|
3205
|
+
this.setInfo(key, data);
|
|
3206
|
+
};
|
|
3207
|
+
Debugger.prototype.loadHook = function () {
|
|
3208
|
+
var _this = this;
|
|
3209
|
+
this.collect.on(DebuggerMesssge.DEBUGGER_MESSAGE, function (data) {
|
|
3210
|
+
switch (data.type) {
|
|
3211
|
+
case DebuggerMesssge.DEBUGGER_MESSAGE_SDK:
|
|
3212
|
+
var logObj = {
|
|
3213
|
+
time: data.time,
|
|
3214
|
+
type: data.logType || 'sdk',
|
|
3215
|
+
infoType: data.infoType || 'sdk',
|
|
3216
|
+
level: data.level,
|
|
3217
|
+
name: data.info,
|
|
3218
|
+
show: true,
|
|
3219
|
+
levelShow: true,
|
|
3220
|
+
needDesc: data.data ? true : false
|
|
3221
|
+
};
|
|
3222
|
+
if (data.data) {
|
|
3223
|
+
logObj['desc'] = {
|
|
3224
|
+
content: JSON.stringify(data.data)
|
|
3225
|
+
};
|
|
3226
|
+
}
|
|
3227
|
+
_this.updateLog(logObj);
|
|
3228
|
+
if (data.secType && data.secType === 'AB') {
|
|
3229
|
+
_this.setSecondInfo('ab', 'vid', _this.collect.configManager.getAbVersion());
|
|
3230
|
+
_this.setSecondInfo('ab', 'all_values', _this.collect.configManager.getAbCache());
|
|
3231
|
+
} else if (data.secType === 'USER') {
|
|
3232
|
+
// this.setSecondInfo('user', 'uuid', this.collect.configManager.get('user_unique_id'))
|
|
3233
|
+
// this.setSecondInfo('user', 'web_id', this.collect.configManager.get('web_id'))
|
|
3234
|
+
_this.setSecondInfo('user', data.common === 'user_unique_id' ? 'uuid' : data.common, _this.collect.configManager.get(data.common));
|
|
3235
|
+
} else if (data.secType === 'HEADER') {
|
|
3236
|
+
var value = _this.collect.configManager.get(data.common);
|
|
3237
|
+
_this.setSecondInfo('common', data.common, data.common === 'custom' ? JSON.stringify(value) : value);
|
|
3238
|
+
}
|
|
3239
|
+
_this.updateInfo();
|
|
3240
|
+
return;
|
|
3241
|
+
case DebuggerMesssge.DEBUGGER_MESSAGE_EVENT:
|
|
3242
|
+
if (data.data && data.data.length) {
|
|
3243
|
+
var events = data.data[0];
|
|
3244
|
+
var event_1 = events.events;
|
|
3245
|
+
if (!event_1.length) return;
|
|
3246
|
+
event_1.forEach(function (item) {
|
|
3247
|
+
item['checkShow'] = true;
|
|
3248
|
+
item['searchShow'] = true;
|
|
3249
|
+
item['focusShow'] = true;
|
|
3250
|
+
item['status'] = data.status;
|
|
3251
|
+
item['type'] = _this.filterEvent.has(item.event) ? 'sdk' : 'cus';
|
|
3252
|
+
item['verifyType'] = data.verifyType ? 'verify' : 'no';
|
|
3253
|
+
item['info'] = '';
|
|
3254
|
+
if (data.status === 'fail') {
|
|
3255
|
+
item['info'] = {
|
|
3256
|
+
message: "code: " + data.code + "\uFF0C msg: " + (data.msg || data.failType)
|
|
3257
|
+
};
|
|
3258
|
+
}
|
|
3259
|
+
});
|
|
3260
|
+
_this.updateEvent(events);
|
|
3261
|
+
}
|
|
3262
|
+
return;
|
|
3263
|
+
}
|
|
3264
|
+
});
|
|
3265
|
+
};
|
|
3266
|
+
Debugger.prototype.addLintener = function () {
|
|
3267
|
+
var _this = this;
|
|
3268
|
+
window.addEventListener('message', function (messgae) {
|
|
3269
|
+
if (messgae && messgae.data && messgae.data.type === 'devtool:web:ready') {
|
|
3270
|
+
_this.devToolOrigin = messgae.origin;
|
|
3271
|
+
_this.devToolReady = true;
|
|
3272
|
+
if (_this.sendAlready) return;
|
|
3273
|
+
_this.sendData('devtool:web:init', {
|
|
3274
|
+
info: _this.info,
|
|
3275
|
+
log: _this.log,
|
|
3276
|
+
event: _this.event,
|
|
3277
|
+
sdk_type: SDK_VERSION.includes('tob') ? 'tob' : 'inner',
|
|
3278
|
+
appId: _this.app_id
|
|
3279
|
+
});
|
|
3280
|
+
_this.sendAlready = true;
|
|
3281
|
+
}
|
|
3282
|
+
if (messgae && messgae.data && messgae.data.type === 'devtool:web:ssid') {
|
|
3283
|
+
_this.collect.getToken(function (res) {
|
|
3284
|
+
_this.setSecondInfo('user', 'sid', res.tobid);
|
|
3285
|
+
_this.updateInfo();
|
|
3286
|
+
});
|
|
3287
|
+
}
|
|
3288
|
+
});
|
|
3289
|
+
};
|
|
3290
|
+
Debugger.prototype.sendData = function (type, data) {
|
|
3291
|
+
try {
|
|
3292
|
+
var postData = {
|
|
3293
|
+
type: type,
|
|
3294
|
+
payload: data
|
|
3295
|
+
};
|
|
3296
|
+
// (window.opener || window.parent).postMessage(postData, this.devToolOrigin);
|
|
3297
|
+
window && window.postMessage(postData, this.devToolOrigin);
|
|
3298
|
+
} catch (e) {}
|
|
3299
|
+
};
|
|
3300
|
+
Debugger.prototype.updateInfo = function () {
|
|
3301
|
+
if (!this.devToolReady) {
|
|
3302
|
+
return;
|
|
3303
|
+
}
|
|
3304
|
+
this.sendData('devtool:web:info', this.info);
|
|
3305
|
+
};
|
|
3306
|
+
Debugger.prototype.updateLog = function (logObj) {
|
|
3307
|
+
if (!this.devToolReady) {
|
|
3308
|
+
this.log.push(logObj);
|
|
3309
|
+
return;
|
|
3310
|
+
}
|
|
3311
|
+
this.sendData('devtool:web:log', logObj);
|
|
3312
|
+
};
|
|
3313
|
+
Debugger.prototype.updateEvent = function (events) {
|
|
3314
|
+
if (!this.devToolReady) {
|
|
3315
|
+
this.event.push(events);
|
|
3316
|
+
return;
|
|
3317
|
+
}
|
|
3318
|
+
this.sendData('devtool:web:event', events);
|
|
3319
|
+
};
|
|
3320
|
+
Debugger.prototype.loadDebuggerModule = function () {
|
|
3321
|
+
var debugCss = "#debugger-applog-web {\n position: fixed;\n width: 90px;\n height: 30px;\n background: #23c243;\n border-radius: 6px;\n color: #fff;\n font-size: 12px;\n bottom: 5%;\n right: 10%;\n text-align: center;\n line-height: 30px;\n cursor: not-allowed;\n z-index:1000;\n font-weight:bold;\n opacity: 0.6;\n }";
|
|
3322
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
3323
|
+
var style = document.createElement('style');
|
|
3324
|
+
style.appendChild(document.createTextNode(debugCss));
|
|
3325
|
+
head.appendChild(style);
|
|
3326
|
+
var debuggerHtml = "<div id=\"debugger-applog-web\" class=\"debugger-applog-web\">AppLog\u8C03\u8BD5</div>";
|
|
3327
|
+
var debugDiv = document.createElement('div');
|
|
3328
|
+
debugDiv.innerHTML = debuggerHtml;
|
|
3329
|
+
var debuggerContainer = "<div id=\"debugger-container\" class=\"debugger-container\"></div>";
|
|
3330
|
+
var debugContainerDiv = document.createElement('div');
|
|
3331
|
+
debugContainerDiv.innerHTML = debuggerContainer;
|
|
3332
|
+
document.getElementsByTagName('body')[0].appendChild(debugDiv);
|
|
3333
|
+
document.getElementsByTagName('body')[0].appendChild(debugContainerDiv);
|
|
3334
|
+
var debugTool = document.getElementById('debugger-applog-web');
|
|
3335
|
+
this.debugButton = new DraggableButton(debugTool);
|
|
3336
|
+
};
|
|
3337
|
+
Debugger.prototype.enableDebugButton = function () {
|
|
3338
|
+
this.debugButton && this.debugButton.enable();
|
|
3339
|
+
};
|
|
3340
|
+
return Debugger;
|
|
3341
|
+
}();
|
|
3342
|
+
|
|
2932
3343
|
var jsbn = createCommonjsModule(function (module, exports) {
|
|
2933
3344
|
(function(){
|
|
2934
3345
|
var dbits;
|
|
@@ -5089,7 +5500,7 @@ var Collector$1 = /** @class */function () {
|
|
|
5089
5500
|
this.configManager = new ConfigManager(this, initConfig);
|
|
5090
5501
|
this.appBridge = new AppBridge(initConfig, this.configManager);
|
|
5091
5502
|
this.bridgeReport = this.appBridge.bridgeInject();
|
|
5092
|
-
|
|
5503
|
+
this["debugger"] = new Debugger(this, initConfig);
|
|
5093
5504
|
this.requestManager = new RequestManager(this, initConfig);
|
|
5094
5505
|
this.initConfig = initConfig;
|
|
5095
5506
|
this.env = initConfig.channel_domain ? 'self' : 'public';
|