hm-tracking-sdk 0.1.8 → 0.1.9

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/README.md CHANGED
@@ -36,12 +36,13 @@
36
36
  customUser: {
37
37
  user: {
38
38
  id: 123456789,
39
- firstName: "Test",
40
- lastName: "User",
39
+ first_name: "Test",
40
+ last_name: "User",
41
41
  username: "test_user",
42
- languageCode: "zh-hans",
42
+ language_code: "zh-hans",
43
+ photo_url: "https://t.me/i/userpic/320/example.svg",
43
44
  },
44
- authDate: new Date().toISOString(),
45
+ auth_date: Math.floor(Date.now() / 1000),
45
46
  hash: "your_hash_value",
46
47
  },
47
48
  };
@@ -95,7 +96,23 @@
95
96
  - JSON 示例:
96
97
 
97
98
  ```json
98
- {"id":"7506466780","first_name":"first","last_name":"name","nickname":"nickname","username":"nickname1992","language_code":"zh","allows_write_to_pm":1,"auth_date":"2025-04-08T02:08:53.000Z","hash":"a9d2d7c1b066bebb73c170006dc474061d7601183b388b037936aa7cb6620acf","chat_instance":"-2254244616056098321","is_premium_user":0,"photo_url":"https://t.me/i/userpic/320/uLzA4KyVzKwd0vi6Uvupe6U2mdnVEQOIbUZbFTQff6B3UhjRpQObL9I8Nq81G0ln.svg"}
99
+ {
100
+ "user": {
101
+ "id": 7506466780,
102
+ "first_name": "first",
103
+ "last_name": "name",
104
+ "username": "nickname1992",
105
+ "language_code": "zh",
106
+ "allows_write_to_pm": true,
107
+ "is_premium": false,
108
+ "photo_url": "https://t.me/i/userpic/320/uLzA4KyVzKwd0vi6Uvupe6U2mdnVEQOIbUZbFTQff6B3UhjRpQObL9I8Nq81G0ln.svg"
109
+ },
110
+ "auth_date": 1735792133,
111
+ "hash": "a9d2d7c1b066bebb73c170006dc474061d7601183b388b037936aa7cb6620acf",
112
+ "chat_instance": "-2254244616056098321",
113
+ "chat_type": "sender",
114
+ "start_param": "..."
115
+ }
99
116
  ```
100
117
 
101
118
  - 若为加密字符串:请与服务端约定解密方式及签名校验流程。
@@ -145,14 +162,21 @@
145
162
 
146
163
  ```ts
147
164
  export interface TelegramUserInfo {
148
- id?: number;
149
- first_name?: string;
150
- last_name?: string;
151
- username?: string;
152
- language_code?: string;
153
- allows_write_to_pm?: boolean;
165
+ user: {
166
+ id: number;
167
+ first_name?: string;
168
+ last_name?: string;
169
+ username?: string;
170
+ photo_url?: string;
171
+ language_code?: string;
172
+ allows_write_to_pm?: boolean;
173
+ is_premium?: boolean;
174
+ };
154
175
  auth_date?: number;
155
176
  hash?: string;
177
+ start_param?: string;
178
+ chat_type?: string;
179
+ chat_instance?: string;
156
180
  [key: string]: unknown;
157
181
  }
158
182
  ```
@@ -4374,18 +4374,19 @@ function getTelegramUserUnsafe() {
4374
4374
  return !r.user || !r.user.id ? null : {
4375
4375
  user: {
4376
4376
  id: r.user.id,
4377
- firstName: r.user.first_name || "",
4378
- lastName: r.user.last_name || "",
4377
+ first_name: r.user.first_name || "",
4378
+ last_name: r.user.last_name || "",
4379
4379
  username: r.user.username,
4380
- languageCode: r.user.language_code,
4381
- isPremium: r.user.is_premium || !1,
4382
- allowsWriteToPm: r.user.allows_write_to_pm || !1
4380
+ photo_url: r.user.photo_url,
4381
+ language_code: r.user.language_code,
4382
+ allows_write_to_pm: r.user.allows_write_to_pm || !1,
4383
+ is_premium: r.user.is_premium || !1
4383
4384
  },
4384
- authDate: (/* @__PURE__ */ new Date()).toISOString(),
4385
+ auth_date: r.auth_date,
4385
4386
  hash: r.hash || "",
4386
- startParam: r.start_param,
4387
- chatType: r.chat_type,
4388
- chatInstance: r.chat_instance
4387
+ start_param: r.start_param,
4388
+ chat_type: r.chat_type,
4389
+ chat_instance: r.chat_instance
4389
4390
  };
4390
4391
  } catch {
4391
4392
  return null;
@@ -4425,36 +4426,35 @@ function getAnonymousBrowserUser(r = "tg_tracking_uid") {
4425
4426
  return {
4426
4427
  user: {
4427
4428
  id: d,
4428
- firstName: "Guest",
4429
- lastName: "",
4429
+ first_name: "Guest",
4430
+ last_name: "",
4430
4431
  username: `guest_${f.slice(-6)}`,
4431
- languageCode: m.toLowerCase(),
4432
- isPremium: !1,
4433
- allowsWriteToPm: !1
4432
+ language_code: m.toLowerCase(),
4433
+ allows_write_to_pm: !1
4434
4434
  },
4435
- authDate: (/* @__PURE__ */ new Date()).toISOString(),
4435
+ auth_date: Math.floor(Date.now() / 1e3),
4436
4436
  hash: "anonymous_cookie_user",
4437
- startParam: "browser_guest",
4438
- chatType: "sender",
4439
- chatInstance: ""
4437
+ start_param: "browser_guest",
4438
+ chat_type: "sender",
4439
+ chat_instance: ""
4440
4440
  };
4441
4441
  }
4442
4442
  function getDefaultMockUser() {
4443
4443
  return {
4444
4444
  user: {
4445
4445
  id: 2077220643,
4446
- firstName: "Mock",
4447
- lastName: "User",
4446
+ first_name: "Mock",
4447
+ last_name: "User",
4448
4448
  username: "mock_user_demo",
4449
- languageCode: "zh-hans",
4450
- isPremium: !0,
4451
- allowsWriteToPm: !0
4449
+ language_code: "zh-hans",
4450
+ allows_write_to_pm: !0,
4451
+ is_premium: !0
4452
4452
  },
4453
- authDate: (/* @__PURE__ */ new Date()).toISOString(),
4453
+ auth_date: Math.floor(Date.now() / 1e3),
4454
4454
  hash: "mock_hash_for_demo_purpose",
4455
- startParam: "demo_start_param",
4456
- chatType: "sender",
4457
- chatInstance: "-245769840322609948"
4455
+ start_param: "demo_start_param",
4456
+ chat_type: "sender",
4457
+ chat_instance: "-245769840322609948"
4458
4458
  };
4459
4459
  }
4460
4460
  var naclUtil$1 = { exports: {} }, naclUtil = naclUtil$1.exports, hasRequiredNaclUtil;