コード例 #1
0
def count_tags():
    data = {}

    data_from_func = base_func.extract_file(
        'C:\\Users\\user\Documents\Projects\LifeReel\Data\\01_140517.json')
    response_js = data_from_func

    # empty counters and all counters
    for i in range(len(response_js['Sessions'])):
        # remove internal users: Israel/ Ukraine
        if 'Location' in response_js['Sessions'][i]:
            loc = response_js['Sessions'][i]['Location']
            country = loc['Country']
            if (country == 'UA') or (country == 'IL'):
                continue
            else:
                countries = base_func.countries_set(countries_code)
                if country in countries:
                    if 'Events' in response_js['Sessions'][i]:
                        event = response_js['Sessions'][i]['Events']
                        # number of events need to review
                        len_event = len(response_js['Sessions'][i]['Events'])
                        # enter every event
                        for j in range(len_event):
                            if (event[j]['Name']
                                    == 'tag_counter') and ('Properties'
                                                           in event[j]):
                                for key in event[j]['Properties']:
                                    if key not in data.keys():
                                        data[key] = 0
                                    data[key] += 1
    print(data)
    return data
コード例 #2
0
def extract_i2t_sessions():
    data_i2t = {}

    response_js = base_func.extract_file(
        'C:\\Users\\user\Documents\Projects\LifeReel\Data\\20_0517.json')

    # enter each session. each session is a list of dictionaries
    for i in range(len(response_js['Sessions'])):
        # remove internal users: Israel/ Ukraine
        if 'Location' in response_js['Sessions'][i]:
            country = response_js['Sessions'][i]['Location']['Country']
            connectivity = response_js['Sessions'][i]['Connectivity']
            if (country == 'UA') or (country == 'IL'):
                continue
            '''if response_js['Sessions'][i]['UserId'] != '161cdf511ef41ca2_1495293097712':
                continue
            if country != 'PE':
                continue'''
            if response_js['Sessions'][i]['Platform'] != Platform:
                continue
            else:
                countries = base_func.countries_set(countries_code)
                if country in countries:
                    if country not in data_i2t.keys():
                        data_i2t[country] = {}
                        data_i2t[country]['requests'] = {}
                        data_i2t[country]['errors'] = {}
                    user_id = response_js['Sessions'][i]['UserId']
                    if 'Events' in response_js['Sessions'][i]:
                        event = response_js['Sessions'][i]['Events']
                        # number of events need to review
                        len_event = len(event)
                        # enter every event
                        for j in range(len_event):
                            if (event[j]['Name'] == 'i2t_counter') and (
                                    event[j]['Properties']['request_count']):
                                if connectivity not in data_i2t[country][
                                        'requests'].keys():
                                    data_i2t[country]['requests'][
                                        connectivity] = 0
                                data_i2t[country]['requests'][
                                    connectivity] += int(event[j]['Properties']
                                                         ['request_count'])
                            if (event[j]['Name'] == 'i2t_response_received'
                                ) and ('Properties' in event[j]) and (
                                    'message' in event[j]['Properties']):
                                if connectivity not in data_i2t[country][
                                        'errors'].keys():
                                    data_i2t[country]['errors'][
                                        connectivity] = 0
                                data_i2t[country]['errors'][connectivity] += 1
                                '''if country == 'PE':
                                    print(user_id)'''
    print(data_i2t)
    return data_i2t
コード例 #3
0
def extract_data():
    data = {}

    response_js = base_func.extract_file(
        'C:\\Users\\user\Documents\Projects\LifeReel\Data\\15_200517.json')

    # enter each session. each session is a list of dictionaries
    for i in range(len(response_js['Sessions'])):
        # remove internal users: Israel/ Ukraine
        if 'Location' in response_js['Sessions'][i]:
            loc = response_js['Sessions'][i]['Location']
            country = loc['Country']
            if (country == 'UA') or (country == 'IL'):
                continue
            if response_js['Sessions'][i]['Platform'] != Platform:
                continue
            else:
                countries = base_func.countries_set(countries_code)
                if country in countries:
                    user_id = response_js['Sessions'][i]['UserId']
                    if country not in data.keys():
                        data[country] = {}
                    if user_id not in data[country].keys():
                        data[country][user_id] = {}
                        data[country][user_id]['request_count'] = 0
                        data[country][user_id]['response_count'] = 0
                    if 'Events' in response_js['Sessions'][i]:
                        event = response_js['Sessions'][i]['Events']
                        # number of events need to review
                        len_event = len(event)
                        # enter every event
                        for j in range(len_event):
                            if event[j]['Name'] == 'i2t_counter':
                                data[country][user_id]['request_count'] += int(
                                    event[j]['Properties']['request_count'])
                                data[country][user_id]['response_count'] += int(
                                    event[j]['Properties']['response_count'])
                            if (event[j]['Name'] == 'i2t_response_received'
                                ) and ('message' in event[j]['Properties']):
                                if event[j]['Properties'][
                                        'message'] not in data[country][
                                            user_id].keys():
                                    data[country][user_id][
                                        event[j]['Properties']['message']] = 0
                                data[country][user_id][event[j]['Properties']
                                                       ['message']] += 1
    print(data)
    return data
コード例 #4
0
def extract_users(StartDate, EndDate, UserId, EventName, Version, Platform):
    pages_num = (base_func.calc_pages(StartDate, EndDate, UserId, EventName,
                                      Version, Platform)) + 1
    data = {}

    data_from_func = base_func.extract_api(pages_num, StartDate, EndDate,
                                           UserId, EventName, Version,
                                           Platform)
    response_js = data_from_func
    json_num = len(response_js)

    # enter each session. each session is a list of dictionaries
    for a in range(json_num):
        for i in range(len(response_js[a]['Sessions'])):
            # remove internal users: Israel/ Ukraine
            if 'Location' in response_js[a]['Sessions'][i]:
                loc = response_js[a]['Sessions'][i]['Location']
                country = loc['Country']
                if (country == 'UA') or (country == 'IL'):
                    continue
                else:
                    countries = base_func.countries_set(countries_code)
                    if country in countries:
                        user_id = response_js[a]['Sessions'][i]['UserId']
                        if 'Events' in response_js[a]['Sessions'][i]:
                            event = response_js[a]['Sessions'][i]['Events']
                            # number of events need to review
                            len_event = len(event)
                            # enter every event
                            for j in range(len_event):
                                if (event[j]['Name'] == 'launch'
                                    ) and ('Properties' in event[j]) and (
                                        event[j]['Properties']['app_installed']
                                        == 'true'):
                                    if user_id not in data.keys():
                                        data[user_id] = {}
                                        data[user_id]['1st_collage'] = 0
                                        data[user_id][
                                            'drive_click_connect'] = 0
                                        data[user_id]['drive_connection'] = 0
    return data
コード例 #5
0
def find_launch_users():
    data = {}

    data_from_func = base_func.extract_file(
        'C:\\Users\\user\Documents\Projects\LifeReel\Data\\01_070517.json')
    response_js = data_from_func

    # empty counters and all counters
    for i in range(len(response_js['Sessions'])):
        # remove internal users: Israel/ Ukraine
        if 'Location' in response_js['Sessions'][i]:
            country = response_js['Sessions'][i]['Location']['Country']
            if (country == 'UA') or (country == 'IL'):
                continue
            else:
                countries = base_func.countries_set(countries_code)
                if country in countries:
                    if response_js['Sessions'][i]['AppVersion'] == '0.9.2.2':
                        user_id = response_js['Sessions'][i]['UserId']
                        if 'Events' in response_js['Sessions'][i]:
                            event = response_js['Sessions'][i]['Events']
                            len_event = len(
                                response_js['Sessions'][i]['Events'])
                            for j in range(len_event):
                                if (event[j]['Name'] == 'launch') and (
                                        'Properties' in event[j]) and (
                                            'app_installed'
                                            in event[j]['Properties']):
                                    if user_id not in data.keys():
                                        data[user_id] = {
                                            'tutorial_p_1': 0,
                                            'tutorial_p_2': 0,
                                            'tutorial_p_3': 0,
                                            'tutorial_p_4': 0,
                                            'first_tm_connect': 0
                                        }
    return data
コード例 #6
0
def find_launch_tutorial_users(data_launch):
    data = data_launch

    data_from_func = base_func.extract_file(
        'C:\\Users\\user\Documents\Projects\LifeReel\Data\\01_070517.json')
    response_js = data_from_func

    # empty counters and all counters
    for i in range(len(response_js['Sessions'])):
        # remove internal users: Israel/ Ukraine
        if 'Location' in response_js['Sessions'][i]:
            country = response_js['Sessions'][i]['Location']['Country']
            if (country == 'UA') or (country == 'IL'):
                continue
            else:
                countries = base_func.countries_set(countries_code)
                if country in countries:
                    if response_js['Sessions'][i]['AppVersion'] == '0.9.2.2':
                        user_id = response_js['Sessions'][i]['UserId']
                        if 'Events' in response_js['Sessions'][i]:
                            event = response_js['Sessions'][i]['Events']
                            len_event = len(
                                response_js['Sessions'][i]['Events'])
                            for j in range(len_event):
                                if (event[j]['Name']
                                        == 'tutorial_page') and ('Properties'
                                                                 in event[j]):
                                    if 'page_number' in event[j]['Properties']:
                                        if event[j]['Properties'][
                                                'page_number'] == 1:
                                            if (user_id in data.keys()) and (
                                                    data[user_id]
                                                ['tutorial_p_1'] < 1):
                                                data[user_id][
                                                    'tutorial_p_1'] = 1
                                        elif event[j]['Properties'][
                                                'page_number'] == 2:
                                            if (user_id in data.keys()) and (
                                                    data[user_id]
                                                ['tutorial_p_2'] < 1):
                                                data[user_id][
                                                    'tutorial_p_2'] = 1
                                        elif event[j]['Properties'][
                                                'page_number'] == 3:
                                            if (user_id in data.keys()) and (
                                                    data[user_id]
                                                ['tutorial_p_3'] < 1):
                                                data[user_id][
                                                    'tutorial_p_3'] = 1
                                        elif event[j]['Properties'][
                                                'page_number'] == 4:
                                            if (user_id in data.keys()) and (
                                                    data[user_id]
                                                ['tutorial_p_4'] < 1):
                                                data[user_id][
                                                    'tutorial_p_4'] = 1
                                '''if ((event[j]['Name'] == 'first_collage_created') and ('Properties' in event[j]) and('creation_duration' in event[j]['Properties']))\
                                    or (event[j]['Name'] == 'time_machine_clicked')\
                                    or (event[j]['Name'] == 'cloud_connect_suggestion')\
                                    or (event[j]['Name'] == 'Google Drive State'):'''
                                if (event[j]['Name'] == 'time_machine_clicked') \
                                   or (event[j]['Name'] == 'cloud_connect_suggestion') \
                                   or (event[j]['Name'] == 'Google Drive State'):
                                    if (user_id in data.keys()) and (
                                            data[user_id]['first_tm_connect'] <
                                            1):
                                        data[user_id]['first_tm_connect'] = 1
                            if 'Screens' in response_js['Sessions'][i]:
                                screen = response_js['Sessions'][i]['Screens']
                                len_screen = len(screen)
                                for j in range(len_screen):
                                    if screen[j]['Name'] == 'Feed':
                                        if (user_id in data.keys()) and (
                                                data[user_id]
                                            ['first_tm_connect'] < 1):
                                            data[user_id][
                                                'first_tm_connect'] = 1
    print(data)
    return data
コード例 #7
0
                                           UserId, EventName, Version,
                                           Platform)
    response_js = data_from_func
    json_num = len(response_js)

    # enter each session. each session is a list of dictionaries
    for a in range(json_num):
        for i in range(len(response_js[a]['Sessions'])):
            # remove internal users: Israel/ Ukraine
            if 'Location' in response_js[a]['Sessions'][i]:
                loc = response_js[a]['Sessions'][i]['Location']
                country = loc['Country']
                if (country == 'UA') or (country == 'IL'):
                    continue
                else:
                    countries = base_func.countries_set(countries_code)
                    if country in countries:
                        user_id = response_js[a]['Sessions'][i]['UserId']
                        # all legal sessions
                        sessions_us.append(user_id)
                        date = response_js[a]['Sessions'][i]['StartTime']
                        dates.append(date)
                        # durations of legal sessions
                        duration_ms = response_js[a]['Sessions'][i]['Duration']
                        duration = timedelta(milliseconds=duration_ms)
                        duration_float = duration.total_seconds()
                        sessions_duration_ms_us.append(duration_ms)
                        sessions_duration_us.append(duration)
                        if user_id not in sessions_us_1.keys():
                            sessions_us_1[user_id] = {}
                        sessions_us_1[user_id][date] = duration_float
コード例 #8
0
ファイル: relevant_4_latm.py プロジェクト: GitO123/LR
    data_from_func = base_func.extract_api(pages_num, StartDate, EndDate, UserId, EventName, Version)
    response_js = data_from_func
    json_num = len(response_js)

    # enter each session. each session is a list of dictionaries
    for a in range(json_num):
        for i in range(len(response_js[a]['Sessions'])):
            # remove internal users: Israel/ Ukraine
            if 'Location' in response_js[a]['Sessions'][i]:
                loc = response_js[a]['Sessions'][i]['Location']
                country = loc['Country']
                if (country == 'UA') or (country == 'IL'):
                    continue
                else:
                    #if country in ['AR', 'BO', 'BR', 'CL', 'CO', 'EC', 'JM', 'MX', 'PA', 'PE', 'PR', 'ES', 'UY']:
                    countries = base_func.countries_set('Latm')
                    if country in countries:
                        #'Argentina', 'Bolivia', 'Brazil', 'Chile', 'Colombia', 'Ecuador', 'Jamaica', 'Mexico', 'Panama', 'Peru', 'Puerto Rico', 'Spain', 'Uruguay'
                        user_id = response_js[a]['Sessions'][i]['UserId']
                        # all legal sessions
                        sessions.append(user_id)
                        date = response_js[a]['Sessions'][i]['StartTime']
                        dates.append(date)
                        # durations of legal sessions
                        duration_ms = response_js[a]['Sessions'][i]['Duration']
                        duration = timedelta(milliseconds=duration_ms)
                        duration_float = duration.total_seconds()
                        sessions_duration_ms.append(duration_ms)
                        sessions_duration.append(duration)
                        if user_id not in sessions_1.keys():
                            sessions_1[user_id] = {}
コード例 #9
0
def extract_data(StartDate, EndDate, UserId, EventName, Version, data):
    pages_num = (base_func.calc_pages(StartDate, EndDate, UserId, EventName,
                                      Version, Platform)) + 1

    data_from_func = base_func.extract_api(pages_num, StartDate, EndDate,
                                           UserId, EventName, Version,
                                           Platform)
    response_js = data_from_func
    json_num = len(response_js)

    # enter each session. each session is a list of dictionaries
    for a in range(json_num):
        for i in range(len(response_js[a]['Sessions'])):
            # remove internal users: Israel/ Ukraine
            if 'Location' in response_js[a]['Sessions'][i]:
                loc = response_js[a]['Sessions'][i]['Location']
                country = loc['Country']
                if (country == 'UA') or (country == 'IL'):
                    continue
                else:
                    countries = base_func.countries_set(countries_code)
                    if country in countries:
                        user_id = response_js[a]['Sessions'][i]['UserId']
                        if user_id in data.keys():
                            if 'Events' in response_js[a]['Sessions'][i]:
                                event = response_js[a]['Sessions'][i]['Events']
                                for j in range(len(event)):
                                    if (event[j]['Name']
                                            == 'first_collage_created') and (
                                                data[user_id]['1st_collage'] <
                                                1):
                                        data[user_id]['1st_collage'] += 1
                                    if event[j][
                                            'Name'] == 'Google Drive State':
                                        if ('Properties' in event[j]) and (
                                                event[j]['Properties']
                                            ['Connected'] == 'true') and (
                                                data[user_id]
                                                ['drive_connection'] < 1):
                                            data[user_id][
                                                'drive_connection'] += 1
                            if 'Screens' in response_js[a]['Sessions'][i]:
                                screen = response_js[a]['Sessions'][i][
                                    'Screens']
                                for j in range(len(screen)):
                                    if len(screen[j]['Actions']) > 0:
                                        for k in range(
                                                len(screen[j]['Actions'])):
                                            if 'Description' in screen[j][
                                                    'Actions'][k]:
                                                # during onboarding drive connection preference
                                                if (screen[j]['Actions'][k]
                                                    ['Description']
                                                        == 'Connect'
                                                        or screen[j]['Actions']
                                                    [k]['Description']
                                                        == 'Conectar'
                                                        or screen[j]['Actions']
                                                    [k]['Description']
                                                        == 'Conectar-se'
                                                    ) and (
                                                        data[user_id]
                                                        ['drive_click_connect']
                                                        < 1):
                                                    data[user_id][
                                                        'drive_click_connect'] += 1
                                                if (screen[j]['Actions'][k]
                                                    ['Description'] ==
                                                        'CONNECT GOOGLE PHOTOS'
                                                        or screen[j]['Actions']
                                                    [k]['Description'] ==
                                                        'CONECTAR GOOGLE FOTOS'
                                                        or screen[j]['Actions']
                                                    [k]['Description'] ==
                                                        'CONECTAR-SE AO GOOGLE PHOTOS'
                                                    ) and (
                                                        data[user_id]
                                                        ['drive_click_connect']
                                                        < 1):
                                                    data[user_id][
                                                        'drive_click_connect'] += 1
    return data