Unity异常上报飞书工具


背景

  • 平常在测试人员做回归测试时,包体会有报错、界面异常等问题,通过这个工具会自动上报异常到飞书表格,方便更全面收集问题。比如自动上报报错,并截图;自动收集非中文环境下,界面存在中文的节点和文本。
  • 相比bugly,能更自由设置要收集的信息和规定格式。不单纯只收集报错。

ID


获取tenant_access_token


获取表格obj_token


上传图片资源

c# 复制代码
curl --location --request POST 'https://open.feishu.cn/open-apis/drive/v1/medias/upload_all' \
--header 'Authorization: Bearer t-g1044hgIxxxxx' \
--header 'Content-Type: multipart/form-data' \
--form 'file_name="bd.png"' \
--form 'parent_type="bitable_image"' \
--form 'parent_node="Njfxxxxxxx"' \
--form 'size="4020"'
  • 上传成功拿到file_token
c# 复制代码
// C# 代码实现上传图片
static public void UploadMedia()
{
    // 1. 定义请求 URL
    string url = "https://open.feishu.cn/open-apis/drive/v1/medias/upload_all";

    // 2. 构建表单数据
    List<IMultipartFormSection> formData = new List<IMultipartFormSection>();

    // 添加文本字段
    formData.Add(new MultipartFormDataSection("file_name", "demo.png"));
    formData.Add(new MultipartFormDataSection("parent_type", "bitable_image"));
    formData.Add(new MultipartFormDataSection("parent_node", "Njfdxxxx"));

    // 添加文件字段(注意路径需要指向实际文件)
    string filePath = Path.Combine(Application.streamingAssetsPath, "demo.png");
    byte[] fileData = File.ReadAllBytes(filePath);
    formData.Add(new MultipartFormDataSection("file", fileData));
    formData.Add(new MultipartFormDataSection("size", fileData.Length.ToString()));

    // 3. 创建 UnityWebRequest
    UnityWebRequest request = UnityWebRequest.Post(url, formData);
    
    // 4. 设置请求头
    request.SetRequestHeader("Authorization", "Bearer t-g1044xxxxxx");
    // request.SetRequestHeader("Content-Type", "multipart/form-data; boundary=---7MA4YWxkTrZu0gW");

    // 5. 发送请求
    request.SendWebRequest();

    while (request.isDone == false);
    
    // 6. 处理响应
    if (request.isHttpError || request.isNetworkError)
    {
        Debug.LogError($"上传失败: [{request.error}][{request.downloadHandler?.text}]");
    }
    else
    {
        Debug.Log("上传成功: " + request.downloadHandler.text);
    }
}

新增一条记录

c# 复制代码
curl -i -X POST 'https://open.feishu.cn/open-apis/bitable/v1/apps/Njfxxxxb/tables/tbxxxx/records' \-H 'Content-Type: application/json' \
-H 'Authorization: Bearer t-g1044hxxxxx' \
-d '{
    "fields": {
        "文本": "啊啊啊大王"
    }
}'

新增多条记录

https://open.feishu.cn/open-apis/bitable/v1/apps/NjfdbMsdGalzJ2sz9JTcukN1nMb/tables/tblQNkGF8LsTt8E4/records/batch_create

c# 复制代码
{ 
    "records": [
        {
            "fields": {
                "问题": "您那还好abe",
                "附件":[
                    {
                        "file_token": "Vl3FbVkvnowlgpxpqsAbBrtFcrd"
                    }
                ]
            }
        },
        {
            "fields": {
                "问题": "您那还好abccc"
            }
        }
    ]
}

查询已有记录

c# 复制代码
{ 
  "view_id": "vewBA13Fjq",
  "field_names": [
    "文本",  "版本"
  ],
  "filter": {
    "conjunction": "and",
    "conditions": [
      {
        "field_name": "文本",
        "operator": "is",
        "value": [
          "啊啊啊大王"
        ]
      },
      {
        "field_name": "版本",
        "operator": "is",
        "value": [
          "1.3.222"
        ]
      }
    ]
  }
}

上报流程

最终效果

  • 报错表格

  • 黑名单配置

相关推荐
海尔辛2 小时前
Unity UI 性能优化--Sprite 篇
ui·unity·性能优化
三巧7 小时前
Godot 敌人生成半径和围墙不匹配,导致敌人错误的生成在围墙外的解决代码
游戏引擎·godot
技术小甜甜7 小时前
【Godot引擎】如何使用内置的全局搜索功能提升开发效率
游戏引擎·godot
技术小甜甜7 小时前
【Godot】如何导出 Release 版本的安卓项目
android·游戏引擎·godot
XR-AI-JK16 小时前
Unity VR/MR开发-VR设备与适用场景分析
unity·vr·mr
Amentos17 小时前
飞书常用功能(留档)
飞书·飞书表格函数
落笔画忧愁e17 小时前
扣子Coze飞书多维表插件-列出全部数据表
java·服务器·飞书
Magnum Lehar18 小时前
vulkan游戏引擎的makefile启动环境实现
游戏引擎
地狱为王1 天前
基于VLC的Unity视频播放器(四)
unity·游戏引擎·音视频