New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

ma-agent

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ma-agent

The MA agent collects data to evaluate the effectiveness of advertising.

latest
npmnpm
Version
0.0.18
Version published
Maintainers
1
Created
Source

MA Agent

The MA agent collects data to evaluate the effectiveness of advertising.

MA Agent Installation

npm i ma-agent

MA Agent initialization

es modules

import { agentInit } from '@kosmos/ma-agent';
         agentInit({
            defaultData: {client_version: '<client version>'},
            url: '<url>',
            token: '<token>'
        });

From bundle

<script src="./dist/bundle.umd.js"></script>
<script type="text/javascript">
    maAgent.agentInit({
        defaultData: {client_version: '<client version>'},
        url: '<url>',
        token: '<token>'
    });
</script>

After initialization, you will have objects

window.mAgent - Analytics

window.kBanner - Cross reference banners

Sending post backs about events using the ma agent

Send visit event

After the download of your game is complete.

!!important!! This function should be called after FBInstant.initializeAsync()


import { EventTypes } from '@kosmos/ma-agent';
window.mAgent
        .sendEvent({
            user_id: '<user_id|social_id>', // the user ID on the server or the id that was issued by the platform
            data: {
                social_id: '<social_id>', //the ID provided by the platform
                is_install: 1 // if this is a new user in the game
            },
            event_type: EventTypes.visit //2
        });
Send Transaction event

After Transaction is complete


import { EventTypes } from '@kosmos/ma-agent';
window.mAgent
        .sendEvent({
            user_id: '<user_id|social_id: string>', // the user ID on the server or the id that was issued by the platform <string>
            data: {
                social_id: '<social_id: string>', // the ID provided by the platform
                transaction_id: 'transaction123', // transaction ID provided by the platform
                price: 10000.0, // purchaise price
                proceed: 1000, // total income from the purchase without platform fees and local tax
                currency: 'USD'  // currency code
            },
            event_type: EventTypes.transaction // 1
        });

Send Raw Transaction event without proceed field

Client Transaction


import { EventTypes } from '@kosmos/ma-agent';
window.mAgent
        .sendEvent({
            user_id: '<user_id|social_id: string>', // the user ID on the server or the id that was issued by the platform <string>
            data: {
                social_id: '<social_id: string>', // the ID provided by the platform
                transaction_id: 'transaction123', // transaction ID provided by the platform
                price: 10000.0, // <optional> purchaise price
                currency: 'USD',  // <optional> currency code
                purchase_platform: 'GOOGLE' // purchase_platform in fb receipt (string)
            },
            event_type: EventTypes.raw_transaction // 5
        });

Send AdShow event

After the ad is shown


import { EventTypes } from '@kosmos/ma-agent';
window.mAgent
        .sendEvent({
            user_id: '<user_id|social_id: string>', // the user ID on the server or the id that was issued by the platform
            data: {
                ad_type: 'Interstitial|rewarded|...',
                revenue: 0.5, // total income from the ad shown without platform fees and local tax
                currency: 'USD',  // currency code
                count: 1, // Number of ad impressions
                client_platform: 1,
            },
            event_type: EventTypes.ad_shown // 3
        });

Send Banner Analytics

After the banner click / sown


window.kBanner
        .emit({
            user_id: '<inside user id>: string', // <optional> 
            social_id: '<social_id>: string',
            case_id: 1, 
            content_type: 'crossBanner',
            redirect_game_id: 'string', // name of the target game
            banner_id: 'default', // custom ID for easy search
            action: 'shown'|'click'
        });

Usage Recommendations

It is important that errors in the application do not interfere with sending the event.

Events that your server can send, such as rawTransactions|Transaction, were sent by the server after they were confirmed.

FAQs

Package last updated on 02 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts