@sentiance-react-native/core 6.1.2 → 6.2.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.
@@ -14,9 +14,7 @@
14
14
  - (NSString*)convertTimelineEventTypeToString:(SENTTimelineEventType)type;
15
15
  - (NSDictionary*)convertGeolocation:(SENTGeolocation*)location;
16
16
  - (NSString*)convertVenueSignificance:(SENTVenueSignificance)type;
17
- - (NSDictionary*)convertVisit:(SENTVisit*)visit;
18
17
  - (NSDictionary*)convertVenue:(SENTVenue*)venue;
19
- - (NSDictionary*)convertVenueCandidate:(SENTVenueCandidate*)candidate;
20
18
  - (void)addStationaryEventInfoToDict:(NSMutableDictionary*)dict event:(SENTStationaryEvent*)event;
21
19
  - (NSString*)convertTransportModeToString:(SENTTimelineTransportMode) mode;
22
20
  - (void)addTransportEventInfoToDict:(NSMutableDictionary*)dict event:(SENTTransportEvent*)event;
@@ -54,6 +52,28 @@
54
52
  };
55
53
  }
56
54
 
55
+ - (NSString*)convertSemanticTime:(SENTSemanticTime)semanticTime {
56
+ switch (semanticTime) {
57
+ case SENTSemanticTimeMorning:
58
+ return @"MORNING";
59
+ case SENTSemanticTimeLateMorning:
60
+ return @"LATE_MORNING";
61
+ case SENTSemanticTimeLunch:
62
+ return @"LUNCH";
63
+ case SENTSemanticTimeAfternoon:
64
+ return @"AFTERNOON";
65
+ case SENTSemanticTimeEarlyEvening:
66
+ return @"EARLY_EVENING";
67
+ case SENTSemanticTimeEvening:
68
+ return @"EVENING";
69
+ case SENTSemanticTimeNight:
70
+ return @"NIGHT";
71
+ case SENTSemanticTimeUnknown:
72
+ default:
73
+ return @"UNKNOWN";
74
+ }
75
+ }
76
+
57
77
  - (NSString*)convertVenueSignificance:(SENTVenueSignificance)type {
58
78
  switch (type) {
59
79
  case SENTVenueSignificanceHome:
@@ -68,62 +88,87 @@
68
88
  }
69
89
  }
70
90
 
71
- - (NSDictionary*)convertVisit:(SENTVisit*)visit {
72
- return @{
73
- @"startTime": [visit.startDate description],
74
- @"startTimeEpoch": [NSString stringWithFormat:@"%d",visit.startDate.timeIntervalSince1970],
75
- @"endTime": [visit.endDate description],
76
- @"endTimeEpoch": [NSString stringWithFormat:@"%d",visit.startDate.timeIntervalSince1970],
77
- @"durationInSeconds": [NSNumber numberWithInt:(int)visit.durationInSeconds],
78
- };
91
+ - (NSString*)convertVenueType:(SENTVenueType)type {
92
+ switch (type) {
93
+ case SENTVenueTypeDrinkDay:
94
+ return @"DRINK_DAY";
95
+ case SENTVenueTypeDrinkEvening:
96
+ return @"DRINK_EVENING";
97
+ case SENTVenueTypeEducationIndependent:
98
+ return @"EDUCATION_INDEPENDENT";
99
+ case SENTVenueTypeEducationParents:
100
+ return @"EDUCATION_PARENTS";
101
+ case SENTVenueTypeHealth:
102
+ return @"HEALTH";
103
+ case SENTVenueTypeIndustrial:
104
+ return @"INDUSTRIAL";
105
+ case SENTVenueTypeLeisureBeach:
106
+ return @"LEISURE_BEACH";
107
+ case SENTVenueTypeLeisureDay:
108
+ return @"LEISURE_DAY";
109
+ case SENTVenueTypeLeisureEvening:
110
+ return @"LEISURE_EVENING";
111
+ case SENTVenueTypeLeisureMuseum:
112
+ return @"LEISURE_MUSEUM";
113
+ case SENTVenueTypeLeisureNature:
114
+ return @"LEISURE_NATURE";
115
+ case SENTVenueTypeLeisurePark:
116
+ return @"LEISURE_PARK";
117
+ case SENTVenueTypeOffice:
118
+ return @"OFFICE";
119
+ case SENTVenueTypeReligion:
120
+ return @"RELIGION";
121
+ case SENTVenueTypeResidential:
122
+ return @"RESIDENTIAL";
123
+ case SENTVenueTypeRestoMid:
124
+ return @"RESTO_MID";
125
+ case SENTVenueTypeRestoShort:
126
+ return @"RESTO_SHORT";
127
+ case SENTVenueTypeShopLong:
128
+ return @"SHOP_LONG";
129
+ case SENTVenueTypeShopShort:
130
+ return @"SHOP_SHORT";
131
+ case SENTVenueTypeSport:
132
+ return @"SPORT";
133
+ case SENTVenueTypeSportAttend:
134
+ return @"SPORT_ATTEND";
135
+ case SENTVenueTypeTravelBus:
136
+ return @"TRAVEL_BUS";
137
+ case SENTVenueTypeTravelConference:
138
+ return @"TRAVEL_CONFERENCE";
139
+ case SENTVenueTypeTravelFill:
140
+ return @"TRAVEL_FILL";
141
+ case SENTVenueTypeTravelHotel:
142
+ return @"TRAVEL_HOTEL";
143
+ case SENTVenueTypeTravelLong:
144
+ return @"TRAVEL_LONG";
145
+ case SENTVenueTypeTravelShort:
146
+ return @"TRAVEL_SHORT";
147
+ case SENTVenueTypeUnknown:
148
+ default:
149
+ return @"UNKNOWN";
150
+ }
79
151
  }
80
152
 
81
153
  - (NSDictionary*)convertVenue:(SENTVenue*)venue {
82
154
  NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
83
155
 
84
- if (venue.name != nil) {
85
- dict[@"name"] = venue.name;
86
- }
87
-
88
156
  if (venue.location != nil) {
89
157
  dict[@"location"] = [self convertGeolocation:venue.location];
90
158
  }
91
159
 
92
- NSMutableDictionary* labels = [[NSMutableDictionary alloc] init];
93
- [venue.labels enumerateKeysAndObjectsUsingBlock:
94
- ^(NSString * _Nonnull key, NSString * _Nonnull obj, BOOL * _Nonnull stop) {
95
- labels[key] = obj;
96
- }];
97
- dict[@"venueLabels"] = labels;
160
+ dict[@"significance"] = [self convertVenueSignificance:venue.significance];
161
+ dict[@"type"] = [self convertVenueType:venue.type];
98
162
 
99
163
  return dict;
100
164
  }
101
165
 
102
- - (NSDictionary*)convertVenueCandidate:(SENTVenueCandidate*)candidate {
103
- NSMutableArray* visits = [[NSMutableArray alloc] init];
104
- for (SENTVisit* visit in candidate.visits) {
105
- [visits addObject:[self convertVisit:visit]];
106
- }
107
-
108
- return @{
109
- @"venue": [self convertVenue:candidate.venue],
110
- @"likelihood": @(candidate.likelihood),
111
- @"visits": visits
112
- };
113
- }
114
-
115
166
  - (void)addStationaryEventInfoToDict:(NSMutableDictionary*)dict event:(SENTStationaryEvent*)event {
116
167
  if (event.location != nil) {
117
168
  dict[@"location"] = [self convertGeolocation:event.location];
118
169
  }
119
170
 
120
- dict[@"venueSignificance"] = [self convertVenueSignificance:event.venueSignificance];
121
-
122
- NSMutableArray* venueCandidates = [[NSMutableArray alloc] init];
123
- for (SENTVenueCandidate* candidate in event.venueCandidates) {
124
- [venueCandidates addObject:[self convertVenueCandidate:candidate]];
125
- }
126
- dict[@"venueCandidates"] = venueCandidates;
171
+ dict[@"venue"] = [self convertVenue:event.venue];
127
172
  }
128
173
 
129
174
  - (NSString*)convertTransportModeToString:(SENTTimelineTransportMode)mode {
@@ -152,13 +197,37 @@
152
197
 
153
198
  - (void)addTransportEventInfoToDict:(NSMutableDictionary*)dict event:(SENTTransportEvent*)event {
154
199
  dict[@"transportMode"] = [self convertTransportModeToString:event.transportMode];
200
+ dict[@"waypoints"] = [self convertWaypointArray:event.waypoints];
201
+
202
+ if (event.distanceInMeters != nil) {
203
+ dict[@"distance"] = event.distanceInMeters;
204
+ }
205
+ }
206
+
207
+ - (NSDictionary*)convertWaypoint:(SENTWaypoint*)waypoint {
208
+ return @{
209
+ @"latitude": @(waypoint.latitude),
210
+ @"longitude": @(waypoint.longitude),
211
+ @"accuracy": @(waypoint.accuracyInMeters),
212
+ @"timestamp": @(waypoint.timestamp * 1000)
213
+ };
214
+ }
215
+
216
+ - (NSArray<NSDictionary *> *)convertWaypointArray:(NSArray<SENTWaypoint *> *)waypoints {
217
+ NSMutableArray *array = [[NSMutableArray alloc] init];
218
+ for (SENTWaypoint *waypoint in waypoints) {
219
+ [array addObject:[self convertWaypoint:waypoint]];
220
+ }
221
+ return array;
155
222
  }
156
223
 
157
224
  - (NSMutableDictionary*)convertEvent:(SENTTimelineEvent*)event {
158
225
  NSMutableDictionary *eventDict = [[NSMutableDictionary alloc] init];
159
226
  eventDict[@"startTime"] = [event.startDate description];
227
+ eventDict[@"startTimeEpoch"] = @((long) (event.startDate.timeIntervalSince1970 * 1000));
160
228
  if (event.endDate != nil) {
161
229
  eventDict[@"endTime"] = [event.endDate description];
230
+ eventDict[@"endTimeEpoch"] = @((long) (event.endDate.timeIntervalSince1970 * 1000));
162
231
 
163
232
  NSInteger durationInSeconds = event.durationInSeconds;
164
233
  if (durationInSeconds != SENTDurationUnknown) {
@@ -436,11 +505,11 @@
436
505
  dict[@"type"] = type;
437
506
  dict[@"id"] = @(segment.uniqueId);
438
507
  dict[@"startTime"] = [segment.startDate description];
439
- dict[@"startTimeEpoch"] = [NSString stringWithFormat:@"%d",segment.startDate.timeIntervalSince1970];
508
+ dict[@"startTimeEpoch"] = @((long) (segment.startDate.timeIntervalSince1970 * 1000));
440
509
 
441
510
  if (segment.endDate != nil) {
442
511
  dict[@"endTime"] = [segment.endDate description];
443
- dict[@"endTimeEpoch"] = [NSString stringWithFormat:@"%d",segment.endDate.timeIntervalSince1970];
512
+ dict[@"endTimeEpoch"] = @((long) (segment.endDate.timeIntervalSince1970 * 1000));
444
513
  }
445
514
  dict[@"attributes"] = [self convertSegmentAttributesToDict:segment.attributes];
446
515
 
@@ -479,6 +548,8 @@
479
548
  dict[@"work"] = [self convertVenue:userContext.work];
480
549
  }
481
550
 
551
+ dict[@"semanticTime"] = [self convertSemanticTime:userContext.semanticTime];
552
+
482
553
  return [dict copy];
483
554
  }
484
555
 
@@ -489,10 +560,6 @@
489
560
  [criteria addObject:@"CURRENT_EVENT"];
490
561
  }
491
562
 
492
- if (criteriaMask & SENTUserContextUpdateCriteriaActiveMoments) {
493
- [criteria addObject:@"ACTIVE_MOMENTS"];
494
- }
495
-
496
563
  if (criteriaMask & SENTUserContextUpdateCriteriaVisitedVenues) {
497
564
  [criteria addObject:@"VISITED_VENUES"];
498
565
  }
@@ -572,6 +639,8 @@
572
639
  @"mobileQuotaStatus":[self convertQuotaStatusToString:status.mobileQuotaStatus],
573
640
  @"diskQuotaStatus":[self convertQuotaStatusToString:status.diskQuotaStatus],
574
641
  @"userExists":@(status.userExists),
642
+ @"isBatterySavingEnabled":@(status.isDeviceLowPowerModeEnabled),
643
+ @"isActivityRecognitionPermGranted":@(status.isMotionActivityPermissionGranted),
575
644
  @"backgroundRefreshStatus":[self convertBackgroundRefreshStatus:status.backgroundRefreshStatus]
576
645
  };
577
646
 
@@ -828,7 +828,6 @@ RCT_EXPORT_METHOD(listenUserContextUpdates:(RCTPromiseResolveBlock)resolve rejec
828
828
  [Sentiance sharedInstance].userContextDelegate = self;
829
829
  [Sentiance sharedInstance].criteriaMaskForUserContextUpdates = SENTUserContextUpdateCriteriaCurrentEvent |
830
830
  SENTUserContextUpdateCriteriaActiveSegments |
831
- SENTUserContextUpdateCriteriaActiveMoments |
832
831
  SENTUserContextUpdateCriteriaVisitedVenues;
833
832
  resolve(nil);
834
833
  }
@@ -19,7 +19,7 @@
19
19
  return [self initializeSDKWithPlatformUrl:nil isAppSessionDataCollectionAllowed:NO launchOptions:nil];
20
20
  }
21
21
 
22
- - (SENTInitializationResult *)initializeSDKWithPlatformUrl:(NSString *)platformUrl
22
+ - (SENTInitializationResult *)initializeSDKWithPlatformUrl:(NSString *)platformUrl
23
23
  launchOptions:(nullable NSDictionary *)launchOptions {
24
24
  return [self initializeSDKWithPlatformUrl:platformUrl isAppSessionDataCollectionAllowed:NO launchOptions:launchOptions];
25
25
  }
package/lib/index.d.ts CHANGED
@@ -9,13 +9,17 @@ declare module "@sentiance-react-native/core" {
9
9
  export type LocationPermission = "ALWAYS" | "ONLY_WHILE_IN_USE" | "NEVER";
10
10
  export type BackgroundRefreshStatus = "AVAILABLE" | "DENIED" | "RESTRICTED";
11
11
  export type SdkInitState =
12
- "NOT_INITIALIZED"
12
+ | "NOT_INITIALIZED"
13
13
  | "INIT_IN_PROGRESS"
14
14
  | "INITIALIZED"
15
15
  | "RESETTING"
16
16
  | "UNRECOGNIZED_STATE";
17
17
  export type TripType = "TRIP_TYPE_SDK" | "TRIP_TYPE_EXTERNAL";
18
- export type TransmittableDataType = "ALL" | "SDK_INFO" | "VEHICLE_CRASH_INFO" | "GENERAL_DETECTIONS";
18
+ export type TransmittableDataType =
19
+ | "ALL"
20
+ | "SDK_INFO"
21
+ | "VEHICLE_CRASH_INFO"
22
+ | "GENERAL_DETECTIONS";
19
23
 
20
24
  export enum TransportMode {
21
25
  UNKNOWN = 1,
@@ -46,8 +50,8 @@ declare module "@sentiance-react-native/core" {
46
50
  userInfo: UserInfo;
47
51
  }
48
52
 
49
- export type Linker = (installId: string) => Promise<boolean>
50
-
53
+ export type Linker = (installId: string) => Promise<boolean>;
54
+
51
55
  export interface UserCreationOptions {
52
56
  appId?: string;
53
57
  appSecret?: string;
@@ -112,16 +116,16 @@ declare module "@sentiance-react-native/core" {
112
116
  diskQuotaStatus: string;
113
117
  locationPermission: LocationPermission;
114
118
  userExists: boolean;
119
+ isBatterySavingEnabled?: boolean;
120
+ isActivityRecognitionPermGranted?: boolean;
121
+ isPreciseLocationAuthorizationGranted: boolean;
115
122
  isBgAccessPermGranted?: boolean; // iOS only
116
- isActivityRecognitionPermGranted?: boolean; // Android only
117
123
  locationSetting?: string; // Android only
118
124
  isAirplaneModeEnabled?: boolean; // Android only
119
125
  isLocationAvailable?: boolean; // Android only
120
126
  isGooglePlayServicesMissing?: boolean; // Android only
121
127
  isBatteryOptimizationEnabled?: boolean; // Android only
122
- isBatterySavingEnabled?: boolean; // Android only
123
128
  isBackgroundProcessingRestricted?: boolean; // Android only
124
- isPreciseLocationAuthorizationGranted: boolean;
125
129
  isSchedulingExactAlarmsPermitted?: boolean; // Android only
126
130
  backgroundRefreshStatus: BackgroundRefreshStatus; // iOS only
127
131
  }
@@ -226,7 +230,9 @@ declare module "@sentiance-react-native/core" {
226
230
  onUserActivityUpdated: (userActivity: UserActivity) => void
227
231
  ): Promise<EmitterSubscription>;
228
232
 
229
- setTransmittableDataTypes(types: Array<TransmittableDataType>): Promise<void>;
233
+ setTransmittableDataTypes(
234
+ types: Array<TransmittableDataType>
235
+ ): Promise<void>;
230
236
 
231
237
  getTransmittableDataTypes(): Promise<Array<TransmittableDataType>>;
232
238
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentiance-react-native/core",
3
- "version": "6.1.2",
3
+ "version": "6.2.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.1.+"
32
+ "sentiance": "6.2.0-rc1"
33
33
  },
34
34
  "ios": {
35
- "sentiance": "~> 6.1.0"
35
+ "sentiance": "~> 6.2.0-rc4"
36
36
  }
37
37
  }
38
38
  }