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 3d87fe2 commit 2209b69
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
3 changes: 1 addition & 2 deletions src/identity.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Constants, { HTTP_OK } from './constants';
import Types from './types';
import Types, { IdentityType } from './types';
import {
cacheOrClearIdCache,
createKnownIdentities,
Expand All @@ -17,7 +17,6 @@ import {
isObject,
} from './utils';
import { hasMPIDAndUserLoginChanged, hasMPIDChanged } from './user-utils';
import { IdentityType } from './types';
import { processReadyQueue } from './pre-init-utils';

export default function Identity(mpInstance) {
Expand Down
4 changes: 2 additions & 2 deletions src/sdkRuntimeModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@mparticle/web-sdk';
import { IStore } from './store';
import Validators from './validators';
import { Dictionary } from './utils';
import { Dictionary, valueof } from './utils';
import { IServerModel } from './serverModel';
import { IKitConfigs } from './configAPIClient';
import { SDKConsentApi, SDKConsentState } from './consent';
Expand Down Expand Up @@ -154,7 +154,7 @@ interface IEvents {
export interface MParticleWebSDK {
addForwarder(mockForwarder: MPForwarder): void;
_IntegrationCapture: IntegrationCapture;
IdentityType: typeof IdentityType;
IdentityType: valueof<typeof IdentityType>;
_Identity: IIdentity;
Identity: SDKIdentityApi;
Logger: SDKLoggerApi;
Expand Down
14 changes: 7 additions & 7 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Constants from './constants';
import { parseNumber } from './utils';
import { parseNumber, valueof } from './utils';

interface IdentitiesByType {
[key: number]: string;
Expand Down Expand Up @@ -87,7 +87,7 @@ export const EventType = {
return 'Other';
}
},
} as const;
};

// Continuation of EventType enum above, but in seperate object since we don't expose these to end user
export const CommerceEventType = {
Expand Down Expand Up @@ -131,7 +131,7 @@ export const IdentityType = {

isValid(identityType: number): boolean {
if (typeof identityType === 'number') {
for (var prop in IdentityType) {
for (const prop in IdentityType) {
if (IdentityType.hasOwnProperty(prop)) {
if (IdentityType[prop] === identityType) {
return true;
Expand Down Expand Up @@ -166,7 +166,7 @@ export const IdentityType = {
}
},

getIdentityType: (identityName: string): typeof IdentityType | boolean => {
getIdentityType: (identityName: string): valueof<typeof IdentityType> | boolean => {
switch (identityName) {
case 'other':
return IdentityType.Other;
Expand Down Expand Up @@ -264,10 +264,10 @@ export const IdentityType = {
}
},

getNewIdentitiesByName: (newIdentitiesByType: IdentitiesByType) => {
getNewIdentitiesByName: (newIdentitiesByType: IdentitiesByType): IdentitiesByType => {
const newIdentitiesByName: IdentitiesByType = {};

for (var key in newIdentitiesByType) {
for (const key in newIdentitiesByType) {
const identityNameKey = IdentityType.getIdentityName(
parseNumber(key)
);
Expand Down Expand Up @@ -384,7 +384,7 @@ export const ApplicationTransitionType = {
AppInit: 1 as const,
};

export default{
export default {
MessageType,
EventType,
CommerceEventType,
Expand Down

0 comments on commit 2209b69

Please sign in to comment.