feat(sdk): 版本注入与事件归属骨架(0.2.0/build_id/schema_version)
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
/** 事件归属四元组:入队时冻结,flush 不再重读(spec §1.1) */
|
||||
export interface Attribution {
|
||||
site_id: string;
|
||||
visitor_id: string;
|
||||
session_id: string;
|
||||
page_id: string;
|
||||
seq: number;
|
||||
purpose?: null; // V1.1 预留
|
||||
epoch?: null; // V1.1 预留
|
||||
grant_ref?: null; // V1.1 预留
|
||||
}
|
||||
export const SDK_VERSION = "0.2.0"; // 与 package.json 同步手维护
|
||||
export const SCHEMA_VERSION = 2;
|
||||
export const CONFIG_VERSION = "1";
|
||||
|
||||
// build_id 由 esbuild/vitest define 注入的全局常量(ambient 声明,
|
||||
// 不能用模块级 export declare——esbuild 打包时会被擦除导致引用悬空)
|
||||
declare global {
|
||||
// eslint-disable-next-line no-var
|
||||
var __BUILD_ID__: string | undefined;
|
||||
}
|
||||
/** 运行时兜底读取(build 注入缺失时降级 "unknown",绝不抛) */
|
||||
export const BUILD_ID: string = globalThis.__BUILD_ID__ ?? "unknown";
|
||||
Reference in New Issue
Block a user