Skip to content

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

Open
@davidtiede

Description

@davidtiede

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions