@transistorsoft/background-geolocation-types 5.0.0-beta.2 → 5.0.0-beta.4
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/dist/core/api/BackgroundGeolocation.d.ts +115 -359
- package/dist/core/api/CurrentPositionRequest.d.ts +0 -36
- package/dist/core/api/DeviceSettings.d.ts +0 -63
- package/dist/core/api/Logger.d.ts +0 -400
- package/dist/core/api/State.d.ts +0 -63
- package/dist/core/api/TransistorAuthorizationService.d.ts +0 -110
- package/dist/core/config/ActivityConfig.d.ts +0 -260
- package/dist/core/config/AppConfig.d.ts +0 -581
- package/dist/core/config/AuthorizationConfig.d.ts +0 -191
- package/dist/core/config/Config.d.ts +0 -176
- package/dist/core/config/GeoConfig.d.ts +0 -876
- package/dist/core/config/HttpConfig.d.ts +0 -565
- package/dist/core/config/LocationFilter.d.ts +0 -256
- package/dist/core/config/LoggerConfig.d.ts +0 -313
- package/dist/core/config/NotificationConfig.d.ts +0 -504
- package/dist/core/config/PersistenceConfig.d.ts +0 -541
- package/dist/core/data/DeviceInfo.d.ts +0 -54
- package/dist/core/data/Geofence.d.ts +0 -5
- package/dist/core/data/Location.d.ts +0 -213
- package/dist/core/data/Sensors.d.ts +0 -22
- package/dist/core/events/AuthorizationEvent.d.ts +0 -9
- package/dist/core/events/ConnectivityChangeEvent.d.ts +0 -6
- package/dist/core/events/GeofenceEvent.d.ts +0 -10
- package/dist/core/events/GeofencesChangeEvent.d.ts +0 -7
- package/dist/core/events/HeadlessEvent.d.ts +0 -7
- package/dist/core/events/HeartbeatEvent.d.ts +0 -10
- package/dist/core/events/HttpEvent.d.ts +0 -8
- package/dist/core/events/MotionActivityEvent.d.ts +0 -7
- package/dist/core/events/MotionChangeEvent.d.ts +0 -7
- package/dist/core/events/ProviderChangeEvent.d.ts +0 -10
- package/dist/core/events/Subscription.d.ts +0 -83
- package/dist/docs-entry.js +0 -3
- package/dist/enums/AccuracyAuthorization.d.ts +1 -12
- package/dist/enums/AccuracyAuthorization.js +0 -12
- package/dist/enums/ActivityType.d.ts +1 -21
- package/dist/enums/ActivityType.js +0 -21
- package/dist/enums/AuthorizationStatus.d.ts +1 -13
- package/dist/enums/AuthorizationStatus.js +0 -13
- package/dist/enums/AuthorizationStrategy.d.ts +1 -6
- package/dist/enums/AuthorizationStrategy.js +0 -6
- package/dist/enums/DesiredAccuracy.d.ts +1 -5
- package/dist/enums/DesiredAccuracy.js +0 -5
- package/dist/enums/Event.d.ts +1 -5
- package/dist/enums/Event.js +0 -5
- package/dist/enums/GeofenceAction.d.ts +1 -13
- package/dist/enums/GeofenceAction.js +0 -13
- package/dist/enums/HttpMethod.d.ts +1 -6
- package/dist/enums/HttpMethod.js +0 -6
- package/dist/enums/KalmanProfile.d.ts +1 -25
- package/dist/enums/KalmanProfile.js +0 -25
- package/dist/enums/LocationError.d.ts +1 -15
- package/dist/enums/LocationError.js +0 -15
- package/dist/enums/LocationFilterPolicy.d.ts +1 -103
- package/dist/enums/LocationFilterPolicy.js +0 -103
- package/dist/enums/LocationRequest.d.ts +1 -15
- package/dist/enums/LocationRequest.js +0 -15
- package/dist/enums/LogLevel.d.ts +1 -16
- package/dist/enums/LogLevel.js +0 -16
- package/dist/enums/LogLevelName.d.ts +8 -1
- package/dist/enums/LogLevelName.js +0 -5
- package/dist/enums/MotionActivityType.d.ts +1 -5
- package/dist/enums/MotionActivityType.js +0 -5
- package/dist/enums/NotificationPriority.d.ts +1 -15
- package/dist/enums/NotificationPriority.js +0 -15
- package/dist/enums/PersistMode.d.ts +1 -6
- package/dist/enums/PersistMode.js +0 -6
- package/dist/enums/SQLQueryOrder.d.ts +0 -11
- package/dist/enums/SQLQueryOrder.js +0 -10
- package/dist/enums/TrackingMode.d.ts +1 -10
- package/dist/enums/TrackingMode.js +0 -10
- package/dist/enums/TriggerActivity.d.ts +1 -6
- package/dist/enums/TriggerActivity.js +0 -6
- package/dist/index.js +0 -4
- package/dist/legacy/LegacyConfig.d.ts +0 -19
- package/package.json +8 -9
- package/dist/core/config/CompoundConfig.d.ts +0 -19
- package/dist/core/config/CompoundConfig.js +0 -2
|
@@ -1,421 +1,21 @@
|
|
|
1
1
|
import { SQLQueryOrder } from "../../enums/SQLQueryOrder";
|
|
2
|
-
/**
|
|
3
|
-
* Used for selecting a range of records from the SDK's log database.
|
|
4
|
-
*
|
|
5
|
-
* Used with:
|
|
6
|
-
* - {@link Logger.getLog}
|
|
7
|
-
* - {@link Logger.emailLog}
|
|
8
|
-
* - {@link Logger.uploadLog}
|
|
9
|
-
*
|
|
10
|
-
* ```ts
|
|
11
|
-
* // Constrain results between optional start/end dates using an SQLQuery
|
|
12
|
-
* const log = await BackgroundGeolocation.logger.getLog({
|
|
13
|
-
* start: Date.parse("2019-10-21 13:00"), // <-- optional HH:mm:ss
|
|
14
|
-
* end: Date.parse("2019-10-22")
|
|
15
|
-
* });
|
|
16
|
-
*
|
|
17
|
-
* // Or just a start date
|
|
18
|
-
* const partial = await BackgroundGeolocation.logger.getLog({
|
|
19
|
-
* start: Date.parse("2019-10-21 13:00")
|
|
20
|
-
* });
|
|
21
|
-
*
|
|
22
|
-
* // Or just an end date
|
|
23
|
-
* await BackgroundGeolocation.logger.uploadLog("https://my.server.com/users/123/logs", {
|
|
24
|
-
* end: Date.parse("2019-10-21")
|
|
25
|
-
* });
|
|
26
|
-
*
|
|
27
|
-
* // Select first 100 records from log (ascending)
|
|
28
|
-
* const Logger = BackgroundGeolocation.logger;
|
|
29
|
-
* await Logger.emailLog("foo@bar.com", {
|
|
30
|
-
* order: SQLQueryOrder.Asc,
|
|
31
|
-
* limit: 100
|
|
32
|
-
* });
|
|
33
|
-
*
|
|
34
|
-
* // Select most recent 100 records from log (descending)
|
|
35
|
-
* await Logger.emailLog("foo@bar.com", {
|
|
36
|
-
* order: SQLQueryOrder.Desc,
|
|
37
|
-
* limit: 100
|
|
38
|
-
* });
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* @category Logger
|
|
42
|
-
*/
|
|
43
2
|
export interface SQLQuery {
|
|
44
|
-
/**
|
|
45
|
-
* Start date of logs to select (unix timestamp in **milliseconds**).
|
|
46
|
-
*/
|
|
47
3
|
start?: number;
|
|
48
|
-
/**
|
|
49
|
-
* End date of logs to select (unix timestamp in **milliseconds**).
|
|
50
|
-
*/
|
|
51
4
|
end?: number;
|
|
52
|
-
/**
|
|
53
|
-
* Limit number of records returned.
|
|
54
|
-
*/
|
|
55
5
|
limit?: number;
|
|
56
|
-
/**
|
|
57
|
-
* Offset into the result set (for paging).
|
|
58
|
-
*/
|
|
59
6
|
offset?: number;
|
|
60
|
-
/**
|
|
61
|
-
* Sort order for results.
|
|
62
|
-
*
|
|
63
|
-
* - `SQLQueryOrder.Asc` → ascending by time
|
|
64
|
-
* - `SQLQueryOrder.Desc` → descending by time
|
|
65
|
-
*
|
|
66
|
-
* Historically this corresponded to:
|
|
67
|
-
* - `1` = ASC
|
|
68
|
-
* - `-1` = DESC
|
|
69
|
-
*/
|
|
70
7
|
order?: SQLQueryOrder;
|
|
71
8
|
}
|
|
72
|
-
/**
|
|
73
|
-
* Logger API
|
|
74
|
-
*
|
|
75
|
-
* The Background Geolocation SDK includes powerful logging features for debugging location-tracking problems. The SDK stores log-entries for a period of {@link LoggerConfig.logMaxDays} (default `3`). The volume of logging events
|
|
76
|
-
* inserted into the database is controlled via {@link LoggerConfig.logLevel}.
|
|
77
|
-
*
|
|
78
|
-
* For more information, see the 📘[Debugging Guide](github:wiki/Debugging).
|
|
79
|
-
*
|
|
80
|
-
* The `Logger` API is accessed via {@link BackgroundGeolocation.logger} property:
|
|
81
|
-
*
|
|
82
|
-
* @example
|
|
83
|
-
* ```typescript
|
|
84
|
-
* let Logger = BackgroundGeolocation.logger;
|
|
85
|
-
* let log = await Logger.getLog();
|
|
86
|
-
* ```
|
|
87
|
-
*
|
|
88
|
-
* ## Fetching the Logs:
|
|
89
|
-
*
|
|
90
|
-
* Logs can be fetched from the SDK in three ways:
|
|
91
|
-
* 1. [[getLog]]
|
|
92
|
-
* 2. [[emailLog]]
|
|
93
|
-
* 3. [[uploadLog]]
|
|
94
|
-
*
|
|
95
|
-
* ## Inserting your own log messages
|
|
96
|
-
*
|
|
97
|
-
* You can even insert your own log messages into the SDK's Log database using the following methods:
|
|
98
|
-
*
|
|
99
|
-
* | method | logLevel | icon |
|
|
100
|
-
* |--------------|----------|-----------------|
|
|
101
|
-
* |[[error]] |`ERROR` | ❗️ |
|
|
102
|
-
* |[[warn]] |`WARNING` | ⚠️ |
|
|
103
|
-
* |[[debug]] |`DEBUG` | 🐞 |
|
|
104
|
-
* |[[info]] |`INFO` | ℹ️ |
|
|
105
|
-
* |[[notice]] |`INFO` | 🔵 |
|
|
106
|
-
*
|
|
107
|
-
* @example
|
|
108
|
-
* ```typescript
|
|
109
|
-
* let Logger = BackgroundGeolocation.logger;
|
|
110
|
-
* BackgroundGeolocation.onLocation((location) => {
|
|
111
|
-
* Logger.debug("Location received in Javascript: " + location.uuid);
|
|
112
|
-
* });
|
|
113
|
-
* ```
|
|
114
|
-
*
|
|
115
|
-
* __Example Logs__
|
|
116
|
-
*
|
|
117
|
-
* ```
|
|
118
|
-
* 09-19 11:12:18.716 ╔═════════════════════════════════════════════
|
|
119
|
-
* 09-19 11:12:18.716 ║ BackgroundGeolocation Service started
|
|
120
|
-
* 09-19 11:12:18.716 ╠═════════════════════════════════════════════
|
|
121
|
-
* 09-19 11:12:18.723 [c.t.l.BackgroundGeolocationService d]
|
|
122
|
-
* 09-19 11:12:18.723 ✅ Started in foreground
|
|
123
|
-
* 09-19 11:12:18.737 [c.t.l.ActivityRecognitionService a]
|
|
124
|
-
* 09-19 11:12:18.737 🎾 Start activity updates: 10000
|
|
125
|
-
* 09-19 11:12:18.761 [c.t.l.BackgroundGeolocationService k]
|
|
126
|
-
* 09-19 11:12:18.761 🔴 Stop heartbeat
|
|
127
|
-
* 09-19 11:12:18.768 [c.t.l.BackgroundGeolocationService a]
|
|
128
|
-
* 09-19 11:12:18.768 🎾 Start heartbeat (60)
|
|
129
|
-
* 09-19 11:12:18.778 [c.t.l.BackgroundGeolocationService a]
|
|
130
|
-
* 09-19 11:12:18.778 🔵 setPace: null → false
|
|
131
|
-
* 09-19 11:12:18.781 [c.t.l.adapter.TSConfig c] ℹ️ Persist config
|
|
132
|
-
* 09-19 11:12:18.794 [c.t.locationmanager.util.b a]
|
|
133
|
-
* 09-19 11:12:18.794 ℹ️ LocationAuthorization: Permission granted
|
|
134
|
-
* 09-19 11:12:18.842 [c.t.l.http.HttpService flush]
|
|
135
|
-
* 09-19 11:12:18.842 ╔═════════════════════════════════════════════
|
|
136
|
-
* 09-19 11:12:18.842 ║ HTTP Service
|
|
137
|
-
* 09-19 11:12:18.842 ╠═════════════════════════════════════════════
|
|
138
|
-
* 09-19 11:12:19.000 [c.t.l.BackgroundGeolocationService onActivityRecognitionResult] still (100%)
|
|
139
|
-
* 09-19 11:12:21.314 [c.t.l.l.SingleLocationRequest$2 onLocationResult]
|
|
140
|
-
* 09-19 11:12:21.314 ╔═════════════════════════════════════════════
|
|
141
|
-
* 09-19 11:12:21.314 ║ SingleLocationRequest: 1
|
|
142
|
-
* 09-19 11:12:21.314 ╠═════════════════════════════════════════════
|
|
143
|
-
* 09-19 11:12:21.314 ╟─ 📍 Location[fused 45.519239,-73.617058 hAcc=15]999923706055 vAcc=2 sAcc=??? bAcc=???
|
|
144
|
-
* 09-19 11:12:21.327 [c.t.l.l.TSLocationManager onSingleLocationResult]
|
|
145
|
-
* 09-19 11:12:21.327 🔵 Acquired motionchange position, isMoving: false
|
|
146
|
-
* 09-19 11:12:21.342 [c.t.l.l.TSLocationManager a] 15.243
|
|
147
|
-
* 09-19 11:12:21.405 [c.t.locationmanager.data.a.c persist]
|
|
148
|
-
* 09-19 11:12:21.405 ✅ INSERT: bca5acc8-e358-4d8f-827f-b8c0d556b7bb
|
|
149
|
-
* 09-19 11:12:21.423 [c.t.l.http.HttpService flush]
|
|
150
|
-
* 09-19 11:12:21.423 ╔═════════════════════════════════════════════
|
|
151
|
-
* 09-19 11:12:21.423 ║ HTTP Service
|
|
152
|
-
* 09-19 11:12:21.423 ╠═════════════════════════════════════════════
|
|
153
|
-
* 09-19 11:12:21.446 [c.t.locationmanager.data.a.c first]
|
|
154
|
-
* 09-19 11:12:21.446 ✅ Locked 1 records
|
|
155
|
-
* 09-19 11:12:21.454 [c.t.l.http.HttpService a]
|
|
156
|
-
* 09-19 11:12:21.454 🔵 HTTP POST: bca5acc8-e358-4d8f-827f-b8c0d556b7bb
|
|
157
|
-
* 09-19 11:12:22.083 [c.t.l.http.HttpService$a onResponse]
|
|
158
|
-
* 09-19 11:12:22.083 🔵 Response: 200
|
|
159
|
-
* 09-19 11:12:22.100 [c.t.locationmanager.data.a.c destroy]
|
|
160
|
-
* 09-19 11:12:22.100 ✅ DESTROY: bca5acc8-e358-4d8f-827f-b8c0d556b7bb
|
|
161
|
-
* 09-19 11:12:55.226 [c.t.l.BackgroundGeolocationService onActivityRecognitionResult] still (100%)
|
|
162
|
-
* ```
|
|
163
|
-
*
|
|
164
|
-
* @category Logger
|
|
165
|
-
*/
|
|
166
9
|
export interface Logger {
|
|
167
|
-
/** Sort ascending when querying logs. Mirrors {@link Logger.ORDER_ASC} constant. */
|
|
168
10
|
readonly ORDER_ASC: 1;
|
|
169
|
-
/** Sort descending when querying logs. Mirrors {@link Logger.ORDER_DESC} constant. */
|
|
170
11
|
readonly ORDER_DESC: -1;
|
|
171
|
-
/**
|
|
172
|
-
* Inserts a debug log message into the SDK's log database
|
|
173
|
-
*
|
|
174
|
-
* @example
|
|
175
|
-
* ```typescript
|
|
176
|
-
* BackgroundGeolocation.logger.debug("This is a debug message");
|
|
177
|
-
* ```
|
|
178
|
-
*
|
|
179
|
-
* ```
|
|
180
|
-
* D TSLocationManager: [c.t.l.logger.TSLog log] This is a debug message
|
|
181
|
-
* ```
|
|
182
|
-
*/
|
|
183
12
|
debug(message: string): void;
|
|
184
|
-
/**
|
|
185
|
-
* Inserts an "error" log message into the SDK's log database
|
|
186
|
-
*
|
|
187
|
-
* @example
|
|
188
|
-
* ```typescript
|
|
189
|
-
* BackgroundGeolocation.logger.error("Something BAD");
|
|
190
|
-
* ```
|
|
191
|
-
*
|
|
192
|
-
* ```
|
|
193
|
-
* E TSLocationManager: [c.t.l.logger.TSLog log]
|
|
194
|
-
* E TSLocationManager: ‼ Something BAD
|
|
195
|
-
* ```
|
|
196
|
-
*/
|
|
197
13
|
error(message: string): void;
|
|
198
|
-
/**
|
|
199
|
-
* Inserts a "warning" log message into the SDK's log database
|
|
200
|
-
*
|
|
201
|
-
* @example
|
|
202
|
-
* ```typescript
|
|
203
|
-
* BackgroundGeolocation.logger.warn("Something WEIRD");
|
|
204
|
-
* ```
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
* ```
|
|
208
|
-
* E TSLocationManager: [c.t.l.logger.TSLog log]
|
|
209
|
-
* E TSLocationManager: ⚠️ Something WEIRD
|
|
210
|
-
* ```
|
|
211
|
-
*/
|
|
212
14
|
warn(message: string): void;
|
|
213
|
-
/**
|
|
214
|
-
* Inserts an "info" log message into the SDK's log database
|
|
215
|
-
*
|
|
216
|
-
* @example
|
|
217
|
-
* ```typescript
|
|
218
|
-
* BackgroundGeolocation.logger.info("Something informative");
|
|
219
|
-
* ```
|
|
220
|
-
*
|
|
221
|
-
* ```
|
|
222
|
-
* E TSLocationManager: [c.t.l.logger.TSLog log]
|
|
223
|
-
* I TSLocationManager: ℹ️ Something informative
|
|
224
|
-
* ```
|
|
225
|
-
*/
|
|
226
15
|
info(message: string): void;
|
|
227
|
-
/**
|
|
228
|
-
* Inserts a "notice" log message into the SDK's log database
|
|
229
|
-
*
|
|
230
|
-
* @example
|
|
231
|
-
* ```typescript
|
|
232
|
-
* BackgroundGeolocation.logger.notice("A Notice");
|
|
233
|
-
* ```
|
|
234
|
-
*
|
|
235
|
-
* ```
|
|
236
|
-
* E TSLocationManager: [c.t.l.logger.TSLog log]
|
|
237
|
-
* I TSLocationManager: 🔵 A Notice
|
|
238
|
-
* ```
|
|
239
|
-
*/
|
|
240
16
|
notice(message: string): void;
|
|
241
|
-
/**
|
|
242
|
-
* Returns the records from log database as a `String`. Provide an optional {@link SQLQuery} to contrain results between dates.
|
|
243
|
-
*
|
|
244
|
-
* Depending on the configured {@link LoggerConfig.logLevel}, the plugin can store an *immense* amount of helpful logging information for debugging location-tracking
|
|
245
|
-
* problems.
|
|
246
|
-
*
|
|
247
|
-
* __ℹ️ See also:__
|
|
248
|
-
* - {@link LoggerConfig.logMaxDays} (default `3` days)
|
|
249
|
-
* - {@link LoggerConfig.logLevel} (default {@link LogLevel.Off})
|
|
250
|
-
* - {@link emailLog}
|
|
251
|
-
* - {@link uploadLog}
|
|
252
|
-
* - {@link getLog}
|
|
253
|
-
* - 📘[Debugging Guide](github:wiki/Debugging)
|
|
254
|
-
*
|
|
255
|
-
* @example
|
|
256
|
-
* ```typescript
|
|
257
|
-
* BackgroundGeolocation.logger.getLog().then((log) => {
|
|
258
|
-
* // Warning: this string could be several megabytes.
|
|
259
|
-
* console.log("[log] success: ", log);
|
|
260
|
-
* });
|
|
261
|
-
*
|
|
262
|
-
* // Or constrain results by providing a SQLQuery
|
|
263
|
-
* let Logger = BackgroundGeolocation.logger;
|
|
264
|
-
*
|
|
265
|
-
* let log = await Logger.getLog({
|
|
266
|
-
* start: Date.parse("2019-09-19 11:12"),
|
|
267
|
-
* end: Date.parse("2019-09-19 11:13"),
|
|
268
|
-
* order: Logger.ORDER_ASC,
|
|
269
|
-
* limit: 100
|
|
270
|
-
* });
|
|
271
|
-
* ```
|
|
272
|
-
*
|
|
273
|
-
* ```
|
|
274
|
-
* 09-19 11:12:18.716 ╔═════════════════════════════════════════════
|
|
275
|
-
* 09-19 11:12:18.716 ║ BackgroundGeolocation Service started
|
|
276
|
-
* 09-19 11:12:18.716 ╠═════════════════════════════════════════════
|
|
277
|
-
* 09-19 11:12:18.723 [c.t.l.BackgroundGeolocationService d]
|
|
278
|
-
* 09-19 11:12:18.723 ✅ Started in foreground
|
|
279
|
-
* 09-19 11:12:18.737 [c.t.l.ActivityRecognitionService a]
|
|
280
|
-
* 09-19 11:12:18.737 🎾 Start activity updates: 10000
|
|
281
|
-
* 09-19 11:12:18.761 [c.t.l.BackgroundGeolocationService k]
|
|
282
|
-
* 09-19 11:12:18.761 🔴 Stop heartbeat
|
|
283
|
-
* 09-19 11:12:18.768 [c.t.l.BackgroundGeolocationService a]
|
|
284
|
-
* 09-19 11:12:18.768 🎾 Start heartbeat (60)
|
|
285
|
-
* 09-19 11:12:18.778 [c.t.l.BackgroundGeolocationService a]
|
|
286
|
-
* 09-19 11:12:18.778 🔵 setPace: null → false
|
|
287
|
-
* 09-19 11:12:18.781 [c.t.l.adapter.TSConfig c] ℹ️ Persist config
|
|
288
|
-
* 09-19 11:12:18.794 [c.t.locationmanager.util.b a]
|
|
289
|
-
* 09-19 11:12:18.794 ℹ️ LocationAuthorization: Permission granted
|
|
290
|
-
* 09-19 11:12:18.842 [c.t.l.http.HttpService flush]
|
|
291
|
-
* 09-19 11:12:18.842 ╔═════════════════════════════════════════════
|
|
292
|
-
* 09-19 11:12:18.842 ║ HTTP Service
|
|
293
|
-
* 09-19 11:12:18.842 ╠═════════════════════════════════════════════
|
|
294
|
-
* 09-19 11:12:19.000 [c.t.l.BackgroundGeolocationService onActivityRecognitionResult] still (100%)
|
|
295
|
-
* 09-19 11:12:21.314 [c.t.l.l.SingleLocationRequest$2 onLocationResult]
|
|
296
|
-
* 09-19 11:12:21.314 ╔═════════════════════════════════════════════
|
|
297
|
-
* 09-19 11:12:21.314 ║ SingleLocationRequest: 1
|
|
298
|
-
* 09-19 11:12:21.314 ╠═════════════════════════════════════════════
|
|
299
|
-
* 09-19 11:12:21.314 ╟─ 📍 Location[fused 45.519239,-73.617058 hAcc=15]999923706055 vAcc=2 sAcc=??? bAcc=???
|
|
300
|
-
* 09-19 11:12:21.327 [c.t.l.l.TSLocationManager onSingleLocationResult]
|
|
301
|
-
* 09-19 11:12:21.327 🔵 Acquired motionchange position, isMoving: false
|
|
302
|
-
* 09-19 11:12:21.342 [c.t.l.l.TSLocationManager a] 15.243
|
|
303
|
-
* 09-19 11:12:21.405 [c.t.locationmanager.data.a.c persist]
|
|
304
|
-
* 09-19 11:12:21.405 ✅ INSERT: bca5acc8-e358-4d8f-827f-b8c0d556b7bb
|
|
305
|
-
* 09-19 11:12:21.423 [c.t.l.http.HttpService flush]
|
|
306
|
-
* 09-19 11:12:21.423 ╔═════════════════════════════════════════════
|
|
307
|
-
* 09-19 11:12:21.423 ║ HTTP Service
|
|
308
|
-
* 09-19 11:12:21.423 ╠═════════════════════════════════════════════
|
|
309
|
-
* 09-19 11:12:21.446 [c.t.locationmanager.data.a.c first]
|
|
310
|
-
* 09-19 11:12:21.446 ✅ Locked 1 records
|
|
311
|
-
* 09-19 11:12:21.454 [c.t.l.http.HttpService a]
|
|
312
|
-
* 09-19 11:12:21.454 🔵 HTTP POST: bca5acc8-e358-4d8f-827f-b8c0d556b7bb
|
|
313
|
-
* 09-19 11:12:22.083 [c.t.l.http.HttpService$a onResponse]
|
|
314
|
-
* 09-19 11:12:22.083 🔵 Response: 200
|
|
315
|
-
* 09-19 11:12:22.100 [c.t.locationmanager.data.a.c destroy]
|
|
316
|
-
* 09-19 11:12:22.100 ✅ DESTROY: bca5acc8-e358-4d8f-827f-b8c0d556b7bb
|
|
317
|
-
* 09-19 11:12:55.226 [c.t.l.BackgroundGeolocationService onActivityRecognitionResult] still (100%)
|
|
318
|
-
*```
|
|
319
|
-
*/
|
|
320
17
|
getLog(query?: SQLQuery): Promise<string>;
|
|
321
|
-
/**
|
|
322
|
-
* Email the result of {@link Logger.getLog} using device's mail client.
|
|
323
|
-
*
|
|
324
|
-
* @example
|
|
325
|
-
* ```typescript
|
|
326
|
-
* let Logger = BackgroundGeolocation.logger;
|
|
327
|
-
* Logger.emailLog("foo@bar.com").then((success) => {
|
|
328
|
-
* console.log("[emailLog] success");
|
|
329
|
-
* }).catch((error) => {
|
|
330
|
-
* console.log("[emailLog] FAILURE: ", error);
|
|
331
|
-
* });
|
|
332
|
-
*
|
|
333
|
-
* // Or constrain results by providing a SQLQuery
|
|
334
|
-
* Logger.emailLog("foo@bar.com", {
|
|
335
|
-
* start: Date.parse("2019-09-19"),
|
|
336
|
-
* end: Date.parse("2019-09-20"),
|
|
337
|
-
* order: Logger.ORDER_ASC,
|
|
338
|
-
* limit: 1000
|
|
339
|
-
* });
|
|
340
|
-
* ```
|
|
341
|
-
*
|
|
342
|
-
* __ℹ️ See also:__
|
|
343
|
-
* - {@link LoggerConfig.logLevel}
|
|
344
|
-
* - {@link Logger.getLog}
|
|
345
|
-
* - {@link Logger.uploadLog}
|
|
346
|
-
* - 📘[Debugging Guide](github:wiki/Debugging).
|
|
347
|
-
*/
|
|
348
18
|
emailLog(email: string, query?: SQLQuery): Promise<void | boolean>;
|
|
349
|
-
/**
|
|
350
|
-
* Upload the result of {@link getLog} to provided url. Provide an optional {@link SQLQuery} to contrain results between dates. The file-upload
|
|
351
|
-
* request will attach your configured {@link HttpConfig.headers} for authentication.
|
|
352
|
-
*
|
|
353
|
-
* @example
|
|
354
|
-
*
|
|
355
|
-
* ```typescript
|
|
356
|
-
* BackgroundGeolocation.logger.uploadLog("https://my.server.com/users/123/logs").then((success) => {
|
|
357
|
-
* console.log("[uploadLog] success");
|
|
358
|
-
* }).catch((error) => {
|
|
359
|
-
* console.log("[uploadLog] FAILURE:", error);
|
|
360
|
-
* });
|
|
361
|
-
*
|
|
362
|
-
* // Or constrain results by providing a [SQLQuery]:
|
|
363
|
-
* BackgroundGeolocation.logger.uploadLog("https://my.server.com/users/123/logs", {
|
|
364
|
-
* start: Date.parse("2019-10-20 09:00"),
|
|
365
|
-
* end: Date.parse("2019-10-20 11:59")
|
|
366
|
-
* }).then((success) => {
|
|
367
|
-
* console.log("[uploadLog] success");
|
|
368
|
-
* }).catch((error) => {
|
|
369
|
-
* console.log("[uploadLog] FAILURE:", error);
|
|
370
|
-
* });
|
|
371
|
-
* ```
|
|
372
|
-
*
|
|
373
|
-
* __MultiPart File Upload__
|
|
374
|
-
* The SDK will upload the gzipped log-file to your server as a *Multi-part* file upload, the same log-file as used in {@link emailLog}. This is what I see with my [Node server](https://github.com/transistorsoft/background-geolocation-console) at `request.files`:
|
|
375
|
-
*
|
|
376
|
-
* ```typescript
|
|
377
|
-
* app.post("/log", async function(req, res) {
|
|
378
|
-
* console.log("[body]: ", req.body);
|
|
379
|
-
* console.log("[files]: ", req.files);
|
|
380
|
-
* res.status(200).send();
|
|
381
|
-
* });
|
|
382
|
-
* ```
|
|
383
|
-
* 
|
|
384
|
-
*
|
|
385
|
-
* __Form Part__
|
|
386
|
-
*
|
|
387
|
-
* In addition to the log-file, the SDK will upload a form as well, containing the following parameters:
|
|
388
|
-
*
|
|
389
|
-
* | Key | Value |
|
|
390
|
-
* |--------------|------------------------------------------|
|
|
391
|
-
* | **`state`** | *JSON-encoded result of SDK's `#getState`*|
|
|
392
|
-
* | **`model`** | *Device model* |
|
|
393
|
-
* | **`manufacturer`** | *Device manufacturer* |
|
|
394
|
-
* | **`platform`** | *iOS or Android* |
|
|
395
|
-
* | **`version`** | *OS version* |
|
|
396
|
-
*
|
|
397
|
-
* ### ℹ️ See also:
|
|
398
|
-
* - {@link LoggerConfig.logLevel}
|
|
399
|
-
* - {@link getLog}
|
|
400
|
-
* - {@link emailLog}
|
|
401
|
-
* - {@link destroyLog}
|
|
402
|
-
* - 📘[Debugging Guide](github:wiki/Debugging).
|
|
403
|
-
*/
|
|
404
19
|
uploadLog(url: string, query?: SQLQuery): Promise<void | boolean>;
|
|
405
|
-
/**
|
|
406
|
-
* Destroy the entire contents of SDK's log database.
|
|
407
|
-
*
|
|
408
|
-
* @example
|
|
409
|
-
* ```typescript
|
|
410
|
-
* BackgroundGeolocation.logger.destroyLog();
|
|
411
|
-
* ```
|
|
412
|
-
*
|
|
413
|
-
* __ℹ️ See also:__
|
|
414
|
-
* - {@link LoggerConfig.logLevel}
|
|
415
|
-
* - {@link getLog}
|
|
416
|
-
* - {@link emailLog}
|
|
417
|
-
* - {@link uploadLog}
|
|
418
|
-
* - 📘[Debugging Guide](github:wiki/Debugging)
|
|
419
|
-
*/
|
|
420
20
|
destroyLog(): Promise<void>;
|
|
421
21
|
}
|
package/dist/core/api/State.d.ts
CHANGED
|
@@ -1,75 +1,12 @@
|
|
|
1
1
|
import type { Config } from '../config/Config';
|
|
2
2
|
import type { TrackingMode } from '../../enums/TrackingMode';
|
|
3
|
-
/**
|
|
4
|
-
* Effective runtime state returned by `BackgroundGeolocation.ready/getState`.
|
|
5
|
-
*
|
|
6
|
-
* `State` **is** the active {@link Config} (compound), plus runtime-only fields.
|
|
7
|
-
*
|
|
8
|
-
* @category Primary API
|
|
9
|
-
*/
|
|
10
3
|
export interface State extends Config {
|
|
11
|
-
/** Whether the SDK has been enabled via `start` or `startGeofences`. */
|
|
12
4
|
enabled: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Whether the SDK is currently in the *moving* state (vs stationary).
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```typescript
|
|
18
|
-
* // If the SDK is currently in the *stationary* state, with State.isMoving == false:
|
|
19
|
-
*
|
|
20
|
-
* BackgroundGeolocation.onMotionChange((isMoving) => {
|
|
21
|
-
* console.log('[onMotionChange] isMoving?', isMoving);
|
|
22
|
-
* });
|
|
23
|
-
*
|
|
24
|
-
* await BackgroundGeolocation.changePace(true);
|
|
25
|
-
* // State.isMoving is now true.
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
5
|
isMoving: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* `true` when a schedule is configured and `startSchedule()` executed.
|
|
31
|
-
* `stopSchedule()` will set this to `false`.
|
|
32
|
-
*/
|
|
33
6
|
schedulerEnabled: boolean;
|
|
34
|
-
/**
|
|
35
|
-
* Tracking mode.
|
|
36
|
-
*
|
|
37
|
-
* | Value | Name | Description |
|
|
38
|
-
* |------:|------------|-------------------------------|
|
|
39
|
-
* | 0 | Geofences | Monitor geofences only. |
|
|
40
|
-
* | 1 | Location | Monitor location + geofences. |
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* ```typescript
|
|
44
|
-
* await BackgroundGeolocation.start();
|
|
45
|
-
*
|
|
46
|
-
* const state = await BackgroundGeolocation.getState();
|
|
47
|
-
* console.log('Tracking mode:', state.trackingMode);
|
|
48
|
-
* > 'Tracking mode: 1'
|
|
49
|
-
*
|
|
50
|
-
* await BackgroundGeolocation.startGeofences();
|
|
51
|
-
* console.log('Tracking mode:', state.trackingMode);
|
|
52
|
-
* > 'Tracking mode: 0'
|
|
53
|
-
* ```
|
|
54
|
-
*/
|
|
55
7
|
trackingMode: TrackingMode;
|
|
56
|
-
/**
|
|
57
|
-
* Current distance-traveled in meters.
|
|
58
|
-
* See: {@link odometerError}, {@link BackgroundGeolocation.setOdometer}, {@link BackgroundGeolocation.getOdometer}.
|
|
59
|
-
*/
|
|
60
8
|
odometer: number;
|
|
61
|
-
/**
|
|
62
|
-
* The accumulated error in the odometer (in meters).
|
|
63
|
-
*/
|
|
64
9
|
odometerError: number;
|
|
65
|
-
/**
|
|
66
|
-
* iOS only. `true` when the app was launched in the background due to a
|
|
67
|
-
* background event (fetch, geofence exit, stationary geofence exit).
|
|
68
|
-
* Always `false` on Android.
|
|
69
|
-
*/
|
|
70
10
|
didLaunchInBackground: boolean;
|
|
71
|
-
/**
|
|
72
|
-
* Indicates if the app was launched after a device reboot.
|
|
73
|
-
*/
|
|
74
11
|
didDeviceReboot: boolean;
|
|
75
12
|
}
|
|
@@ -1,123 +1,13 @@
|
|
|
1
1
|
import type { Config } from '../config/Config';
|
|
2
|
-
/**
|
|
3
|
-
* Represents an authorization token issued by a Transistorsoft Tracking Server.
|
|
4
|
-
*
|
|
5
|
-
* Returned from {@link TransistorAuthorizationService.findOrCreate} and consumed by
|
|
6
|
-
* `Config.authorization` / `transistorAuthorizationToken` flows.
|
|
7
|
-
*
|
|
8
|
-
* @category Demo / Debug Server
|
|
9
|
-
*/
|
|
10
2
|
export interface TransistorAuthorizationToken {
|
|
11
|
-
/** JWT access token used for `Authorization: Bearer <token>`. */
|
|
12
3
|
accessToken: string;
|
|
13
|
-
/** JWT refresh token used at the `refreshUrl` endpoint. */
|
|
14
4
|
refreshToken: string;
|
|
15
|
-
/**
|
|
16
|
-
* Expiry time of the access token (epoch milliseconds).
|
|
17
|
-
* Typically used to drive {@link AuthorizationConfig.expires}.
|
|
18
|
-
*/
|
|
19
5
|
expires: number;
|
|
20
|
-
/** Base tracker server URL that issued this token. */
|
|
21
6
|
url: string;
|
|
22
7
|
}
|
|
23
|
-
/**
|
|
24
|
-
* Transistor Software hosts a demo server at [tracker.transistorsoft.com](http://tracker.transistorsoft.com) which is
|
|
25
|
-
* designed to consume location data from devices running the Background Geolocation SDK.
|
|
26
|
-
*
|
|
27
|
-
* You may also run your own instance of Demo Server locally. See [background-geolocation-console](https://github.com/transistorsoft/background-geolocation-console)
|
|
28
|
-
*
|
|
29
|
-
* The test server is a great way to debug location problems or evalute the SDK's behaviour, since the results can easily
|
|
30
|
-
* be shared with *Transistor Software* when requesting support.
|
|
31
|
-
*
|
|
32
|
-
* 
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```typescript
|
|
37
|
-
* // Url to demo server.
|
|
38
|
-
* const url = "http://tracker.transistorsoft.com";
|
|
39
|
-
* const orgname = "my-company-name";
|
|
40
|
-
* const username = "my-username";
|
|
41
|
-
*
|
|
42
|
-
* // Fetch an authoriztion token from server. The SDK will cache the received token.
|
|
43
|
-
* const token = await
|
|
44
|
-
* BackgroundGeolocation.findOrCreateTransistorAuthorizationToken(orgname, username, url);
|
|
45
|
-
*
|
|
46
|
-
* BackgroundGeolocation.ready({
|
|
47
|
-
* transistorAuthorizationToken: token
|
|
48
|
-
* })
|
|
49
|
-
* ```
|
|
50
|
-
*
|
|
51
|
-
* __Viewing Your Tracking Results__
|
|
52
|
-
*
|
|
53
|
-
* To *view* your tracking results in the browser, use your configured "Organization Name" and visit:
|
|
54
|
-
*
|
|
55
|
-
* http://tracker.transistorsoft.com/my-organization-name
|
|
56
|
-
*
|
|
57
|
-
* @category Demo / Debug Server
|
|
58
|
-
*/
|
|
59
8
|
export interface TransistorAuthorizationService {
|
|
60
|
-
/**
|
|
61
|
-
* Find or create a token for the given organization and username.
|
|
62
|
-
*
|
|
63
|
-
* @param orgName - Organization / company identifier.
|
|
64
|
-
* @param username - Username or device label.
|
|
65
|
-
* @param url - Optional tracker base URL. Defaults to the SDK's built‑in value.
|
|
66
|
-
*
|
|
67
|
-
* @returns A Promise resolving with a {@link TransistorAuthorizationToken} instance.
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ```typescript
|
|
71
|
-
* // Url to demo server.
|
|
72
|
-
* const url = "http://tracker.transistorsoft.com";
|
|
73
|
-
* const orgname = "my-company-name";
|
|
74
|
-
* const username = "my-username";
|
|
75
|
-
*
|
|
76
|
-
* // Fetch an authoriztion token from server. The SDK will cache the received token.
|
|
77
|
-
* const token = await
|
|
78
|
-
* BackgroundGeolocation.findOrCreateTransistorAuthorizationToken(orgname, username, url);
|
|
79
|
-
*
|
|
80
|
-
* BackgroundGeolocation.ready({
|
|
81
|
-
* transistorAuthorizationToken: token
|
|
82
|
-
* })
|
|
83
|
-
* ```
|
|
84
|
-
*/
|
|
85
9
|
findOrCreate(orgName: string, username: string, url?: string): Promise<TransistorAuthorizationToken>;
|
|
86
|
-
/**
|
|
87
|
-
* Destroy the token associated with the given tracker base URL.
|
|
88
|
-
*
|
|
89
|
-
* @param url - Tracker base URL. Defaults to the SDK's built‑in value.
|
|
90
|
-
*/
|
|
91
10
|
destroy(url?: string): Promise<void>;
|
|
92
|
-
/**
|
|
93
|
-
* Mutates a {@link Config} to apply the given Transistor token if present.
|
|
94
|
-
*
|
|
95
|
-
* The JS implementation typically:
|
|
96
|
-
* - Reads `config.transistorAuthorizationToken`
|
|
97
|
-
* - Deletes that property
|
|
98
|
-
* - Sets `config.http.url` or `config.url` to `"<token.url>/api/locations"`
|
|
99
|
-
* - Sets `config.authorization = { strategy: "jwt", ... }`
|
|
100
|
-
*
|
|
101
|
-
* If no `transistorAuthorizationToken` is found, the `config` is returned unchanged.
|
|
102
|
-
*
|
|
103
|
-
* @param config - A config that may contain a `transistorAuthorizationToken` field.
|
|
104
|
-
* @returns A {@link Config} with HTTP + authorization wired to the token, if present.
|
|
105
|
-
*
|
|
106
|
-
* @example
|
|
107
|
-
* ```ts
|
|
108
|
-
* async function applyDemoToken(
|
|
109
|
-
* service: TransistorAuthorizationService,
|
|
110
|
-
* config: Config
|
|
111
|
-
* ): Promise<Config> {
|
|
112
|
-
* const token = await service.findOrCreate('my-org', 'user@example.com');
|
|
113
|
-
*
|
|
114
|
-
* return service.applyIf({
|
|
115
|
-
* ...config,
|
|
116
|
-
* transistorAuthorizationToken: token
|
|
117
|
-
* });
|
|
118
|
-
* }
|
|
119
|
-
* ```
|
|
120
|
-
*/
|
|
121
11
|
applyIf<T extends Config & {
|
|
122
12
|
transistorAuthorizationToken?: TransistorAuthorizationToken;
|
|
123
13
|
}>(config: T): Config;
|