@lark-apaas/fullstack-rspack-preset 1.0.13-alpha.proxy.8 → 1.0.14-alpha.tea.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.
package/lib/preset.js CHANGED
@@ -152,7 +152,7 @@ function createRecommendRspackConfig(options) {
152
152
  },
153
153
  minify: false, // 关闭 html 压缩,导致数据注入异常
154
154
  }),
155
- // 性能监控插件
155
+ // 性能监控&tea埋点sdk插件
156
156
  new slardar_performance_monitor_plugin_1.default(),
157
157
  // 视图上下文注入插件
158
158
  new view_context_injection_plugin_1.default(),
@@ -38,6 +38,7 @@ class SlardarPerformanceMonitorPlugin {
38
38
  bid: this.options.bid,
39
39
  globalName: this.options.globalName,
40
40
  });
41
+ const teaSnippet = getTeaScriptContent();
41
42
  if (!snippet)
42
43
  return data;
43
44
  // 创建 Slardar 脚本标签对象
@@ -47,6 +48,13 @@ class SlardarPerformanceMonitorPlugin {
47
48
  innerHTML: snippet,
48
49
  attributes: {},
49
50
  };
51
+ // 创建 Tea 脚本标签对象
52
+ const teaTag = {
53
+ tagName: 'script',
54
+ voidTag: false,
55
+ innerHTML: teaSnippet,
56
+ attributes: {},
57
+ };
50
58
  // 找到 main.js 的索引位置
51
59
  const mainJsIndex = data.headTags.findIndex((tag) => tag.tagName === 'script' &&
52
60
  tag.attributes &&
@@ -54,11 +62,12 @@ class SlardarPerformanceMonitorPlugin {
54
62
  tag.attributes.src.includes('main.js'));
55
63
  if (mainJsIndex !== -1) {
56
64
  // 在 main.js 之前插入 Slardar 脚本
57
- data.headTags.splice(mainJsIndex, 0, slardarTag);
65
+ data.headTags.splice(mainJsIndex, 0, slardarTag, teaTag);
58
66
  }
59
67
  else {
60
68
  // 如果没找到 main.js,插入到 headTags 最前面
61
69
  data.headTags.unshift(slardarTag);
70
+ data.headTags.unshift(teaTag);
62
71
  }
63
72
  return data;
64
73
  });
@@ -106,3 +115,33 @@ function getSlardarScriptContent(option = {}) {
106
115
  document.head.appendChild(performanceScript);
107
116
  `;
108
117
  }
118
+ // 获取 tea sdk 脚本
119
+ function getTeaScriptContent() {
120
+ return `
121
+ (function (win, export_obj) {
122
+ win['LogAnalyticsObject'] = export_obj;
123
+ if (!win[export_obj]) {
124
+ function _collect() {
125
+ _collect.q.push(arguments);
126
+ }
127
+ _collect.q = _collect.q || [];
128
+ win[export_obj] = _collect;
129
+ }
130
+ win[export_obj].l = +new Date();
131
+ })(window, 'collectEvent');
132
+
133
+ // 创建 tea sdk 脚本元素
134
+ const teaScript = document.createElement('script');
135
+ teaScript.src = 'https://lf3-cdn-tos.bytescm.com/obj/static/log-sdk/collect/5.1/collect.js';
136
+ teaScript.crossOrigin = 'anonymous';
137
+ teaScript.async = true;
138
+
139
+ // 添加错误处理
140
+ teaScript.onerror = function() {
141
+ console.warn('Failed to load Tea script');
142
+ };
143
+
144
+ // 将脚本添加到页面
145
+ document.head.appendChild(teaScript);
146
+ `;
147
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-rspack-preset",
3
- "version": "1.0.13-alpha.proxy.8",
3
+ "version": "1.0.14-alpha.tea.1",
4
4
  "files": [
5
5
  "lib",
6
6
  "patches",
@@ -39,7 +39,6 @@
39
39
  "colorjs.io": "^0.5.2",
40
40
  "dotenv": "^16.4.5",
41
41
  "echarts": "^6.0.0",
42
- "http-proxy-middleware": "^3.0.5",
43
42
  "patch-package": "^8.0.0",
44
43
  "postcss-import": "^16.1.1",
45
44
  "react-refresh": "^0.17.0",