@sentiance-react-native/core 6.2.3 → 6.3.0-rc.2
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/android/src/main/java/com/sentiance/react/bridge/core/SentianceConverter.java +2 -13
- package/android/src/main/java/com/sentiance/react/bridge/core/common/SentianceCommonConverter.java +24 -0
- package/ios/RNSentianceCore+Converter.m +25 -54
- package/ios/RNSentianceCore.podspec +1 -1
- package/lib/index.d.ts +4 -4
- package/package.json +3 -3
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
package com.sentiance.react.bridge.core;
|
|
2
2
|
|
|
3
|
+
import static com.sentiance.react.bridge.core.common.SentianceCommonConverter.convertLocation;
|
|
4
|
+
|
|
3
5
|
import android.location.Location;
|
|
4
6
|
|
|
5
7
|
import com.facebook.react.bridge.Arguments;
|
|
@@ -207,19 +209,6 @@ public class SentianceConverter {
|
|
|
207
209
|
return map;
|
|
208
210
|
}
|
|
209
211
|
|
|
210
|
-
public static WritableMap convertLocation(Location location) {
|
|
211
|
-
WritableMap locationMap = Arguments.createMap();
|
|
212
|
-
|
|
213
|
-
locationMap.putString("latitude", String.valueOf(location.getLatitude()));
|
|
214
|
-
locationMap.putString("longitude", String.valueOf(location.getLongitude()));
|
|
215
|
-
locationMap.putString("accuracy", String.valueOf(location.getAccuracy()));
|
|
216
|
-
locationMap.putString("altitude", String.valueOf(location.getAltitude()));
|
|
217
|
-
locationMap.putString("provider", location.getProvider());
|
|
218
|
-
|
|
219
|
-
return locationMap;
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
|
|
223
212
|
public static String convertTripType(TripType tripType) {
|
|
224
213
|
switch (tripType) {
|
|
225
214
|
case ANY:
|
package/android/src/main/java/com/sentiance/react/bridge/core/common/SentianceCommonConverter.java
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
package com.sentiance.react.bridge.core.common;
|
|
2
|
+
|
|
3
|
+
import android.location.Location;
|
|
4
|
+
|
|
5
|
+
import com.facebook.react.bridge.Arguments;
|
|
6
|
+
import com.facebook.react.bridge.WritableMap;
|
|
7
|
+
|
|
8
|
+
public class SentianceCommonConverter {
|
|
9
|
+
|
|
10
|
+
public static WritableMap convertLocation(Location location) {
|
|
11
|
+
WritableMap locationMap = Arguments.createMap();
|
|
12
|
+
locationMap.putDouble("timestamp", location.getTime());
|
|
13
|
+
locationMap.putDouble("latitude", location.getLatitude());
|
|
14
|
+
locationMap.putDouble("longitude", location.getLongitude());
|
|
15
|
+
if (location.hasAccuracy()) {
|
|
16
|
+
locationMap.putDouble("accuracy", location.getAccuracy());
|
|
17
|
+
}
|
|
18
|
+
if (location.hasAltitude()) {
|
|
19
|
+
locationMap.putDouble("altitude", location.getAltitude());
|
|
20
|
+
}
|
|
21
|
+
locationMap.putString("provider", location.getProvider());
|
|
22
|
+
return locationMap;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -8,11 +8,13 @@
|
|
|
8
8
|
|
|
9
9
|
#import "RNSentianceCore+Converter.h"
|
|
10
10
|
@import UIKit.UIApplication;
|
|
11
|
+
@import CoreLocation;
|
|
11
12
|
|
|
12
13
|
@interface RNSentianceCore (Private)
|
|
13
14
|
|
|
14
15
|
- (NSString*)convertTimelineEventTypeToString:(SENTTimelineEventType)type;
|
|
15
16
|
- (NSDictionary*)convertGeolocation:(SENTGeolocation*)location;
|
|
17
|
+
- (NSDictionary*)convertCllocation:(CLLocation*)location;
|
|
16
18
|
- (NSString*)convertVenueSignificance:(SENTVenueSignificance)type;
|
|
17
19
|
- (NSDictionary*)convertVenue:(SENTVenue*)venue;
|
|
18
20
|
- (void)addStationaryEventInfoToDict:(NSMutableDictionary*)dict event:(SENTStationaryEvent*)event;
|
|
@@ -52,6 +54,22 @@
|
|
|
52
54
|
};
|
|
53
55
|
}
|
|
54
56
|
|
|
57
|
+
- (NSDictionary*)convertCllocation:(CLLocation*)location {
|
|
58
|
+
NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
|
|
59
|
+
dict[@"timestamp"] = @((long) ([location.timestamp timeIntervalSince1970] * 1000));
|
|
60
|
+
dict[@"latitude"] = @(location.coordinate.latitude);
|
|
61
|
+
dict[@"longitude"] = @(location.coordinate.longitude);
|
|
62
|
+
|
|
63
|
+
if (location.horizontalAccuracy >= 0) {
|
|
64
|
+
dict[@"accuracy"] = @(location.horizontalAccuracy);
|
|
65
|
+
}
|
|
66
|
+
if (location.verticalAccuracy > 0) {
|
|
67
|
+
dict[@"altitude"] = @(location.altitude);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return dict;
|
|
71
|
+
}
|
|
72
|
+
|
|
55
73
|
- (NSString*)convertSemanticTime:(SENTSemanticTime)semanticTime {
|
|
56
74
|
switch (semanticTime) {
|
|
57
75
|
case SENTSemanticTimeMorning:
|
|
@@ -299,40 +317,18 @@
|
|
|
299
317
|
return @"ANTICIPATIVE_DRIVER";
|
|
300
318
|
case SENTSegmentTypeBarGoer:
|
|
301
319
|
return @"BAR_GOER";
|
|
302
|
-
case SENTSegmentTypeBeautyQueen:
|
|
303
|
-
return @"BEAUTY_QUEEN";
|
|
304
|
-
case SENTSegmentTypeBrandLoyalBar:
|
|
305
|
-
return @"BRAND_LOYAL__BAR";
|
|
306
|
-
case SENTSegmentTypeBrandLoyalCafe:
|
|
307
|
-
return @"BRAND_LOYAL__CAFE";
|
|
308
|
-
case SENTSegmentTypeBrandLoyalRestaurant:
|
|
309
|
-
return @"BRAND_LOYAL__RESTAURANT";
|
|
310
|
-
case SENTSegmentTypeBrandLoyalRetail:
|
|
311
|
-
return @"BRAND_LOYAL__RETAIL";
|
|
312
|
-
case SENTSegmentTypeBrandLoyalty:
|
|
313
|
-
return @"BRAND_LOYALTY";
|
|
314
|
-
case SENTSegmentTypeBrandLoyaltyGasStations:
|
|
315
|
-
return @"BRAND_LOYALTY__GAS_STATIONS";
|
|
316
|
-
case SENTSegmentTypeBrandLoyaltyRestaurantBar:
|
|
317
|
-
return @"BRAND_LOYALTY__RESTAURANT_BAR";
|
|
318
|
-
case SENTSegmentTypeBrandLoyaltySupermarket:
|
|
319
|
-
return @"BRAND_LOYALTY__SUPERMARKET";
|
|
320
320
|
case SENTSegmentTypeCityDriver:
|
|
321
321
|
return @"CITY_DRIVER";
|
|
322
322
|
case SENTSegmentTypeCityHome:
|
|
323
323
|
return @"CITY_HOME";
|
|
324
324
|
case SENTSegmentTypeCityWorker:
|
|
325
325
|
return @"CITY_WORKER";
|
|
326
|
-
case SENTSegmentTypeClubber:
|
|
327
|
-
return @"CLUBBER";
|
|
328
326
|
case SENTSegmentTypeCultureBuff:
|
|
329
327
|
return @"CULTURE_BUFF";
|
|
330
328
|
case SENTSegmentTypeDieHardDriver:
|
|
331
329
|
return @"DIE_HARD_DRIVER";
|
|
332
330
|
case SENTSegmentTypeDistractedDriver:
|
|
333
331
|
return @"DISTRACTED_DRIVER";
|
|
334
|
-
case SENTSegmentTypeDoItYourselver:
|
|
335
|
-
return @"DO_IT_YOURSELVER";
|
|
336
332
|
case SENTSegmentTypeDogWalker:
|
|
337
333
|
return @"DOG_WALKER";
|
|
338
334
|
case SENTSegmentTypeEarlyBird:
|
|
@@ -341,16 +337,12 @@
|
|
|
341
337
|
return @"EASY_COMMUTER";
|
|
342
338
|
case SENTSegmentTypeEfficientDriver:
|
|
343
339
|
return @"EFFICIENT_DRIVER";
|
|
344
|
-
case SENTSegmentTypeFashionista:
|
|
345
|
-
return @"FASHIONISTA";
|
|
346
340
|
case SENTSegmentTypeFoodie:
|
|
347
341
|
return @"FOODIE";
|
|
348
342
|
case SENTSegmentTypeFrequentFlyer:
|
|
349
343
|
return @"FREQUENT_FLYER";
|
|
350
344
|
case SENTSegmentTypeFulltimeWorker:
|
|
351
345
|
return @"FULLTIME_WORKER";
|
|
352
|
-
case SENTSegmentTypeGamer:
|
|
353
|
-
return @"GAMER";
|
|
354
346
|
case SENTSegmentTypeGreenCommuter:
|
|
355
347
|
return @"GREEN_COMMUTER";
|
|
356
348
|
case SENTSegmentTypeHealthyBiker:
|
|
@@ -413,34 +405,6 @@
|
|
|
413
405
|
return @"RECENTLY_MOVED_HOME";
|
|
414
406
|
case SENTSegmentTypeRestoLover:
|
|
415
407
|
return @"RESTO_LOVER";
|
|
416
|
-
case SENTSegmentTypeRestoLoverAmerican:
|
|
417
|
-
return @"RESTO_LOVER__AMERICAN";
|
|
418
|
-
case SENTSegmentTypeRestoLoverAsian:
|
|
419
|
-
return @"RESTO_LOVER__ASIAN";
|
|
420
|
-
case SENTSegmentTypeRestoLoverBarbecue:
|
|
421
|
-
return @"RESTO_LOVER__BARBECUE";
|
|
422
|
-
case SENTSegmentTypeRestoLoverFastfood:
|
|
423
|
-
return @"RESTO_LOVER__FASTFOOD";
|
|
424
|
-
case SENTSegmentTypeRestoLoverFrench:
|
|
425
|
-
return @"RESTO_LOVER__FRENCH";
|
|
426
|
-
case SENTSegmentTypeRestoLoverGerman:
|
|
427
|
-
return @"RESTO_LOVER__GERMAN";
|
|
428
|
-
case SENTSegmentTypeRestoLoverGreek:
|
|
429
|
-
return @"RESTO_LOVER__GREEK";
|
|
430
|
-
case SENTSegmentTypeRestoLoverGrill:
|
|
431
|
-
return @"RESTO_LOVER__GRILL";
|
|
432
|
-
case SENTSegmentTypeRestoLoverInternational:
|
|
433
|
-
return @"RESTO_LOVER__INTERNATIONAL";
|
|
434
|
-
case SENTSegmentTypeRestoLoverItalian:
|
|
435
|
-
return @"RESTO_LOVER__ITALIAN";
|
|
436
|
-
case SENTSegmentTypeRestoLoverMediterranean:
|
|
437
|
-
return @"RESTO_LOVER__MEDITERRANEAN";
|
|
438
|
-
case SENTSegmentTypeRestoLoverMexican:
|
|
439
|
-
return @"RESTO_LOVER__MEXICAN";
|
|
440
|
-
case SENTSegmentTypeRestoLoverSeafood:
|
|
441
|
-
return @"RESTO_LOVER__SEAFOOD";
|
|
442
|
-
case SENTSegmentTypeRestoLoverSnack:
|
|
443
|
-
return @"RESTO_LOVER__SNACK";
|
|
444
408
|
case SENTSegmentTypeRuralHome:
|
|
445
409
|
return @"RURAL_HOME";
|
|
446
410
|
case SENTSegmentTypeRuralWorker:
|
|
@@ -756,6 +720,13 @@
|
|
|
756
720
|
dict[@"speedAtImpact"] = @(crashEvent.speedAtImpact);
|
|
757
721
|
dict[@"deltaV"] = @(crashEvent.deltaV);
|
|
758
722
|
dict[@"confidence"] = @(crashEvent.confidence);
|
|
723
|
+
|
|
724
|
+
NSMutableArray *precedingLocations = [[NSMutableArray alloc] init];
|
|
725
|
+
for (CLLocation* location in crashEvent.precedingLocations) {
|
|
726
|
+
[precedingLocations addObject:[self convertCllocation:location]];
|
|
727
|
+
}
|
|
728
|
+
dict[@"precedingLocations"] = precedingLocations;
|
|
729
|
+
|
|
759
730
|
return [dict copy];
|
|
760
731
|
}
|
|
761
732
|
|
package/lib/index.d.ts
CHANGED
|
@@ -61,10 +61,10 @@ declare module "@sentiance-react-native/core" {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
export interface Location {
|
|
64
|
-
latitude:
|
|
65
|
-
longitude:
|
|
66
|
-
accuracy?:
|
|
67
|
-
altitude?:
|
|
64
|
+
latitude: number;
|
|
65
|
+
longitude: number;
|
|
66
|
+
accuracy?: number;
|
|
67
|
+
altitude?: number;
|
|
68
68
|
provider?: string; // Android only
|
|
69
69
|
}
|
|
70
70
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentiance-react-native/core",
|
|
3
|
-
"version": "6.2
|
|
3
|
+
"version": "6.3.0-rc.2",
|
|
4
4
|
"description": "React Native Sentiance core library",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"targetSdk": 31,
|
|
30
30
|
"compileSdk": 31,
|
|
31
31
|
"buildTools": "30.0.3",
|
|
32
|
-
"sentiance": "6.
|
|
32
|
+
"sentiance": "6.3.0-rc1"
|
|
33
33
|
},
|
|
34
34
|
"ios": {
|
|
35
|
-
"sentiance": "~> 6.
|
|
35
|
+
"sentiance": "~> 6.3.0-rc2"
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
}
|