@@ -136,35 +136,12 @@ public interface MessageListener {
136
136
* Prepare Messages for Upload.
137
137
*/
138
138
139
- public void createSessionHistoryUploadMessage (ConfigManager configManager , DeviceAttributes deviceAttributes , String currentSessionId ) throws JSONException {
140
- MPDatabase db = getDatabase ();
141
- db .beginTransaction ();
142
- try {
143
- List <MessageService .ReadyMessage > readyMessages = MessageService .getSessionHistory (db , currentSessionId );
144
- if (readyMessages .size () <= 0 ) {
145
- db .setTransactionSuccessful ();
146
- return ;
147
- }
148
-
149
- HashMap <BatchId , MessageBatch > uploadMessagesByBatchId = getUploadMessageByBatchIdMap (readyMessages , db , configManager , true );
150
-
151
- List <JSONObject > deviceInfos = SessionService .processSessions (db , uploadMessagesByBatchId );
152
- for (JSONObject deviceInfo : deviceInfos ) {
153
- deviceAttributes .updateDeviceInfo (mContext , deviceInfo );
154
- }
155
- createUploads (uploadMessagesByBatchId , db , deviceAttributes , configManager , currentSessionId , true );
156
- db .setTransactionSuccessful ();
157
- } finally {
158
- db .endTransaction ();
159
- }
160
- }
161
-
162
139
public boolean hasMessagesForUpload () {
163
140
MPDatabase db = getDatabase ();
164
141
return MessageService .hasMessagesForUpload (db );
165
142
}
166
143
167
- public void createMessagesForUploadMessage (ConfigManager configManager , DeviceAttributes deviceAttributes , String currentSessionId , boolean sessionHistoryEnabled ) throws JSONException {
144
+ public void createMessagesForUploadMessage (ConfigManager configManager , DeviceAttributes deviceAttributes , String currentSessionId ) throws JSONException {
168
145
MPDatabase db = getDatabase ();
169
146
db .beginTransaction ();
170
147
try {
@@ -173,7 +150,7 @@ public void createMessagesForUploadMessage(ConfigManager configManager, DeviceAt
173
150
db .setTransactionSuccessful ();
174
151
return ;
175
152
}
176
- HashMap <BatchId , MessageBatch > uploadMessagesByBatchId = getUploadMessageByBatchIdMap (readyMessages , db , configManager , false , sessionHistoryEnabled );
153
+ HashMap <BatchId , MessageBatch > uploadMessagesByBatchId = getUploadMessageByBatchIdMap (readyMessages , db , configManager , false );
177
154
178
155
List <ReportingService .ReportingMessage > reportingMessages = ReportingService .getReportingMessagesForUpload (db );
179
156
for (ReportingService .ReportingMessage reportingMessage : reportingMessages ) {
@@ -209,7 +186,7 @@ public void createMessagesForUploadMessage(ConfigManager configManager, DeviceAt
209
186
for (JSONObject deviceInfo : deviceInfos ) {
210
187
deviceAttributes .updateDeviceInfo (mContext , deviceInfo );
211
188
}
212
- createUploads (uploadMessagesByBatchId , db , deviceAttributes , configManager , currentSessionId , false , sessionHistoryEnabled );
189
+ createUploads (uploadMessagesByBatchId , db , deviceAttributes , configManager , currentSessionId );
213
190
db .setTransactionSuccessful ();
214
191
} finally {
215
192
db .endTransaction ();
@@ -228,11 +205,11 @@ public void deleteMessagesAndSessions(String currentSessionId) {
228
205
}
229
206
}
230
207
231
- private HashMap <BatchId , MessageBatch > getUploadMessageByBatchIdMap (List <MessageService .ReadyMessage > readyMessages , MPDatabase db , ConfigManager configManager , boolean isHistory ) throws JSONException {
232
- return getUploadMessageByBatchIdMap (readyMessages , db , configManager , isHistory , false );
208
+ private HashMap <BatchId , MessageBatch > getUploadMessageByBatchIdMap (List <MessageService .ReadyMessage > readyMessages , MPDatabase db , ConfigManager configManager ) throws JSONException {
209
+ return getUploadMessageByBatchIdMap (readyMessages , db , configManager , false );
233
210
}
234
211
235
- private HashMap <BatchId , MessageBatch > getUploadMessageByBatchIdMap (List <MessageService .ReadyMessage > readyMessages , MPDatabase db , ConfigManager configManager , boolean isHistory , boolean markAsUpload ) throws JSONException {
212
+ private HashMap <BatchId , MessageBatch > getUploadMessageByBatchIdMap (List <MessageService .ReadyMessage > readyMessages , MPDatabase db , ConfigManager configManager , boolean markAsUpload ) throws JSONException {
236
213
HashMap <BatchId , MessageBatch > uploadMessagesByBatchId = new HashMap <BatchId , MessageBatch >();
237
214
int highestUploadedMessageId = -1 ;
238
215
for (MessageService .ReadyMessage readyMessage : readyMessages ) {
@@ -247,11 +224,7 @@ private HashMap<BatchId, MessageBatch> getUploadMessageByBatchIdMap(List<Message
247
224
if (messageLength + uploadMessage .getMessageLengthBytes () > Constants .LIMIT_MAX_UPLOAD_SIZE ) {
248
225
break ;
249
226
}
250
- if (isHistory ) {
251
- uploadMessage .addSessionHistoryMessage (msgObject );
252
- } else {
253
- uploadMessage .addMessage (msgObject );
254
- }
227
+ uploadMessage .addMessage (msgObject );
255
228
InternalListenerManager .getListener ().onCompositeObjects (readyMessage , uploadMessage );
256
229
uploadMessage .incrementMessageLengthBytes (messageLength );
257
230
highestUploadedMessageId = readyMessage .getMessageId ();
@@ -266,11 +239,7 @@ private HashMap<BatchId, MessageBatch> getUploadMessageByBatchIdMap(List<Message
266
239
return uploadMessagesByBatchId ;
267
240
}
268
241
269
- private void createUploads (Map <BatchId , MessageBatch > uploadMessagesByBatchId , MPDatabase db , DeviceAttributes deviceAttributes , ConfigManager configManager , String currentSessionId , boolean historyMessages ) {
270
- createUploads (uploadMessagesByBatchId , db , deviceAttributes , configManager , currentSessionId , historyMessages , false );
271
- }
272
-
273
- private void createUploads (Map <BatchId , MessageBatch > uploadMessagesByBatchId , MPDatabase db , DeviceAttributes deviceAttributes , ConfigManager configManager , String currentSessionId , boolean historyMessages , boolean sessionHistoryEnabled ) {
242
+ private void createUploads (Map <BatchId , MessageBatch > uploadMessagesByBatchId , MPDatabase db , DeviceAttributes deviceAttributes , ConfigManager configManager , String currentSessionId ) {
274
243
for (Map .Entry <BatchId , MessageBatch > messageBatchEntry : uploadMessagesByBatchId .entrySet ()) {
275
244
BatchId batchId = messageBatchEntry .getKey ();
276
245
MessageBatch uploadMessage = messageBatchEntry .getValue ();
@@ -284,12 +253,7 @@ private void createUploads(Map<BatchId, MessageBatch> uploadMessagesByBatchId, M
284
253
if (uploadMessage .getDeviceInfo () == null || sessionId .equals (currentSessionId )) {
285
254
uploadMessage .setDeviceInfo (deviceAttributes .getDeviceInfo (mContext ));
286
255
}
287
- JSONArray messages ;
288
- if (historyMessages ) {
289
- messages = uploadMessage .getSessionHistoryMessages ();
290
- } else {
291
- messages = uploadMessage .getMessages ();
292
- }
256
+ JSONArray messages = uploadMessage .getMessages ();
293
257
JSONArray identities = findIdentityState (configManager , messages , batchId .getMpid ());
294
258
uploadMessage .setIdentities (identities );
295
259
JSONObject userAttributes = findUserAttributeState (messages , batchId .getMpid ());
@@ -311,12 +275,7 @@ private void createUploads(Map<BatchId, MessageBatch> uploadMessagesByBatchId, M
311
275
}
312
276
313
277
UploadService .insertUpload (db , batch , configManager .getApiKey ());
314
- //if this was to process session history, or
315
- //if we're never going to process history AND
316
- //this batch contains a previous session, then delete the session.
317
- if (!historyMessages && !sessionHistoryEnabled ) {
318
- cleanSessions (currentSessionId );
319
- }
278
+ cleanSessions (currentSessionId );
320
279
}
321
280
}
322
281
}
0 commit comments