Skip to content

Commit

Permalink
Save Point
Browse files Browse the repository at this point in the history
  • Loading branch information
alexs-mparticle committed Nov 21, 2024
1 parent ca3e97f commit a45d30f
Show file tree
Hide file tree
Showing 18 changed files with 1,025 additions and 697 deletions.
2 changes: 1 addition & 1 deletion src/apiClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export default function APIClient(
this.queueEventForBatchUpload(event);
}

if (event.EventName !== Types.MessageType.AppStateTransition) {
if (event.EventName !== Types.MessageType.AppStateTransition.toString()) {
if (kitBlocker && kitBlocker.kitBlockingEnabled) {
event = kitBlocker.createBlockedEvent(event);
}
Expand Down
6 changes: 3 additions & 3 deletions src/identity-user-interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AllUserAttributes, MPID, Product, User } from '@mparticle/web-sdk';
import { SDKIdentityTypeEnum } from './identity.interfaces';
import { MessageType } from './types.interfaces';
import { MessageType } from './types';
import { BaseEvent } from './sdkRuntimeModels';
import Constants from './constants';
const { HTTPCodes } = Constants;
Expand Down Expand Up @@ -58,7 +58,7 @@ export interface ISDKUserIdentityChangeData {
}

export interface IUserIdentityChangeEvent extends BaseEvent {
messageType: MessageType.UserIdentityChange;
messageType: typeof MessageType.UserIdentityChange;
userIdentityChanges: ISDKUserIdentityChanges;
}

Expand All @@ -75,7 +75,7 @@ export interface ISDKUserAttributeChangeData {
}

export interface IUserAttributeChangeEvent extends BaseEvent {
messageType: MessageType.UserAttributeChange;
messageType: typeof MessageType.UserAttributeChange;
userAttributeChanges: ISDKUserAttributeChangeData;
}

Expand Down
4 changes: 2 additions & 2 deletions src/identity.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
isObject,
} from './utils';
import { hasMPIDAndUserLoginChanged, hasMPIDChanged } from './user-utils';
import { getNewIdentitiesByName } from './type-utils';
import { IdentityType } from './types';
import { processReadyQueue } from './pre-init-utils';

export default function Identity(mpInstance) {
Expand Down Expand Up @@ -1623,7 +1623,7 @@ export default function Identity(mpInstance) {
self.setForwarderCallbacks(newUser, method);
}

const newIdentitiesByName = getNewIdentitiesByName(
const newIdentitiesByName = IdentityType.getNewIdentitiesByName(
newIdentitiesByType
);

Expand Down
12 changes: 6 additions & 6 deletions src/kitFilterHelper.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { generateHash } from "./utils";
import { generateHash, valueof } from "./utils";
// TODO: https://mparticle-eng.atlassian.net/browse/SQDSDKS-5381
import { EventTypeEnum, IdentityType } from "./types.interfaces";
import { EventType, IdentityType } from "./types";

export default class KitFilterHelper {
static hashEventType(eventType: EventTypeEnum): number {
static hashEventType(eventType: valueof<typeof EventType>): number {
return generateHash(eventType as unknown as string);
};

static hashEventName(eventName: string, eventType: EventTypeEnum): number {
static hashEventName(eventName: string, eventType: valueof<typeof EventType>): number {
return generateHash(eventType + eventName);
};

static hashEventAttributeKey(eventType: EventTypeEnum, eventName: string, customAttributeName: string): number {
static hashEventAttributeKey(eventType: valueof<typeof EventType>, eventName: string, customAttributeName: string): number {
return generateHash(eventType + eventName + customAttributeName);
}

Expand All @@ -21,7 +21,7 @@ export default class KitFilterHelper {

// User Identities are not actually hashed, this method is named this way to
// be consistent with the filter class. UserIdentityType is also a number
static hashUserIdentity(userIdentity: IdentityType): IdentityType {
static hashUserIdentity(userIdentity: typeof IdentityType): typeof IdentityType {
return userIdentity;
}

Expand Down
4 changes: 2 additions & 2 deletions src/sdkRuntimeModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
IdentityCallback,
ISDKUserAttributes,
} from './identity-user-interfaces';
import { IIdentityType } from './types.interfaces';
import { IdentityType } from './types';
import IntegrationCapture from './integrationCapture';
import { INativeSdkHelpers } from './nativeSdkHelpers.interfaces';
import { ICookieSyncManager, IPixelConfiguration } from './cookieSyncManager.interfaces';
Expand Down Expand Up @@ -154,7 +154,7 @@ interface IEvents {
export interface MParticleWebSDK {
addForwarder(mockForwarder: MPForwarder): void;
_IntegrationCapture: IntegrationCapture;
IdentityType: IIdentityType;
IdentityType: typeof IdentityType;
_Identity: IIdentity;
Identity: SDKIdentityApi;
Logger: SDKLoggerApi;
Expand Down
23 changes: 12 additions & 11 deletions src/sideloadedKit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,23 @@ import {
IKitFilterSettings,
} from './configAPIClient';
import { UnregisteredKit } from './forwarders.interfaces';
import { EventTypeEnum, IdentityType } from './types.interfaces';
import { EventType, IdentityType } from './types';
import { valueof } from './utils';

export interface IMPSideloadedKit {
kitInstance: UnregisteredKit;
filterDictionary: IKitFilterSettings;

addEventTypeFilter(eventType: EventTypeEnum): void;
addEventNameFilter(eventType: EventTypeEnum, eventName: string): void;
addEventTypeFilter(eventType: valueof<typeof EventType>): void;
addEventNameFilter(eventType: valueof<typeof EventType>, eventName: string): void;
addEventAttributeFilter(
eventType: EventTypeEnum,
eventType: valueof<typeof EventType>,
eventName: string,
customAttributeKey: string
): void;
addScreenNameFilter(screenName: string): void;
addScreenAttributeFilter(screenName: string, screenAttribute: string): void;
addUserIdentityFilter(userIdentity: IdentityType): void;
addUserIdentityFilter(userIdentity: typeof IdentityType): void;
addUserAttributeFilter(userAttributeKey: string): void;
}

Expand Down Expand Up @@ -57,13 +58,13 @@ export default class MPSideloadedKit implements IMPSideloadedKit{
this.kitInstance = unregisteredKitInstance;
}

public addEventTypeFilter(eventType: EventTypeEnum): void {
public addEventTypeFilter(eventType: valueof<typeof EventType>): void {
const hashedEventType = KitFilterHelper.hashEventType(eventType);
this.filterDictionary.eventTypeFilters.push(hashedEventType);
}

public addEventNameFilter(
eventType: EventTypeEnum,
eventType: valueof<typeof EventType>,
eventName: string
): void {
const hashedEventName = KitFilterHelper.hashEventName(
Expand All @@ -74,7 +75,7 @@ export default class MPSideloadedKit implements IMPSideloadedKit{
}

public addEventAttributeFilter(
eventType: EventTypeEnum,
eventType: valueof<typeof EventType>,
eventName: string,
customAttributeKey: string
): void {
Expand All @@ -89,7 +90,7 @@ export default class MPSideloadedKit implements IMPSideloadedKit{
public addScreenNameFilter(screenName: string): void {
const hashedScreenName = KitFilterHelper.hashEventName(
screenName,
EventTypeEnum.Unknown
EventType.Unknown,
);
this.filterDictionary.screenNameFilters.push(hashedScreenName);
}
Expand All @@ -99,7 +100,7 @@ export default class MPSideloadedKit implements IMPSideloadedKit{
screenAttribute: string
): void {
const hashedScreenAttribute = KitFilterHelper.hashEventAttributeKey(
EventTypeEnum.Unknown,
EventType.Unknown,
screenName,
screenAttribute
);
Expand All @@ -108,7 +109,7 @@ export default class MPSideloadedKit implements IMPSideloadedKit{
);
}

public addUserIdentityFilter(userIdentity: IdentityType): void {
public addUserIdentityFilter(userIdentity: typeof IdentityType): void {
const hashedIdentityType = KitFilterHelper.hashUserIdentity(
userIdentity
);
Expand Down
129 changes: 0 additions & 129 deletions src/type-utils.ts

This file was deleted.

Loading

0 comments on commit a45d30f

Please sign in to comment.