Skip to content

Fix removeGlobalContexts not removing expected context #1006

Description

Describe the bug
When calling removeGlobalContexts the equality statement is backwards, so it removes unexpected schemas.

globalPrimitives = globalPrimitives.filter((item) => JSON.stringify(item) === JSON.stringify(context));

To Reproduce

    window.snowplow('addGlobalContexts', [{
      schema: 'iglu:com.snowplowanalytics.snowplow/schema1/jsonschema/1-0-0',
      data: {
        prop1: 'hello'
      }
    },
    {
      schema: 'iglu:com.snowplowanalytics.snowplow/schema2/jsonschema/1-0-0',
      data: {
        prop2: 'hello2'
      }
    }]);
    window.snowplow('trackPageView');
    window.snowplow('removeGlobalContexts', [{
      schema: 'iglu:com.snowplowanalytics.snowplow/schema2/jsonschema/1-0-0',
      data: {
        prop2: 'hello2'
      }
    }]);
    window.snowplow('trackPageView');

Expected behavior
With this, schema1 is removed, when it is expected that schema2 should be removed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:defectBugs or weaknesses. The issue has to contain steps to reproduce.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions