@dcloudio/uni-stat 2.0.2-alpha-5010420260626002 → 2.0.2-alpha-5020120260710001

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.
@@ -57,36 +57,36 @@ function toIey(input) {
57
57
  return IEY.No;
58
58
  }
59
59
 
60
- /******************************************************************************
61
- Copyright (c) Microsoft Corporation.
62
-
63
- Permission to use, copy, modify, and/or distribute this software for any
64
- purpose with or without fee is hereby granted.
65
-
66
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
67
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
68
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
69
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
70
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
71
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
72
- PERFORMANCE OF THIS SOFTWARE.
73
- ***************************************************************************** */
74
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
75
-
76
-
77
- function __awaiter(thisArg, _arguments, P, generator) {
78
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
79
- return new (P || (P = Promise))(function (resolve, reject) {
80
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
81
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
82
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
83
- step((generator = generator.apply(thisArg, _arguments || [])).next());
84
- });
85
- }
86
-
87
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
88
- var e = new Error(message);
89
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
60
+ /******************************************************************************
61
+ Copyright (c) Microsoft Corporation.
62
+
63
+ Permission to use, copy, modify, and/or distribute this software for any
64
+ purpose with or without fee is hereby granted.
65
+
66
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
67
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
68
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
69
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
70
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
71
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
72
+ PERFORMANCE OF THIS SOFTWARE.
73
+ ***************************************************************************** */
74
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
75
+
76
+
77
+ function __awaiter(thisArg, _arguments, P, generator) {
78
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
79
+ return new (P || (P = Promise))(function (resolve, reject) {
80
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
81
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
82
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
83
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
84
+ });
85
+ }
86
+
87
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
88
+ var e = new Error(message);
89
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
90
90
  };
91
91
 
92
92
  /**
@@ -4760,6 +4760,45 @@ function createStatDataBuilder(deps) {
4760
4760
  return { build };
4761
4761
  }
4762
4762
 
4763
+ /**
4764
+ * App 渠道包标识适配(对齐私有版 `utils/pageInfo.js#get_channel`)。
4765
+ *
4766
+ * HBuilderX 云打包会为每个渠道包写入 `plus.runtime.channel`(如 huawei、oppo),
4767
+ * 统计上行字段 `ch` 应优先读取该运行时值,而非 manifest 静态配置。
4768
+ *
4769
+ * 职责:
4770
+ * - 仅 App 端(`isApp()`)尝试读取 `plus.runtime.channel`。
4771
+ * - 任意 API 缺失 / 抛错 → 降级 `''`,不阻断 install。
4772
+ * - 返回值统一为 `string`(原生偶发返回数字时转为字符串)。
4773
+ */
4774
+ /**
4775
+ * 将原生渠道值规范为上行用的字符串。
4776
+ *
4777
+ * @param value `plus.runtime.channel` 原值。
4778
+ * @returns 非空字符串;无法识别时返回 `''`。
4779
+ */
4780
+ function normalizeChannelValue(value) {
4781
+ if (typeof value === 'string')
4782
+ return value;
4783
+ if (typeof value === 'number' && Number.isFinite(value))
4784
+ return String(value);
4785
+ return '';
4786
+ }
4787
+ /**
4788
+ * 读取 App 渠道包标识(`plus.runtime.channel`)。
4789
+ *
4790
+ * 与私有版 `get_channel()` 对齐:仅原生 App 有意义;小程序 / H5 恒为 `''`。
4791
+ *
4792
+ * @returns 渠道字符串;未配置或读取失败时为 `''`。
4793
+ */
4794
+ function getAppChannel() {
4795
+ if (!isApp())
4796
+ return '';
4797
+ const plus = getGlobalObject().plus;
4798
+ const raw = tryRun(() => { var _a; return (_a = plus === null || plus === void 0 ? void 0 : plus.runtime) === null || _a === void 0 ? void 0 : _a.channel; }, undefined);
4799
+ return normalizeChannelValue(raw);
4800
+ }
4801
+
4763
4802
  /**
4764
4803
  * 系统信息适配。
4765
4804
  *
@@ -6173,15 +6212,27 @@ class StatApp {
6173
6212
  this.config = undefined;
6174
6213
  this.installed = false;
6175
6214
  }
6215
+ /**
6216
+ * 解析上行渠道字段 `ch`。
6217
+ *
6218
+ * 优先级:显式配置(manifest / install 入参)> `plus.runtime.channel`(云打包渠道包)> `''`。
6219
+ * 与私有版一致,默认从原生运行时读取;仅当业务方显式传入非空 `ch` 时才覆盖。
6220
+ */
6221
+ resolveChannel(explicit) {
6222
+ if (typeof explicit === 'string' && explicit.length > 0) {
6223
+ return explicit;
6224
+ }
6225
+ return getAppChannel();
6226
+ }
6176
6227
  normalizeConfig(c) {
6177
- var _a, _b, _c, _d, _e;
6228
+ var _a, _b, _c, _d;
6178
6229
  return {
6179
6230
  ak: (_a = c.ak) !== null && _a !== void 0 ? _a : getAppId$1(),
6180
6231
  v: c.v,
6181
- ch: (_b = c.ch) !== null && _b !== void 0 ? _b : '',
6182
- version: (_c = c.version) !== null && _c !== void 0 ? _c : 'image',
6183
- backgroundTimeoutSec: (_d = c.backgroundTimeoutSec) !== null && _d !== void 0 ? _d : 300,
6184
- pageInactiveTimeoutSec: (_e = c.pageInactiveTimeoutSec) !== null && _e !== void 0 ? _e : 1800,
6232
+ ch: this.resolveChannel(c.ch),
6233
+ version: (_b = c.version) !== null && _b !== void 0 ? _b : 'image',
6234
+ backgroundTimeoutSec: (_c = c.backgroundTimeoutSec) !== null && _c !== void 0 ? _c : 300,
6235
+ pageInactiveTimeoutSec: (_d = c.pageInactiveTimeoutSec) !== null && _d !== void 0 ? _d : 1800,
6185
6236
  reportIntervalSec: typeof c.reportIntervalSec === 'number'
6186
6237
  ? c.reportIntervalSec
6187
6238
  : REPORT_INTERVAL_SEC,
@@ -55,36 +55,36 @@ function toIey(input) {
55
55
  return IEY.No;
56
56
  }
57
57
 
58
- /******************************************************************************
59
- Copyright (c) Microsoft Corporation.
60
-
61
- Permission to use, copy, modify, and/or distribute this software for any
62
- purpose with or without fee is hereby granted.
63
-
64
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
65
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
66
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
67
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
68
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
69
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
70
- PERFORMANCE OF THIS SOFTWARE.
71
- ***************************************************************************** */
72
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
73
-
74
-
75
- function __awaiter(thisArg, _arguments, P, generator) {
76
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
77
- return new (P || (P = Promise))(function (resolve, reject) {
78
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
79
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
80
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
81
- step((generator = generator.apply(thisArg, _arguments || [])).next());
82
- });
83
- }
84
-
85
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
86
- var e = new Error(message);
87
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
58
+ /******************************************************************************
59
+ Copyright (c) Microsoft Corporation.
60
+
61
+ Permission to use, copy, modify, and/or distribute this software for any
62
+ purpose with or without fee is hereby granted.
63
+
64
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
65
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
66
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
67
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
68
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
69
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
70
+ PERFORMANCE OF THIS SOFTWARE.
71
+ ***************************************************************************** */
72
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
73
+
74
+
75
+ function __awaiter(thisArg, _arguments, P, generator) {
76
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
77
+ return new (P || (P = Promise))(function (resolve, reject) {
78
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
79
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
80
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
81
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
82
+ });
83
+ }
84
+
85
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
86
+ var e = new Error(message);
87
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
88
88
  };
89
89
 
90
90
  /**
@@ -4758,6 +4758,45 @@ function createStatDataBuilder(deps) {
4758
4758
  return { build };
4759
4759
  }
4760
4760
 
4761
+ /**
4762
+ * App 渠道包标识适配(对齐私有版 `utils/pageInfo.js#get_channel`)。
4763
+ *
4764
+ * HBuilderX 云打包会为每个渠道包写入 `plus.runtime.channel`(如 huawei、oppo),
4765
+ * 统计上行字段 `ch` 应优先读取该运行时值,而非 manifest 静态配置。
4766
+ *
4767
+ * 职责:
4768
+ * - 仅 App 端(`isApp()`)尝试读取 `plus.runtime.channel`。
4769
+ * - 任意 API 缺失 / 抛错 → 降级 `''`,不阻断 install。
4770
+ * - 返回值统一为 `string`(原生偶发返回数字时转为字符串)。
4771
+ */
4772
+ /**
4773
+ * 将原生渠道值规范为上行用的字符串。
4774
+ *
4775
+ * @param value `plus.runtime.channel` 原值。
4776
+ * @returns 非空字符串;无法识别时返回 `''`。
4777
+ */
4778
+ function normalizeChannelValue(value) {
4779
+ if (typeof value === 'string')
4780
+ return value;
4781
+ if (typeof value === 'number' && Number.isFinite(value))
4782
+ return String(value);
4783
+ return '';
4784
+ }
4785
+ /**
4786
+ * 读取 App 渠道包标识(`plus.runtime.channel`)。
4787
+ *
4788
+ * 与私有版 `get_channel()` 对齐:仅原生 App 有意义;小程序 / H5 恒为 `''`。
4789
+ *
4790
+ * @returns 渠道字符串;未配置或读取失败时为 `''`。
4791
+ */
4792
+ function getAppChannel() {
4793
+ if (!isApp())
4794
+ return '';
4795
+ const plus = getGlobalObject().plus;
4796
+ const raw = tryRun(() => { var _a; return (_a = plus === null || plus === void 0 ? void 0 : plus.runtime) === null || _a === void 0 ? void 0 : _a.channel; }, undefined);
4797
+ return normalizeChannelValue(raw);
4798
+ }
4799
+
4761
4800
  /**
4762
4801
  * 系统信息适配。
4763
4802
  *
@@ -6171,15 +6210,27 @@ class StatApp {
6171
6210
  this.config = undefined;
6172
6211
  this.installed = false;
6173
6212
  }
6213
+ /**
6214
+ * 解析上行渠道字段 `ch`。
6215
+ *
6216
+ * 优先级:显式配置(manifest / install 入参)> `plus.runtime.channel`(云打包渠道包)> `''`。
6217
+ * 与私有版一致,默认从原生运行时读取;仅当业务方显式传入非空 `ch` 时才覆盖。
6218
+ */
6219
+ resolveChannel(explicit) {
6220
+ if (typeof explicit === 'string' && explicit.length > 0) {
6221
+ return explicit;
6222
+ }
6223
+ return getAppChannel();
6224
+ }
6174
6225
  normalizeConfig(c) {
6175
- var _a, _b, _c, _d, _e;
6226
+ var _a, _b, _c, _d;
6176
6227
  return {
6177
6228
  ak: (_a = c.ak) !== null && _a !== void 0 ? _a : getAppId$1(),
6178
6229
  v: c.v,
6179
- ch: (_b = c.ch) !== null && _b !== void 0 ? _b : '',
6180
- version: (_c = c.version) !== null && _c !== void 0 ? _c : 'image',
6181
- backgroundTimeoutSec: (_d = c.backgroundTimeoutSec) !== null && _d !== void 0 ? _d : 300,
6182
- pageInactiveTimeoutSec: (_e = c.pageInactiveTimeoutSec) !== null && _e !== void 0 ? _e : 1800,
6230
+ ch: this.resolveChannel(c.ch),
6231
+ version: (_b = c.version) !== null && _b !== void 0 ? _b : 'image',
6232
+ backgroundTimeoutSec: (_c = c.backgroundTimeoutSec) !== null && _c !== void 0 ? _c : 300,
6233
+ pageInactiveTimeoutSec: (_d = c.pageInactiveTimeoutSec) !== null && _d !== void 0 ? _d : 1800,
6183
6234
  reportIntervalSec: typeof c.reportIntervalSec === 'number'
6184
6235
  ? c.reportIntervalSec
6185
6236
  : REPORT_INTERVAL_SEC,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-stat",
3
- "version": "2.0.2-alpha-5010420260626002",
3
+ "version": "2.0.2-alpha-5020120260710001",
4
4
  "description": "",
5
5
  "main": "dist/uni-stat.es.js",
6
6
  "repository": {
@@ -34,5 +34,5 @@
34
34
  "rollup-plugin-replace": "^2.2.0",
35
35
  "rollup-plugin-uglify": "^6.0.2"
36
36
  },
37
- "gitHead": "e8896942ca8268595233f9ec566d8ae0a475696d"
37
+ "gitHead": "cf7b7801e8bc5a7e8b9cac638f4e3bece2599e42"
38
38
  }