Beispiel #1
0
def extract_users():
    data_users = {}

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

    # number of sessions=> number of lists need to access
    len_res_js = len(response_js['Sessions'])
    if len_res_js == 0:
        print('No data for the requested dates')
        exit()

    # enter each session. each session is a list of dictionaries
    for i in range(len_res_js):
        # 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') or (
                    response_js['Sessions'][i]['AppVersion'] != Version):
                continue
            else:
                # find user id
                user_id = response_js['Sessions'][i]['UserId']
                if user_id not in data_users.keys():
                    data_users[user_id] = {}
    print(data_users)
    return data_users
Beispiel #2
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
Beispiel #3
0
def extract_versions(data_users):
    data_users_versions = data_users

    response_js = base_func.extract_file(
        'C:\\Users\\user\Documents\Projects\LifeReel\Data\April_17\\30_0417.json'
    )

    # number of sessions=> number of lists need to access
    len_res_js = len(response_js['Sessions'])

    # enter each session. each session is a list of dictionaries
    for i in range(len_res_js):
        # 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:
                # find user id
                user_id = response_js['Sessions'][i]['UserId']
                version = response_js['Sessions'][i]['AppVersion']
                if version not in data_users_versions[user_id]:
                    data_users_versions[user_id].append(version)
    print(data_users_versions)
    return data_users_versions
Beispiel #4
0
def extract_data():
    data = {}
    data['users'] = []
    data['print_shop_clicked'] = []
    data['print_item_clicked'] = {}
    data['edit_click'] = []
    data['premium_bg_click'] = {}
    data['premium_bg_click_buy'] = {}

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

    # enter each session. each session is a list of dictionaries
    for a in range(len(response_js)):
        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]['AppVersion'] != Version:
                    continue
                if ('Platform' in response_js['Sessions'][i]) and (response_js['Sessions'][i]['Platform'] != 'Android'):
                    continue
                else:
                    #countries = base_func.countries_set(countries_code)
                    #if country in countries:
                        user_id = response_js['Sessions'][i]['UserId']
                        if user_id not in data['users']:
                            data['users'].append(user_id)
                        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):
                                # print flow (print->buy print)
                                if event[j]['Name'] == 'print_shop_clicked':
                                    data['print_shop_clicked'].append(user_id)
                                if event[j]['Name'] == 'print_item_clicked':
                                    if 'Properties' in event[j]:
                                        if user_id not in data['print_item_clicked'].keys():
                                            data['print_item_clicked'][user_id] = []
                                        data['print_item_clicked'][user_id].append(event[j]['Properties']['item_name'])
                                # BG flow (edit->BG->buy BG)
                                if event[j]['Name'] == 'edit_click':
                                    data['edit_click'].append(user_id)
                                if event[j]['Name'] == 'premium_bg_click':
                                    if 'Properties' in event[j]:
                                        if user_id not in data['premium_bg_click'].keys():
                                            data['premium_bg_click'][user_id] = []
                                        data['premium_bg_click'][user_id].append(event[j]['Properties']['bg'])
                                if event[j]['Name'] == 'premium_bg_click_buy':
                                    if 'Properties' in event[j]:
                                        if user_id not in data['premium_bg_click_buy'].keys():
                                            data['premium_bg_click_buy'][user_id] = []
                                        data['premium_bg_click_buy'][user_id].append(event[j]['Properties']['bg'])
    print(data)
    return data
Beispiel #5
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
Beispiel #6
0
def extract_data(data_users):
    data = data_users

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

    # number of sessions=> number of lists need to access
    len_res_js = len(response_js['Sessions'])
    if len_res_js == 0:
        print('No data for the requested dates')
        exit()

    # enter each session. each session is a list of dictionaries
    for i in range(len_res_js):
        # 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') or (
                    response_js['Sessions'][i]['AppVersion'] != Version):
                continue
            else:
                # find user id
                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'] == 'gallery_size') and (
                                'Properties'
                                in event[j]) and ('gallery_size'
                                                  in event[j]['Properties']):
                            data[user_id]['gallery_size'] = event[j][
                                'Properties']['gallery_size']
                        if (event[j]['Name']
                                == 'photo_folders') and ('Properties'
                                                         in event[j]):
                            for key_folder, value_folder in event[j][
                                    'Properties'].items():
                                # print(event[j]['Properties'][key])
                                # if the folder doesn't exist yet in the dictionary, create it, otherwise, add the user id
                                if key_folder not in data[user_id].keys():
                                    data[user_id][key_folder] = {}
                                    # populate dictionary value with the key, user id and value, number of folder photos
                                data[user_id][key_folder] = value_folder
    print(data)
    return data
Beispiel #7
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
Beispiel #8
0
def extract_gallery():
    data_gallery = {}

    response_js = base_func.extract_file(
        'C:\\Users\\user\Documents\Projects\LifeReel\Data\May_17\\18_240517.json'
    )

    # number of sessions=> number of lists need to access
    len_res_js = len(response_js['Sessions'])
    if len_res_js == 0:
        print('No data for the requested dates')
        exit()

    # enter each session. each session is a list of dictionaries
    for i in range(len_res_js):
        # 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'
            ) or response_js['Sessions'][i]['Platform'] != 'Android':
                continue
            else:
                # find user id
                user_id = response_js['Sessions'][i]['UserId']
                if user_id not in data_gallery.keys():
                    data_gallery[user_id] = []
                if 'Events' in response_js['Sessions'][i]:
                    # enter the Events. The name of the list I want to access: response_js[l]['Sessions'], [i] indicates the index in the list and ['Events']
                    # the key of the dictionary in index i. the variable event is a list of dictionaries
                    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'] == 'gallery_size' and 'Properties' in event[
                                    j] and 'gallery_size' in event[j][
                                        'Properties']:
                            gallery_size_value = event[j]['Properties'][
                                'gallery_size']
                            data_gallery[user_id].append(gallery_size_value)
    print(data_gallery)
    return data_gallery
Beispiel #9
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
Beispiel #10
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
    # connect to drive via suggestions
    suggest_drive_active = []
    # disconnect from drive via suggestions
    suggest_drive_disabled = []
    # connect to drive via settings
    settings_connect_us = []
    # days for counting 1st week
    days_range = dt.timedelta(days=6)
    days_range_str = 6
    # 1st week new users
    first_week_new_users_us = []
    # countries to create the report for
    countries = []
    countries_code = 'Latm'

    response_js = base_func.extract_file('C:\\Users\\user\Documents\Projects\LifeReel\Data\\June_17\\1805_030617.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']
            if (country == 'UA') or (country == 'IL'):
                continue
            if response_js['Sessions'][i]['AppVersion'] != Version:
                continue
            if response_js['Sessions'][i]['Platform'] != Platform:
                continue
            else:
                countries = base_func.countries_set(countries_code)
                if country in countries: