hina-cloud-js-sdk 3.1.8 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. package/dist/hina.cjs.js +1 -0
  2. package/dist/hina.esm.full.js +1 -0
  3. package/dist/hina.esm.js +1 -0
  4. package/dist/hina.full.js +1 -0
  5. package/dist/hina.iife.js +1 -0
  6. package/dist/index.d.ts +411 -0
  7. package/package.json +27 -37
  8. package/readme.md +1 -0
  9. package/.eslintrc.js +0 -12
  10. package/.gitlab-ci.yml +0 -16
  11. package/.vscode/settings.json +0 -5
  12. package/build/hina.cjs.min.js +0 -1
  13. package/build/hina.esm.min.js +0 -1
  14. package/build/hina.min.js +0 -1
  15. package/build/hotAnalyse.min.js +0 -1
  16. package/packages/core/dist/index.cjs.js +0 -64
  17. package/packages/core/dist/index.cjs.js.map +0 -1
  18. package/packages/core/dist/index.d.ts +0 -45
  19. package/packages/core/dist/index.esm.js +0 -62
  20. package/packages/core/dist/index.esm.js.map +0 -1
  21. package/packages/core/dist/index.global.js +0 -1199
  22. package/packages/core/dist/index.global.js.map +0 -1
  23. package/packages/core/dist/index.js +0 -1200
  24. package/packages/core/dist/index.js.map +0 -1
  25. package/packages/monitor/dist/index.cjs.js +0 -150
  26. package/packages/monitor/dist/index.cjs.js.map +0 -1
  27. package/packages/monitor/dist/index.d.ts +0 -35
  28. package/packages/monitor/dist/index.esm.js +0 -145
  29. package/packages/monitor/dist/index.esm.js.map +0 -1
  30. package/packages/monitor/dist/index.global.js +0 -1343
  31. package/packages/monitor/dist/index.global.js.map +0 -1
  32. package/packages/monitor/dist/index.js +0 -1344
  33. package/packages/monitor/dist/index.js.map +0 -1
  34. package/packages/track/dist/index.cjs.js +0 -1930
  35. package/packages/track/dist/index.cjs.js.map +0 -1
  36. package/packages/track/dist/index.d.ts +0 -212
  37. package/packages/track/dist/index.esm.js +0 -1925
  38. package/packages/track/dist/index.esm.js.map +0 -1
  39. package/packages/track/dist/index.global.js +0 -4259
  40. package/packages/track/dist/index.global.js.map +0 -1
  41. package/packages/track/dist/index.js +0 -4260
  42. package/packages/track/dist/index.js.map +0 -1
  43. package/packages/types/dist/index.d.ts +0 -603
  44. package/packages/types/dist/index.esm.js +0 -25
  45. package/packages/types/dist/index.esm.js.map +0 -1
  46. package/packages/utils/dist/index.cjs.js +0 -1535
  47. package/packages/utils/dist/index.cjs.js.map +0 -1
  48. package/packages/utils/dist/index.d.ts +0 -394
  49. package/packages/utils/dist/index.esm.js +0 -1465
  50. package/packages/utils/dist/index.esm.js.map +0 -1
  51. package/packages/utils/dist/index.global.js +0 -2507
  52. package/packages/utils/dist/index.global.js.map +0 -1
  53. package/packages/utils/dist/index.js +0 -2508
  54. package/packages/utils/dist/index.js.map +0 -1
  55. package/report.json +0 -101
  56. package/rollup.config.epm.js +0 -42
  57. package/rollup.config.sdk.js +0 -42
  58. package/sonar-project.properties +0 -3
@@ -0,0 +1,411 @@
1
+ import { Monitor } from 'hina-cloud-js-monitor';
2
+ export { MonitorInstance } from 'hina-cloud-js-monitor';
3
+ import { WebClient } from 'hina-cloud-js-core';
4
+ import { PluginBase, TrackOptions, ReportDataType, VariablesTypes, FetchParams, ResultItem, StorageDataType, RequestData, ResponseData, PageLeaveAutoTrackObject, IAnyObject, LinkerItem, SiteLinkerOptions, AbTestingOptions, VoidFn, UnKnownFn, ReportProperties, AnyFn, ReportTypes } from 'hina-cloud-type';
5
+ export * from 'hina-cloud-type';
6
+ import { State } from 'hina-cloud-util';
7
+
8
+ declare class AbTestingPlugin extends PluginBase<TrackOptions> {
9
+ options: TrackOptions;
10
+ context: TrackInstance;
11
+ name: string;
12
+ isReady: boolean;
13
+ /**
14
+ * 浏览器平台 H5 Web
15
+ */
16
+ platform: "H5" | "Web";
17
+ /**
18
+ * 项目key
19
+ */
20
+ projectKey: string;
21
+ /**
22
+ * 本地存储名称
23
+ */
24
+ storageName: string;
25
+ constructor(options: TrackOptions, context: TrackInstance);
26
+ init(): void;
27
+ transform(): ReportDataType<any>;
28
+ /**
29
+ * 判断类型和值是否匹配
30
+ * @param value
31
+ * @param type
32
+ */
33
+ valueMatchType(value: unknown, type: VariablesTypes): boolean;
34
+ /**
35
+ * 处理参数
36
+ * @param prefixLog
37
+ * @param params
38
+ * @param validateKeys
39
+ */
40
+ normalizeParams(prefixLog: string, params: FetchParams, validateKeys?: (keyof FetchParams)[]): {
41
+ verify_success: boolean;
42
+ para: FetchParams;
43
+ };
44
+ /**
45
+ * 发送 H_ABTestTrigger事件
46
+ * @param data
47
+ */
48
+ sendTriggerEvent(data: {
49
+ abtest_experiment_id: string;
50
+ abtest_experiment_group_id: string;
51
+ }): void;
52
+ /**
53
+ * 从本地缓存中获取实验结果
54
+ * @param params 实验参数对象
55
+ * @param list
56
+ */
57
+ getExpResult(params: FetchParams, list?: ResultItem[]): string | number | boolean;
58
+ /**
59
+ * 获取本地数据
60
+ * @returns
61
+ */
62
+ getStorageData(): StorageDataType | null;
63
+ /**
64
+ * 保存数据到本地
65
+ * @param list
66
+ */
67
+ saveResponseData(list: ResultItem[]): void;
68
+ /**
69
+ * 创建请求数据
70
+ * @param params
71
+ */
72
+ createRequestData(params: FetchParams): RequestData;
73
+ /**
74
+ * 从服务器获取数据
75
+ * @param params
76
+ */
77
+ getResultFromServer(params: FetchParams): Promise<ResponseData>;
78
+ /**
79
+ * 请求服务接口获取数据
80
+ * @param params
81
+ */
82
+ asyncFetch(params: FetchParams): Promise<ResponseData>;
83
+ /**
84
+ * 调用方法前验证参数
85
+ */
86
+ preFetch(prefixLog: string, params: FetchParams): boolean;
87
+ /**
88
+ * 获取试验变量
89
+ * 忽略本地缓存,从服务端获取数据
90
+ * @param params
91
+ */
92
+ asyncFetchABTest(params: FetchParams): void;
93
+ /**
94
+ * 获取试验变量
95
+ * 读取本地缓存,缓存不存在时使用默认值
96
+ * @param params
97
+ */
98
+ fetchCacheABTest(params: FetchParams): void;
99
+ /**
100
+ * 获取试验变量
101
+ * 优先读取本地缓存,缓存不存在时从服务端获取数据
102
+ * @param params
103
+ */
104
+ fastFetchABTest(params: FetchParams): void;
105
+ }
106
+
107
+ declare class PageLeavePlugin extends PluginBase<TrackOptions> {
108
+ options: TrackOptions;
109
+ context: TrackInstance;
110
+ name: string;
111
+ isReady: boolean;
112
+ pageId: number;
113
+ storageName: string;
114
+ heartbeatIntervalTime: number;
115
+ maxDuration: number;
116
+ heartbeatIntervalTimer: any;
117
+ startTime: number;
118
+ /**
119
+ * 页面url
120
+ */
121
+ url: string;
122
+ /**
123
+ * 页面显示状态
124
+ */
125
+ pageShowStatus: boolean;
126
+ constructor(options: TrackOptions, context: TrackInstance);
127
+ init(): void;
128
+ transform(): ReportDataType<any>;
129
+ normalizePageLeaveAutoTrack(): PageLeaveAutoTrackObject;
130
+ addPageLeaveEventListener(): void;
131
+ addPageStartListener(): void;
132
+ addPageSwitchListener(): void;
133
+ addSinglePageListener(): void;
134
+ addPageEndListener(): void;
135
+ pageStartHandler(): void;
136
+ pageEndHandler(): void;
137
+ startHeartBeatInterval(): void;
138
+ reissueHeartBeatData(): void;
139
+ stopHeartBeatInterval(): void;
140
+ delHeartBeatData(storageKey?: string): void;
141
+ isCollectUrl(): boolean;
142
+ saveHeartBeatData(type?: string): void;
143
+ getPageLeaveProperties(): IAnyObject;
144
+ }
145
+
146
+ declare class SiteLinkerPlugin extends PluginBase<TrackOptions> {
147
+ options: TrackOptions;
148
+ context: TrackInstance;
149
+ name: string;
150
+ isReady: boolean;
151
+ linker: LinkerItem[];
152
+ constructor(options: TrackOptions, context: TrackInstance);
153
+ init(): void;
154
+ transform(): ReportDataType<any>;
155
+ getLinkerConfig(): {
156
+ linker: LinkerItem[];
157
+ re_login: boolean;
158
+ };
159
+ resolveOption(): void;
160
+ /**
161
+ * 多域名打通设置
162
+ */
163
+ setRefferId(): void;
164
+ /**
165
+ * 获取链接上的id
166
+ */
167
+ getUrlId(): string;
168
+ /**
169
+ * 判断url链接是否包含part_url
170
+ * @param url
171
+ */
172
+ getPartUrl(url: string): boolean;
173
+ /**
174
+ * 获取url链接对应的linker配置中after_hash的值
175
+ * @param url
176
+ */
177
+ getPartHash(url: string): boolean;
178
+ /**
179
+ * 获取当前的匿名ID和当前的登录ID
180
+ */
181
+ getCurrentId(): string;
182
+ /**
183
+ * 重写a 标签的href链接
184
+ * @param url
185
+ * @param dom
186
+ */
187
+ rewriteUrl(url: string, dom: HTMLAnchorElement): string;
188
+ addClickListen(): void;
189
+ }
190
+
191
+ /**
192
+ * 内置插件实例
193
+ */
194
+ interface BuiltPluginsInstanceMap {
195
+ /**
196
+ * 页面浏览时长插件
197
+ */
198
+ PageLeave: PageLeavePlugin;
199
+ /**
200
+ * 多域名打通插件
201
+ */
202
+ SiteLinker: SiteLinkerPlugin;
203
+ /**
204
+ * abTest插件
205
+ */
206
+ HinaABTest: AbTestingPlugin;
207
+ }
208
+ /**
209
+ * 内置插件配置
210
+ */
211
+ interface BuiltPluginsConfig {
212
+ /**
213
+ * 页面浏览时长插件
214
+ */
215
+ PageLeave: PageLeaveAutoTrackObject;
216
+ /**
217
+ * 多域名打通插件
218
+ */
219
+ SiteLinker?: SiteLinkerOptions;
220
+ /**
221
+ * abTest插件
222
+ */
223
+ HinaABTest?: AbTestingOptions;
224
+ }
225
+
226
+ declare class HinaTrack extends WebClient<TrackOptions> {
227
+ consolePrefix: string;
228
+ /**
229
+ * 存储对象
230
+ */
231
+ store: State<TrackOptions>;
232
+ /**
233
+ * 性能监控实例
234
+ */
235
+ epmInstance: Monitor;
236
+ /**
237
+ * 上报数据的dom元素 默认有 'a', 'input', 'button', 'textarea'
238
+ */
239
+ trackTags: string[];
240
+ /**
241
+ * 事件静态公共属性
242
+ */
243
+ presetProps: IAnyObject;
244
+ constructor(options: TrackOptions, useInstancing?: boolean);
245
+ /**
246
+ * 注册/初始化SDK
247
+ * @param options
248
+ */
249
+ init(options: TrackOptions): void;
250
+ /**
251
+ * 初始化共享数据
252
+ */
253
+ initState(): void;
254
+ /**
255
+ * 处理配置信息
256
+ */
257
+ normalizeConfig(): void;
258
+ /**
259
+ * 更新采集的dom元素
260
+ */
261
+ updateTrackTags(): void;
262
+ /**
263
+ * 初始化广告参数
264
+ */
265
+ initAdvProps(): void;
266
+ /**
267
+ * 应用插件
268
+ */
269
+ initPlugins(): void;
270
+ /**
271
+ * 启动内置插件
272
+ */
273
+ use<T extends keyof BuiltPluginsConfig, U extends BuiltPluginsConfig[T]>(pluginName: T, options: U): BuiltPluginsInstanceMap[T];
274
+ /**
275
+ * 获取指定插件实例
276
+ * @param pluginName
277
+ */
278
+ getPluginInstance<T extends keyof BuiltPluginsInstanceMap | keyof any, U extends T extends keyof BuiltPluginsInstanceMap ? BuiltPluginsInstanceMap[T] : any>(pluginName: T): U;
279
+ /**
280
+ * 设置配置选项
281
+ * @param options 配置对象
282
+ */
283
+ setConfig(options: Partial<TrackOptions>): void;
284
+ /**
285
+ * 获取配置选项 参数为空时 返回整个配置对象
286
+ * @param key
287
+ */
288
+ getConfig(key?: keyof TrackOptions): TrackOptions[keyof TrackOptions] | TrackOptions;
289
+ /**
290
+ * 设置用户登录的唯一标识
291
+ * @param uid
292
+ * @param callback
293
+ */
294
+ setUserUId(uid: string | number, callback?: VoidFn): void;
295
+ /**
296
+ * 获取用户登录的唯一标识
297
+ */
298
+ getUserUid(): string;
299
+ /**
300
+ * 设置设备ID
301
+ * @param uid
302
+ */
303
+ setDeviceUId(uid: string): void;
304
+ /**
305
+ * 获取设备ID
306
+ */
307
+ getDeviceUId(): string;
308
+ /**
309
+ * 添加用户属性
310
+ * 直接设置用户的属性,如果存在则覆盖。
311
+ * @param data
312
+ * @param callback
313
+ */
314
+ userSet(data: IAnyObject, callback?: VoidFn): void;
315
+ /**
316
+ * 添加用户属性
317
+ * 如果不存在则设置,存在就不设置
318
+ * @param data
319
+ * @param callback
320
+ */
321
+ userSetOnce(data: IAnyObject, callback?: VoidFn): void;
322
+ /**
323
+ * 对当前用户的属性做递增或者递减
324
+ * @param data
325
+ * @param callback
326
+ */
327
+ userAdd(data: string | {
328
+ [key: string]: number;
329
+ }, callback?: VoidFn): void;
330
+ /**
331
+ * 给数组属性添加值。通过userSet只能改变属性的值。如果这个属性是数组类型的,你不想完全改变这个值,只想做添加操作可以使用此方法。
332
+ */
333
+ userAppend(data: IAnyObject, callback?: VoidFn): void;
334
+ /**
335
+ * 删除当前用户的一些属性
336
+ * @param data
337
+ * @param callback
338
+ */
339
+ userUnset(data: string | string[], callback?: VoidFn): void;
340
+ /**
341
+ * 删除当前用户及他的所有属性。
342
+ * @param callback
343
+ */
344
+ userDelete(callback?: VoidFn): void;
345
+ /**
346
+ * 添加事件公共属性
347
+ * 当使用函数类型作为属性值、函数返回值只能是string、bool、number、date、array类型
348
+ * @param params
349
+ */
350
+ registerCommonProperties(params: IAnyObject | UnKnownFn): void;
351
+ /**
352
+ * 获取预置属性
353
+ * 此方法可获取,页面地址,页面标题,前向地址,SDK 类型及版本,屏幕宽高,最近一次的相关属性
354
+ */
355
+ getPresetProperties(): ReportProperties;
356
+ /**
357
+ * 清空或删除指定预置属性
358
+ * @param payload
359
+ */
360
+ clearPageRegister(payload?: boolean | string[]): void;
361
+ /**
362
+ * 检查发送数据
363
+ * @param props
364
+ */
365
+ checkReportProperties(props: IAnyObject): void;
366
+ /**
367
+ * 自定义埋点事件
368
+ * @param event
369
+ * @param properties
370
+ * @param callback
371
+ */
372
+ track(event: string, properties?: IAnyObject, callback?: VoidFn): void;
373
+ /**
374
+ * 手动调用埋点
375
+ * @param name
376
+ * @param data
377
+ * @param callback
378
+ */
379
+ quick(name: 'autoTrack' | 'autoTrackSinglePage', data?: IAnyObject | VoidFn, callback?: VoidFn): void;
380
+ /**
381
+ * 开启页面浏览采集
382
+ * @param data
383
+ * @param callback
384
+ */
385
+ autoTrack(data?: IAnyObject, callback?: VoidFn): void;
386
+ /**
387
+ * 上报数据
388
+ * @param data
389
+ * @param callback
390
+ * @param type
391
+ */
392
+ report(data: ReportDataType<any>, callback?: AnyFn, type?: ReportTypes): void;
393
+ /**
394
+ * 获取上报数据
395
+ * @param type
396
+ * @param event
397
+ * @param data
398
+ */
399
+ getReportData<T = any>(type: string, event: string, data?: T): ReportDataType<T & ReportProperties>;
400
+ /**
401
+ * 获取通用的上报数据
402
+ * @param type 上报类型
403
+ * @param event 事件名称
404
+ */
405
+ getReportProperties(type?: string, event?: string): ReportProperties;
406
+ }
407
+ type TrackInstance = InstanceType<typeof HinaTrack>;
408
+
409
+ declare const hinaSdk: HinaTrack;
410
+
411
+ export { HinaTrack, type TrackInstance, hinaSdk as default };
package/package.json CHANGED
@@ -1,46 +1,36 @@
1
1
  {
2
2
  "name": "hina-cloud-js-sdk",
3
- "version": "3.1.8",
4
- "description": "hinaCloud javascript sdk",
5
- "main": "build/hina.cjs.min.js",
6
- "jsnext:main": "build/hina.esm.min.js",
7
- "scripts": {
8
- "test": "echo \"Error: no test specified\" && exit 1",
9
- "build": "rollup -c",
10
- "build:epm": "rollup -c rollup.config.epm.js",
11
- "build:sdk": "rollup -c rollup.config.sdk.js",
12
- "watch": "rollup -c -w",
13
- "lint:report": "eslint ./src -f json -o report.json --ext .js,.ts || exit 0"
3
+ "version": "4.0.1",
4
+ "description": "WEB埋点SDK",
5
+ "main": "dist/hina.full.js",
6
+ "module": "dist/hina.esm.js",
7
+ "types": "dist/index.d.ts",
8
+ "publishConfig": {
9
+ "access": "public"
14
10
  },
15
- "repository": {
16
- "type": "git",
17
- "url": "git@gitlab.hinadt.com:hina-cloud/hina-cloud-js-sdk.git"
18
- },
19
- "keywords": [
20
- "sdk",
21
- "hinaCloud",
22
- "hina-cloud-js-sdk",
23
- "hinaCloudJsSdk"
11
+ "files": [
12
+ "dist"
24
13
  ],
25
- "devDependencies": {
26
- "@babel/cli": "^7.23.9",
27
- "@babel/core": "^7.23.9",
28
- "@babel/plugin-proposal-optional-chaining": "^7.21.0",
29
- "@babel/preset-env": "^7.23.9",
30
- "@rollup/plugin-commonjs": "^25.0.4",
31
- "@rollup/plugin-node-resolve": "^15.1.0",
32
- "@rollup/plugin-terser": "^0.4.4",
33
- "rollup": "^2.53.1",
34
- "rollup-plugin-babel": "^4.4.0",
35
- "rollup-plugin-copy": "^3.5.0",
36
- "rollup-plugin-javascript-obfuscator": "^1.0.4",
37
- "rollup-plugin-uglify": "^6.0.4",
38
- "rollup-watch": "^4.3.1"
14
+ "author": {
15
+ "name": "dongrudong@hinadt.com"
39
16
  },
40
- "author": "",
41
17
  "license": "ISC",
42
18
  "dependencies": {
43
- "mobile-detect": "^1.4.5",
44
- "raven-js": "^3.27.2"
19
+ "hina-cloud-js-core": "4.0.0",
20
+ "hina-cloud-type": "2.0.0",
21
+ "hina-cloud-util": "2.0.0",
22
+ "hina-cloud-js-monitor": "4.0.0"
23
+ },
24
+ "buildOptions": {
25
+ "name": "hinaDataStatistic",
26
+ "fileName": "hina",
27
+ "formats": [
28
+ "esm",
29
+ "esm-full",
30
+ "cjs",
31
+ "global",
32
+ "umd"
33
+ ],
34
+ "external": []
45
35
  }
46
36
  }
package/readme.md ADDED
@@ -0,0 +1 @@
1
+ ## WEB埋点SDK
package/.eslintrc.js DELETED
@@ -1,12 +0,0 @@
1
- module.exports = {
2
- root: true,
3
- env: {
4
- node: true,
5
- browser: true,
6
- es2021: true,
7
- },
8
- parserOptions: {
9
- ecmaVersion: "latest",
10
- sourceType: "module",
11
- },
12
- };
package/.gitlab-ci.yml DELETED
@@ -1,16 +0,0 @@
1
- sonarqube-check:
2
- image:
3
- name: sonarsource/sonar-scanner-cli:latest
4
- entrypoint: [""]
5
- variables:
6
- SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
7
- GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
8
- cache:
9
- key: "${CI_JOB_NAME}"
10
- paths:
11
- - .sonar/cache
12
- script:
13
- - sonar-scanner
14
- allow_failure: true
15
- only:
16
- - master # or the name of your main branch
@@ -1,5 +0,0 @@
1
- {
2
- "cSpell.words": [
3
- "Hina"
4
- ]
5
- }