コード例 #1
0
    def __init__(self, userInfo):
        self.userInfo = userInfo
        self.batch = mparticle.Batch()
        self.batch.environment = 'development'

        configuration = mparticle.Configuration()
        configuration.api_key = os.environ['MP_KEY']
        configuration.api_secret = os.environ['MP_SECRET']


        configuration.debug = True #enable logging of HTTP traffic
        self.api_instance = mparticle.EventsApi(configuration)

        mp_identity = mparticle.UserIdentities()
        mp_identity.customerid = userInfo.userid
        mp_identity.email = userInfo.email
        mp_identity.other = userInfo.name

        self.batch.user_itentities = mp_identity
コード例 #2
0
batch.events = [session_start, app_event, commerce_event, session_end]

batch.mpid = '600868121729048600'
batch.mp_deviceid = '59780f39-d7a0-4ebe-9950-280f937c29e2'

install = mparticle.ApplicationStateTransitionEvent.create_install_event()
install.timestamp_unixtime_ms = 1552596256103

upgrade = mparticle.ApplicationStateTransitionEvent.create_upgrade_event()
upgrade.timestamp_unixtime_ms = 1552596256103

foreground = mparticle.ApplicationStateTransitionEvent.create_foreground_event(
)
foreground.timestamp_unixtime_ms = 1552596256103

background = mparticle.ApplicationStateTransitionEvent.create_background_event(
)
background.timestamp_unixtime_ms = 1552596256103

configuration = mparticle.Configuration()
configuration.api_key = 'foo-key'
configuration.api_secret = 'foo-secret'
configuration.debug = True  #enable logging of HTTP traffic
api_instance = mparticle.EventsApi(configuration)

try:
    api_instance.upload_events(batch)
    # you can also send multiple batches at a time to decrease the amount of network calls
    #api_instance.bulk_upload_events([batch, batch])
except mparticle.rest.ApiException as e:
    print "Exception while calling mParticle: %s\n" % e