-
Notifications
You must be signed in to change notification settings - Fork 57
refactor: Migrate Types Module to TypeScript #950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ import { Batch } from '@mparticle/event-models'; | |
| import Constants from './constants'; | ||
| import { SDKEvent, MParticleWebSDK, SDKLoggerApi } from './sdkRuntimeModels'; | ||
| import { convertEvents } from './sdkToEventsApiConverter'; | ||
| import Types from './types'; | ||
| import { MessageType } from './types'; | ||
| import { getRampNumber, isEmpty } from './utils'; | ||
| import { SessionStorageVault, LocalStorageVault } from './vault'; | ||
| import { | ||
|
|
@@ -167,29 +167,35 @@ export class BatchUploader { | |
| * @param event event that should be queued | ||
| */ | ||
| public queueEvent(event: SDKEvent): void { | ||
| if (!isEmpty(event)) { | ||
| this.eventsQueuedForProcessing.push(event); | ||
| if (this.offlineStorageEnabled && this.eventVault) { | ||
| this.eventVault.store(this.eventsQueuedForProcessing); | ||
| } | ||
| this.mpInstance.Logger.verbose( | ||
| `Queuing event: ${JSON.stringify(event)}` | ||
| ); | ||
| this.mpInstance.Logger.verbose( | ||
| `Queued event count: ${this.eventsQueuedForProcessing.length}` | ||
| ); | ||
| if (isEmpty(event)) { | ||
| return; | ||
| } | ||
|
|
||
| // TODO: Remove this check once the v2 code path is removed | ||
| // https://go.mparticle.com/work/SQDSDKS-3720 | ||
| if ( | ||
| !this.batchingEnabled || | ||
| Types.TriggerUploadType[event.EventDataType] | ||
| ) { | ||
| this.prepareAndUpload(false, false); | ||
| } | ||
| const { verbose } = this.mpInstance.Logger; | ||
|
|
||
| this.eventsQueuedForProcessing.push(event); | ||
| if (this.offlineStorageEnabled && this.eventVault) { | ||
| this.eventVault.store(this.eventsQueuedForProcessing); | ||
| } | ||
|
|
||
| verbose(`Queuing event: ${JSON.stringify(event)}`); | ||
| verbose(`Queued event count: ${this.eventsQueuedForProcessing.length}`); | ||
|
|
||
| if (this.shouldTriggerImmediateUpload(event.EventDataType)) { | ||
| this.prepareAndUpload(false, false); | ||
| } | ||
| } | ||
|
|
||
| // https://go.mparticle.com/work/SQDSDKS-3720 | ||
| private shouldTriggerImmediateUpload (eventDataType: number): boolean { | ||
| const priorityEvents = [ | ||
| MessageType.Commerce, | ||
| MessageType.UserIdentityChange, | ||
| ] as const; | ||
alexs-mparticle marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| return !this.batchingEnabled || priorityEvents.includes(eventDataType as typeof priorityEvents[number]); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this some sort of TS black magic? shouldn't
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sort of. This will transpile to |
||
| }; | ||
|
|
||
| /** | ||
| * This implements crucial logic to: | ||
| * - bucket pending events by MPID, and then by Session, and upload individual batches for each bucket. | ||
|
|
||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.