Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Introduction:

This documents describes the design for capturing Device and User location. This design requires following changes

  • Get Device Location Profile API - To return back the IP resolved location for the device.
  • Device Register API Enhancements - API to save User confirmed location to device_profile Cassandra table as derived location.
  • Telemetry Location Updater Samza Job Changes - To stamp derived location in the telemetry.

...

Code Block
{
    "id": "analytics.device-location",
    "ver": "1.0",
    "ts": "2019-07-30T18:54:10.627+00:00",
    "params": {
        "resmsgid": "e045d484-eedb-4fa9-a9d8-9c3e489e664f",
        "status": "successful",
        "client_key": null
    },
    "responseCode": "OK",
    "result": {
        "user_declared_location": {
            "state": "Karnataka",
            "district": "Bengaluru"
        },
        "device_profile": {

        }
    }
}


Device Register API Enhancements:

  • For signed in users - Saves location details as derived location in device_profile cassandra table.
  • For anonymous users - Resolves the IP address from the x-forwarded-for header and writes to cassandra.

Request Details:

End point: POST /v3/device/register/<deviceId>

...

Code Block
{
    "id": "dev.sunbird.portal",
    "ver": "1.15.0",
    "ts": "2019-04-23T19:23:02+05:30",
    "params": {
        "msgid": "4f92a44f-127f-0c82-b2ad-715faa558a8d"
    },
    "request": {
        "uaspec": {
            "agent": "Chrome",
            "ver": "72.0.3626.121",
            "system": "mac-os-x-14",
            "platform": "Mac",
            "raw": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36"
        },
        "channel": "b00bc992ef25f1a9a8d63291e20efc8d",
        "fcmToken": "asda",
        "producer": "app12",
        "dspec": {"id": "oppo"},
        "ext": {
            "userid": "user1"
        },
        "user_declared_location": {
            "state": "Karnataka",
            "district": "Bengaluru"
        }
    }
}

...

Code Block
CREATE TABLE IF NOT EXISTS {{ cassandra.keyspace_prefix }}device_db.device_profile (
    device_id text,
    first_access timestamp,
    last_access timestamp,
    total_ts double,
    total_launches bigint,
    avg_ts double,
    device_spec Map<text,text>,
    updated_date timestamp,
    state text,
    state_code text,
    country text,
    country_code text,
    state_custom text,
    state_code_custom text,
    district_custom text,
    city text,
    uaspec Map<text,text>,
    fcm_token text, 
    producer_id text,
    deriveduser_declared_state text,
    deriveduser_declared_district text,
    PRIMARY KEY (device_id)
);

...