Skip to content

feat: Add disabledKits option to MParticleOptions#347

Merged
BrandonStalnaker merged 4 commits intodevelopmentfrom
feat/SQDSDKS-7214-Add-DisabledKits-Option-To-MParticleOptions
Apr 22, 2025
Merged

feat: Add disabledKits option to MParticleOptions#347
BrandonStalnaker merged 4 commits intodevelopmentfrom
feat/SQDSDKS-7214-Add-DisabledKits-Option-To-MParticleOptions

Conversation

@BrandonStalnaker
Copy link
Copy Markdown
Collaborator

Summary

  • Added a disabledKits property to mParticleOptions that prevents an kit with a matching kit ID from being initialized or sent events.

Testing Plan

  • Was this tested locally? If not, explain why.
  • Tested locally and through sample app

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

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot wasn't able to review any files in this pull request.

Files not reviewed (5)
  • UnitTests/MPKitContainerTests.m: Language not supported
  • mParticle-Apple-SDK/Include/MPKitContainer.h: Language not supported
  • mParticle-Apple-SDK/Include/mParticle.h: Language not supported
  • mParticle-Apple-SDK/Kits/MPKitContainer.mm: Language not supported
  • mParticle-Apple-SDK/mParticle.m: Language not supported

if (active && !disabledByRamping && !disabledByConsent && !disabledByExcludingAnonymousUsers) {
BOOL disabledKit = [_disabledKits containsObject:kitRegister.code];

if (active && !disabledByRamping && !disabledByConsent && !disabledByExcludingAnonymousUsers && !disabledKit) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nitpick: I would extract all of these individual AND conditionals into a convenience method (hasKitBeenDisabled or something concise) to keep this code readable.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I don't necessarily agree with this since this logic isn't reused anywhere else but I did the change anyway. To me this is less readable and more obfuscated.


self.kitsInitialized = YES;
BOOL shouldStartKit = !(_disabledKits != nil && [_disabledKits containsObject:kitConfiguration.integrationId]);
if (shouldStartKit) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: The indenting looks way off here.

if (kitInstance) {

BOOL disabled = [self isDisabledByConsentKitFilter:kitConfiguration.consentKitFilter];
BOOL disabled = [self isDisabledByConsentKitFilter:kitConfiguration.consentKitFilter] || [_disabledKits containsObject:kitRegister.code];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nitpick/Readability: Same here. I would consider creating an isDisabled convenience method here.

self.kitConfigurations[kitConfiguration.integrationId] = kitConfiguration;
[self startKit:kitConfiguration.integrationId configuration:kitConfiguration];

self.kitsInitialized = YES;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit. kitsInitialized will be set to YES for every iteration of the loop. It might be better to just check the list of configured kits once the loop is done, then set it to YES, kind of like how self.sideloadedKits.count is being checked below.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i concur

@rmi22186
Copy link
Copy Markdown
Member

Can we add enums so that a customer doesn't have to look through code to determine the module id when passing through?

Copy link
Copy Markdown
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.

Seeing from cursor that a couple additional tests shoudl be added...can you leverage cursor to try to add tests such as:

  • (void)testDisableMultipleKits
  • (void)testDisableNonExistentKit
  • (void)testDisableKitAfterStart // not really sure what this means
  • (void)testDisableKitAfterConfiguration // not really sure what this means
  • (void)testEmptyDisabledKitsArray
  • (void)testNilDisabledKits

@rmi22186
Copy link
Copy Markdown
Member

besides the additon of stated tests and smll comment about confirming the reason eau is false, this looks good

@BrandonStalnaker BrandonStalnaker merged commit f708431 into development Apr 22, 2025
10 of 12 checks passed
@BrandonStalnaker BrandonStalnaker deleted the feat/SQDSDKS-7214-Add-DisabledKits-Option-To-MParticleOptions branch April 22, 2025 13:45
mparticle-automation added a commit that referenced this pull request Apr 24, 2025
# [8.30.0](v8.29.0...v8.30.0) (2025-04-24)

### Features

* Add disabledKits option to MParticleOptions ([#347](#347)) ([f708431](f708431))
* Add MPRoktEmbeddedView Class ([#345](#345)) ([f4fb946](f4fb946))
* Add user attribute mapping ([#343](#343)) ([50ce934](50ce934))
* Automatically include sandbox in MPRokt Attributes ([#344](#344)) ([bdf4280](bdf4280))
@mparticle-automation
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 8.30.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants