# 可交互指标

更新时间:2025-07-10 16:48:02

# 一、概述

在小游戏场景中,用户对启动时长极度敏感,启动速度的快慢直接影响其是否愿意继续停留 。为帮助开发者快速定位启动问题,平台开放「启动场景」上报分析能力:

系统启动场景: 覆盖从「启动点击」到「首屏渲染完成」的上报统计,帮助定位基础性能问题。系统自带场景、维度、指标的上报,无需开发者手动上报;

自定义启动场景:通过接口 ks.reportScene,开发者可主动上报自定义的启动场景,完整追踪用户从点击到交互前的全链路表现

注意:「启动场景」上报能力仅适用于启动阶段分析,对于其他场景的统计上报,可能会无法得出正确结论,不建议使用。

# 二、系统启动场景

围绕小游戏的启动流程,平台默认提供了部分启动场景,其中大部分场景无需开发者手动上报,但某些场景的统计,需要开发者主动调用接口来上报数据,以便平台能够准确统计该场景的耗时情况。具体的场景说明如下表所示:

场景ID场景名称场景说明
7001游戏可交互资源加载完毕,用户最早可操作游戏画面的时机(如新手引导或游戏主大厅界面)

# 三、上报自定义启动场景

更多参数请参考 ks.reportScene (opens new window)接口文档

// 接口上报示例代码
ks.reportScene({
  sceneId: 70002,  //「必填」sceneId 为「新建场景」后,由系统生成的场景 Id 值,用于区分当前是哪个启动场景的数据
  costTime: 200,  //「非必填」costTime 为当前场景的耗时(ms),默认为 0
  dimension: {
    d1: 'value', //「非必填」value仅支持传入String类型。若value表示Boolean,请将值处理为0、1进行上报;若value为Number,请转换为String进行上报
  },
  success(res) {// 上报接口执行完成后的回调,用于检查上报数据是否符合预期,也可通过启动调试能力进行验证
    console.log(res);
  },
  fail(res) {// 上报报错时的回调,用于查看上报错误的原因:如参数类型错误等
    console.log(res);
  },
})

unity webGL KS.ReportScene (opens new window) 接口文档

// unity webGL
public void ReportScene()
{
    Debug.Log("[ReportScene]");
    KSReportSceneOption param = new KSReportSceneOption();
    param.sceneId = int.Parse(InputReportSceneSceneId.text);
    param.costTime = int.Parse(InputReportSceneCostTime.text);
    param.dimension = new Dictionary<string, string>
    {
        { "dimension1", "dimension1" },
        { "dimension2", "dimension2" },
        { "dimension3", "dimension3" },
        { "dimension4", "dimension4" },
    };
    param.metric = new Dictionary<string, string>
    {
        { "metric1", "1.3" },
        { "metric2", "100" },
        { "metric3", "1" },
        { "metric4", "111" },
    };
    param.success = (ret) =>
    {
        Debug.Log(
            "[ReportScene]: -data:" + JsonMapper.ToJson(ret.data) + "-errMsg:" + ret.errMsg
        );
    };
    param.fail = (ret) =>
    {
        Debug.Log("[ReportScene]: -errNo:" + ret.errNo + "-errMsg:" + ret.errMsg);
    };
    param.complete = (ret) =>
    {
        Debug.Log("[ReportScene] completeCB");
        Debug.Log(ret);
    };
    KS.ReportScene(param);
}

unity IG KS.ReportScene (opens new window) 接口文档

// unity IG
public void ReportScene()
{
    KSReportSceneParam param = new KSReportSceneParam();
    param.sceneId = int.Parse(InputReportSceneSceneId.text);
    param.costTime = int.Parse(InputReportSceneCostTime.text);
    param.dimension = new Dictionary<string, string>
    {
        { "dimension1", "dimension1" },
        { "dimension2", "dimension2" },
        { "dimension3", "dimension3" },
        { "dimension4", "dimension4" },
    };
    param.metric = new Dictionary<string, string>
    {
        { "metric1", "1.3" },
        { "metric2", "100" },
        { "metric3", "1" },
        { "metric4", "111" },
    };
    KS.ReportScene(
        param,
        (ret) =>
        {
            Debug.Log(ret.data);
            Debug.Log("[ReportScene]: -data:" + ret.data + "-errMsg:" + ret.errMsg);
        },
        (errNo, errMsg) =>
        {
            Debug.Log("[ReportScene] 失败:" + errNo + " " + errMsg);
        },
        (ret) =>
        {
            Debug.Log(
                "[ReportScene] completeCB"
                    + "-success:"
                    + ret.success
                    + "-code:"
                    + ret.code
                    + "-msg:"
                    + ret.msg
            );
        }
    );
}
Copyright ©2025, All Rights Reserved