gio-uniapp-sdk 0.0.0-stage → 1.0.0

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 (80) hide show
  1. package/LICENSE +176 -0
  2. package/README.md +201 -2
  3. package/THIRD_PARTY_LICENSES.txt +192 -0
  4. package/autotrack.d.ts +1 -0
  5. package/autotrack.js +3 -0
  6. package/index.d.ts +69 -0
  7. package/index.js +175 -0
  8. package/package.json +50 -4
  9. package/src/adapters/uniapp.d.ts +66 -0
  10. package/src/adapters/uniapp.js +408 -0
  11. package/src/compiler/vite.d.ts +39 -0
  12. package/src/constants/config.d.ts +69 -0
  13. package/src/constants/config.js +140 -0
  14. package/src/constants/miniprogram.d.ts +96 -0
  15. package/src/constants/miniprogram.js +19 -0
  16. package/src/constants/platform.d.ts +23 -0
  17. package/src/constants/platform.js +33 -0
  18. package/src/core/dataStore/app.d.ts +64 -0
  19. package/src/core/dataStore/app.js +124 -0
  20. package/src/core/dataStore/index.d.ts +85 -0
  21. package/src/core/dataStore/index.js +199 -0
  22. package/src/core/dataStore/page.d.ts +90 -0
  23. package/src/core/dataStore/page.js +194 -0
  24. package/src/core/dataStore/protocol.d.ts +27 -0
  25. package/src/core/dataStore/protocol.js +217 -0
  26. package/src/core/growingIO.d.ts +42 -0
  27. package/src/core/growingIO.js +37 -0
  28. package/src/core/lifecycle.d.ts +151 -0
  29. package/src/core/lifecycle.js +280 -0
  30. package/src/core/localRuntime.d.ts +139 -0
  31. package/src/core/localRuntime.js +759 -0
  32. package/src/core/queue.d.ts +107 -0
  33. package/src/core/queue.js +408 -0
  34. package/src/core/storage/encrypt.d.ts +6 -0
  35. package/src/core/storage/encrypt.js +140 -0
  36. package/src/core/storage/index.d.ts +107 -0
  37. package/src/core/storage/index.js +338 -0
  38. package/src/core/storage/legacyIdentity.d.ts +8 -0
  39. package/src/core/storage/legacyIdentity.js +28 -0
  40. package/src/core/uploader.d.ts +121 -0
  41. package/src/core/uploader.js +407 -0
  42. package/src/core/userStore.d.ts +84 -0
  43. package/src/core/userStore.js +239 -0
  44. package/src/platform/index.d.ts +19 -0
  45. package/src/platform/index.js +96 -0
  46. package/src/platform/miniprogram.d.ts +19 -0
  47. package/src/platform/miniprogram.js +58 -0
  48. package/src/platform/native-identifiers.d.ts +10 -0
  49. package/src/platform/native-identifiers.js +34 -0
  50. package/src/platform/network.d.ts +44 -0
  51. package/src/platform/network.js +138 -0
  52. package/src/platform/resolve.d.ts +9 -0
  53. package/src/platform/resolve.js +38 -0
  54. package/src/platform/system.d.ts +19 -0
  55. package/src/platform/system.js +153 -0
  56. package/src/platform/uni.d.ts +58 -0
  57. package/src/platform/uni.js +100 -0
  58. package/src/platform/unimp-native-module.d.ts +12 -0
  59. package/src/platform/unimp-native-module.js +42 -0
  60. package/src/platform/unimp.d.ts +3 -0
  61. package/src/platform/unimp.js +13 -0
  62. package/src/plugins/gioEventAutoTracking/contract.d.ts +42 -0
  63. package/src/plugins/gioEventAutoTracking/contract.js +7 -0
  64. package/src/plugins/gioEventAutoTracking/index.d.ts +29 -0
  65. package/src/plugins/gioEventAutoTracking/index.js +366 -0
  66. package/src/plugins/gioHybridAdapter/contract.d.ts +138 -0
  67. package/src/plugins/gioHybridAdapter/contract.js +150 -0
  68. package/src/plugins/gioHybridAdapter/info.d.ts +13 -0
  69. package/src/plugins/gioHybridAdapter/info.js +20 -0
  70. package/src/plugins/gioHybridAdapter/runtime.d.ts +133 -0
  71. package/src/plugins/gioHybridAdapter/runtime.js +736 -0
  72. package/src/plugins/gioNativeIdentifiers/index.d.ts +28 -0
  73. package/src/plugins/gioNativeIdentifiers/index.js +58 -0
  74. package/src/types/index.d.ts +111 -0
  75. package/src/types/index.js +1 -0
  76. package/src/utils/tools.d.ts +4 -0
  77. package/src/utils/tools.js +144 -0
  78. package/vite-runtime.js +69851 -0
  79. package/vite.d.ts +2 -0
  80. package/vite.js +4 -0
package/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
package/README.md CHANGED
@@ -1,3 +1,202 @@
1
- # Temporary Holding Version
1
+ # gio-uniapp-sdk
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ GrowingIO 传统 uni-app Vue 3 数据采集 SDK。一行初始化即可自动采集页面浏览、App 生命周期与用户交互,同时支持手动埋点上报自定义事件、用户身份与属性。
4
+
5
+ > 当前版本面向 **HarmonyOS(鸿蒙)端** 的 `.vue` App 发布,提供开箱即用的无埋点与手动埋点能力。
6
+ >
7
+ > 自动交互采集(点击、输入完成、选择器、TabBar)当前仅在鸿蒙端默认开启;Android 与 iOS 需通过验证构建另行开启,尚未纳入本次发布范围。
8
+
9
+ ## 功能特性
10
+
11
+ - **自动采集**包括 App 会话开始(`VISIT`)、页面浏览(`PAGE`),以及鸿蒙端的按钮点击、输入完成等交互。
12
+ - **手动埋点**:通过 `gdp()` 上报自定义事件、用户身份(`setUserId`)、用户属性(`setUserAttributes`)与位置信息。
13
+ - **无埋点插桩**:Vite 构建期自动为模板插桩,业务代码无需改动,原有事件 handler 完整保留。
14
+ - **隐私保护**:内置敏感字段拦截,密码、安全密码等输入内容永不读取、永不上报。
15
+ - **类型安全**:完整 TypeScript 类型定义,未知命令、参数错误在编译期即可发现。
16
+ - **离线缓存**:App 端在存储容量允许时将事件落盘,最多保留 7 天,恢复联网后自动补发。
17
+
18
+ ## 安装
19
+
20
+ 选择以下任一方式,同一应用内不要同时加载两份 SDK。
21
+
22
+ ### npm
23
+
24
+ ```sh
25
+ npm install gio-uniapp-sdk
26
+ ```
27
+
28
+ ### uni_modules
29
+
30
+ 从 GitHub Release 下载 `*-uni_modules.tgz`,解压后将 `uni_modules/gio-uniapp-autotracker` 放入项目根目录。运行时导入路径为 `@/uni_modules/gio-uniapp-autotracker/index.js`,Vite 配置导入路径为 `./uni_modules/gio-uniapp-autotracker/vite.js`。
31
+
32
+ 两种渠道均提供 ESM JavaScript 与 `.d.ts` 类型声明。
33
+
34
+ ## 快速开始
35
+
36
+ 在应用入口创建 App 后,注册插件并初始化 SDK:
37
+
38
+ ```ts
39
+ import gdp from 'gio-uniapp-sdk'
40
+
41
+ export function createApp() {
42
+ const app = createSSRApp(App)
43
+
44
+ // 注册自动采集插件
45
+ gdp('registerPlugins', [{ name: 'gioEventAutoTracking' }])
46
+
47
+ // 初始化:传入账户 ID、数据源 ID 与配置
48
+ gdp('init', 'account-id', 'data-source-id', {
49
+ uniVue: app,
50
+ serverUrl: 'https://collector.example.com',
51
+ dataCollect: true,
52
+ })
53
+
54
+ return { app }
55
+ }
56
+ ```
57
+
58
+ 初始化完成后,SDK 会自动读取 `uni` 宿主,通过全局 Vue mixin 接管 App / Page 生命周期。业务侧的 `App.vue` 与页面**无需**再引入任何 lifecycle bridge,也无需手动埋页面事件。
59
+
60
+ ### 初始化配置
61
+
62
+ | 配置项 | 类型 | 必填 | 说明 |
63
+ | --- | --- | --- | --- |
64
+ | `uniVue` | `App` | 是 | 应用实例,SDK 据此接管生命周期 |
65
+ | `accountId` | `string` | 是 | 账户 ID(`init` 第一个参数) |
66
+ | `dataSourceId` | `string` | 是 | 数据源 ID(`init` 第二个参数) |
67
+ | `serverUrl` | `string` | 否 | 数据上报地址 |
68
+ | `dataCollect` | `boolean` | 否 | 是否开启采集,默认开启 |
69
+ | `sessionExpires` | `number` | 否 | 会话过期时长(分钟),默认 0.5,最大 360 |
70
+ | `appVersion` | `string` | 否 | 上报的应用版本,缺省时自动读取宿主版本 |
71
+ | `idMapping` | `boolean` | 否 | 是否启用身份映射 |
72
+ | `debug` | `boolean` | 否 | 是否在控制台输出调试信息 |
73
+
74
+ 非必填配置缺省、类型错误或超出范围时,SDK 会回退到默认值,不会阻断初始化。
75
+
76
+ 需要等待用户同意时,初始化传入 `dataCollect: false`。已有的离线事件会暂存在本地,在调用 `gdp('setOptions', { dataCollect: true })` 后才恢复上传。
77
+
78
+ ## 手动埋点
79
+
80
+ 业务代码统一通过 `gdp()` 调用 SDK,无需持有任何内部实例:
81
+
82
+ ```ts
83
+ // 上报自定义事件
84
+ gdp('track', 'purchase', { sku: 'sku-1', price: 99 })
85
+
86
+ // 设置用户 ID
87
+ gdp('setUserId', 'user-123')
88
+
89
+ // 清除用户 ID
90
+ gdp('clearUserId')
91
+
92
+ // 设置用户属性
93
+ gdp('setUserAttributes', { vip: true, level: 3 })
94
+
95
+ // 设置位置信息
96
+ gdp('setLocation', 31.23, 121.47)
97
+
98
+ // 清除位置信息
99
+ gdp('clearLocation')
100
+
101
+ // 动态开关采集
102
+ gdp('setOptions', { dataCollect: false })
103
+ ```
104
+
105
+ ### 支持的命令
106
+
107
+ | 命令 | 说明 |
108
+ | --- | --- |
109
+ | `track` | 上报自定义事件及属性 |
110
+ | `setUserId` | 设置当前用户 ID |
111
+ | `clearUserId` | 清除用户 ID |
112
+ | `setUserAttributes` | 设置用户属性 |
113
+ | `identify` | 高级身份识别 |
114
+ | `getGioInfo` | 获取 SDK 信息,返回 `string \| null` |
115
+ | `setOptions({ dataCollect })` | 动态开关采集 |
116
+ | `setLocation` / `clearLocation` | 设置 / 清除位置信息 |
117
+ | `registerPlugins` / `init` | 入口命令(初始化时调用) |
118
+
119
+ ## 无埋点自动采集
120
+
121
+ SDK 通过 Vite 插件在**构建期**为模板插桩,自动采集以下交互:
122
+
123
+ - 内置组件的 `@click`、`@tap`、`@change` 事件
124
+ - input / textarea 的输入完成(优先 `@blur`,其次 `@confirm`)
125
+ - 列表项的 `data-index` 维度信息
126
+ - picker 的选中项文案
127
+
128
+ ### 配置 Vite 插件
129
+
130
+ 无埋点插桩是构建期能力,需在 `vite.config.ts` 中注册插件,且**必须放在 `uni()` 之前**:
131
+
132
+ ```ts
133
+ import { defineConfig } from 'vite'
134
+ import uni from '@dcloudio/vite-plugin-uni'
135
+
136
+ const uniPlugin = (uni as unknown as { default?: typeof uni }).default ?? uni
137
+
138
+ export default defineConfig(async () => {
139
+ const { gioUniappAutoTrack } = await import('gio-uniapp-sdk/vite')
140
+ return {
141
+ plugins: [gioUniappAutoTrack(), uniPlugin()],
142
+ }
143
+ })
144
+ ```
145
+
146
+ > uni_modules 渠道将导入路径替换为 `./uni_modules/gio-uniapp-autotracker/vite.js`。
147
+
148
+ ### 自定义采集粒度
149
+
150
+ - 不想采集的交互:给监听声明静态 `data-growing-ignore`。
151
+ - 需要标记敏感内容的字段:声明 `data-growing-sensitive`。
152
+ - 需要手动补充采集:在业务原有 handler 中调用 `gdp('track', ...)`。
153
+
154
+ 插桩始终以「业务行为不变」为前提。无法安全分析的复杂表达式、动态事件、自定义组件等会保持源码原样,不会擅自改写业务逻辑。
155
+
156
+ ## 隐私与敏感数据
157
+
158
+ SDK 默认保护以下内容:
159
+
160
+ - **密码字段**(含动态 `:password`):保留 `VIEW_CHANGE` 事件,但**始终不读取、不上报**输入内容。
161
+ - **敏感标记**:显式 `data-growing-sensitive` 的元素整条采集会被拒绝。
162
+ - **忽略标记**:`data-growing-ignore` 的元素不会被自动采集。
163
+
164
+ 需要精确控制采集范围的场景,请结合 `data-growing-sensitive`、`data-growing-ignore` 与手动 `gdp('track', ...)` 使用。
165
+
166
+ ## TypeScript 类型
167
+
168
+ SDK 在客户项目中自动声明全局 `gdp`,无需额外 `.d.ts` 文件。也可按需从根入口导入类型:
169
+
170
+ ```ts
171
+ import gdp, {
172
+ type GioAttributes,
173
+ type GioGdpInitOptions,
174
+ type GioPlugin,
175
+ type GioPluginRuntime,
176
+ } from 'gio-uniapp-sdk'
177
+
178
+ const options = {
179
+ uniVue: app,
180
+ dataCollect: true,
181
+ idMapping: true,
182
+ } satisfies GioGdpInitOptions
183
+
184
+ const attributes = { sku: 'sku-1', price: 99, tags: ['new', 'sale'] } satisfies GioAttributes
185
+
186
+ gdp('init', 'account-id', 'data-source-id', options)
187
+ gdp('track', 'purchase_completed', attributes)
188
+ ```
189
+
190
+ 未知命令、错误参数个数、嵌套属性或非布尔 `dataCollect` 等错误用法会在 TypeScript 编译期直接报错。
191
+
192
+ ## 调试
193
+
194
+ 初始化时设置 `debug: true`,SDK 会在控制台输出 `[GrowingIO Debug]:` 前缀的操作标签与即将派发的协议事件数组,便于排查采集问题。该开关不影响隐私、重试或采集行为。
195
+
196
+ ## 示例
197
+
198
+ 项目内提供了可运行的 showcase demo,展示生命周期、页面上下文、自定义事件、用户身份/属性、无埋点交互与 `dataCollect` 动态开关等完整用法。可用 HBuilderX 打开 `demo/` 目录运行体验。
199
+
200
+ ## 许可证
201
+
202
+ [Apache-2.0](./LICENSE)
@@ -0,0 +1,192 @@
1
+ @babel/parser@7.29.8
2
+ MIT
3
+ Copyright (C) 2012-2014 by various contributors (see AUTHORS)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+
24
+ ----------------
25
+
26
+ @vue/compiler-core@3.4.21
27
+ MIT
28
+ The MIT License (MIT)
29
+
30
+ Copyright (c) 2018-present, Yuxi (Evan) You
31
+
32
+ Permission is hereby granted, free of charge, to any person obtaining a copy
33
+ of this software and associated documentation files (the "Software"), to deal
34
+ in the Software without restriction, including without limitation the rights
35
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
36
+ copies of the Software, and to permit persons to whom the Software is
37
+ furnished to do so, subject to the following conditions:
38
+
39
+ The above copyright notice and this permission notice shall be included in
40
+ all copies or substantial portions of the Software.
41
+
42
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
43
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
44
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
45
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
46
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
47
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
48
+ THE SOFTWARE.
49
+
50
+
51
+ ----------------
52
+
53
+ @vue/compiler-dom@3.4.21
54
+ MIT
55
+ The MIT License (MIT)
56
+
57
+ Copyright (c) 2018-present, Yuxi (Evan) You
58
+
59
+ Permission is hereby granted, free of charge, to any person obtaining a copy
60
+ of this software and associated documentation files (the "Software"), to deal
61
+ in the Software without restriction, including without limitation the rights
62
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
63
+ copies of the Software, and to permit persons to whom the Software is
64
+ furnished to do so, subject to the following conditions:
65
+
66
+ The above copyright notice and this permission notice shall be included in
67
+ all copies or substantial portions of the Software.
68
+
69
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
70
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
71
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
72
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
73
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
74
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
75
+ THE SOFTWARE.
76
+
77
+
78
+ ----------------
79
+
80
+ @vue/compiler-sfc@3.4.21
81
+ MIT
82
+ The MIT License (MIT)
83
+
84
+ Copyright (c) 2018-present, Yuxi (Evan) You
85
+
86
+ Permission is hereby granted, free of charge, to any person obtaining a copy
87
+ of this software and associated documentation files (the "Software"), to deal
88
+ in the Software without restriction, including without limitation the rights
89
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
90
+ copies of the Software, and to permit persons to whom the Software is
91
+ furnished to do so, subject to the following conditions:
92
+
93
+ The above copyright notice and this permission notice shall be included in
94
+ all copies or substantial portions of the Software.
95
+
96
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
97
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
98
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
99
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
100
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
101
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
102
+ THE SOFTWARE.
103
+
104
+
105
+ ----------------
106
+
107
+ @vue/shared@3.4.21
108
+ MIT
109
+ The MIT License (MIT)
110
+
111
+ Copyright (c) 2018-present, Yuxi (Evan) You
112
+
113
+ Permission is hereby granted, free of charge, to any person obtaining a copy
114
+ of this software and associated documentation files (the "Software"), to deal
115
+ in the Software without restriction, including without limitation the rights
116
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
117
+ copies of the Software, and to permit persons to whom the Software is
118
+ furnished to do so, subject to the following conditions:
119
+
120
+ The above copyright notice and this permission notice shall be included in
121
+ all copies or substantial portions of the Software.
122
+
123
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
124
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
125
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
126
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
127
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
128
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
129
+ THE SOFTWARE.
130
+
131
+
132
+ ----------------
133
+
134
+ entities@4.5.0
135
+ BSD-2-Clause
136
+ Copyright (c) Felix Böhm
137
+ All rights reserved.
138
+
139
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
140
+
141
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
142
+
143
+ Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
144
+
145
+ THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS,
146
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
147
+
148
+
149
+ ----------------
150
+
151
+ estree-walker@2.0.2
152
+ MIT
153
+ Copyright (c) 2015-20 [these people](https://github.com/Rich-Harris/estree-walker/graphs/contributors)
154
+
155
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
156
+
157
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
158
+
159
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
160
+
161
+ ----------------
162
+
163
+ source-map-js@1.2.1
164
+ BSD-3-Clause
165
+
166
+ Copyright (c) 2009-2011, Mozilla Foundation and contributors
167
+ All rights reserved.
168
+
169
+ Redistribution and use in source and binary forms, with or without
170
+ modification, are permitted provided that the following conditions are met:
171
+
172
+ * Redistributions of source code must retain the above copyright notice, this
173
+ list of conditions and the following disclaimer.
174
+
175
+ * Redistributions in binary form must reproduce the above copyright notice,
176
+ this list of conditions and the following disclaimer in the documentation
177
+ and/or other materials provided with the distribution.
178
+
179
+ * Neither the names of the Mozilla Foundation nor the names of project
180
+ contributors may be used to endorse or promote products derived from this
181
+ software without specific prior written permission.
182
+
183
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
184
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
185
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
186
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
187
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
188
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
189
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
190
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
191
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
192
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/autotrack.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { dispatchAutoTrack } from './src/plugins/gioEventAutoTracking/index.js';
package/autotrack.js ADDED
@@ -0,0 +1,3 @@
1
+ // 本入口仅供 Vite 插桩生成的代码调用,与面向客户的 SDK 根入口分开。
2
+ // 业务侧运行时统一通过 gdp() 使用 SDK。
3
+ export { dispatchAutoTrack } from './src/plugins/gioEventAutoTracking/index.js';
package/index.d.ts ADDED
@@ -0,0 +1,69 @@
1
+ import { type GioInitOptions } from './src/constants/config.js';
2
+ import { type GioBuiltinPlugin } from './src/core/lifecycle.js';
3
+ import { type UniMPInitOptions } from './src/plugins/gioHybridAdapter/contract.js';
4
+ import { TrackerRuntime } from './src/core/growingIO.js';
5
+ import { type UniAppVueApp } from './src/adapters/uniapp.js';
6
+ /** 生命周期安装器所需的最小 Vue 应用接口,createSSRApp(App) 的结果满足此约束。 */
7
+ export type GioUniVueApp = UniAppVueApp;
8
+ export type GioGdpInitOptions = (Omit<GioInitOptions, 'accountId' | 'dataSourceId'> & {
9
+ runtime?: 'app';
10
+ } | Omit<UniMPInitOptions, 'accountId' | 'dataSourceId'>) & Readonly<{
11
+ /** 由 createSSRApp(App) 返回的 Vue 应用,SDK 通过它接管 App 和 Page 生命周期。 */
12
+ uniVue: GioUniVueApp;
13
+ }>;
14
+ /** 可归一化为 GrowingIO 事件属性或用户属性字符串的基础值。 */
15
+ export type GioAttributeScalar = string | number | boolean | Date | null | undefined;
16
+ export type GioAttributeValue = GioAttributeScalar | readonly GioAttributeScalar[];
17
+ export type GioAttributes = Readonly<Record<string, GioAttributeValue>>;
18
+ /** 初始化完成后,仅允许在运行时修改 dataCollect。 */
19
+ export type GioMutableOptions = Readonly<{
20
+ dataCollect: boolean;
21
+ }>;
22
+ /** 内部实例仅通过显式注册的客户插件安装参数提供。 */
23
+ export type GioPluginRuntime = TrackerRuntime;
24
+ export type GioPlugin = Readonly<{
25
+ name: string;
26
+ /** 首次有效初始化后安装客户插件;单个插件失败不阻止其他插件安装。 */
27
+ install: (growingio: GioPluginRuntime) => void;
28
+ }>;
29
+ export type GioPluginRegistration = GioBuiltinPlugin | GioPlugin;
30
+ /** 客户可调用的完整命令接口,不提供接受任意命令的兜底重载;未知命令或错误参数会先被 TypeScript 拒绝。 */
31
+ export interface GdpCommand {
32
+ /** 首次 init 前声明内置或客户插件,重复名称使整批注册失败。 */
33
+ (command: 'registerPlugins', plugins: readonly GioPluginRegistration[]): boolean;
34
+ /** 校验配置并启动异步初始化;重复调用输出警告并返回 false,保留首次实例与配置。 */
35
+ (command: 'init', accountId: string, dataSourceId: string, options: GioGdpInitOptions): boolean;
36
+ /** 提交手动事件;true 表示本地接纳或暂存,不代表服务端接收成功。 */
37
+ (command: 'track', eventName: string, attributes?: GioAttributes): boolean;
38
+ /** 更新登录身份;userKey 仅在初始化启用 idMapping 时生效。 */
39
+ (command: 'setUserId', userId: string, userKey?: string | null): boolean;
40
+ /** 清除当前登录字段,保留设备身份与内部最近登录身份。 */
41
+ (command: 'clearUserId'): boolean;
42
+ /** forceLogin 模式下,为本次等待上传的事件分配设备身份;每个运行期仅一次。 */
43
+ (command: 'identify', deviceId: string | number): boolean;
44
+ /** 当前身份查询串,需拼入受信任的 H5 URL;未就绪或托管模式不提供身份快照。 */
45
+ (command: 'getGioInfo'): string | null;
46
+ /** 提交用户属性事件,使用与手动事件一致的属性归一化规则。 */
47
+ (command: 'setUserAttributes', attributes: GioAttributes): boolean;
48
+ /** 仅允许修改 dataCollect;恢复时按生命周期建立新会话,有当前页时补发 PAGE。 */
49
+ (command: 'setOptions', options: GioMutableOptions): boolean;
50
+ /** 设置后续事件使用的内存位置,不主动定位、不请求权限。 */
51
+ (command: 'setLocation', latitude: number, longitude: number): boolean;
52
+ /** 清除后续事件的位置字段,不修改宿主定位或持久记录。 */
53
+ (command: 'clearLocation'): boolean;
54
+ }
55
+ /**
56
+ * 与独立小程序 SDK 对齐的命令入口。业务在 main.ts 注册插件,再将 Vue 应用作为 uniVue 传给 init。
57
+ * SDK 读取全局 uni 并自行转发生命周期,业务页面统一调用 gdp()。
58
+ *
59
+ * @returns 命令是否被本地接纳;事件命令成功不代表采集服务已接收。
60
+ */
61
+ export declare const gdp: GdpCommand;
62
+ declare global {
63
+ /** main.ts 导入 SDK 根入口后,uni-app 页面可使用由 SDK 声明的全局命令。 */
64
+ const gdp: GdpCommand;
65
+ }
66
+ export default gdp;
67
+ export type { GioBuiltinPlugin } from './src/core/lifecycle.js';
68
+ export type { HybridOptions, HybridReady, HybridError, HybridErrorCode } from './src/plugins/gioHybridAdapter/contract.js';
69
+ export type { NativeIdentifierField } from './src/plugins/gioNativeIdentifiers/index.js';