Skip to content

Conversation

@alexs-mparticle
Copy link
Collaborator

@alexs-mparticle alexs-mparticle commented Feb 10, 2025

Instructions

  1. PR target branch should be against development
  2. PR title name should follow this format: https://github.com/mParticle/mparticle-workflows/blob/main/.github/workflows/pr-title-check.yml
  3. PR branch prefix should follow this format: https://github.com/mParticle/mparticle-workflows/blob/main/.github/workflows/pr-branch-check-name.yml

Summary

  • Migrates Forwarder Tests to TypeScript
  • Verifies imported interfaces and types to ensure they are properly implemented.

Testing Plan

  • Was this tested locally? If not, explain why.
  • Verify automated tests pass and the repo builds properly
  • Manually confirm Identity and Event Types are accessible via the mParticle object in the dev console.

Reference Issue (For mParticle employees only. Ignore if you are an outside contributor)

@alexs-mparticle alexs-mparticle force-pushed the test/SQDSDKS-5767-forwarder-tests-ts branch from b7b5e0c to f06f6e2 Compare February 10, 2025 14:53
@alexs-mparticle alexs-mparticle added the refactor Changes to the structure of the code label Feb 10, 2025
Copy link
Member

@rmi22186 rmi22186 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good so far...

// this.EventType = EventType as unknown as valueof<typeof EventType>;
this.EventType = EventType;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which one works here?

Comment on lines 36 to 35
// this.EventType = EventType as unknown as valueof<typeof EventType>;
this.EventType = EventType;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto to comment above

} = Utils;

const mParticle = window.mParticle;
// interface MockMParticleForIntegrationCapture extends IMParticleInstanceManager {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

necessary?

import Types from '../../src/types';
import { DataPlanVersion } from '@mparticle/data-planning-models';
import fetchMock from 'fetch-mock/esm/client';
// import { IMockForwarder } from './tests-forwarders';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed?

mParticle.logPageView();

Should(window.MockForwarder1.instance.receivedEvent).not.be.ok();
mParticle.logPageView('Page View');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This argument to logPageView is technically optional, so we should update that in the definition. When it is invoked with no arguments, it will automatically log event attributes with title and hostname, but when you pass an argument, it will set an attribute called screen_name


mParticle.init(apiKey, window.mParticle.config);
await waitForCondition(hasIdentityCallInflightReturned);
await waitForCondition(() => window.mParticle.getInstance()?._Store?.identityCallInFlight === false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, why the change for this? Should we change the definition of hasIdentityCallInflightReturned to be this instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this a mistake on my part.

});

it('should set only strings as integration attributes', async function() {
it('should set only strings as integration attributes', async () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think renaming this to sanitize is better actually, otherwise it sounds like we may be converting to strings

Suggested change
it('should set only strings as integration attributes', async () => {
it('should sanitize any non-strings from integration attributes', async () => {

// client calls reset
mParticle.reset();
// QUESTION: Should this actually take a parameter? it should probably be optional
mParticle.reset(null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't look like it based on the function signatures and how its used - in this case you are calling reset on the instance manager, which will automatically call the default instance and pass in that instance.

however, we should make a ticket to revisit reset in general and see how we can make it better. right now it's mostly used for tests, but i do believe customers have asked how they could perform some sort of similar functionality

Comment on lines 3388 to 3389
// QUESTION: Where is this coming from?
// expect(mpInstance._Store.isUsingSideloadedKits).to.be.undefined;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is likely a relic of a test when I was developing this. Putting my archaeology hat on...when i look at the store.ts, I see sideloadedKitsCount. So that probably suppllanted isUsingSideloadedKits and adds more info because if sideloadedKitsCount is greater than 0, that gives us the answer to "are they using side loaded kits", and also "how many are they using"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC I added sideloadedKitsCount when we were trying to add metrics around side loaded kits. Not sure if that helps add context.

I say we probably should just remove this line since it's not a real method.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea i agree with removing

@alexs-mparticle alexs-mparticle marked this pull request as ready for review February 12, 2025 20:21
Copy link
Member

@rmi22186 rmi22186 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one question otherwise looks great

@alexs-mparticle alexs-mparticle force-pushed the test/SQDSDKS-5767-forwarder-tests-ts branch from 8d9f826 to 351b0ff Compare February 17, 2025 15:51
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
39.0% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@alexs-mparticle alexs-mparticle merged commit 40d4f1d into development Feb 28, 2025
21 of 29 checks passed
@mparticle-automation
Copy link
Collaborator

🎉 This PR is included in version 2.34.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Changes to the structure of the code released wait to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants