11import { Batch } from '@mparticle/event-models' ;
22import Constants from './constants' ;
3- import { SDKEvent , MParticleWebSDK , SDKLoggerApi } from './sdkRuntimeModels' ;
3+ import { SDKEvent , SDKLoggerApi } from './sdkRuntimeModels' ;
44import { convertEvents } from './sdkToEventsApiConverter' ;
55import { MessageType } from './types' ;
66import { getRampNumber , isEmpty } from './utils' ;
@@ -12,6 +12,7 @@ import {
1212 IFetchPayload ,
1313} from './uploaders' ;
1414import { IMParticleUser } from './identity-user-interfaces' ;
15+ import { IMParticleWebSDKInstance } from './mp-instance' ;
1516
1617/**
1718 * BatchUploader contains all the logic to store/retrieve events and batches
@@ -36,7 +37,7 @@ export class BatchUploader {
3637 uploadIntervalMillis : number ;
3738 eventsQueuedForProcessing : SDKEvent [ ] ;
3839 batchesQueuedForProcessing : Batch [ ] ;
39- mpInstance : MParticleWebSDK ;
40+ mpInstance : IMParticleWebSDKInstance ;
4041 uploadUrl : string ;
4142 batchingEnabled : boolean ;
4243 private eventVault : SessionStorageVault < SDKEvent [ ] > ;
@@ -46,10 +47,10 @@ export class BatchUploader {
4647
4748 /**
4849 * Creates an instance of a BatchUploader
49- * @param {MParticleWebSDK } mpInstance - the mParticle SDK instance
50+ * @param {IMParticleWebSDKInstance } mpInstance - the mParticle SDK instance
5051 * @param {number } uploadInterval - the desired upload interval in milliseconds
5152 */
52- constructor ( mpInstance : MParticleWebSDK , uploadInterval : number ) {
53+ constructor ( mpInstance : IMParticleWebSDKInstance , uploadInterval : number ) {
5354 this . mpInstance = mpInstance ;
5455 this . uploadIntervalMillis = uploadInterval ;
5556 this . batchingEnabled =
@@ -208,7 +209,7 @@ export class BatchUploader {
208209 private static createNewBatches (
209210 sdkEvents : SDKEvent [ ] ,
210211 defaultUser : IMParticleUser ,
211- mpInstance : MParticleWebSDK
212+ mpInstance : IMParticleWebSDKInstance
212213 ) : Batch [ ] | null {
213214 if ( ! defaultUser || ! sdkEvents || ! sdkEvents . length ) {
214215 return null ;
@@ -280,9 +281,9 @@ export class BatchUploader {
280281 * @param triggerFuture whether to trigger the loop again - for manual/forced uploads this should be false
281282 * @param useBeacon whether to use the beacon API - used when the page is being unloaded
282283 */
283- private async prepareAndUpload (
284- triggerFuture : boolean ,
285- useBeacon : boolean
284+ public async prepareAndUpload (
285+ triggerFuture : boolean = false ,
286+ useBeacon : boolean = false ,
286287 ) : Promise < void > {
287288 // Fetch current user so that events can be grouped by MPID
288289 const currentUser = this . mpInstance . Identity . getCurrentUser ( ) ;
0 commit comments