From 3710586500dbd3725760f46f6a736fd909e18ee7 Mon Sep 17 00:00:00 2001 From: Alex S <49695018+alexs-mparticle@users.noreply.github.com> Date: Wed, 11 Dec 2024 17:01:02 -0500 Subject: [PATCH] refactor: Remove Cookie Sync Interfaces File (#961) --- src/configAPIClient.ts | 2 +- src/cookieSyncManager.interfaces.ts | 39 ----------------------------- src/cookieSyncManager.ts | 39 +++++++++++++++++++++++++++-- src/persistence.interfaces.ts | 2 +- src/sdkRuntimeModels.ts | 2 +- src/store.ts | 2 +- test/jest/cookieSyncManager.spec.ts | 6 +++-- test/src/tests-cookie-syncing.ts | 2 +- 8 files changed, 46 insertions(+), 48 deletions(-) delete mode 100644 src/cookieSyncManager.interfaces.ts diff --git a/src/configAPIClient.ts b/src/configAPIClient.ts index 551d70db..99a00798 100644 --- a/src/configAPIClient.ts +++ b/src/configAPIClient.ts @@ -13,7 +13,7 @@ import { FetchUploader, XHRUploader, } from './uploaders'; -import { IPixelConfiguration } from './cookieSyncManager.interfaces'; +import { IPixelConfiguration } from './cookieSyncManager'; export interface IKitConfigs extends IKitFilterSettings { name: string; diff --git a/src/cookieSyncManager.interfaces.ts b/src/cookieSyncManager.interfaces.ts deleted file mode 100644 index 54b363b5..00000000 --- a/src/cookieSyncManager.interfaces.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { MPID } from '@mparticle/web-sdk'; -import { Dictionary } from './utils'; -import { IConsentRules } from './consent'; - -export type CookieSyncDates = Dictionary; - -export interface IPixelConfiguration { - name?: string; - moduleId: number; - esId?: number; - isDebug?: boolean; - isProduction?: boolean; - settings: Dictionary; - frequencyCap: number; - pixelUrl: string; - redirectUrl: string; - filteringConsentRuleValues?: IConsentRules; -} -export interface ICookieSyncManager { - attemptCookieSync: ( - previousMPID: MPID, - mpid: MPID, - mpidIsNotInCookies?: boolean - ) => void; - performCookieSync: ( - url: string, - moduleId: string, - mpid: MPID, - cookieSyncDates: CookieSyncDates, - filteringConsentRuleValues: IConsentRules, - mpidIsNotInCookies: boolean, - requiresConsent: boolean - ) => void; - combineUrlWithRedirect: ( - mpid: MPID, - pixelUrl: string, - redirectUrl: string - ) => string; -} diff --git a/src/cookieSyncManager.ts b/src/cookieSyncManager.ts index 9f056fed..9822a577 100644 --- a/src/cookieSyncManager.ts +++ b/src/cookieSyncManager.ts @@ -1,6 +1,5 @@ -import { isEmpty, replaceAmpWithAmpersand, replaceMPID } from './utils'; +import { Dictionary, isEmpty, replaceAmpWithAmpersand, replaceMPID } from './utils'; import Constants from './constants'; -import { CookieSyncDates, ICookieSyncManager, IPixelConfiguration } from './cookieSyncManager.interfaces'; import { MParticleWebSDK } from './sdkRuntimeModels'; import { MPID } from '@mparticle/web-sdk'; import { IConsentRules } from './consent'; @@ -10,6 +9,42 @@ const { InformationMessages } = Messages; export const DAYS_IN_MILLISECONDS = 1000 * 60 * 60 * 24; +export type CookieSyncDates = Dictionary; + +export interface IPixelConfiguration { + name?: string; + moduleId: number; + esId?: number; + isDebug?: boolean; + isProduction?: boolean; + settings: Dictionary; + frequencyCap: number; + pixelUrl: string; + redirectUrl: string; + filteringConsentRuleValues?: IConsentRules; +} +export interface ICookieSyncManager { + attemptCookieSync: ( + previousMPID: MPID, + mpid: MPID, + mpidIsNotInCookies?: boolean + ) => void; + performCookieSync: ( + url: string, + moduleId: string, + mpid: MPID, + cookieSyncDates: CookieSyncDates, + filteringConsentRuleValues: IConsentRules, + mpidIsNotInCookies: boolean, + requiresConsent: boolean + ) => void; + combineUrlWithRedirect: ( + mpid: MPID, + pixelUrl: string, + redirectUrl: string + ) => string; +} + const hasFrequencyCapExpired = ( frequencyCap: number, lastSyncDate?: number, diff --git a/src/persistence.interfaces.ts b/src/persistence.interfaces.ts index 4c89ec69..1fc58533 100644 --- a/src/persistence.interfaces.ts +++ b/src/persistence.interfaces.ts @@ -14,7 +14,7 @@ import { import { Dictionary } from './utils'; import { IMinifiedConsentJSONObject } from './consent'; import { UserAttributes } from './identity-user-interfaces'; -import { CookieSyncDates } from './cookieSyncManager.interfaces'; +import { CookieSyncDates } from './cookieSyncManager'; export type UploadsTable = Dictionary; export interface iForwardingStatsBatches { diff --git a/src/sdkRuntimeModels.ts b/src/sdkRuntimeModels.ts index 91379055..b4637b5b 100644 --- a/src/sdkRuntimeModels.ts +++ b/src/sdkRuntimeModels.ts @@ -36,7 +36,7 @@ import { } from './types'; import IntegrationCapture from './integrationCapture'; import { INativeSdkHelpers } from './nativeSdkHelpers.interfaces'; -import { ICookieSyncManager, IPixelConfiguration } from './cookieSyncManager.interfaces'; +import { ICookieSyncManager, IPixelConfiguration } from './cookieSyncManager'; // TODO: Resolve this with version in @mparticle/web-sdk export type SDKEventCustomFlags = Dictionary; diff --git a/src/store.ts b/src/store.ts index 91f6fd51..0c8534db 100644 --- a/src/store.ts +++ b/src/store.ts @@ -37,7 +37,7 @@ import { IGlobalStoreV2MinifiedKeys, IPersistenceMinified, } from './persistence.interfaces'; -import { CookieSyncDates, IPixelConfiguration } from './cookieSyncManager.interfaces'; +import { CookieSyncDates, IPixelConfiguration } from './cookieSyncManager'; // This represents the runtime configuration of the SDK AFTER // initialization has been complete and all settings and diff --git a/test/jest/cookieSyncManager.spec.ts b/test/jest/cookieSyncManager.spec.ts index 860251ab..01467a92 100644 --- a/test/jest/cookieSyncManager.spec.ts +++ b/test/jest/cookieSyncManager.spec.ts @@ -1,5 +1,7 @@ -import CookieSyncManager, { DAYS_IN_MILLISECONDS } from '../../src/cookieSyncManager'; -import { IPixelConfiguration } from '../../src/cookieSyncManager.interfaces'; +import CookieSyncManager, { + DAYS_IN_MILLISECONDS, + IPixelConfiguration, +} from '../../src/cookieSyncManager'; import { MParticleWebSDK } from '../../src/sdkRuntimeModels'; import { testMPID } from '../src/config/constants'; diff --git a/test/src/tests-cookie-syncing.ts b/test/src/tests-cookie-syncing.ts index e30e27aa..6eae3050 100644 --- a/test/src/tests-cookie-syncing.ts +++ b/test/src/tests-cookie-syncing.ts @@ -4,7 +4,7 @@ import fetchMock from 'fetch-mock/esm/client'; import { urls, testMPID, MPConfig, v4LSKey, apiKey } from './config/constants'; import { MParticleWebSDK } from '../../src/sdkRuntimeModels'; import { IMParticleUser } from '../../src/identity-user-interfaces'; -import { IPixelConfiguration } from '../../src/cookieSyncManager.interfaces'; +import { IPixelConfiguration } from '../../src/cookieSyncManager'; import { IConsentRules } from '../../src/consent'; const { fetchMockSuccess, waitForCondition, hasIdentifyReturned } = Utils;