@sentiance-react-native/core 6.1.1 → 6.2.0-rc.1

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;
@@ -68,62 +66,87 @@
68
66
  }
69
67
  }
70
68
 
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
- };
69
+ - (NSString*)convertVenueType:(SENTVenueType)type {
70
+ switch (type) {
71
+ case SENTVenueTypeDrinkDay:
72
+ return @"DRINK_DAY";
73
+ case SENTVenueTypeDrinkEvening:
74
+ return @"DRINK_EVENING";
75
+ case SENTVenueTypeEducationIndependent:
76
+ return @"EDUCATION_INDEPENDENT";
77
+ case SENTVenueTypeEducationParents:
78
+ return @"EDUCATION_PARENTS";
79
+ case SENTVenueTypeHealth:
80
+ return @"HEALTH";
81
+ case SENTVenueTypeIndustrial:
82
+ return @"INDUSTRIAL";
83
+ case SENTVenueTypeLeisureBeach:
84
+ return @"LEISURE_BEACH";
85
+ case SENTVenueTypeLeisureDay:
86
+ return @"LEISURE_DAY";
87
+ case SENTVenueTypeLeisureEvening:
88
+ return @"LEISURE_EVENING";
89
+ case SENTVenueTypeLeisureMuseum:
90
+ return @"LEISURE_MUSEUM";
91
+ case SENTVenueTypeLeisureNature:
92
+ return @"LEISURE_NATURE";
93
+ case SENTVenueTypeLeisurePark:
94
+ return @"LEISURE_PARK";
95
+ case SENTVenueTypeOffice:
96
+ return @"OFFICE";
97
+ case SENTVenueTypeReligion:
98
+ return @"RELIGION";
99
+ case SENTVenueTypeResidential:
100
+ return @"RESIDENTIAL";
101
+ case SENTVenueTypeRestoMid:
102
+ return @"RESTO_MID";
103
+ case SENTVenueTypeRestoShort:
104
+ return @"RESTO_SHORT";
105
+ case SENTVenueTypeShopLong:
106
+ return @"SHOP_LONG";
107
+ case SENTVenueTypeShopShort:
108
+ return @"SHOP_SHORT";
109
+ case SENTVenueTypeSport:
110
+ return @"SPORT";
111
+ case SENTVenueTypeSportAttend:
112
+ return @"SPORT_ATTEND";
113
+ case SENTVenueTypeTravelBus:
114
+ return @"TRAVEL_BUS";
115
+ case SENTVenueTypeTravelConference:
116
+ return @"TRAVEL_CONFERENCE";
117
+ case SENTVenueTypeTravelFill:
118
+ return @"TRAVEL_FILL";
119
+ case SENTVenueTypeTravelHotel:
120
+ return @"TRAVEL_HOTEL";
121
+ case SENTVenueTypeTravelLong:
122
+ return @"TRAVEL_LONG";
123
+ case SENTVenueTypeTravelShort:
124
+ return @"TRAVEL_SHORT";
125
+ case SENTVenueTypeUnknown:
126
+ default:
127
+ return @"UNKNOWN";
128
+ }
79
129
  }
80
130
 
81
131
  - (NSDictionary*)convertVenue:(SENTVenue*)venue {
82
132
  NSMutableDictionary* dict = [[NSMutableDictionary alloc] init];
83
133
 
84
- if (venue.name != nil) {
85
- dict[@"name"] = venue.name;
86
- }
87
-
88
134
  if (venue.location != nil) {
89
135
  dict[@"location"] = [self convertGeolocation:venue.location];
90
136
  }
91
-
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;
137
+
138
+ dict[@"significance"] = [self convertVenueSignificance:venue.significance];
139
+ dict[@"type"] = [self convertVenueType:venue.type];
98
140
 
99
141
  return dict;
100
142
  }
101
143
 
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
144
  - (void)addStationaryEventInfoToDict:(NSMutableDictionary*)dict event:(SENTStationaryEvent*)event {
116
145
  if (event.location != nil) {
117
146
  dict[@"location"] = [self convertGeolocation:event.location];
118
147
  }
119
148
 
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;
149
+ dict[@"venue"] = [self convertVenue:event.venue];
127
150
  }
128
151
 
129
152
  - (NSString*)convertTransportModeToString:(SENTTimelineTransportMode)mode {
@@ -152,13 +175,37 @@
152
175
 
153
176
  - (void)addTransportEventInfoToDict:(NSMutableDictionary*)dict event:(SENTTransportEvent*)event {
154
177
  dict[@"transportMode"] = [self convertTransportModeToString:event.transportMode];
178
+ dict[@"waypoints"] = [self convertWaypointArray:event.waypoints];
179
+
180
+ if (event.distanceInMeters != nil) {
181
+ dict[@"distance"] = event.distanceInMeters;
182
+ }
183
+ }
184
+
185
+ - (NSDictionary*)convertWaypoint:(SENTWaypoint*)waypoint {
186
+ return @{
187
+ @"latitude": @(waypoint.latitude),
188
+ @"longitude": @(waypoint.longitude),
189
+ @"accuracy": @(waypoint.accuracyInMeters),
190
+ @"timestamp": @(waypoint.timestamp * 1000)
191
+ };
192
+ }
193
+
194
+ - (NSArray<NSDictionary *> *)convertWaypointArray:(NSArray<SENTWaypoint *> *)waypoints {
195
+ NSMutableArray *array = [[NSMutableArray alloc] init];
196
+ for (SENTWaypoint *waypoint in waypoints) {
197
+ [array addObject:[self convertWaypoint:waypoint]];
198
+ }
199
+ return array;
155
200
  }
156
201
 
157
202
  - (NSMutableDictionary*)convertEvent:(SENTTimelineEvent*)event {
158
203
  NSMutableDictionary *eventDict = [[NSMutableDictionary alloc] init];
159
204
  eventDict[@"startTime"] = [event.startDate description];
205
+ eventDict[@"startTimeEpoch"] = @((long) (event.startDate.timeIntervalSince1970 * 1000));
160
206
  if (event.endDate != nil) {
161
207
  eventDict[@"endTime"] = [event.endDate description];
208
+ eventDict[@"endTimeEpoch"] = @((long) (event.endDate.timeIntervalSince1970 * 1000));
162
209
 
163
210
  NSInteger durationInSeconds = event.durationInSeconds;
164
211
  if (durationInSeconds != SENTDurationUnknown) {
@@ -436,11 +483,11 @@
436
483
  dict[@"type"] = type;
437
484
  dict[@"id"] = @(segment.uniqueId);
438
485
  dict[@"startTime"] = [segment.startDate description];
439
- dict[@"startTimeEpoch"] = [NSString stringWithFormat:@"%d",segment.startDate.timeIntervalSince1970];
440
-
486
+ dict[@"startTimeEpoch"] = @((long) (segment.startDate.timeIntervalSince1970 * 1000));
487
+
441
488
  if (segment.endDate != nil) {
442
489
  dict[@"endTime"] = [segment.endDate description];
443
- dict[@"endTimeEpoch"] = [NSString stringWithFormat:@"%d",segment.endDate.timeIntervalSince1970];
490
+ dict[@"endTimeEpoch"] = @((long) (segment.endDate.timeIntervalSince1970 * 1000));
444
491
  }
445
492
  dict[@"attributes"] = [self convertSegmentAttributesToDict:segment.attributes];
446
493
 
@@ -489,10 +536,6 @@
489
536
  [criteria addObject:@"CURRENT_EVENT"];
490
537
  }
491
538
 
492
- if (criteriaMask & SENTUserContextUpdateCriteriaActiveMoments) {
493
- [criteria addObject:@"ACTIVE_MOMENTS"];
494
- }
495
-
496
539
  if (criteriaMask & SENTUserContextUpdateCriteriaVisitedVenues) {
497
540
  [criteria addObject:@"VISITED_VENUES"];
498
541
  }
@@ -572,6 +615,8 @@
572
615
  @"mobileQuotaStatus":[self convertQuotaStatusToString:status.mobileQuotaStatus],
573
616
  @"diskQuotaStatus":[self convertQuotaStatusToString:status.diskQuotaStatus],
574
617
  @"userExists":@(status.userExists),
618
+ @"isBatterySavingEnabled":@(status.isDeviceLowPowerModeEnabled),
619
+ @"isActivityRecognitionPermGranted":@(status.isMotionActivityPermissionGranted),
575
620
  @"backgroundRefreshStatus":[self convertBackgroundRefreshStatus:status.backgroundRefreshStatus]
576
621
  };
577
622
 
@@ -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
  }
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,12 +50,14 @@ declare module "@sentiance-react-native/core" {
46
50
  userInfo: UserInfo;
47
51
  }
48
52
 
53
+ export type Linker = (installId: string) => Promise<boolean>;
54
+
49
55
  export interface UserCreationOptions {
50
- appId: string;
51
- appSecret: string;
52
- authCode: string;
53
- platformUrl: string;
54
- linker: (installId: string) => boolean;
56
+ appId?: string;
57
+ appSecret?: string;
58
+ authCode?: string;
59
+ platformUrl?: string;
60
+ linker?: Linker;
55
61
  }
56
62
 
57
63
  export interface Location {
@@ -110,16 +116,16 @@ declare module "@sentiance-react-native/core" {
110
116
  diskQuotaStatus: string;
111
117
  locationPermission: LocationPermission;
112
118
  userExists: boolean;
119
+ isBatterySavingEnabled?: boolean;
120
+ isActivityRecognitionPermGranted?: boolean;
121
+ isPreciseLocationAuthorizationGranted: boolean;
113
122
  isBgAccessPermGranted?: boolean; // iOS only
114
- isActivityRecognitionPermGranted?: boolean; // Android only
115
123
  locationSetting?: string; // Android only
116
124
  isAirplaneModeEnabled?: boolean; // Android only
117
125
  isLocationAvailable?: boolean; // Android only
118
126
  isGooglePlayServicesMissing?: boolean; // Android only
119
127
  isBatteryOptimizationEnabled?: boolean; // Android only
120
- isBatterySavingEnabled?: boolean; // Android only
121
128
  isBackgroundProcessingRestricted?: boolean; // Android only
122
- isPreciseLocationAuthorizationGranted: boolean;
123
129
  isSchedulingExactAlarmsPermitted?: boolean; // Android only
124
130
  backgroundRefreshStatus: BackgroundRefreshStatus; // iOS only
125
131
  }
@@ -224,7 +230,9 @@ declare module "@sentiance-react-native/core" {
224
230
  onUserActivityUpdated: (userActivity: UserActivity) => void
225
231
  ): Promise<EmitterSubscription>;
226
232
 
227
- setTransmittableDataTypes(types: Array<TransmittableDataType>): Promise<void>;
233
+ setTransmittableDataTypes(
234
+ types: Array<TransmittableDataType>
235
+ ): Promise<void>;
228
236
 
229
237
  getTransmittableDataTypes(): Promise<Array<TransmittableDataType>>;
230
238
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentiance-react-native/core",
3
- "version": "6.1.1",
3
+ "version": "6.2.0-rc.1",
4
4
  "description": "React Native Sentiance core library",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",