@kbapp/media-fusion-tracker 0.0.1

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.
Files changed (34) hide show
  1. package/README.MD +225 -0
  2. package/dist/es/helpers/filter-undefined-properties.js +12 -0
  3. package/dist/es/index.js +8 -0
  4. package/dist/es/media-fusion-tracker.js +35 -0
  5. package/dist/es/models/DocActionEvent.js +27 -0
  6. package/dist/es/models/DocVisitEvent.js +27 -0
  7. package/dist/es/node_modules/@kbapp/gsido-tracker/dist/es/_virtual/_commonjsHelpers.js +8 -0
  8. package/dist/es/node_modules/@kbapp/gsido-tracker/dist/es/_virtual/index.js +7 -0
  9. package/dist/es/node_modules/@kbapp/gsido-tracker/dist/es/_virtual/index2.js +4 -0
  10. package/dist/es/node_modules/@kbapp/gsido-tracker/dist/es/gsido-tracker.js +86 -0
  11. package/dist/es/node_modules/@kbapp/gsido-tracker/dist/es/helpers/filter-undefined-properties.js +12 -0
  12. package/dist/es/node_modules/@kbapp/gsido-tracker/dist/es/helpers/load-script.js +11 -0
  13. package/dist/es/node_modules/@kbapp/gsido-tracker/dist/es/helpers/object-to-map.js +9 -0
  14. package/dist/es/node_modules/@kbapp/gsido-tracker/dist/es/lib/gsido-proxy.js +79 -0
  15. package/dist/es/node_modules/@kbapp/gsido-tracker/dist/es/models/DocActionEvent.js +27 -0
  16. package/dist/es/node_modules/@kbapp/gsido-tracker/dist/es/models/DocVisitEvent.js +27 -0
  17. package/dist/es/node_modules/@kbapp/gsido-tracker/dist/es/node_modules/lodash.clonedeep/index.js +452 -0
  18. package/dist/es/node_modules/@kbapp/tmuyun-tracker/dist/es/_virtual/_commonjsHelpers.js +8 -0
  19. package/dist/es/node_modules/@kbapp/tmuyun-tracker/dist/es/_virtual/dayjs.min.js +4 -0
  20. package/dist/es/node_modules/@kbapp/tmuyun-tracker/dist/es/core/tmuyun-sdk-report.js +15 -0
  21. package/dist/es/node_modules/@kbapp/tmuyun-tracker/dist/es/core/tmuyun-sdk.js +36 -0
  22. package/dist/es/node_modules/@kbapp/tmuyun-tracker/dist/es/index.js +38 -0
  23. package/dist/es/node_modules/@kbapp/tmuyun-tracker/dist/es/models/TmuyunDocModel.js +99 -0
  24. package/dist/es/node_modules/@kbapp/tmuyun-tracker/dist/es/models/TmuyunDocType.js +16 -0
  25. package/dist/es/node_modules/@kbapp/tmuyun-tracker/dist/es/node_modules/dayjs/dayjs.min.js +282 -0
  26. package/dist/types/__tests__/index.test.d.ts +1 -0
  27. package/dist/types/helpers/filter-undefined-properties.d.ts +8 -0
  28. package/dist/types/index.d.ts +3 -0
  29. package/dist/types/media-fusion-tracker.d.ts +50 -0
  30. package/dist/types/models/DocActionEvent.d.ts +66 -0
  31. package/dist/types/models/DocVisitEvent.d.ts +75 -0
  32. package/dist/umd/index.js +1 -0
  33. package/examples/index.html +241 -0
  34. package/package.json +47 -0
package/README.MD ADDED
@@ -0,0 +1,225 @@
1
+ # 开吧融媒体上报平台
2
+
3
+ > ⚠️ 重要提示:本 SDK 基于 TypeScript 开发,所有 API 参数均带有明确的必填 / 选填类型标注。使用时请务必开启 TS 类型检查或在 IDE 中查看参数提示,必填项缺失会直接提示错误,选填项可按需传入,请勿忽略类型提示以避免使用异常。
4
+
5
+ ## 功能特点
6
+
7
+ - 融合开吧(Gsido)和天目云双平台埋点上报能力
8
+ - 异步加载核心上报SDK,避免包体积过大
9
+ - 支持全局公共属性设置
10
+ - 内置标准稿件事件模型(浏览事件、动作事件)
11
+ - 完全TypeScript支持,提供完整的类型定义
12
+
13
+ ## 安装方式 1:npm
14
+
15
+ ```bash
16
+ npm install @kbapp/media-fusion-tracker
17
+ ```
18
+
19
+ ```typescript
20
+ import { MediaFusionTracker } from '@kbapp/media-fusion-tracker';
21
+
22
+ // 创建埋点实例
23
+ const kbTracker = new MediaFusionTracker({
24
+ sdkUrl: 'https://page.kaiba315.com.cn/js/gsido-h5-min-1.0.7.1_final.js',
25
+ appid: '由开吧分配',
26
+ enableLog: false, // 开发环境可设为 true,开启埋点日志输出
27
+ });
28
+ ```
29
+
30
+ ## 安装方式 2:通过 script 标签引入
31
+
32
+ 请先引入 JS Bridge:`<script src="https://unpkg.com/@kbapp/js-bridge@latest/dist/umd/index.js"></script>`,再引入本 SDK。
33
+
34
+ 使用 unpkg CDN:
35
+
36
+ ```html
37
+ <script src="https://unpkg.com/@kbapp/media-fusion-tracker@latest/dist/umd/index.js"></script>
38
+ ```
39
+
40
+ 使用 jsdelivr CDN:
41
+
42
+ ```html
43
+ <script src="https://cdn.jsdelivr.net/npm/@kbapp/media-fusion-tracker@latest/dist/umd/index.js"></script>
44
+ ```
45
+
46
+ > 通过 script 标签引入后,SDK 将作为全局变量 `kbMediaFusionTracker` 挂载在 window 对象上
47
+
48
+ ```html
49
+ <script src="https://unpkg.com/@kbapp/js-bridge@latest/dist/umd/index.js"></script>
50
+ <script src="https://unpkg.com/@kbapp/media-fusion-tracker@latest/dist/umd/index.js"></script>
51
+
52
+ <script>
53
+ // 通过全局变量kbMediaFusionTracker创建埋点实例
54
+ const kbTracker = new kbMediaFusionTracker.MediaFusionTracker({
55
+ sdkUrl: 'https://page.kaiba315.com.cn/js/gsido-h5-min-1.0.7.1_final.js',
56
+ appid: '由开吧分配',
57
+ enableLog: false,
58
+ });
59
+ </script>
60
+ ```
61
+
62
+ ## 基本使用
63
+
64
+ ### 如何设置全局公共属性
65
+
66
+ 设置全局公共属性后,所有上报的埋点将自动携带这些属性。
67
+
68
+ ```typescript
69
+ kbTracker.setReportGlobalAttrs({
70
+ userId: '123456', // 用户唯一标识
71
+ platform: 'h5', // 平台类型(h5/ios/android)
72
+ appVersion: '1.0.0', // APP版本号
73
+ });
74
+
75
+ // 支持多次调用,属性将合并
76
+ kbTracker.setReportGlobalAttrs({
77
+ channel: 'official',
78
+ });
79
+ ```
80
+
81
+ ### 如何上报稿件浏览事件
82
+
83
+ 同时上报到开吧(gsido)和天目云两个平台。
84
+
85
+ ```typescript
86
+ kbTracker.reportDocVisit({
87
+ biz: 'MISC_PAGE', // 业务类型(必填)
88
+ title: '稿件标题', // 稿件标题(必填)
89
+ pubTime: '2024-01-01 12:00:00', // 发布时间(必填)
90
+ unit: '业务单元', // 业务单元(选填)
91
+ ref1: '对象标识1', // 对象标识1(选填)
92
+ channel: '所属单位', // 所属单位(选填)
93
+ depart: '所属部门', // 所属部门(选填)
94
+ });
95
+ ```
96
+
97
+ ### 如何上报稿件动作事件
98
+
99
+ 上报到开吧(gsido)平台,记录用户对稿件的操作(如点赞、评论、分享等)。
100
+
101
+ ```typescript
102
+ kbTracker.reportDocAction({
103
+ act: 'click', // 动作标识(必填)
104
+ biz: 'MISC_PAGE', // 业务类型(必填)
105
+ title: '稿件标题', // 稿件标题(必填)
106
+ unit: '业务单元', // 业务单元(选填)
107
+ ref1: '对象标识1', // 对象标识1(选填)
108
+ });
109
+ ```
110
+
111
+ **标准动作标识参考:**
112
+
113
+ | 动作 | 标识 |
114
+ |------|------|
115
+ | 点赞 | `like` |
116
+ | 分享 | `share` |
117
+ | 评论 | `reply` |
118
+ | 评论的评论 | `reply_r` |
119
+ | 评论的点赞 | `reply_l` |
120
+ | 投票 | `vote` |
121
+ | 签到 | `sign` |
122
+ | 购买 | `buy` |
123
+ | 打赏 | `reward` |
124
+
125
+ ## API 参考
126
+
127
+ ### MediaFusionTracker 类
128
+
129
+ #### 构造函数
130
+
131
+ ```typescript
132
+ constructor(params: {
133
+ sdkUrl: string; // 开吧(gsido)SDK地址
134
+ appid: string; // 埋点应用ID,由开吧分配
135
+ enableLog?: boolean; // 是否开启日志,默认不开启
136
+ })
137
+ ```
138
+
139
+ #### 属性
140
+
141
+ ##### tmuyunTracker
142
+
143
+ 天目云埋点实例,可直接调用天目云 SDK 的更多方法。
144
+
145
+ ```typescript
146
+ kbTracker.tmuyunTracker.report({
147
+ docId: 'xxx',
148
+ title: '标题',
149
+ pubTime: Date.now(),
150
+ });
151
+ ```
152
+
153
+ ##### gsidoTracker
154
+
155
+ 开吧(gsido)埋点实例,可直接调用开吧(gsido) SDK 的更多方法。
156
+
157
+ ```typescript
158
+ kbTracker.gsidoTracker.report({
159
+ name: 'custom_event',
160
+ params: { key: 'value' },
161
+ });
162
+ ```
163
+
164
+ #### 方法
165
+
166
+ ##### setReportGlobalAttrs
167
+
168
+ 设置全局公共属性,将附加到所有上报事件中。
169
+
170
+ ```typescript
171
+ setReportGlobalAttrs(attrs: Record<string, any>): void
172
+ ```
173
+
174
+ ##### reportDocVisit
175
+
176
+ 上报稿件浏览事件,同时上报到开吧(gsido)和天目云平台。
177
+
178
+ ```typescript
179
+ reportDocVisit(params: {
180
+ biz: string; // 业务类型(必填)
181
+ title: string; // 稿件标题(必填)
182
+ pubTime: string | number; // 发布时间(必填)YYYY-MM-DD HH:mm:ss
183
+ unit?: string; // 业务单元
184
+ ref1?: string; // 对象标识1
185
+ ref2?: string; // 对象标识2
186
+ ref3?: string; // 对象标识3
187
+ sid?: number; // 站点ID
188
+ channel?: string; // 所属单位
189
+ depart?: string; // 所属部门
190
+ modules?: string[]; // 所属统计模块
191
+ suid?: string; // 分享人用户ID
192
+ referer?: string; // 访问来源
193
+ }): void
194
+ ```
195
+
196
+ ##### reportDocAction
197
+
198
+ 上报稿件动作事件,上报到开吧(gsido)平台。
199
+
200
+ ```typescript
201
+ reportDocAction(params: {
202
+ act: string; // 动作标识(必填)
203
+ biz: string; // 业务类型(必填)
204
+ title: string; // 稿件标题(必填)
205
+ unit?: string; // 业务单元
206
+ ref1?: string; // 对象标识1
207
+ ref2?: string; // 对象标识2
208
+ ref3?: string; // 对象标识3
209
+ sid?: number; // 站点ID
210
+ channel?: string; // 所属单位
211
+ depart?: string; // 所属部门
212
+ modules?: string[]; // 所属统计模块
213
+ }): void
214
+ ```
215
+
216
+ ## 最佳实践
217
+
218
+ 1. **全局唯一实例**:建议在应用入口处创建一个全局唯一的 MediaFusionTracker 实例
219
+ 2. **合理使用全局属性**:将通用信息(如用户ID、平台等)设置为全局属性
220
+ 3. **开发环境开启调试**:在开发环境设置 `enableLog: true` 以查看埋点日志
221
+
222
+ ## 注意事项
223
+
224
+ 1. `sdkUrl` 和 `appid` 是必需参数,需要正确配置
225
+ 2. `reportDocAction` 中的 `act` 字段有标准值,语义相同时应复用(如点赞使用 `like`)
@@ -0,0 +1,12 @@
1
+ function i(r) {
2
+ if (typeof r != "object" || r === null || Array.isArray(r))
3
+ return {};
4
+ const e = {};
5
+ return Object.keys(r).forEach((t) => {
6
+ const n = r[t];
7
+ n !== void 0 && (e[t] = n);
8
+ }), e;
9
+ }
10
+ export {
11
+ i as filterUndefinedProperties
12
+ };
@@ -0,0 +1,8 @@
1
+ import { MediaFusionTracker as e } from "./media-fusion-tracker.js";
2
+ import { DocActionEvent as i } from "./models/DocActionEvent.js";
3
+ import { DocVisitEvent as n } from "./models/DocVisitEvent.js";
4
+ export {
5
+ i as DocActionEvent,
6
+ n as DocVisitEvent,
7
+ e as MediaFusionTracker
8
+ };
@@ -0,0 +1,35 @@
1
+ import { TmuyunTracker as o } from "./node_modules/@kbapp/tmuyun-tracker/dist/es/index.js";
2
+ import { GsidoTracker as i } from "./node_modules/@kbapp/gsido-tracker/dist/es/gsido-tracker.js";
3
+ import { DocActionEvent as c } from "./node_modules/@kbapp/gsido-tracker/dist/es/models/DocActionEvent.js";
4
+ import { DocVisitEvent as s } from "./node_modules/@kbapp/gsido-tracker/dist/es/models/DocVisitEvent.js";
5
+ class m {
6
+ constructor(e) {
7
+ this.setReportGlobalAttrs = (t = {}) => {
8
+ this.gsidoTracker.setReportGlobalAttrs(t);
9
+ }, this.report = (t) => {
10
+ this.gsidoTracker.report(t), t.name === "DocVisitEvent" && this.tmuyunTracker.report({
11
+ docId: t.params.docId,
12
+ title: t.params.title,
13
+ pubTime: t.params.pubTime
14
+ });
15
+ }, this.reportDocVisit = (t) => {
16
+ const r = s.createDocTrackEvent(t);
17
+ this.gsidoTracker.report({
18
+ name: "DocVisitEvent",
19
+ params: r
20
+ }), this.tmuyunTracker.report({
21
+ docId: r.docId,
22
+ title: r.title,
23
+ pubTime: t.pubTime
24
+ });
25
+ }, this.reportDocAction = (t) => {
26
+ this.gsidoTracker.report({
27
+ name: "DocActionEvent",
28
+ params: c.createDocTrackEvent(t)
29
+ });
30
+ }, this.gsidoTracker = new i({ enableLog: e.enableLog, sdkUrl: e.sdkUrl, appid: e.appid }), this.tmuyunTracker = new o({ enableLog: e.enableLog });
31
+ }
32
+ }
33
+ export {
34
+ m as MediaFusionTracker
35
+ };
@@ -0,0 +1,27 @@
1
+ import { filterUndefinedProperties as r } from "../helpers/filter-undefined-properties.js";
2
+ class t {
3
+ constructor(e) {
4
+ this.act = e.act, this.biz = e.biz, this.unit = e.unit, this.ref1 = e.ref1, this.ref2 = e.ref2, this.ref3 = e.ref3, this.sid = e.sid, this.title = e.title, this.channel = e.channel, this.depart = e.depart, this.modules = e.modules, Object.defineProperty(this, "docId", {
5
+ enumerable: !0,
6
+ configurable: !1,
7
+ get: () => t.generateDocId(this)
8
+ });
9
+ }
10
+ /**
11
+ *
12
+ * @description 生成稿件标识
13
+ */
14
+ static generateDocId(e) {
15
+ return [e.biz, e.unit, e.ref1, e.ref2, e.ref3, e.sid].filter((i) => !!i).join("-");
16
+ }
17
+ /**
18
+ *
19
+ * @description 生成稿件数据(自动生成docId)
20
+ */
21
+ static createDocTrackEvent(e) {
22
+ return r(new t(e));
23
+ }
24
+ }
25
+ export {
26
+ t as DocActionEvent
27
+ };
@@ -0,0 +1,27 @@
1
+ import { filterUndefinedProperties as r } from "../helpers/filter-undefined-properties.js";
2
+ class t {
3
+ constructor(e) {
4
+ this.referer = e.referer, this.suid = e.suid, this.biz = e.biz, this.unit = e.unit, this.ref1 = e.ref1, this.ref2 = e.ref2, this.ref3 = e.ref3, this.sid = e.sid, this.title = e.title, this.channel = e.channel, this.depart = e.depart, this.modules = e.modules, this.pubTime = e.pubTime, Object.defineProperty(this, "docId", {
5
+ enumerable: !0,
6
+ configurable: !1,
7
+ get: () => t.generateDocId(this)
8
+ });
9
+ }
10
+ /**
11
+ *
12
+ * @description 生成稿件标识
13
+ */
14
+ static generateDocId(e) {
15
+ return [e.biz, e.unit, e.ref1, e.ref2, e.ref3, e.sid].filter((i) => !!i).join("-");
16
+ }
17
+ /**
18
+ *
19
+ * @description 生成稿件数据(自动生成docId)
20
+ */
21
+ static createDocTrackEvent(e) {
22
+ return r(new t(e));
23
+ }
24
+ }
25
+ export {
26
+ t as DocVisitEvent
27
+ };
@@ -0,0 +1,8 @@
1
+ var e = typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : {};
2
+ function l(o) {
3
+ return o && o.__esModule && Object.prototype.hasOwnProperty.call(o, "default") ? o.default : o;
4
+ }
5
+ export {
6
+ e as commonjsGlobal,
7
+ l as getDefaultExportFromCjs
8
+ };
@@ -0,0 +1,7 @@
1
+ import { getDefaultExportFromCjs as r } from "./_commonjsHelpers.js";
2
+ import { __require as o } from "../node_modules/lodash.clonedeep/index.js";
3
+ var t = o();
4
+ const m = /* @__PURE__ */ r(t);
5
+ export {
6
+ m as default
7
+ };
@@ -0,0 +1,4 @@
1
+ var e = { exports: {} };
2
+ export {
3
+ e as __module
4
+ };
@@ -0,0 +1,86 @@
1
+ import { IS_KB_APP_ENV as r, reportDAEvent as o } from "@kbapp/js-bridge";
2
+ import { objectToMap as n } from "./helpers/object-to-map.js";
3
+ import { GsidoProxy as i } from "./lib/gsido-proxy.js";
4
+ import g from "./_virtual/index.js";
5
+ class b {
6
+ constructor(t) {
7
+ this.globalAttrs = [], this.enableLog = t.enableLog || !1, this.debugger = t.debugger || !1, this.gsidoProxy = new i({ sdkURL: t.sdkUrl, gsAppid: t.appid }), this.gsidoProxy.init(), this.gsidoProxy.setDebugEnable(this.debugger);
8
+ }
9
+ /** 打印日志 */
10
+ log(...t) {
11
+ this.enableLog && console.log(...t);
12
+ }
13
+ /**
14
+ *
15
+ * @description 获取用于上报的属性 (合并公共属性)
16
+ */
17
+ getReportDataMergeGlobalAttrs(t) {
18
+ const a = {}, e = g(Object.assign.apply(null, [{}, ...this.globalAttrs, t]));
19
+ return Object.keys(e).forEach((s) => {
20
+ if (typeof e[s] == "number")
21
+ return a[s] = e[s];
22
+ e[s] && (a[s] = String(e[s]));
23
+ }), a;
24
+ }
25
+ /**
26
+ *
27
+ * @description 获取原始 GsIdo 对象
28
+ */
29
+ getGsido() {
30
+ return this.gsidoProxy.getGsido();
31
+ }
32
+ /**
33
+ *
34
+ * @description 设置上报的公共属性
35
+ */
36
+ setReportGlobalAttrs(t = {}) {
37
+ this.globalAttrs.push(t);
38
+ }
39
+ /**
40
+ *
41
+ * @description 上报事件
42
+ */
43
+ report(t) {
44
+ return r ? ((a, e) => {
45
+ this.log("[个推] app.桥接.埋点", { name: a, params: e }), o({
46
+ eventName: a,
47
+ eventParams: e
48
+ });
49
+ })(t.name, this.getReportDataMergeGlobalAttrs(t.params)) : ((a, e) => {
50
+ this.log("[个推] js.埋点", { name: a, params: e }), this.gsidoProxy.onEvent({ id: a, attrs: n(e) });
51
+ })(t.name, this.getReportDataMergeGlobalAttrs(t.params));
52
+ }
53
+ /**
54
+ *
55
+ * @description 持续类型事件上报 - 开始事件
56
+ */
57
+ reportBeginEvent(t) {
58
+ return r ? ((a, e) => {
59
+ this.log("[个推] app.桥接.begin埋点", { name: a, params: e }), o({
60
+ eventName: a,
61
+ eventParams: e,
62
+ eventType: "Begin"
63
+ });
64
+ })(t.name, this.getReportDataMergeGlobalAttrs(t.params)) : ((a, e) => {
65
+ this.log("[个推] js.begin埋点", { name: a, params: e }), this.gsidoProxy.onBeginEvent({ id: a, attrs: n(e) });
66
+ })(t.name, this.getReportDataMergeGlobalAttrs(t.params));
67
+ }
68
+ /**
69
+ *
70
+ * @description 持续类型事件上报 - 结束事件
71
+ */
72
+ reportEndEvent(t) {
73
+ return r ? ((a, e) => {
74
+ this.log("[个推] app.桥接.end埋点", { name: a, params: e }), o({
75
+ eventName: a,
76
+ eventParams: e,
77
+ eventType: "End"
78
+ });
79
+ })(t.name, this.getReportDataMergeGlobalAttrs(t.params)) : ((a, e) => {
80
+ this.log("[个推] js.end埋点", { name: a, params: e }), this.gsidoProxy.onEndEvent({ id: a, attrs: n(e) });
81
+ })(t.name, this.getReportDataMergeGlobalAttrs(t.params));
82
+ }
83
+ }
84
+ export {
85
+ b as GsidoTracker
86
+ };
@@ -0,0 +1,12 @@
1
+ function r(e) {
2
+ if (typeof e != "object" || e === null || Array.isArray(e))
3
+ return {};
4
+ const n = {};
5
+ return Object.keys(e).forEach((t) => {
6
+ const o = e[t];
7
+ o !== void 0 && (n[t] = o);
8
+ }), n;
9
+ }
10
+ export {
11
+ r as filterUndefinedProperties
12
+ };
@@ -0,0 +1,11 @@
1
+ const r = (o) => window[o.key] ? window[o.key] : new Promise((t, d) => {
2
+ const e = window.document.createElement("script");
3
+ e.setAttribute("src", o.src), e.async = !0, e.onload = () => {
4
+ t(window[o.key]);
5
+ }, e.onerror = (n) => {
6
+ d(n);
7
+ }, window.document.head.appendChild(e);
8
+ });
9
+ export {
10
+ r as loadScript
11
+ };
@@ -0,0 +1,9 @@
1
+ function o(e) {
2
+ const c = [];
3
+ return Object.keys(e).forEach((n) => {
4
+ c.push([n, e[n]]);
5
+ }), new Map(c);
6
+ }
7
+ export {
8
+ o as objectToMap
9
+ };
@@ -0,0 +1,79 @@
1
+ import { loadScript as a } from "../helpers/load-script.js";
2
+ var u = (l, t, n) => new Promise((d, o) => {
3
+ var r = (e) => {
4
+ try {
5
+ i(n.next(e));
6
+ } catch (c) {
7
+ o(c);
8
+ }
9
+ }, s = (e) => {
10
+ try {
11
+ i(n.throw(e));
12
+ } catch (c) {
13
+ o(c);
14
+ }
15
+ }, i = (e) => e.done ? d(e.value) : Promise.resolve(e.value).then(r, s);
16
+ i((n = n.apply(l, t)).next());
17
+ });
18
+ const h = (l) => {
19
+ let t;
20
+ const n = l.sdkURL, d = l.gsAppid;
21
+ function o() {
22
+ return u(this, null, function* () {
23
+ return n ? t || (t = new Promise((r, s) => u(null, null, function* () {
24
+ try {
25
+ yield a({ src: n, key: "GsIdo" }), r(window.GsIdo);
26
+ } catch (i) {
27
+ t = void 0, s(i);
28
+ }
29
+ }))) : Promise.reject(new Error("GsIdo SDK 地址未配置,请先在构造函数中传入 sdkURL"));
30
+ });
31
+ }
32
+ return {
33
+ load: o,
34
+ init: /* @__PURE__ */ (() => {
35
+ let r;
36
+ return () => r || (r = new Promise((s, i) => u(null, null, function* () {
37
+ try {
38
+ return yield o(), yield window.GsIdo.init({ gsAppid: d }), s(window.GsIdo);
39
+ } catch (e) {
40
+ i(e), r = void 0;
41
+ }
42
+ })));
43
+ })()
44
+ };
45
+ };
46
+ class v {
47
+ constructor(t) {
48
+ this.loader = h(t);
49
+ }
50
+ getGsido() {
51
+ return window.GsIdo;
52
+ }
53
+ init() {
54
+ return this.loader.init();
55
+ }
56
+ setDebugEnable(...t) {
57
+ return this.callMethod("setDebugEnable", ...t);
58
+ }
59
+ onEvent(...t) {
60
+ return this.callMethod("onEvent", ...t);
61
+ }
62
+ onBeginEvent(...t) {
63
+ return this.callMethod("onBeginEvent", ...t);
64
+ }
65
+ onEndEvent(...t) {
66
+ return this.callMethod("onEndEvent", ...t);
67
+ }
68
+ callMethod(t, ...n) {
69
+ return this.loader.init().then((d) => {
70
+ const o = d[t];
71
+ if (typeof o != "function")
72
+ throw new Error(`${String(t)} 不是 GsIdo 的有效方法`);
73
+ return o(...n);
74
+ });
75
+ }
76
+ }
77
+ export {
78
+ v as GsidoProxy
79
+ };
@@ -0,0 +1,27 @@
1
+ import { filterUndefinedProperties as r } from "../helpers/filter-undefined-properties.js";
2
+ class i {
3
+ constructor(t) {
4
+ this.act = t.act, this.biz = t.biz, this.unit = t.unit, this.ref1 = t.ref1, this.ref2 = t.ref2, this.ref3 = t.ref3, this.sid = t.sid, this.title = t.title, this.channel = t.channel, this.depart = t.depart, this.modules = t.modules, Object.defineProperty(this, "docId", {
5
+ enumerable: !0,
6
+ configurable: !1,
7
+ get: () => i.generateDocId(this)
8
+ });
9
+ }
10
+ /**
11
+ *
12
+ * @description 生成稿件标识
13
+ */
14
+ static generateDocId(t) {
15
+ return [t.biz, t.unit, t.ref1, t.ref2, t.ref3, t.sid].filter((e) => !!e).join("-");
16
+ }
17
+ /**
18
+ *
19
+ * @description 生成稿件数据(自动生成docId)
20
+ */
21
+ static createDocTrackEvent(t) {
22
+ return r(new i(t));
23
+ }
24
+ }
25
+ export {
26
+ i as DocActionEvent
27
+ };
@@ -0,0 +1,27 @@
1
+ import { filterUndefinedProperties as e } from "../helpers/filter-undefined-properties.js";
2
+ class i {
3
+ constructor(t) {
4
+ this.referer = t.referer, this.suid = t.suid, this.biz = t.biz, this.unit = t.unit, this.ref1 = t.ref1, this.ref2 = t.ref2, this.ref3 = t.ref3, this.sid = t.sid, this.title = t.title, this.channel = t.channel, this.depart = t.depart, this.modules = t.modules, Object.defineProperty(this, "docId", {
5
+ enumerable: !0,
6
+ configurable: !1,
7
+ get: () => i.generateDocId(this)
8
+ });
9
+ }
10
+ /**
11
+ *
12
+ * @description 生成稿件标识
13
+ */
14
+ static generateDocId(t) {
15
+ return [t.biz, t.unit, t.ref1, t.ref2, t.ref3, t.sid].filter((r) => !!r).join("-");
16
+ }
17
+ /**
18
+ *
19
+ * @description 生成稿件数据(自动生成docId)
20
+ */
21
+ static createDocTrackEvent(t) {
22
+ return e(new i(t));
23
+ }
24
+ }
25
+ export {
26
+ i as DocVisitEvent
27
+ };