Ejemplo n.º 1
0
def test_raise_error_other_error():
    from adobe_analytics.client import Client

    response = {
        "error": "Bad Request",
        "error_description": "Authentication key not found",
        "error_uri": None
    }
    with pytest.raises(Exception):
        Client.raise_error(response)
Ejemplo n.º 2
0
def test_raise_error_report_not_ready():
    from adobe_analytics.client import Client

    response = {
        "error": "report_not_ready",
        "error_description": "Report not ready",
        "error_uri": None
    }
    with pytest.raises(FileNotFoundError):
        Client.raise_error(response)
Ejemplo n.º 3
0
 def _retrieve_data(self,
                    data_source: AdobeAnalyticsDataSource) -> pd.DataFrame:
     suites = Client(self.username, self.password, self.endpoint).suites()
     df = suites[data_source.suite_id].download(
         data_source.report_definition)
     df['suite_id'] = data_source.suite_id
     return df
Ejemplo n.º 4
0
def test_fom_json():
    from adobe_analytics import Client

    json_path = mock_dir+"/_login.json"
    client = Client.from_json(json_path)
    assert client.username == "my_username"
    assert client.password == "my_password"
Ejemplo n.º 5
0
import pandas as pd
from adobe_analytics import Client, ClassificationUploader

client = Client.from_json("my_credentials.json")
suites = client.suties()
suite_ids = list(suites.keys())

dataframe = pd.read_csv("my_classification_data.csv")

uploader = ClassificationUploader(
    client=client,
    suite_ids=suite_ids,
    variable_id="evar24",
    data=dataframe,
    email="my_email",
    description="my trial classification for evar24.")
uploader.upload()
Ejemplo n.º 6
0
# adobe_analytics https://github.com/SaturnFromTitan/adobe_analytics
# pandas
# datetime
# matplotlib.pyplot
# scipy.stats

# importing python libraries (already installed via UI)
from datetime import datetime
import matplotlib.pyplot as plt
from scipy.stats import mannwhitneyu
from adobe_analytics import Client, ReportDefinition
import pandas as pd
pd.set_option("display.max_columns", None)

# setting client variable with my username and shared secret (from Adobe Analytis user management)
client = Client("username", "shared secret")

# setting suite variable with the global report suite id
suites = client.suites()
suite = suites["fairfaxnz-stuffoverall-production"]

# can be used to return a list of available metrics, dimensions and segments if the code needs to be updated
# print(suite.metrics())
# print(suite.dimensions())
# print(suite.segments())

# running report for top 400 dimensions for 2018-09-01 to 2018-09-15
# dimensions - prop45(Device ID), evar131(AB Testing Segment)
# metrics - visits, page views, event22(Article View)

report_definition = ReportDefinition(
Ejemplo n.º 7
0
"""
The client class has a request method that allows all sorts of generic API requests to Adobe's v1.4 REST API.

To get a comprehensive overview of available APIs and methods check out the official Adobe Analytics API Explorer:
https://marketing.adobe.com/developer/api-explorer
"""
from adobe_analytics import Client

client = Client.from_json("my_path.json")

# The request below returns a list of all evars available in all specified report suites.
result = client.request(api="ReportSuite",
                        method="GetEvars",
                        data={
                            "rsid_list": [
                                "my_report_suite_id_1", "my_report_suite_id_2",
                                "...", "my_report_suite_id_n"
                            ]
                        })
print(result)
from adobe_analytics import download_async
import pandas as pd
from datetime import date
from datetime import timedelta

#Create dymanic datetime range for automation purpose (you may ignore this step , if you want the date rnage to static)

today = date.today()
d1 = str(date(today.year, today.month, today.day) - timedelta(days=7))
d2 = str(date(today.year, today.month, today.day) - timedelta(days=1))
d3 = str(date(today.year, today.month, today.day))

# Authenticate your access to adobe analytics API using unique key ( Ask you Adobe administrator to provide you the unique key against your account)
# organisation name is the name of organisation as per adobe analytics

client = Client('[email protected]:Organisation Name', 'unique Key')

# Remeber, Adobe Analytics takes every aurgument as IDs , not their actual names as per workspace so it is important to know the ID's of all dimentions, segemnts, report suites.

# get the list of report suites with ID's available in organisation and save them to csv file for future references

d = client.suites()
df1 = pd.DataFrame.from_dict(d, orient='index')
df1.to_csv("path" + '.csv', index=True)

# Get the Dimentions of specific report suite

suite = client.suites()['Suite-ID']

seg = suite.dimensions()
df2 = pd.DataFrame.from_dict(seg, orient='index')