def floodlight_report(floodlight_id): account_id, subaccount_id, profile_id = parse_account( project.task['auth'], project.task['account']) name = 'Floodlight Monitor %s %s ( StarThinker )' % (account_id, floodlight_id) if project.verbose: print "FLOODLIGHT MONITOR REPORT: ", name # create report if it does not exists report = report_build( project.task['auth'], project.task['account'], { 'kind': 'dfareporting#report', 'type': 'FLOODLIGHT', 'accountId': account_id, 'ownerProfileId': profile_id, 'name': name, 'fileName': name.replace('( ', '').replace(' )', '').replace( ' ', '_'), 'format': 'CSV', 'delivery': { 'emailOwner': False }, 'floodlightCriteria': { 'dateRange': { 'kind': 'dfareporting#dateRange', 'relativeDateRange': 'LAST_7_DAYS' }, 'dimensions': [{ 'kind': 'dfareporting#sortedDimension', 'name': 'dfa:date' }, { 'kind': 'dfareporting#sortedDimension', 'name': 'dfa:floodlightConfigId' }, { 'kind': 'dfareporting#sortedDimension', 'name': 'dfa:activityGroupId' }, { 'kind': 'dfareporting#sortedDimension', 'name': 'dfa:activityGroup' }, { 'kind': 'dfareporting#sortedDimension', 'name': 'dfa:activityId' }, { 'kind': 'dfareporting#sortedDimension', 'name': 'dfa:activity' }], 'floodlightConfigId': { 'dimensionName': 'dfa:floodlightConfigId', 'kind': 'dfareporting#dimensionValue', 'matchType': 'EXACT', 'value': floodlight_id }, 'metricNames': ['dfa:floodlightImpressions'], 'reportProperties': { 'includeUnattributedCookieConversions': False, 'includeUnattributedIPConversions': False } }, 'schedule': { 'active': True, 'every': 1, 'repeats': 'DAILY', 'startDate': str(date.today()), 'expirationDate': str((date.today() + timedelta(days=365))), }, }) # fetch report file if it exists ( timeout = 0 means grab most reent ready ) filename, report = report_file(project.task['auth'], project.task['account'], report['id'], None, 0, DCM_CHUNK_SIZE) return report
def floodlight_report(floodlight_id: int) -> int: """ Create a report for a specific floodlight if it does not exist. Args: floodlight_id - the floodlight being monitored Returns: The id of the created report. """ account_id, subaccount_id = parse_account(project.task['auth'], project.task['account']) name = 'Floodlight Monitor %s %s ( StarThinker )' % (account_id, floodlight_id) if project.verbose: print('FLOODLIGHT MONITOR REPORT: ', name) # create report if it does not exists report = report_build( project.task['auth'], project.task['account'], { 'kind': 'dfareporting#report', 'type': 'FLOODLIGHT', 'accountId': account_id, 'name': name, 'fileName': name.replace('( ', '').replace(' )', '').replace( ' ', '_'), 'format': 'CSV', 'delivery': { 'emailOwner': False }, 'floodlightCriteria': { 'dateRange': { 'kind': 'dfareporting#dateRange', 'relativeDateRange': 'LAST_7_DAYS' }, 'dimensions': [{ 'kind': 'dfareporting#sortedDimension', 'name': 'dfa:date' }, { 'kind': 'dfareporting#sortedDimension', 'name': 'dfa:floodlightConfigId' }, { 'kind': 'dfareporting#sortedDimension', 'name': 'dfa:activityGroupId' }, { 'kind': 'dfareporting#sortedDimension', 'name': 'dfa:activityGroup' }, { 'kind': 'dfareporting#sortedDimension', 'name': 'dfa:activityId' }, { 'kind': 'dfareporting#sortedDimension', 'name': 'dfa:activity' }], 'floodlightConfigId': { 'dimensionName': 'dfa:floodlightConfigId', 'kind': 'dfareporting#dimensionValue', 'matchType': 'EXACT', 'value': floodlight_id }, 'metricNames': ['dfa:floodlightImpressions'], 'reportProperties': { 'includeUnattributedCookieConversions': False, 'includeUnattributedIPConversions': False } }, 'schedule': { 'active': True, 'every': 1, 'repeats': 'DAILY', 'startDate': str(date.today()), 'expirationDate': str((date.today() + timedelta(days=365))), }, }) return report['id']