Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Alex S <[email protected]>
  • Loading branch information
rmi22186 and alexs-mparticle authored Nov 9, 2023
1 parent 196b7b8 commit e0f364d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
8 changes: 4 additions & 4 deletions src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,8 @@ export function processBaseUrls(
}

function processCustomBaseUrls(config: SDKInitConfig): Dictionary<string> {
let defaultBaseUrls: Dictionary<string> = Constants.DefaultBaseUrls;
let newBaseUrls: Dictionary<string> = {};
const defaultBaseUrls: Dictionary<string> = Constants.DefaultBaseUrls;
const newBaseUrls: Dictionary<string> = {};

// If there is no custo base url, we use the default base url
for (let baseUrlKey in defaultBaseUrls) {
Expand All @@ -485,8 +485,8 @@ function processDirectBaseUrls(
config: SDKInitConfig,
apiKey: string
): Dictionary {
let defaultBaseUrls = Constants.DefaultBaseUrls;
let directBaseUrls: Dictionary<string> = {};
const defaultBaseUrls = Constants.DefaultBaseUrls;
const directBaseUrls: Dictionary<string> = {};
// When Direct URL Routing is true, we create a new set of baseUrls that
// include the silo in the urls. mParticle API keys are prefixed with the
// silo and a hyphen (ex. "us1-", "us2-", "eu1-"). us1 was the first silo,
Expand Down
44 changes: 22 additions & 22 deletions test/src/tests-core-sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,7 @@ describe('core SDK', function() {
describe('pod feature flag', function() {
const endpoints = Constants.DefaultBaseUrls;
// set up URLs object for each silo
let URLs = {
const URLs = {
us1: {},
us2: {},
eu1: {},
Expand Down Expand Up @@ -1167,9 +1167,9 @@ describe('core SDK', function() {
});

it('should use US1 endpoints for apiKeys that do not start with a prefix', function(done) {
let silo = 'us1';
let apiKey = 'noSiloPrefixApiKey';
let eventsEndpoint = `https://${URLs[silo].v3SecureServiceUrl}${apiKey}/events`;
const silo = 'us1';
const apiKey = 'noSiloPrefixApiKey';
const eventsEndpoint = `https://${URLs[silo].v3SecureServiceUrl}${apiKey}/events`;

fetchMock.post(eventsEndpoint, 200);

Expand All @@ -1185,9 +1185,9 @@ describe('core SDK', function() {
});

it('should use US1 endpoints for apiKeys with prefix `us1`', function(done) {
let silo = 'us1';
let apiKey = 'us1-apiKey';
let eventsEndpoint = `https://${URLs.us1.v3SecureServiceUrl}${apiKey}/events`;
const silo = 'us1';
const apiKey = 'us1-apiKey';
const eventsEndpoint = `https://${URLs.us1.v3SecureServiceUrl}${apiKey}/events`;

fetchMock.post(eventsEndpoint, 200);

Expand All @@ -1203,9 +1203,9 @@ describe('core SDK', function() {
});

it('should use US2 endpoints for apiKeys with prefix `us2`', function(done) {
let silo = 'us2';
let apiKey = 'us2-apiKey';
let eventsEndpoint = `https://${URLs[silo].v3SecureServiceUrl}${apiKey}/events`;
const silo = 'us2';
const apiKey = 'us2-apiKey';
const eventsEndpoint = `https://${URLs[silo].v3SecureServiceUrl}${apiKey}/events`;

fetchMock.post(eventsEndpoint, 200);

Expand All @@ -1221,9 +1221,9 @@ describe('core SDK', function() {
});

it('should use EU1 endpoints for apiKeys with prefix `eu1`', function(done) {
let silo = 'eu1';
let apiKey = 'eu1-apiKey';
let eventsEndpoint = `https://${URLs[silo].v3SecureServiceUrl}${apiKey}/events`;
const silo = 'eu1';
const apiKey = 'eu1-apiKey';
const eventsEndpoint = `https://${URLs[silo].v3SecureServiceUrl}${apiKey}/events`;

fetchMock.post(eventsEndpoint, 200);

Expand All @@ -1239,9 +1239,9 @@ describe('core SDK', function() {
});

it('should use AU1 endpoints for apiKeys with prefix `au1`', function(done) {
let silo = 'au1';
let apiKey = 'au1-apiKey';
let eventsEndpoint = `https://${URLs[silo].v3SecureServiceUrl}${apiKey}/events`;
const silo = 'au1';
const apiKey = 'au1-apiKey';
const eventsEndpoint = `https://${URLs[silo].v3SecureServiceUrl}${apiKey}/events`;

fetchMock.post(eventsEndpoint, 200);

Expand All @@ -1257,9 +1257,9 @@ describe('core SDK', function() {
});

it('should use AU1 endpoints for apiKeys with prefix `st1`', function(done) {
let silo = 'st1';
let apiKey = 'st1-apiKey';
let eventsEndpoint = `https://${URLs[silo].v3SecureServiceUrl}${apiKey}/events`;
const silo = 'st1';
const apiKey = 'st1-apiKey';
const eventsEndpoint = `https://${URLs[silo].v3SecureServiceUrl}${apiKey}/events`;

fetchMock.post(eventsEndpoint, 200);

Expand All @@ -1282,9 +1282,9 @@ describe('core SDK', function() {

const {configUrl, v3SecureServiceUrl, identityUrl, aliasUrl} = window.mParticle.config

let silo = 'us1';
let apiKey = 'noSiloPrefixApiKey';
let eventsEndpoint = `https://${v3SecureServiceUrl}${apiKey}/events`;
const silo = 'us1';
const apiKey = 'noSiloPrefixApiKey';
const eventsEndpoint = `https://${v3SecureServiceUrl}${apiKey}/events`;

fetchMock.post(eventsEndpoint, 200)

Expand Down

0 comments on commit e0f364d

Please sign in to comment.