This repository was archived by the owner on Oct 24, 2022. It is now read-only.
File tree 2 files changed +21
-16
lines changed
2 files changed +21
-16
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " sensorsdata-sdk" ,
3
- "version" : " 0.1.0 " ,
3
+ "version" : " 0.1.1 " ,
4
4
"description" : " SDK of sensorsdata Written in Typescript" ,
5
5
"main" : " dist/src/sensors-analytics.js" ,
6
6
"scripts" : {
Original file line number Diff line number Diff line change @@ -129,22 +129,27 @@ export class SensorsAnalytics extends Writable {
129
129
130
130
this . dataQueue . push ( envelope )
131
131
const now = Date . now ( )
132
- if (
133
- this . debug ||
134
- this . dataQueue . length >= this . options . buffCount ||
135
- now >= this . nextSubmitTime
136
- ) {
137
- if ( this . timer ) {
138
- clearTimeout ( this . timer )
132
+ try {
133
+ if (
134
+ this . debug ||
135
+ this . dataQueue . length >= this . options . buffCount ||
136
+ now >= this . nextSubmitTime
137
+ ) {
138
+ if ( this . timer ) {
139
+ clearTimeout ( this . timer )
140
+ }
141
+ await this . flush ( )
142
+ } else {
143
+ if ( this . timer ) {
144
+ clearTimeout ( this . timer )
145
+ }
146
+ this . timer = setTimeout ( ( ) => this . flush ( ) , this . nextSubmitTime - now )
139
147
}
140
- await this . flush ( )
141
- } else {
142
- if ( this . timer ) {
143
- clearTimeout ( this . timer )
144
- }
145
- this . timer = setTimeout ( ( ) => this . flush ( ) , this . nextSubmitTime - now )
148
+
149
+ callback ( )
150
+ } catch ( err ) {
151
+ callback ( err )
146
152
}
147
- callback ( )
148
153
}
149
154
150
155
async submit ( messages : object [ ] ) {
@@ -255,7 +260,7 @@ export class SensorsAnalytics extends Writable {
255
260
await this . submit ( this . popAllData ( ) )
256
261
}
257
262
async close ( ) {
258
- await new Promise ( resolve => {
263
+ await new Promise ( ( resolve ) => {
259
264
super . end ( ( ) => resolve ( ) )
260
265
} )
261
266
await this . flush ( )
You can’t perform that action at this time.
0 commit comments