@aochuang/client-sdk 1.0.382 → 1.0.401
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/components/chat-editor/chat-editor-suggestions/chat-editor-suggestions.vue +4 -40
- package/components/chat-editor/chat-editor.vue +5 -75
- package/components/index.js +6 -1
- package/components/session-select/session-select-item.vue +8 -9
- package/components/wechat-chat-control/location/location.vue +3 -3
- package/components/wework-chat-control/channel-card/channel-card.vue +144 -0
- package/components/wework-chat-control/channel-live/channel-live.vue +7 -2
- package/components/wework-chat-control/company-card/company-card.vue +1 -1
- package/components/wework-chat-control/custom-expression/custom-expression.vue +2 -1
- package/components/wework-chat-control/file-url/file-url.vue +34 -16
- package/components/wework-chat-control/image/image.vue +137 -2
- package/components/wework-chat-control/index.js +15 -7
- package/components/wework-chat-control/location/location.vue +3 -3
- package/components/wework-chat-control/merge-message/merge-message-panel.vue +63 -0
- package/components/wework-chat-control/merge-message/merge-message.vue +84 -0
- package/components/wework-chat-control/merge-message/util.js +59 -0
- package/components/wework-chat-control/metting/enterprise-wechat.png +0 -0
- package/components/wework-chat-control/metting/meeting-video.svg +4 -0
- package/components/wework-chat-control/metting/metting.vue +181 -0
- package/components/wework-chat-control/red-envelopes/red-envelopes.vue +3 -2
- package/components/wework-chat-control/text/text-default.vue +99 -0
- package/components/wework-chat-control/text/text-quote.vue +138 -0
- package/components/wework-chat-control/text/text.vue +27 -143
- package/components/wework-chat-control/url/url-channel-live.vue +53 -0
- package/components/wework-chat-control/url/url-miniprogram.vue +6 -7
- package/components/wework-chat-control/url/url.vue +26 -2
- package/components/wework-chat-control/util.js +30 -17
- package/components/wework-chat-control/video/video.vue +11 -3
- package/components/wework-chat-control/voice/voice.vue +14 -3
- package/components/wework-chat-control/wework-chat-control-config-item.vue +24 -0
- package/components/wework-chat-control/wework-chat-control-config-msg.vue +25 -0
- package/{uni-components/chat-control/chat-control-config.vue → components/wework-chat-control/wework-chat-control-config.vue} +16 -13
- package/components/wework-chat-panel/chat-panel-chat-status/chat-panel-chat-status.vue +120 -0
- package/components/wework-chat-panel/chat-panel-item.vue +70 -39
- package/components/wework-chat-panel/chat-panel.vue +96 -13
- package/package.json +10 -3
- package/services/client-chat/client-chat-wechat/client-chat-account.js +37 -7
- package/services/client-chat/client-chat-wechat/client-chat-message.js +175 -18
- package/services/client-chat/client-chat-wechat/client-chat-session.js +83 -10
- package/services/client-chat/client-chat-wechat/client-chat-socket.js +80 -22
- package/services/client-chat/client-chat-wechat/client-chat.js +59 -11
- package/services/client-chat/client-chat-wework/client-chat-account.js +93 -1
- package/services/client-chat/client-chat-wework/client-chat-concats.js +104 -18
- package/services/client-chat/client-chat-wework/client-chat-message.js +268 -11
- package/services/client-chat/client-chat-wework/client-chat-session.js +271 -191
- package/services/client-chat/client-chat-wework/client-chat-socket.js +18 -2
- package/services/client-chat/client-chat-wework/client-chat.js +470 -85
- package/services/client-chat/client-chat-wework/docs/README.md +308 -0
- package/services/client-chat/client-chat-wework/utils.js +5 -5
- package/services/socket/socket.js +56 -7
- package/utils/log/constants.js +13 -0
- package/utils/log/export.js +88 -0
- package/utils/log/findings.md +141 -0
- package/utils/log/index.js +331 -0
- package/utils/log/indexed-db.js +228 -0
- package/utils/log/progress.md +267 -0
- package/utils/log/serialize.js +146 -0
- package/utils/log/task_plan.md +149 -0
- package/utils/log//345/210/206/346/236/220/344/270/216/344/274/230/345/214/226/346/226/271/346/241/210.md +303 -0
- package/utils/log//346/212/200/346/234/257/346/226/271/346/241/210/346/226/207/346/241/243.md +201 -0
- package/utils/log//346/236/266/346/236/204/346/226/207/346/241/243.md +169 -0
- package/utils/log//351/234/200/346/261/202/346/226/207/346/241/243.md +124 -0
- package/utils/log.js +2 -626
- package/components/wework-chat-panel/chat-panel-controls/company-card/company-card.vue +0 -35
- package/components/wework-chat-panel/chat-panel-controls/expression/expression.vue +0 -36
- package/components/wework-chat-panel/chat-panel-controls/file-url/file-url.vue +0 -35
- package/components/wework-chat-panel/chat-panel-controls/image/image.vue +0 -36
- package/components/wework-chat-panel/chat-panel-controls/index.js +0 -35
- package/components/wework-chat-panel/chat-panel-controls/jx-sys-text/jx-sys-text.vue +0 -28
- package/components/wework-chat-panel/chat-panel-controls/link/link.vue +0 -35
- package/components/wework-chat-panel/chat-panel-controls/location/location.vue +0 -35
- package/components/wework-chat-panel/chat-panel-controls/text/text.vue +0 -43
- package/components/wework-chat-panel/chat-panel-controls/unkonw/unkonw.vue +0 -39
- package/components/wework-chat-panel/chat-panel-controls/video/video.vue +0 -37
- package/components/wework-chat-panel/chat-panel-controls/voice/voice.vue +0 -35
- package/uni-common/account-portray/account-portray.vue +0 -51
- package/uni-common/account-select/account-select-item.vue +0 -172
- package/uni-common/account-select/account-select.vue +0 -252
- package/uni-common/all-friend-avatar/all-friend-avatar.vue +0 -49
- package/uni-common/friend-avatar/default.svg +0 -1
- package/uni-common/friend-avatar/friend-avatar.vue +0 -27
- package/uni-common/friend-avatar/index.js +0 -3
- package/uni-common/friend-loader/friend-loader.vue +0 -53
- package/uni-common/friend-portray/friend-portray.vue +0 -56
- package/uni-common/group-avatar/default.svg +0 -1
- package/uni-common/group-avatar/group-avatar.vue +0 -18
- package/uni-common/group-avatar/index.js +0 -3
- package/uni-common/room-avatar/default.svg +0 -6
- package/uni-common/room-avatar/index.js +0 -3
- package/uni-common/room-avatar/room-avatar.vue +0 -27
- package/uni-common/room-loader/room-loader.vue +0 -53
- package/uni-common/room-portray/room-portray.vue +0 -56
- package/uni-components/chat-control/calling/calling.vue +0 -91
- package/uni-components/chat-control/calling/phone-fill.svg +0 -1
- package/uni-components/chat-control/calling/vidicon-fill.svg +0 -1
- package/uni-components/chat-control/channel-video/channel-video.vue +0 -89
- package/uni-components/chat-control/channel-video-card/channel-video-card.vue +0 -105
- package/uni-components/chat-control/channel-video-live/channel-video-live.vue +0 -92
- package/uni-components/chat-control/chat-control-config-item/chat-control-config-item.vue +0 -20
- package/uni-components/chat-control/chat-control-config-item/index.js +0 -3
- package/uni-components/chat-control/chat-control-config-msg/chat-control-config-msg-app.vue +0 -25
- package/uni-components/chat-control/chat-control-config-msg/chat-control-config-msg-h5.vue +0 -21
- package/uni-components/chat-control/chat-control.vue +0 -218
- package/uni-components/chat-control/company-card/company-card.vue +0 -123
- package/uni-components/chat-control/const.js +0 -28
- package/uni-components/chat-control/expression/expression.vue +0 -41
- package/uni-components/chat-control/image/image.vue +0 -68
- package/uni-components/chat-control/index.js +0 -89
- package/uni-components/chat-control/location/location.vue +0 -110
- package/uni-components/chat-control/member-change/member-change.vue +0 -32
- package/uni-components/chat-control/quote-message/quote-message.vue +0 -216
- package/uni-components/chat-control/real-time-position/real-time-position.vue +0 -62
- package/uni-components/chat-control/redpacket/red-envelope.svg +0 -1
- package/uni-components/chat-control/redpacket/redpacket.vue +0 -75
- package/uni-components/chat-control/share-card/share-card.vue +0 -101
- package/uni-components/chat-control/system/system.vue +0 -69
- package/uni-components/chat-control/system-batch-message/system-batch-message.vue +0 -30
- package/uni-components/chat-control/system-text/system-text.vue +0 -32
- package/uni-components/chat-control/text/text.vue +0 -67
- package/uni-components/chat-control/text-with-at/text-with-at.vue +0 -51
- package/uni-components/chat-control/transfer/red-transfer.svg +0 -1
- package/uni-components/chat-control/transfer/transfer.vue +0 -80
- package/uni-components/chat-control/unkonw/unkonw.vue +0 -37
- package/uni-components/chat-control/url/icons/file-excel-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-info-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-music-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-pdf-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-ppt-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-settings-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-text-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-unknow-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-word-line.svg +0 -1
- package/uni-components/chat-control/url/icons/file-zip-line.svg +0 -1
- package/uni-components/chat-control/url/icons/index.js +0 -24
- package/uni-components/chat-control/url/miniprogram.svg +0 -1
- package/uni-components/chat-control/url/url-miniprogram.vue +0 -116
- package/uni-components/chat-control/url/url.vue +0 -306
- package/uni-components/chat-control/url-new/icons/file-excel-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-info-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-music-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-pdf-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-ppt-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-settings-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-text-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-unknow-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-word-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/file-zip-line.svg +0 -1
- package/uni-components/chat-control/url-new/icons/index.js +0 -24
- package/uni-components/chat-control/url-new/url-new.vue +0 -110
- package/uni-components/chat-control/utils.js +0 -12
- package/uni-components/chat-control/video/video.vue +0 -156
- package/uni-components/chat-control/voice/voice.vue +0 -166
- package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet-collect.vue +0 -84
- package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet-system.vue +0 -28
- package/uni-components/chat-editor/chat-editor-chartlet/chat-editor-chartlet.vue +0 -85
- package/uni-components/chat-editor/chat-editor-func/chat-editor-func.vue +0 -157
- package/uni-components/chat-editor/chat-editor-func-at/chat-editor-func-at-panel.vue +0 -158
- package/uni-components/chat-editor/chat-editor-func-at/chat-editor-func-at.vue +0 -61
- package/uni-components/chat-editor/chat-editor-func-button/chat-editor-func-button.vue +0 -58
- package/uni-components/chat-editor/chat-editor-func-file/chat-editor-func-file.vue +0 -54
- package/uni-components/chat-editor/chat-editor-func-image/chat-editor-func-image.vue +0 -42
- package/uni-components/chat-editor/chat-editor-func-video/chat-editor-func-video.vue +0 -42
- package/uni-components/chat-editor/chat-editor-func-voice/chat-editor-func-voice.vue +0 -25
- package/uni-components/chat-editor/chat-editor-message-send/chat-editor-message-send.vue +0 -158
- package/uni-components/chat-editor/chat-editor-quote/chat-editor-quote.vue +0 -75
- package/uni-components/chat-editor/chat-editor.vue +0 -257
- package/uni-components/chat-editor/index.js +0 -10
- package/uni-components/chat-editor/util.js +0 -65
- package/uni-components/chat-panel/chat-panel-chats-box.vue +0 -238
- package/uni-components/chat-panel/chat-panel-chats-forward/chat-panel-chats-forward.vue +0 -273
- package/uni-components/chat-panel/chat-panel-chats-item.vue +0 -578
- package/uni-components/chat-panel/chat-panel-chats-status/chat-panel-chats-status.vue +0 -71
- package/uni-components/chat-panel/chat-panel-chats.vue +0 -368
- package/uni-components/chat-panel/chat-panel.vue +0 -227
- package/uni-components/contacts-group-select/contacts-group-select-item.vue +0 -85
- package/uni-components/contacts-group-select/contacts-group-select-panel.vue +0 -119
- package/uni-components/contacts-group-select/contacts-group-select.vue +0 -150
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import {
|
|
2
|
+
INDEXED_DB_VERSION,
|
|
3
|
+
INDEXED_DB_STORE_NAME,
|
|
4
|
+
INDEXED_DB_META_STORE_NAME,
|
|
5
|
+
INDEXED_DB_ORDER_INDEX_NAME,
|
|
6
|
+
INDEXED_DB_STATS_KEY
|
|
7
|
+
} from './constants'
|
|
8
|
+
import { safeStringify, getByteSize } from './serialize'
|
|
9
|
+
|
|
10
|
+
function supported () {
|
|
11
|
+
return typeof window !== 'undefined' && !!window.indexedDB
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function createStores (db) {
|
|
15
|
+
const store = db.createObjectStore(INDEXED_DB_STORE_NAME, { keyPath: 'recordId' })
|
|
16
|
+
store.createIndex(INDEXED_DB_ORDER_INDEX_NAME, 'order', { unique: false })
|
|
17
|
+
if (!db.objectStoreNames.contains(INDEXED_DB_META_STORE_NAME)) {
|
|
18
|
+
db.createObjectStore(INDEXED_DB_META_STORE_NAME, { keyPath: 'key' })
|
|
19
|
+
}
|
|
20
|
+
return store
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function parseLegacyStore (value) {
|
|
24
|
+
try {
|
|
25
|
+
if (value && value.value !== undefined) {
|
|
26
|
+
value = value.value
|
|
27
|
+
}
|
|
28
|
+
if (typeof value === 'string') {
|
|
29
|
+
value = JSON.parse(value)
|
|
30
|
+
}
|
|
31
|
+
if (Array.isArray(value)) {
|
|
32
|
+
return value
|
|
33
|
+
}
|
|
34
|
+
return value && Array.isArray(value.data) ? value.data : []
|
|
35
|
+
} catch (error) {
|
|
36
|
+
return []
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function legacyRecord (log, index) {
|
|
41
|
+
const payload = safeStringify(log) || '{}'
|
|
42
|
+
return {
|
|
43
|
+
recordId: `legacy:${index}:${Date.now()}`,
|
|
44
|
+
order: index + 1,
|
|
45
|
+
byteSize: getByteSize(payload),
|
|
46
|
+
day: log && typeof log.createTime === 'string' ? log.createTime.slice(0, 10) : 'unknown-date',
|
|
47
|
+
payload,
|
|
48
|
+
log
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default class IndexedDbLogStorage {
|
|
53
|
+
constructor (options) {
|
|
54
|
+
this.name = options.name
|
|
55
|
+
this.storageKey = options.storageKey
|
|
56
|
+
this.maxBytes = options.maxBytes
|
|
57
|
+
this._dbPromise = null
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
get supported () {
|
|
61
|
+
return supported()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
_upgrade (request) {
|
|
65
|
+
const db = request.result
|
|
66
|
+
const transaction = request.transaction
|
|
67
|
+
if (!db.objectStoreNames.contains(INDEXED_DB_STORE_NAME)) {
|
|
68
|
+
createStores(db)
|
|
69
|
+
transaction.objectStore(INDEXED_DB_META_STORE_NAME).put({
|
|
70
|
+
key: INDEXED_DB_STATS_KEY,
|
|
71
|
+
totalBytes: 0,
|
|
72
|
+
nextOrder: 0
|
|
73
|
+
})
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// v1 used one key/value entry. Convert it inside the v2 upgrade transaction.
|
|
78
|
+
if (!db.objectStoreNames.contains(INDEXED_DB_META_STORE_NAME)) {
|
|
79
|
+
const legacyStore = transaction.objectStore(INDEXED_DB_STORE_NAME)
|
|
80
|
+
const requestLegacy = legacyStore.get(this.storageKey)
|
|
81
|
+
requestLegacy.onsuccess = () => {
|
|
82
|
+
const logs = parseLegacyStore(requestLegacy.result)
|
|
83
|
+
db.deleteObjectStore(INDEXED_DB_STORE_NAME)
|
|
84
|
+
const store = createStores(db)
|
|
85
|
+
let totalBytes = 0
|
|
86
|
+
let retained = 0
|
|
87
|
+
logs.slice().reverse().some((log, index) => {
|
|
88
|
+
const record = legacyRecord(log, index)
|
|
89
|
+
if (totalBytes + record.byteSize > this.maxBytes) {
|
|
90
|
+
return true
|
|
91
|
+
}
|
|
92
|
+
totalBytes += record.byteSize
|
|
93
|
+
retained++
|
|
94
|
+
store.put(record)
|
|
95
|
+
return false
|
|
96
|
+
})
|
|
97
|
+
transaction.objectStore(INDEXED_DB_META_STORE_NAME).put({
|
|
98
|
+
key: INDEXED_DB_STATS_KEY,
|
|
99
|
+
totalBytes,
|
|
100
|
+
nextOrder: retained
|
|
101
|
+
})
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
open () {
|
|
107
|
+
if (!this.supported) {
|
|
108
|
+
return Promise.reject(new Error('indexedDB不可用'))
|
|
109
|
+
}
|
|
110
|
+
if (this._dbPromise) {
|
|
111
|
+
return this._dbPromise
|
|
112
|
+
}
|
|
113
|
+
this._dbPromise = new Promise((resolve, reject) => {
|
|
114
|
+
const request = window.indexedDB.open(this.name, INDEXED_DB_VERSION)
|
|
115
|
+
request.onupgradeneeded = () => this._upgrade(request)
|
|
116
|
+
request.onerror = () => {
|
|
117
|
+
this._dbPromise = null
|
|
118
|
+
reject(request.error || new Error('打开日志数据库失败'))
|
|
119
|
+
}
|
|
120
|
+
request.onsuccess = () => {
|
|
121
|
+
const db = request.result
|
|
122
|
+
db.onversionchange = () => {
|
|
123
|
+
db.close()
|
|
124
|
+
this._dbPromise = null
|
|
125
|
+
}
|
|
126
|
+
resolve(db)
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
return this._dbPromise
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
close () {
|
|
133
|
+
const promise = this._dbPromise
|
|
134
|
+
this._dbPromise = null
|
|
135
|
+
if (!promise) {
|
|
136
|
+
return Promise.resolve()
|
|
137
|
+
}
|
|
138
|
+
return promise.then(db => db.close(), () => {})
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
write (records) {
|
|
142
|
+
if (!records || !records.length) {
|
|
143
|
+
return Promise.resolve({ writtenCount: 0, removedCount: 0 })
|
|
144
|
+
}
|
|
145
|
+
return this.open().then(db => new Promise((resolve, reject) => {
|
|
146
|
+
const transaction = db.transaction(
|
|
147
|
+
[INDEXED_DB_STORE_NAME, INDEXED_DB_META_STORE_NAME],
|
|
148
|
+
'readwrite'
|
|
149
|
+
)
|
|
150
|
+
const store = transaction.objectStore(INDEXED_DB_STORE_NAME)
|
|
151
|
+
const metaStore = transaction.objectStore(INDEXED_DB_META_STORE_NAME)
|
|
152
|
+
const metaRequest = metaStore.get(INDEXED_DB_STATS_KEY)
|
|
153
|
+
let removedCount = 0
|
|
154
|
+
transaction.oncomplete = () => resolve({ writtenCount: records.length, removedCount })
|
|
155
|
+
transaction.onerror = () => reject(transaction.error || new Error('写入日志失败'))
|
|
156
|
+
transaction.onabort = () => reject(transaction.error || new Error('写入日志失败'))
|
|
157
|
+
metaRequest.onerror = () => transaction.abort()
|
|
158
|
+
metaRequest.onsuccess = () => {
|
|
159
|
+
const stats = metaRequest.result || {
|
|
160
|
+
key: INDEXED_DB_STATS_KEY,
|
|
161
|
+
totalBytes: 0,
|
|
162
|
+
nextOrder: 0
|
|
163
|
+
}
|
|
164
|
+
records.forEach(record => {
|
|
165
|
+
stats.nextOrder++
|
|
166
|
+
record.order = stats.nextOrder
|
|
167
|
+
stats.totalBytes += record.byteSize || 0
|
|
168
|
+
store.put(record)
|
|
169
|
+
})
|
|
170
|
+
if (stats.totalBytes <= this.maxBytes) {
|
|
171
|
+
metaStore.put(stats)
|
|
172
|
+
return
|
|
173
|
+
}
|
|
174
|
+
const cursorRequest = store.index(INDEXED_DB_ORDER_INDEX_NAME).openCursor(null, 'next')
|
|
175
|
+
cursorRequest.onerror = () => transaction.abort()
|
|
176
|
+
cursorRequest.onsuccess = event => {
|
|
177
|
+
const cursor = event.target.result
|
|
178
|
+
if (stats.totalBytes <= this.maxBytes || !cursor) {
|
|
179
|
+
metaStore.put(stats)
|
|
180
|
+
return
|
|
181
|
+
}
|
|
182
|
+
stats.totalBytes = Math.max(0, stats.totalBytes - (cursor.value.byteSize || 0))
|
|
183
|
+
cursor.delete()
|
|
184
|
+
removedCount++
|
|
185
|
+
cursor.continue()
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}))
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
readRecords (direction = 'prev') {
|
|
192
|
+
return this.open().then(db => new Promise((resolve, reject) => {
|
|
193
|
+
const transaction = db.transaction([INDEXED_DB_STORE_NAME], 'readonly')
|
|
194
|
+
const store = transaction.objectStore(INDEXED_DB_STORE_NAME)
|
|
195
|
+
const request = store.index(INDEXED_DB_ORDER_INDEX_NAME).openCursor(null, direction)
|
|
196
|
+
const records = []
|
|
197
|
+
request.onerror = () => reject(request.error || new Error('读取日志失败'))
|
|
198
|
+
request.onsuccess = event => {
|
|
199
|
+
const cursor = event.target.result
|
|
200
|
+
if (!cursor) {
|
|
201
|
+
resolve(records)
|
|
202
|
+
return
|
|
203
|
+
}
|
|
204
|
+
records.push(cursor.value)
|
|
205
|
+
cursor.continue()
|
|
206
|
+
}
|
|
207
|
+
}))
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
clear () {
|
|
211
|
+
return this.open().then(db => new Promise((resolve, reject) => {
|
|
212
|
+
const transaction = db.transaction(
|
|
213
|
+
[INDEXED_DB_STORE_NAME, INDEXED_DB_META_STORE_NAME],
|
|
214
|
+
'readwrite'
|
|
215
|
+
)
|
|
216
|
+
transaction.objectStore(INDEXED_DB_STORE_NAME).clear()
|
|
217
|
+
transaction.objectStore(INDEXED_DB_META_STORE_NAME).put({
|
|
218
|
+
key: INDEXED_DB_STATS_KEY,
|
|
219
|
+
totalBytes: 0,
|
|
220
|
+
nextOrder: 0
|
|
221
|
+
})
|
|
222
|
+
transaction.oncomplete = resolve
|
|
223
|
+
transaction.onerror = () => reject(transaction.error || new Error('清理日志失败'))
|
|
224
|
+
transaction.onabort = () => reject(transaction.error || new Error('清理日志失败'))
|
|
225
|
+
}))
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
# 进度日志
|
|
2
|
+
|
|
3
|
+
## 会话:2026-11-07
|
|
4
|
+
|
|
5
|
+
### 阶段 1:需求与现状确认
|
|
6
|
+
- **状态:** complete
|
|
7
|
+
- **开始时间:** 2026-11-07
|
|
8
|
+
- 执行的操作:
|
|
9
|
+
- 确认 SDK 和 JavaMain-combine 当前分支及工作区状态。
|
|
10
|
+
- 确认已有相关分析文档目录。
|
|
11
|
+
- 固化 IndexedDB-only、内部异常隔离和 Request 裁剪约束。
|
|
12
|
+
- 审阅现有分析文档、SDK 日志实现及消息/会话日志调用点。
|
|
13
|
+
- 创建/修改的文件:
|
|
14
|
+
- `utils/log/task_plan.md`
|
|
15
|
+
- `utils/log/findings.md`
|
|
16
|
+
- `utils/log/progress.md`
|
|
17
|
+
|
|
18
|
+
### 阶段 2:文档设计
|
|
19
|
+
- **状态:** complete
|
|
20
|
+
- 执行的操作:
|
|
21
|
+
- 确定旧入口转发、目录化实现、批量写入和异常隔离边界。
|
|
22
|
+
- 完成需求、架构和技术方案文档并复核一致性。
|
|
23
|
+
- 创建/修改的文件:
|
|
24
|
+
- `utils/log/需求文档.md`
|
|
25
|
+
- `utils/log/架构文档.md`
|
|
26
|
+
- `utils/log/技术方案文档.md`
|
|
27
|
+
|
|
28
|
+
### 阶段 3:SDK 日志模块重构
|
|
29
|
+
- **状态:** in_progress
|
|
30
|
+
- 执行的操作:
|
|
31
|
+
- 开始复核现有公共 API、存储结构和调用方兼容要求。
|
|
32
|
+
- 将单文件日志实现拆分为常量、安全序列化、IndexedDB、导出和公共 API 模块。
|
|
33
|
+
- 实现 200MB 上限、300ms/50 条批量触发、500 条事务、队列上限和失败退避。
|
|
34
|
+
- 保持 IndexedDB v2 及新旧记录读取兼容,增加按天紧凑 Blob 导出。
|
|
35
|
+
- 创建/修改的文件:
|
|
36
|
+
- `utils/log.js`
|
|
37
|
+
- `utils/log/index.js`
|
|
38
|
+
- `utils/log/constants.js`
|
|
39
|
+
- `utils/log/serialize.js`
|
|
40
|
+
- `utils/log/indexed-db.js`
|
|
41
|
+
- `utils/log/export.js`
|
|
42
|
+
|
|
43
|
+
### 阶段 4:消息、会话与 Request 接入
|
|
44
|
+
- **状态:** complete
|
|
45
|
+
- 执行的操作:
|
|
46
|
+
- 增加消息接收、存储、拒绝、派发和抑制事件。
|
|
47
|
+
- 统一会话轮询、已读及账号未读事件。
|
|
48
|
+
- Axios 接入请求开始、成功、失败、取消、重试、traceid 和有界裁剪。
|
|
49
|
+
- 统一下载入口,操作日志和网络日志按天拆分且不做美化格式化。
|
|
50
|
+
- 创建/修改的文件:
|
|
51
|
+
- `services/client-chat/client-chat-wechat/client-chat-message.js`
|
|
52
|
+
- `services/client-chat/client-chat-wechat/client-chat-session.js`
|
|
53
|
+
- `services/client-chat/client-chat-wechat/client-chat-account.js`
|
|
54
|
+
- `services/client-chat/client-chat-wechat/client-chat-socket.js`
|
|
55
|
+
- JavaMain-combine `src/libs/diagnostic-log.js`
|
|
56
|
+
- JavaMain-combine `src/libs/request-log.js`
|
|
57
|
+
- JavaMain-combine `src/libs/request.js`
|
|
58
|
+
- JavaMain-combine `src/entries/chat/common/develop-log/`
|
|
59
|
+
|
|
60
|
+
### 阶段 5:测试与交付
|
|
61
|
+
- **状态:** complete
|
|
62
|
+
- 执行的操作:
|
|
63
|
+
- SDK 11 个相关模块完成 Babel 语法解析。
|
|
64
|
+
- 定向验证循环对象、BigInt、addLog 内部异常隔离、跨天导出和请求裁剪。
|
|
65
|
+
- JavaMain-combine 生产模式构建成功。
|
|
66
|
+
- JavaMain-combine 现有 15 项安全回归测试全部通过。
|
|
67
|
+
- 两个仓库均通过 `git diff --check`,根目录无规划文件污染。
|
|
68
|
+
- 注意事项:
|
|
69
|
+
- 本机 JavaMain-combine 的 node_modules 是 SDK 1.0.381,package.json 声明 1.0.382;联调前需发布并安装包含 `exportLogFiles()` 的 SDK 版本。
|
|
70
|
+
|
|
71
|
+
## 测试结果
|
|
72
|
+
| 测试 | 输入 | 预期结果 | 实际结果 | 状态 |
|
|
73
|
+
|------|------|---------|---------|------|
|
|
74
|
+
| SDK Babel 解析 | 11 个相关模块 | 无语法错误 | 通过 | passed |
|
|
75
|
+
| SDK 定向运行时检查 | 循环对象、BigInt、异常回调、跨天导出 | 不抛业务异常且结果正确 | 通过 | passed |
|
|
76
|
+
| SDK 批量写入检查 | 连续 1000 条日志 | 事务数远小于 1000,单事务不超过 500 | 20 个事务,单次最多 50 条 | passed |
|
|
77
|
+
| Request 裁剪检查 | 2380 字符、敏感字段、URL 编码/JSON 字符串、Blob、traceid | 100 字符裁剪并脱敏 | 通过 | passed |
|
|
78
|
+
| 前端安全回归 | `security-regression.test.js` | 15 项通过 | 15 项通过 | passed |
|
|
79
|
+
| 前端构建 | `NODE_ENV=test vue-cli-service build` | 构建成功 | 构建成功 | passed |
|
|
80
|
+
| 运行时异常定向测试 | window、Promise、Vue、去重、限流、日志器故障 | 监听完整且不影响业务 | 5 项通过 | passed |
|
|
81
|
+
| 错误日志真实下载 | BrowserSkill 页面下载并解析 ZIP | 错误/操作互斥拆分 | 184/1958 条,交叉重复 0 | passed |
|
|
82
|
+
|
|
83
|
+
## 错误日志
|
|
84
|
+
| 时间戳 | 错误 | 尝试次数 | 解决方案 |
|
|
85
|
+
|--------|------|---------|---------|
|
|
86
|
+
| 2026-11-07 | 直接执行 ESLint 将现有 import 和 Vue SFC 全部判为 parsing error | 1 | 改用项目 Vue CLI 构建及 Babel 定向解析 |
|
|
87
|
+
| 2026-11-07 | SDK 和 Request 运行时测试缺少 `@babel/register` | 1 | 使用已安装的 `@babel/core` 转换并注入依赖测试 |
|
|
88
|
+
| 2026-11-07 | JSON 字符串形式的 `access_token` 未被首版正则脱敏 | 1 | 敏感键匹配改为允许敏感词出现在完整键名中间 |
|
|
89
|
+
| 2026-11-07 | 默认 Node 14 不支持 `node --test` | 1 | 使用 Node 22 运行 node:test |
|
|
90
|
+
| 2026-11-07 | Node 22 构建报 `ERR_OSSL_EVP_UNSUPPORTED` | 1 | 使用项目 Node 14 完成 Vue CLI 正式构建 |
|
|
91
|
+
| 2026-11-07 | 直接 ESLint 无法解析仓库现有 import/Vue SFC | 1 | 使用 Babel、node:test 和正式构建验证 |
|
|
92
|
+
| 2026-11-07 | SDK 仓库独立 Babel 校验缺少 `@babel/core` | 1 | 不重复该失败命令,改由 JavaMain-combine 的 Babel 环境加载 SDK 源码并运行定向测试 |
|
|
93
|
+
| 2026-11-07 | 在前端工作目录读取 SDK 相对路径导致 `sed` 找不到文件 | 1 | 已有 SDK 读取结果可用;后续 SDK 命令固定使用 `/Volumes/Sites/AoChuang/fangzhou/client-sdk` 工作目录 |
|
|
94
|
+
| 2026-11-07 | 消息精简测试把日志容器的 `content:` 属性误判为消息正文 | 1 | 收窄断言,只排除消息克隆、正文属性访问和嵌套 payload |
|
|
95
|
+
| 2026-11-07 | 三份文档的合并补丁因架构文档上下文不匹配未应用 | 1 | 按文件和准确标题拆分补丁,避免大范围上下文依赖 |
|
|
96
|
+
|
|
97
|
+
## 五问重启检查
|
|
98
|
+
| 问题 | 答案 |
|
|
99
|
+
|------|------|
|
|
100
|
+
| 我在哪里? | 阶段 5:测试与交付已完成 |
|
|
101
|
+
| 我要去哪里? | 发布 SDK 后更新前端实际安装依赖并联调下载 |
|
|
102
|
+
| 目标是什么? | 高性能、可诊断且不影响业务的消息与会话日志系统 |
|
|
103
|
+
| 我学到了什么? | 见 findings.md |
|
|
104
|
+
| 我做了什么? | 已建立持久化计划并记录约束 |
|
|
105
|
+
|
|
106
|
+
### 阶段 6:UI 自动化与真实消息验证
|
|
107
|
+
- **状态:** in_progress
|
|
108
|
+
- 执行的操作:
|
|
109
|
+
- 安装并连接 BrowserSkill 0.3.2,使用 Chrome 156 登录真实客服端页面。
|
|
110
|
+
- 验证首次页面启动、刷新识别、IndexedDB v2 持久化和请求日志裁剪。
|
|
111
|
+
- 临时将前端 SDK 依赖链接到本地工作区,验证会话列表、账号未读和历史消息链路。
|
|
112
|
+
- 通过页面入口下载 938470 bytes 的日志 ZIP,核对按天文件结构、JSON 顶层类型和 SHA-256。
|
|
113
|
+
- 记录 SDK 实际安装版本不一致、纯网络错误二次异常和未处理 Promise 拒绝问题。
|
|
114
|
+
- 创建/修改的文件:
|
|
115
|
+
- `utils/log/UI自动化测试报告.md`
|
|
116
|
+
- `utils/log/task_plan.md`
|
|
117
|
+
- `utils/log/findings.md`
|
|
118
|
+
- `utils/log/progress.md`
|
|
119
|
+
- 下一步:
|
|
120
|
+
- 等待测试人员发送真实新消息,补齐消息接收至未读变化的完整证据。
|
|
121
|
+
|
|
122
|
+
#### 真实消息发送前基线
|
|
123
|
+
- 采集时间:`2026-11-07 12:27:29`(Asia/Shanghai)
|
|
124
|
+
- 页面:`http://localhost:8081/user/chat/index.html`,登录状态正常
|
|
125
|
+
- IndexedDB:`log_client_chat` v2
|
|
126
|
+
- 日志记录数:`670`
|
|
127
|
+
- `stats.nextOrder`:`670`
|
|
128
|
+
- `stats.totalBytes`:`1114028`
|
|
129
|
+
- 页面采样期间未提取或保存消息正文;后续仅按新增记录关联诊断 ID、会话 ID 和未读变化。
|
|
130
|
+
|
|
131
|
+
### 阶段 7:脚本异常日志与独立下载
|
|
132
|
+
- **状态:** complete
|
|
133
|
+
- 新增要求:捕获页面脚本异常,并在下载 ZIP 中按天输出独立错误日志文件;错误记录不得重复进入操作日志。
|
|
134
|
+
- 计划覆盖:window error、unhandled rejection、Vue errorHandler、异常风暴去重限流、SDK 分类导出和前端下载入口。
|
|
135
|
+
- 完成运行时异常监听、5 秒指纹去重、每分钟 30 个不同异常限流和 suppressedCount 汇总。
|
|
136
|
+
- SDK v2 记录包装增加可选 group,单次全量扫描按天生成 operation/error 两类 Blob;默认 API 保持兼容。
|
|
137
|
+
- 下载面板增加“错误日志”并默认选择,ZIP 输出 `错误日志/错误日志-YYYY-MM-DD.json`。
|
|
138
|
+
- 新增 5 项定向测试和现有 15 项安全回归全部通过,Node 14 正式构建成功。
|
|
139
|
+
- BrowserSkill 真实页面捕获到 unhandled rejection 和 `suppressedCount=21` 限流汇总。
|
|
140
|
+
- 页面真实下载 ZIP 为 `3270473` bytes,SHA-256 为 `a3a20b7861e7897a07ead470754116de80a9361ad8c5233e348ce324c5e65a3e`。
|
|
141
|
+
- 错误日志 184 条、操作日志 1958 条;分类错误数和重复 errorId 均为 0。
|
|
142
|
+
|
|
143
|
+
### 阶段 8:最终 UI 自动化与证据归档
|
|
144
|
+
- **状态:** complete
|
|
145
|
+
- 用户指定最终报告和真实截图统一归档到 JavaMain-combine 的 `test/ui-automation/log-diagnostics`。
|
|
146
|
+
- 本轮将使用新的 IndexedDB 基线,不复用阶段 6 的历史基线。
|
|
147
|
+
- BrowserSkill 新会话 `cvag` 已进入登录后的客服页面,首屏出现“系统已更新”弹窗。
|
|
148
|
+
- 已保存首张页面截图(1200x893,104567 bytes);视觉复核确认它实际是弹窗异步消失后的登录页(密码为掩码),不是更新弹窗,交付前更正文件名和报告说明。
|
|
149
|
+
- 使用浏览器预填登录信息触发登录,按钮进入“正在登录”状态;未提取凭据。
|
|
150
|
+
- 等待 3 秒后确认客服主界面已加载,更新提示在登录后再次显示。
|
|
151
|
+
- 登录后点击“稍后提醒”未改变弹窗状态,下一步改用关闭按钮。
|
|
152
|
+
- 弹窗随后异步消失;关闭按钮因无可见几何未执行,重新观察确认客服主界面已正常显示,标题为“新消息99+条”。
|
|
153
|
+
- 保存未读徽标截图 `02-current-unread-badge.png`(20x20,989 bytes)。
|
|
154
|
+
- 建立真实消息新鲜基线:`2026-11-07 13:26:04`,记录数/nextOrder `2455`,totalBytes `3448993`,数据库 v2。
|
|
155
|
+
- 页面内 `request-help` 已请求发送真实消息并得到测试人员确认“发了”;提示层运行期间会话独占,提示截图未生成。
|
|
156
|
+
- 捕获 3 条真实消息的完整诊断链路(order 2459~2479),同一会话未读 `0->1->2->3`、账号未读 `0->1->2->3`,3 次缓存结果均为 success(16/21/26ms)。
|
|
157
|
+
- 消息后数据库记录数/nextOrder `2488`,totalBytes `3469449`;未提取消息正文。
|
|
158
|
+
- 页面确认账号和会话未读徽标均为 `3`,保存账号徽标截图 `03-account-unread-after-message.png`(20x20,991 bytes)。
|
|
159
|
+
- 保存会话未读徽标截图 `04-session-unread-after-message.png`(20x20,971 bytes)。
|
|
160
|
+
- 已打开客服端右上角用户菜单,准备进入下载日志面板。
|
|
161
|
+
- 用户按钮点击未显示菜单,已改用悬停触发下拉菜单。
|
|
162
|
+
- DOM 状态确认右上角弹层已打开,`去管理端/下载日志/退出登录` 三个菜单项均可见;主入口下载不展示类型选择框。
|
|
163
|
+
- 保存菜单截图 `05-download-menu.png`(裁剪自真实页面,仅保留右上角菜单,不含聊天正文)。
|
|
164
|
+
- 通过真实菜单项下载完整 ZIP:浏览器建议名 `开发日志2026-11-07 13_32_10.zip`,归档大小 `3617469` bytes,SHA-256 `0ba99fcd15c47c2f473c0b04187f4571d02f19b388b1b5adf6060460182a8710`。
|
|
165
|
+
- 解析 ZIP:操作/错误/网络日志分别 `2296/218/150` 条,分类错误与重复 errorId 均为 `0`,三条真实消息均存在于下载操作日志。
|
|
166
|
+
- 刷新/启动复核:15 条 page_boot 中 9 条为 reload,本轮两次导航均记录完整启动生命周期。
|
|
167
|
+
- Request 复核:399 started、383 completed、15 failed,398 个终态带 traceid;383 个成功响应均已记录裁剪 response,截断字符串 2426 个。
|
|
168
|
+
- 生成最终报告 `JavaMain-combine/test/ui-automation/log-diagnostics/UI自动化测试报告.md`,包含 5 张真实截图和完整 ZIP 链接。
|
|
169
|
+
- 报告 6 个相对链接全部存在;Node 22 运行 20 项测试全部通过;两仓库 `git diff --check` 通过;ZIP SHA-256 复算一致。
|
|
170
|
+
- JavaMain-combine 的 `/test` 当前被 `.gitignore` 忽略,真实环境证据保留在本地指定目录,默认不进入 Git 提交。
|
|
171
|
+
- BrowserSkill 显式停止时会话已自动注销;最终状态 `sessions=[]`、`session_count=0`,无残留自动化会话。
|
|
172
|
+
|
|
173
|
+
### 阶段 9:undefined 与请求异常去重
|
|
174
|
+
- **状态:** complete
|
|
175
|
+
- 用户反馈导出日志存在大量 `"[undefined]"`,并要求错误日志排除已经由 Request 日志记录的请求异常。
|
|
176
|
+
- 方案:SDK 与 Request 裁剪统一省略对象 undefined;请求异常打不可枚举标记,全局异常捕获跳过;数组 undefined 保持索引并转为 null。
|
|
177
|
+
- SDK 安全序列化和 Request 快照已统一省略对象 undefined,数组 undefined 转为 null。
|
|
178
|
+
- 请求拦截、响应失败及 Blob 解析失败路径均写入不可枚举请求异常标记;运行时错误采集同时兼容 Axios 请求上下文识别。
|
|
179
|
+
- 修复无 response 的网络异常处理中直接读取 `response.config` 导致的二次 TypeError。
|
|
180
|
+
- Node 22 执行 `diagnostic-log.test.js + security-regression.test.js` 共 23 项全部通过,其中本轮诊断测试 8 项。
|
|
181
|
+
- Node 14/Vue CLI production build 成功;两个仓库 `git diff --check` 通过,源码无冲突标记及 `"[undefined]"` 生成逻辑。
|
|
182
|
+
|
|
183
|
+
### 阶段 10:undefined 与请求异常 UI 自动化回归
|
|
184
|
+
- **状态:** complete
|
|
185
|
+
- 使用 BrowserSkill 在真实客服页面建立新日志基线,验证新写入数据而非历史日志。
|
|
186
|
+
- 证据继续归档到 JavaMain-combine `test/ui-automation/log-diagnostics`,不覆盖阶段 8 的历史截图和 ZIP。
|
|
187
|
+
- 启动检查:页面 HTTP 200,BrowserSkill/Chrome 连接正常,无残留 session;前端 SDK 依赖已链接本地修改版本。
|
|
188
|
+
- BrowserSkill 会话 `pkke` 已打开登录页;账号密码为空,下一步通过 request-help 由测试人员完成登录,自动化不读取凭据。
|
|
189
|
+
- 测试人员完成凭据填写后,自动化点击登录,页面出现登录后的“系统已更新”弹窗;认证成功且未读取密码。
|
|
190
|
+
- 关闭更新弹窗后客服主界面正常加载;为避免暴露聊天正文,不保存全页面截图,后续证据采用日志统计与裁剪截图。
|
|
191
|
+
- 固定刷新前 IndexedDB 基线:v2,记录/nextOrder `322/322`,总字节 `465324`;已真实刷新同一客服页面以触发初始化请求链路。
|
|
192
|
+
- 刷新后新增 141 条日志(order 323~463):16 个 Request 全部成功,`"[undefined]"` 命中 0;出现 30 条非 Request 的 unhandled rejection,继续分析脱敏消息来源。
|
|
193
|
+
- 30 条异常均来自账号未读初始化的 `未找到<账号ID>未读数据`,不是请求错误重复;页面没有全局 Axios/request 实例,需改用网络故障注入或可控 UI 请求验证失败链路。
|
|
194
|
+
- 通过 Webpack 测试模块定位已加载的 `src/libs/request.js` Axios service;固定请求失败测试基线 nextOrder `477`,不读取认证信息。
|
|
195
|
+
- 真实发起不可达地址请求:request_started/request_failed 使用相同 requestId `1794031915232_22`,结果 network_error;新增 runtime_error 0、`"[undefined]"` 0,且页面保持可操作。
|
|
196
|
+
- 触发普通未处理 Promise rejection 后,order 487 生成 runtime_error(errorId `dd32cb43`、source unhandled_rejection);同期 request_failed 0、`"[undefined]"` 0。
|
|
197
|
+
- 准备页面下载时刷新提示仍在顶层,已通过关闭按钮移除,未执行“立即刷新”,避免改变已验证的日志基线。
|
|
198
|
+
- 已重新观察客服主界面并悬停右上角用户按钮,准备通过真实“下载日志”入口获取最终 ZIP。
|
|
199
|
+
- 语义树确认用户菜单已显示,真实“下载日志”按钮可操作;将保存裁剪截图并从此按钮触发下载。
|
|
200
|
+
- 真实入口下载完成;截图与 ZIP 已写入 `test/ui-automation/log-diagnostics`,等待视觉和归档内容校验。
|
|
201
|
+
- 截图视觉复核通过,仅含“下载日志”按钮;ZIP 为 805326 bytes,SHA-256 `13de562d264a68f018d8d04f9f1389c81fc95c356955fcad0405fe7af3218230`。
|
|
202
|
+
- 系统 unzip 中文名显示异常且 shasum 有 locale fallback 警告;不重复该方式解析文件名,改用项目 JSZip。首次规划补丁上下文不匹配,重新定位后已完成记录。
|
|
203
|
+
- JSZip 解析完成:操作/错误/网络日志 `406/94/18` 条,ZIP 全部文本 `"[undefined]"` 0;Request 探针只在操作日志,普通异常探针只在错误日志,分类交叉 0。
|
|
204
|
+
- 已更新最终 UI 自动化测试报告,并显式停止 BrowserSkill 会话 `pkke`;最终 `sessions=[]`,无残留自动化 session。
|
|
205
|
+
- 交付校验:报告 8 个相对链接全部存在,ZIP 5 个 JSON 全部可解析,大小/哈希复算一致,截图尺寸 130x36;两个仓库 `git diff --check` 均通过。
|
|
206
|
+
|
|
207
|
+
### 阶段 11:精简关联日志与页面启动上下文
|
|
208
|
+
- **状态:** complete
|
|
209
|
+
- 用户要求新增日志避免重复消息对象,优先保存关联 ID、阶段结果和差异值;能推导的数据不重复记录。
|
|
210
|
+
- 页面环境只在每次启动/刷新记录一次;登录账号在身份可用后补充一次,不扩散到每条消息日志。
|
|
211
|
+
- 认证上下文来源确认为 Vuex `global.account`,需等待用户信息接口完成;采用 `page_boot` 环境 + 既有 `user_init_result` 身份两条低频事件并用 pageInstanceId 关联,不新增身份事件。
|
|
212
|
+
- 检索时误用不存在的 `src/store` 且 zsh `.env*` 无匹配;已记录并改用实际 store 路径和显式文件查询。
|
|
213
|
+
- `page_boot` 现在每个页面实例只记录一次完整环境;既有 `user_init_result` 成功事件记录账号 ID、用户名、姓名和租户 ID,两者使用同一个 pageInstanceId。
|
|
214
|
+
- 后续诊断事件只自动附加 pageInstanceId/pageSequence,不再重复 appVersion/pageAgeMs;页面耗时可由时间戳推导。
|
|
215
|
+
- Socket 新消息日志移除 friendMessage/chatroomMessage 嵌套副本和正文,只保留 messageId、msgSvrId、处理结果;消息阶段以 messageId/msgSvrId/sessionId 串联。
|
|
216
|
+
- 正常消息路径没有新增高频事件;只在 Socket 通知过滤、会话更新同步/异步异常、账号未读刷新失败时各写一条低频日志。
|
|
217
|
+
- Node 22 执行 `diagnostic-log.test.js + security-regression.test.js` 共 28 项全部通过;Node 14/Vue CLI production build 成功;两仓库 `git diff --check` 通过。
|
|
218
|
+
|
|
219
|
+
### 阶段 12:保留 Socket 新消息完整快照
|
|
220
|
+
- **状态:** complete
|
|
221
|
+
- 用户明确要求 Socket 收到的新消息仍保留完整 `friendMessage/chatroomMessage`,精简仅适用于后续处理阶段。
|
|
222
|
+
- 完整快照只允许出现在处理成功/失败的 `message_received` 或通知过滤的 `message_received_suppressed` 之一,避免同一 Socket 消息重复保存两份。
|
|
223
|
+
- SDK 最终序列化仍执行 10,000 字符单值上限、二进制占位和敏感 token 排除,防止极端消息拖垮日志。
|
|
224
|
+
- 新增 `getSocketMessageLogData()`:完整浅拷贝 Socket 数据及 friendMessage/chatroomMessage,不再对消息 content/contBody 做 100 字符裁剪,同时移除外层和消息内 token/accessToken。
|
|
225
|
+
- 正常处理写 `message_received`,通知过滤写 `message_received_suppressed`;分支互斥,因此每条 Socket 新消息只有一份完整快照。
|
|
226
|
+
- 定向测试验证 150 字符正文和自定义嵌套字段完整保留,后续消息诊断仍无正文;Node 22 共 28 项测试通过,Node 14 正式构建成功,两仓库 `git diff --check` 通过。
|
|
227
|
+
|
|
228
|
+
### 阶段 13:清空日志后的 UI 自动化回归
|
|
229
|
+
- **状态:** in_progress
|
|
230
|
+
- 用户要求本轮必须先通过浏览器清理本地日志,再从空库建立测试证据;不清理 Cookie、登录态或其他业务 IndexedDB。
|
|
231
|
+
- 证据继续归档到 `JavaMain-combine/test/ui-automation/log-diagnostics`,报告追加本轮独立章节。
|
|
232
|
+
- 初始 `bsk status` 返回 daemon 未运行;页面服务 HTTP 200。按 BrowserSkill 流程使用相同 `BSK_HOME=/Users/yangyu/.bsk` 启动持久前台 daemon 后再独立复查。
|
|
233
|
+
- daemon 0.3.2 / protocol 1.3 已正常运行,但 `browsers=[]`;Chrome 和 BrowserSkill 专用 profile 进程均存在。`bsk doctor` 确认唯一失败项为扩展未连接,需测试人员点击浏览器扩展完成连接后继续,当前尚未清理任何数据。
|
|
234
|
+
- 重新打开 BrowserSkill 专用 Chrome 后扩展自动连接,browser instance `bb89af49`;启动 session `fmsh` 并进入真实客服页面。
|
|
235
|
+
- 关闭“系统已更新”弹窗后确认登录态正常,页面账号显示 `demo222(demo111)`,会话和未读区域已加载;尚未执行日志清理。
|
|
236
|
+
- 浏览器清理前只读基线:`log_client_chat` v2,stores=`logs/meta`,`count=889`、`nextOrder=889`、`totalBytes=1185992`。
|
|
237
|
+
- 检查清理实现时误在 SDK 工作目录附带检索前端 `src/libs/diagnostic-log.js`,该相对路径不存在;不重复此命令,SDK `clearLogData` 位置已正确找到。
|
|
238
|
+
- 通过浏览器页面 Vue `Chat` 组件调用真实 `clientChat.log.clearLogData()`,返回 `cleared=true`;该 API 已同时清空内存队列、日志 store 并重置 meta。
|
|
239
|
+
- 清理后立即独立读取 IndexedDB:旧 889 条已移除,但运行中页面随后产生 3 条新日志,`nextOrder=3`、`totalBytes=1695`;下一步确认事件名后再次清零并立即刷新建立新页面基线。
|
|
240
|
+
- 首次清理后运行页面继续产生的记录增长到 6 条,事件仅为 Socket sendMessage 心跳和两组 Request started/completed,确认不是旧日志残留。
|
|
241
|
+
- 第二次调用真实清理 API 后立即导航同一客服 URL,页面重新加载并关闭“系统已更新”提示;此后 IndexedDB 全部记录均属于清空后的本轮测试。
|
|
242
|
+
- 清空后稳定采样为 176 条、228592 bytes;page_boot order 17 为 navigate,user_init_result order 21 为 success,两者 pageInstanceId 均为 `1794035216520_6r55wx`,账号为 `demo111`。
|
|
243
|
+
- 清理到导航的极短窗口内旧页面收到两条真实消息,产生 order 1~16;这些属于清理后的新日志,因此没有误报 page_boot 为第一条。
|
|
244
|
+
- 重新打开 BrowserSkill 人工协助提示后,测试人员发送一条真实群聊消息;order 207~213 形成 stored/unread/resolved/emitted/received/account-unread/cache 完整链路。
|
|
245
|
+
- 本条 messageId `95735e115fc9d7a03a513702aa58fe9bc4b8dde4`、msgSvrId `4340647118050738830`、sessionId `f5a2b25f037c7b28f0e92bc1e17a057216a8203a`;会话与账号未读均 13->14,缓存 success/24ms。
|
|
246
|
+
- Socket `message_received` 保留唯一完整 chatroomMessage(34 个业务字段、正文长度 2);下游消息阶段没有重复正文,均通过关联 ID 串联。
|
|
247
|
+
- 保存账号和两个未读徽标的裁剪截图 `07~09`,视觉复核分别显示 `demo222(demo111)`、账号未读 14、会话未读 14,无聊天正文泄露。
|
|
248
|
+
- 刷新前基线 227 条/256001 bytes;真实 reload 后 page_boot order 228 为 reload,user_init_result order 232 与其共享 pageInstanceId `1794035487094_33kh08`,page_ready order 238 为 rendered。
|
|
249
|
+
- 从真实“下载日志”菜单下载 ZIP:589929 bytes,SHA-256 `03d6f894160442bf12810f019910ebacfb7855a6058e5d06c3a193a4dbf8c107`。
|
|
250
|
+
- JSZip 校验:操作日志 407 条/486426 bytes、网络日志 48 条/9200 bytes,另含微号数据 109 条和已加载会话 49 条;4 个 JSON 均可解析,`"[undefined]"` 命中 0。
|
|
251
|
+
- 本轮无 runtime_error,因此下载包不生成空错误文件;操作日志 runtime_error 为 0。指定真实 msgSvrId 在导出包命中 stored/emitted/received/cache 四条,完整内容只在 received。
|
|
252
|
+
- Request 实测为 44 started/44 completed,全部成功终态包含裁剪 response;本轮响应没有 traceid 字段,因此未记录伪造空值。
|
|
253
|
+
- 已将清空、启动、真实消息、刷新、Request、截图与下载证据追加至 `UI自动化测试报告.md`,阶段 13 完成。
|
|
254
|
+
|
|
255
|
+
### 阶段 14:生产发布前非侵入性审查
|
|
256
|
+
- **状态:** in_progress
|
|
257
|
+
- 用户要求在发布生产前确认本次日志改造不会影响既有功能,本阶段只做代码审查和验证,不修改业务源码。
|
|
258
|
+
- 前端当前分支 `master-3081-云客服补充一些日志记录`,SDK 当前分支 `master-3081云客服补充一些日志记录`。
|
|
259
|
+
- 前端存在 7 个已跟踪修改、4 个未跟踪日志/测试文件;SDK 存在 7 个业务/入口修改、`utils/log/` 未跟踪目录以及 1 个旧分析文档删除。
|
|
260
|
+
- 后续审查必须显式包含未跟踪文件,不能只依赖普通 `git diff`。
|
|
261
|
+
- 发现生产发布阻断:前端依赖与 lock 仍为 SDK 1.0.382,本地 UI/构建使用的是指向 SDK 工作区的符号链接;新前端依赖 `exportLogFiles()`,必须先发布 SDK 新版本并更新前端依赖/锁文件。
|
|
262
|
+
- 从 npm registry 下载正式 1.0.382 核验,确认其仍是旧日志实现且没有 exportLogFiles;阻断项已由推断升级为实证。
|
|
263
|
+
- `npm pack --dry-run` 确认 SDK 会把 utils/log 下内部规划、进度和测试证据文档打进公开包;文档含测试账号和真实诊断 ID,发布前需增加包文件排除规则。
|
|
264
|
+
- Node 22 定向与安全回归 28/28 通过;Node 14 production build 成功,只有 31 个项目既有 CSS 顺序/体积 warning。
|
|
265
|
+
- 性能抽测:大响应裁剪约 0.0471ms/次,完整消息安全序列化约 0.0248ms/次;正常 3 秒一条消息不构成可见 CPU 压力。
|
|
266
|
+
- Socket 故障注入确认一个低概率但真实的隔离缺口:完整快照在业务 onCmdNewMessage 前构造,抛错 getter 会直接阻断业务回调;建议发布前调整顺序并包 try/catch。
|
|
267
|
+
- 阶段 14 审查完成;当前结论不是“可直接生产发布”,需先处理 SDK 发版/前端锁版本、npm 包文档排除和 Socket 快照隔离,再用正式 tarball 复验。
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
const DEFAULT_OPTIONS = {
|
|
2
|
+
maxDepth: 10,
|
|
3
|
+
maxArrayLength: 500,
|
|
4
|
+
maxObjectKeys: 500,
|
|
5
|
+
maxStringLength: 10000
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function isFile (value) {
|
|
9
|
+
return typeof File !== 'undefined' && value instanceof File
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function isBlob (value) {
|
|
13
|
+
return typeof Blob !== 'undefined' && value instanceof Blob
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function isBinary (value) {
|
|
17
|
+
return typeof ArrayBuffer !== 'undefined' && (
|
|
18
|
+
value instanceof ArrayBuffer ||
|
|
19
|
+
(typeof ArrayBuffer.isView === 'function' && ArrayBuffer.isView(value))
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function cropString (value, maxLength) {
|
|
24
|
+
if (value.length <= maxLength) {
|
|
25
|
+
return value
|
|
26
|
+
}
|
|
27
|
+
return `${value.slice(0, maxLength)}...+${value.length - maxLength}`
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function normalizeForJson (input, options = {}) {
|
|
31
|
+
const settings = Object.assign({}, DEFAULT_OPTIONS, options)
|
|
32
|
+
const ancestors = []
|
|
33
|
+
|
|
34
|
+
function normalize (value, depth) {
|
|
35
|
+
if (value === null || typeof value === 'boolean' || typeof value === 'number') {
|
|
36
|
+
return value
|
|
37
|
+
}
|
|
38
|
+
if (typeof value === 'string') {
|
|
39
|
+
return cropString(value, settings.maxStringLength)
|
|
40
|
+
}
|
|
41
|
+
if (typeof value === 'undefined') {
|
|
42
|
+
return undefined
|
|
43
|
+
}
|
|
44
|
+
if (typeof value === 'bigint') {
|
|
45
|
+
return `${value.toString()}n`
|
|
46
|
+
}
|
|
47
|
+
if (typeof value === 'function') {
|
|
48
|
+
return '[function]'
|
|
49
|
+
}
|
|
50
|
+
if (typeof value === 'symbol') {
|
|
51
|
+
return '[symbol]'
|
|
52
|
+
}
|
|
53
|
+
if (isFile(value)) {
|
|
54
|
+
return '[file]'
|
|
55
|
+
}
|
|
56
|
+
if (isBlob(value)) {
|
|
57
|
+
return '[blob]'
|
|
58
|
+
}
|
|
59
|
+
if (isBinary(value)) {
|
|
60
|
+
return '[binary]'
|
|
61
|
+
}
|
|
62
|
+
if (value instanceof Date) {
|
|
63
|
+
try {
|
|
64
|
+
return value.toISOString()
|
|
65
|
+
} catch (error) {
|
|
66
|
+
return '[invalid date]'
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (value instanceof Error) {
|
|
70
|
+
return {
|
|
71
|
+
name: cropString(String(value.name || 'Error'), settings.maxStringLength),
|
|
72
|
+
message: cropString(String(value.message || ''), settings.maxStringLength),
|
|
73
|
+
code: value.code,
|
|
74
|
+
stack: cropString(String(value.stack || ''), settings.maxStringLength)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (depth >= settings.maxDepth) {
|
|
78
|
+
return '[max depth]'
|
|
79
|
+
}
|
|
80
|
+
if (ancestors.indexOf(value) >= 0) {
|
|
81
|
+
return '[circular]'
|
|
82
|
+
}
|
|
83
|
+
ancestors.push(value)
|
|
84
|
+
let result
|
|
85
|
+
try {
|
|
86
|
+
if (Array.isArray(value)) {
|
|
87
|
+
result = value.slice(0, settings.maxArrayLength).map(item => {
|
|
88
|
+
const normalized = normalize(item, depth + 1)
|
|
89
|
+
return normalized === undefined ? null : normalized
|
|
90
|
+
})
|
|
91
|
+
if (value.length > settings.maxArrayLength) {
|
|
92
|
+
result.push(`[+${value.length - settings.maxArrayLength} items]`)
|
|
93
|
+
}
|
|
94
|
+
} else if (typeof Map !== 'undefined' && value instanceof Map) {
|
|
95
|
+
result = normalize(Array.from(value.entries()), depth + 1)
|
|
96
|
+
} else if (typeof Set !== 'undefined' && value instanceof Set) {
|
|
97
|
+
result = normalize(Array.from(value.values()), depth + 1)
|
|
98
|
+
} else {
|
|
99
|
+
result = {}
|
|
100
|
+
let keys
|
|
101
|
+
try {
|
|
102
|
+
keys = Object.keys(value)
|
|
103
|
+
} catch (error) {
|
|
104
|
+
return '[unavailable]'
|
|
105
|
+
}
|
|
106
|
+
keys.slice(0, settings.maxObjectKeys).forEach(key => {
|
|
107
|
+
try {
|
|
108
|
+
const normalized = normalize(value[key], depth + 1)
|
|
109
|
+
if (normalized !== undefined) {
|
|
110
|
+
result[key] = normalized
|
|
111
|
+
}
|
|
112
|
+
} catch (error) {
|
|
113
|
+
result[key] = '[unavailable]'
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
if (keys.length > settings.maxObjectKeys) {
|
|
117
|
+
result['[truncated keys]'] = keys.length - settings.maxObjectKeys
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
} finally {
|
|
121
|
+
ancestors.pop()
|
|
122
|
+
}
|
|
123
|
+
return result
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return normalize(input, 0)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function safeStringify (value, options) {
|
|
130
|
+
try {
|
|
131
|
+
return JSON.stringify(normalizeForJson(value, options))
|
|
132
|
+
} catch (error) {
|
|
133
|
+
return undefined
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function getByteSize (value) {
|
|
138
|
+
if (typeof Blob !== 'undefined') {
|
|
139
|
+
return new Blob([value]).size
|
|
140
|
+
}
|
|
141
|
+
try {
|
|
142
|
+
return unescape(encodeURIComponent(value)).length
|
|
143
|
+
} catch (error) {
|
|
144
|
+
return value.length
|
|
145
|
+
}
|
|
146
|
+
}
|