Skip to content

Commit fa9e65e

Browse files
fix: Update new mParticleInstance instantiation (#974)
1 parent 827f3ef commit fa9e65e

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/mparticle-instance-manager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function mParticle() {
6767
).toLowerCase();
6868
var client = self._instances[instanceName];
6969
if (client === undefined) {
70-
client = new mParticleInstance(apiKey, config, instanceName);
70+
client = new mParticleInstance(instanceName);
7171
self._instances[instanceName] = client;
7272
}
7373

src/sdkRuntimeModels.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ export interface SDKProduct {
163163

164164
export interface MParticleWebSDK {
165165
addForwarder(mockForwarder: MPForwarder): void;
166+
_instanceName: string;
166167
_IntegrationCapture: IntegrationCapture;
167168
IdentityType: valueof<typeof IdentityType>;
168169
CommerceEventType: valueof<typeof CommerceEventType>;

test/src/tests-mparticle-instance-manager.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,18 @@ describe('mParticle instance manager', () => {
291291
fetchMock.restore();
292292
});
293293

294+
it('uses the correct instance name to identify an instance', async () => {
295+
await waitForCondition(() => (
296+
mParticle.getInstance('default_instance')._Store.configurationLoaded === true &&
297+
mParticle.getInstance('instance2')._Store.configurationLoaded === true &&
298+
mParticle.getInstance('instance3')._Store.configurationLoaded === true
299+
));
300+
301+
expect(mParticle.getInstance('default_instance')._instanceName).to.equal('default_instance');
302+
expect(mParticle.getInstance('instance2')._instanceName).to.equal('instance2');
303+
expect(mParticle.getInstance('instance3')._instanceName).to.equal('instance3');
304+
});
305+
294306
it('creates multiple instances with their own cookies', done => {
295307
// setTimeout to allow config to come back from the beforeEach initialization
296308
setTimeout(() => {

0 commit comments

Comments
 (0)