|
11 | 11 | // Default 10MB.
|
12 | 12 | maximum?: number;
|
13 | 13 |
|
14 |
| - // Specit which types of data to cache |
| 14 | + // Specify which types of data to cache |
15 | 15 | caredData?: Record<DataType, boolean>;
|
16 | 16 |
|
17 | 17 | // Specify the offline log filename, with the default being named according to the current time
|
|
21 | 21 | onDownload?: (data: CacheMessageItem[]) => void;
|
22 | 22 | }
|
23 | 23 |
|
24 |
| - delcare class DataHarborPlugin implements PageSpyPlugin { |
| 24 | + declare class DataHarborPlugin implements PageSpyPlugin { |
25 | 25 | constructor(config?: DataHarborConfig);
|
26 | 26 | }
|
27 | 27 | ```
|
28 | 28 |
|
| 29 | + |
29 | 30 | #### onOfflineLog()#onOfflineLog
|
30 | 31 |
|
31 |
| -Upload / download log manaually. |
| 32 | +Manually download / upload offline logs. |
32 | 33 |
|
33 | 34 | - Type
|
34 | 35 |
|
35 | 36 | ```ts
|
36 | 37 | declare class DataHarborPlugin {
|
37 |
| - onOfflineLog(type: 'download' | 'upload'): Promise<string | null | undefined>; |
| 38 | + onOfflineLog(type: 'download' | 'upload', clearCache?: boolean): Promise<string | null | undefined>; |
38 | 39 | }
|
39 | 40 | ```
|
40 | 41 |
|
41 |
| -- Details |
42 |
| - |
43 |
| - If you hide the automatically rendered floating or want to automatically trigger offline log operations at certain times, you can achieve through this method. |
44 |
| - |
45 |
| - Each invocation logs the entire current session. Once the upload is complete, a replay URL will be returned. |
| 42 | + If you hide the automatically rendered UI controls by `autoRender: false`, or you want to automatically trigger the offline log operation at certain times, you can use this method. |
46 | 43 |
|
| 44 | + After each call, the recorded log data will be cleared by default and recording will be restarted; on the contrary, if the user upload / download the log multiple times through the buttons on the UI dialog, it will be a complete log from beginning to end of the current session. You can also control it yourself through the second parameter `clearCache: boolean`. |
| 45 | + |
| 46 | + After the upload is completed, the replay URL will be returned and printed to the console. |
| 47 | + |
47 | 48 | - Example
|
48 | 49 |
|
49 | 50 | ```ts
|
| 51 | + - details |
50 | 52 | window.$harbor = new DataHarborPlugin();
|
51 | 53 |
|
52 |
| - // upload |
| 54 | + // Upload (clear existing data and re-record) |
53 | 55 | const url = await window.$harbor.onOfflineLog('upload');
|
54 | 56 |
|
| 57 | + // Upload (do not clear data) |
| 58 | + const url = await window.$harbor.onOfflineLog('upload', false); |
| 59 | + |
55 | 60 | // download
|
56 | 61 | window.$harbor.onOfflineLog('download');
|
57 | 62 | ```
|
58 | 63 |
|
59 | 64 |
|
| 65 | +#### pause()#pause |
| 66 | + |
| 67 | +Pause recording. |
| 68 | + |
| 69 | +- Type |
| 70 | + |
| 71 | + ```ts |
| 72 | + declare class DataHarborPlugin { |
| 73 | + pause(): void; |
| 74 | + } |
| 75 | + ``` |
| 76 | + |
| 77 | + More flexible control of logging behavior. |
| 78 | + |
| 79 | + The data generated by the program after the pause will not be recorded. Call `$harbor.resume()` to resume. |
| 80 | + |
| 81 | +- Example |
| 82 | + |
| 83 | + ```ts |
| 84 | + window.$harbor = new DataHarborPlugin(); |
| 85 | + |
| 86 | + // pause |
| 87 | + window.$harbor.pause(); |
| 88 | + |
| 89 | + // resume |
| 90 | + window.$harbor.resume(); |
| 91 | + ``` |
| 92 | + |
| 93 | + |
| 94 | +#### resume()#resume |
| 95 | + |
| 96 | + |
| 97 | +Resume records. |
| 98 | + |
| 99 | +- Type |
| 100 | + |
| 101 | + ```ts |
| 102 | + declare class DataHarborPlugin { |
| 103 | + resume(): void; |
| 104 | + } |
| 105 | + ``` |
| 106 | + |
| 107 | + More flexible control of logging behavior. |
| 108 | + |
| 109 | +- Details |
| 110 | + |
| 111 | + Data during <Pause - Resume> will not be recorded. |
| 112 | + |
| 113 | +- Example |
| 114 | + |
| 115 | + ```ts |
| 116 | + window.$harbor = new DataHarborPlugin(); |
| 117 | + |
| 118 | + // pause |
| 119 | + window.$harbor.pause(); |
| 120 | + |
| 121 | + // resume |
| 122 | + window.$harbor.resume(); |
| 123 | + ``` |
| 124 | + |
| 125 | +#### reharbor()#reharbor |
| 126 | + |
| 127 | +Clear the recorded data and continue recording. In short, remastered. |
| 128 | + |
| 129 | +- Type |
| 130 | + |
| 131 | + ```ts |
| 132 | + declare class DataHarborPlugin { |
| 133 | + reharbor(): void; |
| 134 | + } |
| 135 | + ``` |
| 136 | + |
| 137 | +- Example |
| 138 | + |
| 139 | + ```ts |
| 140 | + window.$harbor = new DataHarborPlugin(); |
| 141 | + |
| 142 | + window.$harbor.reharbor(); |
| 143 | + ``` |
0 commit comments