Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: unregisterSuperProperty only removes the first property when called multiple times #270

Open
davidtiede opened this issue Sep 26, 2024 · 0 comments

Comments

@davidtiede
Copy link

davidtiede commented Sep 26, 2024

Description:

The public unregisterSuperProperty method in the Mixpanel instance calls an internal asynchronous function (unregisterSuperProperty), but it is handled synchronously. When making multiple calls to unregister super properties, only the first property gets removed, and subsequent properties are missed.

Usage Example

// Example of unregistering multiple super properties
const mixpanelInstance = getMixpanelInstance();  // Assume a Mixpanel instance is initialized

mixpanelInstance.unregisterSuperProperty('property1');
mixpanelInstance.unregisterSuperProperty('property2');
mixpanelInstance.unregisterSuperProperty('property3');

Related Instance Function

unregisterSuperProperty(propertyName) {
  if (!StringHelper.isValid(propertyName)) {
    StringHelper.raiseError(PARAMS.PROPERTY_NAME);
  }
  this.mixpanelImpl.unregisterSuperProperty(this.token, propertyName);
}

Internal Function

async unregisterSuperProperty(token, propertyName) {
  MixpanelLogger.log(token, `Unregister super property '${propertyName}'`);
  let superProperties = this.mixpanelPersistent.getSuperProperties(token);
  delete superProperties[propertyName];
  this._updateSuperProperties(token, superProperties);
  MixpanelLogger.log(token, `Updated Super Properties:`, superProperties);
}

Expected Behavior:

All specified properties should be unregistered when calling unregisterSuperProperty multiple times.

Actual Behavior:

Only the first property is unregistered, and subsequent properties are not removed.

Suggested Enhancement:

Allow unregisterSuperProperty to optionally accept an array of property names and unregister them in a single call.

@davidtiede davidtiede changed the title Make unregisterSuperProperty async (to mimic Bug: unregisterSuperProperty only removes the first property when called multiple times Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant