feat(monitor): 添加神策数据诊断日志,排查 platform_type 和 uid 为未知的问题

This commit is contained in:
hjhan
2026-04-29 16:54:36 +08:00
parent 94461f46f7
commit 735b7177ba
2 changed files with 34 additions and 0 deletions
+15
View File
@@ -60,5 +60,20 @@
}
}
[HttpPost]
public IActionResult LogSensors([FromBody] SensorsLogModel model)
{
var logger = LogFactory.GetLogger("SensorsDiag");
logger.Info($"[SensorsLog] uid={model?.Uid ?? "NULL"} platform={model?.Platform ?? "NULL"} ua={model?.Ua ?? "NULL"} url={model?.Url ?? "NULL"}");
return Ok();
}
}
public class SensorsLogModel
{
public string Uid { get; set; }
public string Platform { get; set; }
public string Ua { get; set; }
public string Url { get; set; }
}
}
+19
View File
@@ -121,6 +121,25 @@
sensors.setOnceProfile({ userId: '@CurUser.OaAccount', name: '@CurUser.UserName' });
}
// 神策诊断日志(精简版)
(function () {
try {
var diag = {
uid: '@CurUser?.UserId' || 'NULL',
platform: sensorsConfig._platformType || 'onederiv',
ua: (navigator.userAgent || '').substring(0, 50) || 'NULL',
url: location.href
};
$.ajax({
url: '/common/LogSensors',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(diag),
async: true
});
} catch (e) { }
})();
window.saTrack = function (eventName, props) {
try {
if (!window.sensors || !sensors.track) { return; }