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

Core: fix issue with Events sharing one context object. #143

Closed
jbeemster opened this issue Jul 20, 2015 · 1 comment
Closed

Core: fix issue with Events sharing one context object. #143

jbeemster opened this issue Jul 20, 2015 · 1 comment
Assignees
Labels
type:defect Bugs or weaknesses. The issue has to contain steps to reproduce.
Milestone

Comments

@jbeemster
Copy link
Member

The Event builder is returning a single pointer to a context object, so Ecommerce Items end up sharing one context to the effect that if you process one item and update the context, this is reflected in the next item and so on. To fix this the Event class must pass a new ArrayList<>(the context) each time it is fetched so we do not end up with one context in memory.

As you can see contexts have been added multiple times:

"{
    \"schema\": \"iglu: com.snowplowanalytics.snowplow\\/contexts\\/jsonschema\\/1-0-1\",
    \"data\": [
        {
            \"schema\": \"iglu: com.snowplowanalytics.snowplow\\/client_session\\/jsonschema\\/1-0-0\",
            \"data\": {
                \"storageMechanism\": \"SQLITE\",
                \"sessionIndex\": 48,
                \"sessionId\": \"255403fc-6c76-4661-a9ee-bfc0961b5ac3\",
                \"userId\": \"b8cfca3a-6156-4b96-8518-de94d4fa88de\",
                \"previousSessionId\": \"6ad87afa-b774-442a-a80c-b44157f94097\"
            }
        },
        {
            \"schema\": \"iglu: com.snowplowanalytics.snowplow\\/geolocation_context\\/jsonschema\\/1-0-0\",
            \"data\": {
                \"bearing\": 0,
                \"altitude\": 0,
                \"latitude\": 47.3235597,
                \"speed\": 0,
                \"latitudeLongitudeAccuracy\": 20,
                \"longitude\": 5.0383196
            }
        },
        {
            \"schema\": \"iglu: com.snowplowanalytics.snowplow\\/mobile_context\\/jsonschema\\/1-0-0\",
            \"data\": {
                \"osVersion\": \"5.0.2\",
                \"deviceModel\": \"A0001\",
                \"androidIdfa\": \"fc3ca7a9-82c9-4961-a93c-282fb7da9954\",
                \"deviceManufacturer\": \"OnePlus\",
                \"osType\": \"android\",
                \"carrier\": \"Free\"
            }
        },
        {
            \"schema\": \"iglu: com.snowplowanalytics.snowplow\\/client_session\\/jsonschema\\/1-0-0\",
            \"data\": {
                \"storageMechanism\": \"SQLITE\",
                \"sessionIndex\": 48,
                \"sessionId\": \"255403fc-6c76-4661-a9ee-bfc0961b5ac3\",
                \"userId\": \"b8cfca3a-6156-4b96-8518-de94d4fa88de\",
                \"previousSessionId\": \"6ad87afa-b774-442a-a80c-b44157f94097\"
            }
        },
        {
            \"schema\": \"iglu: com.snowplowanalytics.snowplow\\/geolocation_context\\/jsonschema\\/1-0-0\",
            \"data\": {
                \"bearing\": 0,
                \"altitude\": 0,
                \"latitude\": 47.3235597,
                \"speed\": 0,
                \"latitudeLongitudeAccuracy\": 20,
                \"longitude\": 5.0383196
            }
        },
        {
            \"schema\": \"iglu: com.snowplowanalytics.snowplow\\/mobile_context\\/jsonschema\\/1-0-0\",
            \"data\": {
                \"osVersion\": \"5.0.2\",
                \"deviceModel\": \"A0001\",
                \"androidIdfa\": \"fc3ca7a9-82c9-4961-a93c-282fb7da9954\",
                \"deviceManufacturer\": \"OnePlus\",
                \"osType\": \"android\",
                \"carrier\": \"Free\"
            }
        },
        {
            \"schema\": \"iglu: com.snowplowanalytics.snowplow\\/client_session\\/jsonschema\\/1-0-0\",
            \"data\": {
                \"storageMechanism\": \"SQLITE\",
                \"sessionIndex\": 48,
                \"sessionId\": \"255403fc-6c76-4661-a9ee-bfc0961b5ac3\",
                \"userId\": \"b8cfca3a-6156-4b96-8518-de94d4fa88de\",
                \"previousSessionId\": \"6ad87afa-b774-442a-a80c-b44157f94097\"
            }
        },
        {
            \"schema\": \"iglu: com.snowplowanalytics.snowplow\\/geolocation_context\\/jsonschema\\/1-0-0\",
            \"data\": {
                \"bearing\": 0,
                \"altitude\": 0,
                \"latitude\": 47.3235597,
                \"speed\": 0,
                \"latitudeLongitudeAccuracy\": 20,
                \"longitude\": 5.0383196
            }
        },
        {
            \"schema\": \"iglu: com.snowplowanalytics.snowplow\\/mobile_context\\/jsonschema\\/1-0-0\",
            \"data\": {
                \"osVersion\": \"5.0.2\",
                \"deviceModel\": \"A0001\",
                \"androidIdfa\": \"fc3ca7a9-82c9-4961-a93c-282fb7da9954\",
                \"deviceManufacturer\": \"OnePlus\",
                \"osType\": \"android\",
                \"carrier\": \"Free\"
            }
        },
        {
            \"schema\": \"iglu: com.snowplowanalytics.snowplow\\/client_session\\/jsonschema\\/1-0-0\",
            \"data\": {
                \"storageMechanism\": \"SQLITE\",
                \"sessionIndex\": 48,
                \"sessionId\": \"255403fc-6c76-4661-a9ee-bfc0961b5ac3\",
                \"userId\": \"b8cfca3a-6156-4b96-8518-de94d4fa88de\",
                \"previousSessionId\": \"6ad87afa-b774-442a-a80c-b44157f94097\"
            }
        },
        {
            \"schema\": \"iglu: com.snowplowanalytics.snowplow\\/geolocation_context\\/jsonschema\\/1-0-0\",
            \"data\": {
                \"bearing\": 0,
                \"altitude\": 0,
                \"latitude\": 47.3235597,
                \"speed\": 0,
                \"latitudeLongitudeAccuracy\": 20,
                \"longitude\": 5.0383196
            }
        },
        {
            \"schema\": \"iglu: com.snowplowanalytics.snowplow\\/mobile_context\\/jsonschema\\/1-0-0\",
            \"data\": {
                \"osVersion\": \"5.0.2\",
                \"deviceModel\": \"A0001\",
                \"androidIdfa\": \"fc3ca7a9-82c9-4961-a93c-282fb7da9954\",
                \"deviceManufacturer\": \"OnePlus\",
                \"osType\": \"android\",
                \"carrier\": \"Free\"
            }
        }
    ]
}"
@jbeemster jbeemster added the type:defect Bugs or weaknesses. The issue has to contain steps to reproduce. label Jul 20, 2015
@jbeemster jbeemster self-assigned this Jul 20, 2015
@jbeemster jbeemster added this to the Version 0.5.0 milestone Jul 20, 2015
@alexanderdean
Copy link
Member

Ouch good catch...
On 20 Jul 2015 1:17 pm, "Josh" [email protected] wrote:

The Event builder is returning a single pointer to a context object, so
Ecommerce Items end up sharing one context to the effect that if you
process one item and update the context, this is reflected in the next item
and so on. To fix this the Event class must pass a new ArrayList<>(the
context) each time it is fetched so we do not end up with one context in
memory.

As you can see contexts have been added multiple times:

"{ "schema": "iglu: com.snowplowanalytics.snowplow/contexts/jsonschema/1-0-1", "data": [ { "schema": "iglu: com.snowplowanalytics.snowplow/client_session/jsonschema/1-0-0", "data": { "storageMechanism": "SQLITE", "sessionIndex": 48, "sessionId": "255403fc-6c76-4661-a9ee-bfc0961b5ac3", "userId": "b8cfca3a-6156-4b96-8518-de94d4fa88de", "previousSessionId": "6ad87afa-b774-442a-a80c-b44157f94097" } }, { "schema": "iglu: com.snowplowanalytics.snowplow/geolocation_context/jsonschema/1-0-0", "data": { "bearing": 0, "altitude": 0, "latitude": 47.3235597, "speed": 0, "latitudeLongitudeAccuracy": 20, "longitude": 5.0383196 } }, { "schema": "iglu: com.snowplowanalytics.snowplow/mobile_context/jsonschema/1-0-0", "data": { "osVersion": "5.0.2", "deviceModel": "A0001", "androidIdfa": "fc3ca7a9-82c9-4961-a93c-282fb7da9954", "deviceManufacturer": "OnePlus", "osType": "android", "carrier": "Free" } }, { "schema": "iglu: com.snowplowanalytics.snowplow/client_session/jsonschema/1-0-0", "data": { "storageMechanism": "SQLITE", "sessionIndex": 48, "sessionId": "255403fc-6c76-4661-a9ee-bfc0961b5ac3", "userId": "b8cfca3a-6156-4b96-8518-de94d4fa88de", "previousSessionId": "6ad87afa-b774-442a-a80c-b44157f94097" } }, { "schema": "iglu: com.snowplowanalytics.snowplow/geolocation_context/jsonschema/1-0-0", "data": { "bearing": 0, "altitude": 0, "latitude": 47.3235597, "speed": 0, "latitudeLongitudeAccuracy": 20, "longitude": 5.0383196 } }, { "schema": "iglu: com.snowplowanalytics.snowplow/mobile_context/jsonschema/1-0-0", "data": { "osVersion": "5.0.2", "deviceModel": "A0001", "androidIdfa": "fc3ca7a9-82c9-4961-a93c-282fb7da9954", "deviceManufacturer": "OnePlus", "osType": "android", "carrier": "Free" } }, { "schema": "iglu: com.snowplowanalytics.snowplow/client_session/jsonschema/1-0-0", "data": { "storageMechanism": "SQLITE", "sessionIndex": 48, "sessionId": "255403fc-6c76-4661-a9ee-bfc0961b5ac3", "userId": "b8cfca3a-6156-4b96-8518-de94d4fa88de", "previousSessionId": "6ad87afa-b774-442a-a80c-b44157f94097" } }, { "schema": "iglu: com.snowplowanalytics.snowplow/geolocation_context/jsonschema/1-0-0", "data": { "bearing": 0, "altitude": 0, "latitude": 47.3235597, "speed": 0, "latitudeLongitudeAccuracy": 20, "longitude": 5.0383196 } }, { "schema": "iglu: com.snowplowanalytics.snowplow/mobile_context/jsonschema/1-0-0", "data": { "osVersion": "5.0.2", "deviceModel": "A0001", "androidIdfa": "fc3ca7a9-82c9-4961-a93c-282fb7da9954", "deviceManufacturer": "OnePlus", "osType": "android", "carrier": "Free" } }, { "schema": "iglu: com.snowplowanalytics.snowplow/client_session/jsonschema/1-0-0", "data": { "storageMechanism": "SQLITE", "sessionIndex": 48, "sessionId": "255403fc-6c76-4661-a9ee-bfc0961b5ac3", "userId": "b8cfca3a-6156-4b96-8518-de94d4fa88de", "previousSessionId": "6ad87afa-b774-442a-a80c-b44157f94097" } }, { "schema": "iglu: com.snowplowanalytics.snowplow/geolocation_context/jsonschema/1-0-0", "data": { "bearing": 0, "altitude": 0, "latitude": 47.3235597, "speed": 0, "latitudeLongitudeAccuracy": 20, "longitude": 5.0383196 } }, { "schema": "iglu: com.snowplowanalytics.snowplow/mobile_context/jsonschema/1-0-0", "data": { "osVersion": "5.0.2", "deviceModel": "A0001", "androidIdfa": "fc3ca7a9-82c9-4961-a93c-282fb7da9954", "deviceManufacturer": "OnePlus", "osType": "android", "carrier": "Free" } } ]}"


Reply to this email directly or view it on GitHub
#143.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:defect Bugs or weaknesses. The issue has to contain steps to reproduce.
Projects
None yet
Development

No branches or pull requests

2 participants