Skip to content

Commit 744665d

Browse files
Clean up interfaces
1 parent c13ea83 commit 744665d

File tree

2 files changed

+17
-37
lines changed

2 files changed

+17
-37
lines changed

src/mp-instance.ts

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import NativeSdkHelpers from './nativeSdkHelpers';
2424
import CookieSyncManager, { ICookieSyncManager, IPixelConfiguration } from './cookieSyncManager';
2525
import SessionManager, { ISessionManager } from './sessionManager';
2626
import Ecommerce from './ecommerce';
27-
import Store, { IntegrationAttribute, IStore } from './store';
27+
import Store, { IStore } from './store';
2828
import Logger from './logger';
2929
import Persistence from './persistence';
3030
import Events from './events';
@@ -41,8 +41,8 @@ import { LocalStorageVault } from './vault';
4141
import { removeExpiredIdentityCacheDates } from './identity-utils';
4242
import IntegrationCapture from './integrationCapture';
4343
import { IPreInit, processReadyQueue } from './pre-init-utils';
44-
import { BaseEvent, MParticleWebSDK, SDKEventCustomFlags, SDKHelpersApi, } from './sdkRuntimeModels';
45-
import { Callback, SDKEventAttrs, SDKEventOptions } from '@mparticle/web-sdk';
44+
import { BaseEvent, MParticleWebSDK, SDKHelpersApi, } from './sdkRuntimeModels';
45+
import { Callback, SDKEventAttrs } from '@mparticle/web-sdk';
4646
import { IIdentity } from './identity.interfaces';
4747
import { IEvents } from './events.interfaces';
4848
import { IECommerce } from './ecommerce.interfaces';
@@ -85,29 +85,17 @@ export interface IMParticleWebSDKInstance extends MParticleWebSDK {
8585
_Store: IStore;
8686
_ServerModel: IServerModel;
8787

88-
89-
9088
configurePixel(config: IPixelConfiguration): void;
9189
reset(instance: IMParticleWebSDKInstance): void;
9290
ready(f: Function): void;
9391
isInitialized(): boolean;
9492
getEnvironment(): valueof<typeof Constants.Environment>;
9593
getVersion(): string;
94+
logError(error: IErrorLogMessage, attrs?: SDKEventAttrs): void;
9695
setAppVersion(version: string): void;
9796
setAppName(name: string): void;
9897
startTrackingLocation(callback?: Callback): void;
9998
stopTrackingLocation(): void;
100-
logError(error: IErrorLogMessage | string, attrs?: any): void;
101-
102-
// TODO: Define EventInfo
103-
logLink(selector: string, eventName: string, eventType: valueof<typeof EventType>, eventInfo: any): void;
104-
logForm(selector: string, eventName: string, eventType: valueof<typeof EventType>, eventInfo: any): void;
105-
logPageView(eventName: string, attrs?: SDKEventAttrs, customFlags?: SDKEventCustomFlags, eventOptions?: SDKEventOptions): void;
106-
setOptOut(isOptingOut: boolean): void;
107-
108-
// QUESTION: Should integration ID be a number or a string?
109-
setIntegrationAttribute(integrationId: number, attrs: IntegrationAttribute): void;
110-
getIntegrationAttributes(integrationId: number): IntegrationAttribute;
11199
}
112100

113101
const { Messages, HTTPCodes, FeatureFlags } = Constants;
@@ -540,8 +528,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
540528
};
541529
}
542530

543-
// FIXME: Replace var with const/let
544-
var data: IErrorLogMessageMinified = {
531+
const data: IErrorLogMessageMinified = {
545532
m: error.message ? error.message : error as string,
546533
s: 'Error',
547534
t: error.stack || null,
@@ -557,9 +544,8 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
557544
self._Events.logEvent({
558545
messageType: MessageType.CrashReport,
559546
name: error.name ? error.name : 'Error',
560-
// data: data, // QUESTION: Is this a bug? This should be eventType
561547
eventType: EventType.Other,
562-
data: data as { [key: string]: string },
548+
data: data as SDKEventAttrs,
563549
});
564550
};
565551
/**

src/sdkRuntimeModels.ts

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { IMPSideloadedKit } from './sideloadedKit';
1717
import { ISessionManager } from './sessionManager';
1818
import { Kit, MPForwarder } from './forwarders.interfaces';
1919
import {
20-
IIdentity,
2120
SDKIdentityApi,
2221
IAliasCallback,
2322
} from './identity.interfaces';
@@ -38,8 +37,8 @@ import {
3837
} from './types';
3938
import { IPixelConfiguration } from './cookieSyncManager';
4039
import _BatchValidator from './mockBatchCreator';
41-
import { SDKECommerceAPI } from './ecommerce.interfaces';
42-
import { IErrorLogMessage, IMParticleWebSDKInstance, IntegrationDelays } from './mp-instance';
40+
import { SDKECommerceAPI } from './ecommerce.interfaces';
41+
import { IMParticleWebSDKInstance, IntegrationDelays } from './mp-instance';
4342
import Constants from './constants';
4443

4544
// TODO: Resolve this with version in @mparticle/web-sdk
@@ -200,6 +199,10 @@ export interface MParticleWebSDK {
200199
eventOptions?: SDKEventOptions
201200
): void;
202201
logBaseEvent(event: BaseEvent, eventOptions?: SDKEventOptions): void;
202+
logLink(selector: string, eventName: string, eventType: valueof<typeof EventType>, eventInfo: SDKEventAttrs): void;
203+
logForm(selector: string, eventName: string, eventType: valueof<typeof EventType>, eventInfo: SDKEventAttrs): void;
204+
logPageView(eventName: string, attrs?: SDKEventAttrs, customFlags?: SDKEventCustomFlags, eventOptions?: SDKEventOptions): void;
205+
setOptOut(isOptingOut: boolean): void;
203206
eCommerce: SDKECommerceAPI;
204207

205208
// QUESTION: Is this still used?
@@ -208,6 +211,9 @@ export interface MParticleWebSDK {
208211
ProductActionType: valueof<typeof ProductActionType>;
209212
generateHash(value: string): string;
210213

214+
// QUESTION: Should integration ID be a number or a string?
215+
setIntegrationAttribute(integrationId: number, attrs: IntegrationAttribute): void;
216+
getIntegrationAttributes(integrationId: number): IntegrationAttribute;
211217
}
212218

213219
// https://go.mparticle.com/work/SQDSDKS-4805
@@ -235,13 +241,6 @@ export interface IMParticleInstanceManager extends MParticleWebSDK {
235241
getInstance(instanceName?: string): IMParticleWebSDKInstance;
236242
getVersion(): string;
237243
isInitialized(): boolean;
238-
239-
// TODO: Define EventInfo
240-
logError(error: IErrorLogMessage | string, attrs?: any): void;
241-
logForm(selector: string, eventName: string, eventType: valueof<typeof EventType>, eventInfo: any): void;
242-
logLink(selector: string, eventName: string, eventType: valueof<typeof EventType>, eventInfo: any): void;
243-
logPageView(eventName: string, attrs?: SDKEventAttrs, customFlags?: SDKEventCustomFlags, eventOptions?: SDKEventOptions): void;
244-
245244

246245
ready(f: Function): void;
247246
reset(instance: IMParticleWebSDKInstance): void;
@@ -251,11 +250,6 @@ export interface IMParticleInstanceManager extends MParticleWebSDK {
251250
startTrackingLocation(callback?: Callback): void;
252251
stopTrackingLocation(): void;
253252

254-
255-
// QUESTION: Should integration ID be a number or a string?
256-
setIntegrationAttribute(integrationId: number, attrs: IntegrationAttribute): void;
257-
getIntegrationAttributes(integrationId: number): IntegrationAttribute;
258-
259253
// @deprecated
260254
sessionManager: Pick<ISessionManager, 'getSession'>;
261255
}
@@ -350,7 +344,7 @@ export interface SDKHelpersApi {
350344
previousMpid?: MPID
351345
): void;
352346
sanitizeAttributes?(
353-
attrs: Dictionary<string>,
347+
attrs: SDKEventAttrs,
354348
name: string
355349
): Dictionary<string> | null;
356350
Validators: typeof Validators;
@@ -384,7 +378,7 @@ export interface BaseEvent {
384378
messageType: number;
385379
name?: string;
386380
eventType?: number;
387-
data?: { [key: string]: string };
381+
data?: SDKEventAttrs;
388382
customFlags?: { [key: string]: string };
389383
toEventAPIObject?(): SDKEvent;
390384
sourceMessageId?: string;

0 commit comments

Comments
 (0)