2.3.1 • Published 13 days ago

com.elevatix.unity.sdk v2.3.1

Weekly downloads
-
License
-
Repository
-
Last release
13 days ago

Elevatix SDK

Table of contents

Required dependency

Unity IAP service. Follow this guide to set up

Installation

  • Open Unity editor
  • Edit -> Project Settings
  • Choose "Package Manager"
  • Add new "Scoped Registry"
  • Navigate to Window -> Package Manager
  • In packages dropdown choose "My registries"
  • Select Elevatix SDK and hit install

That concludes the installation of the SDK!

Configuration

Configuration is straightforward and consist only of two steps

Create the Elevatix "Settings file"

Navigate to Assets -> Create -> Elevatix -> Settings file. This action will generate a settings file named "ElevatixSettings.asset" within the "Assets/Resources" folder.

Obtaining the "Application Key":

  • Access dev.admin.elevatix.io and log in using your valid credentials.
  • Select the "Settings" page from the menu, situated on the left side of the screen.
  • Copy the "Application Key" and proceed to paste it into the ElevatixSettings.asset file within the Unity editor.

You have successfully completed the configuration process!

Initialization

Initialize Elevatix during the game startup, specifically in the preloading/loading stage.

using Elevatix;

AnalyticsClient.Init();

Track events

Using Tracker API inform Elevatix about all significant user actions and state changes.

Here is an example of implementation of the initial event that needs to be tracked:

Login tracking sample

using Elevatix;

Tracker.TrackLogin();

Please note that in addition to this, you will also need to implement all other tracking methods as outlined in the Complete Tracker API section

Handle Offers

After an important event happens while playing the game and Elevatix is informed through the Tracking API, Elevatix will then look for a special offer designed for that exact moment. There's a way in which Elevatix tells the game what offer should be shown to the user.

The AnalyticsClient includes an object named OffersDispatcher. This object has method RegisterHanlder that accepts implementation of OfferHandlerBase<T> where T is SingleOffer or MultiOffer.

using Elevatix;
using Elevatix.Offers;

class SingleOfferHandler : OfferHandlerBase<SingleOffer> {
    protected override Task HandleAsync(SingleOffer offer)
    {
        // show dialog with the single offer
    }
}

class MultiOfferHandler : OfferHandlerBase<MultiOffer> {
    protected override Task HandleAsync(MultiOffer offer)
    {
        // show dialog with multiple purchase options
    }
}

// somewhere during start
AnalyticsClient.OffersDispatcher
    .RegisterHandler(new SingleOfferHandler())
    .RegisterHandler(new MultiOfferHandler())
    .Start();

It's necessary to call Start for letting SDK know that game is ready to start handling offers

Inform about user level and balance

There are two compelling reasons why Elevatix requires access to players' product balances and level state:

  • Firstly: This information serves as a crucial safeguard, preventing Elevatix from suggesting non-consumable items that the user has already purchased.
  • Secondly: It enables Elevatix to make more informed and strategic choices when determining which product(s) should be recommended to the user, thereby enhancing the overall user experience.

Important Note: It is imperative that all AnalyticsClient.SetInventoryItem and AnalyticsClient.SetLevel calls are executed prior to the first Tracker call. This sequence is critical for ensuring the accuracy and effectiveness of the tracking process.

For instance, consider the following scenario: \ Given that the user has 300 coins (a form of soft in-game currency, identified as ID - 10) and is at level 15. \ The corresponding code should look following:

using Elevatix;

// 10 - Elevatix, product ID
// 300 - is amount of that product
AnalyticsClient.SetInventoryItem(10, 300);
AnalyticsClient.SetLevel(15);

Testing and Troubleshooting

Once the SDK has been successfully integrated and thoroughly tested within the Unity Editor, there may arise a need to conduct testing on a development or test-flight build of the game. \ In such instances, the game must provide a mechanism to expose the Elevatix user ID to the developer. \ This user ID can be obtained by invoking the AnalyticsClient.GetUserId function.

Complete Api

Analytics Client Class

AnalyticsClient is static class and is part of Elevatix namespace.

AnalyticsClient.Init

Parameter: bool(default - true) - Whether the game is activating offers for a specific player \ Description: Initializes SDK

AnalyticsClient.OffersDispatcher

Description: instance of the OffersDispatcher

AnalyticsClient.UserDataService

Description: instance of the UserDataService

AnalyticsClient.Disable

Description: Deactivates all event tracking and offers functionalities

AnalyticsClient.Enable

Description: Activates event tracking and offers features

AnalyticsClient.AreOffersEnabled

Description: Responds to the inquiry regarding the status of Elevatix offers, which can be either enabled or disabled through the administrative application. This determination can only be ascertained once the Elevatix SDK has been initialized

AnalyticsClient.SetLevel

Parameter: long - level of the user \ Description: Provides Elevatix with information regarding the current state of the player's level

AnalyticsClient.SetInventoryItem

Parameter: long - The Elevatix product identifier corresponding to the product owned by the user \ Parameter: long - The quantity of this product available in the user's balance \ Description: Communicates the current state of the player's balance to Elevatix

AnalyticsClient.GetUserId

Description: The method for obtaining the UserID that Elevatix employs for client identification

AnalyticsClient.GetAssetUrls

Description: Returns a list of image URLs utilized in offers. This function is intended to be invoked during the asset loading phase to facilitate the caching of all images

Tracker Class

Tracker is static class and is part of Elevatix namespace.

Tracker.TrackLogin

Description: Should be used after player is logged in

Tracker.TrackEnterMainScreen

Description: Should be used when when player enters main screen(a.k.a home screen)

Tracker.TrackLevelStart

Parameter: int - Level that player started \ Description: Should be used when player enters level

Tracker.TrackLevelWin

Parameter: int - Level that player won \ Description: Should be used when player wins level

Tracker.TrackLevelFail

Parameter: int - Level that player failed \ Description: Should be used after player fails level

Tracker.TrackOfferPurchase

Parameter: long - Offer id that player bought \ Parameter: long - Pack id that player bought \ Description: Should be used after player bought product from offer provided by the Elevatix

Tracker.TrackProductRestore

Parameter: string - Product that been restored, typically it looks like - com.{your-company}.{productId} \ Parameter: List<PurchasedItem> - List of PurchasedItem that represents goods that player got \ Description: Should be used when player restores(without additional charges) product purchase

Tracker.TrackProductRestore

(DEPRECATED) in favor of two parameters method \ Parameter: string - Product that been restored, typically it looks like - com.{your-company}.{productId} \ Description: Should be used when player restores(without additional charges) product purchase

Tracker.TrackCustomPurchase

Parameter: string - Product that been restored, typically it looks like - com.{your-company}.{productId} \ Parameter: List<PurchasedItem> - List of PurchasedItem that represents goods that player got \ Description: Should be used when player made product purchase

Tracker.TrackCustomPurchase

(DEPRECATED) in favor of two parameters method \ Parameter: string - Product that been restored, typically it looks like - com.{your-company}.{productId} \ Description: Should be used when player made product purchase

Tracker.TrackCustomRollingPurchase

Parameter: string - Product that been bought from the store, typically it looks like - com.{your-company}.{productId} \ Parameter: List<PurchasedItem> - List of PurchasedItem that represents goods that player got \ Parameter: int - Index of product in rolling offer chain \ Description: Should be used when player bought something via game owned rolling offers

Tracker.TrackBalanceUpdate

Parameter: string - ID of the updated product \ Parameter: long - Amount of given(positive number) or taken away(negative number) products \ Description: Should be used after players balance has changed

Tracker.TrackAdEvent

Parameter: AdType - type of advertisement (imported from Elevatix.Advertisement namespace)\ Description: should be tracked after ad complete

Tracker.TrackCustomEvent

Parameter: string - event name \ Description: Should be used to track custom event

Offer

Is high level entity that comes to the game. \ Acts as container for the

public class Offer
    {
        // Offer Id
        public long Id;
    }

SingleOffer

Is offer with exact one pack that user can purchase

public class SingleOffer: Offer
    {
        // Pack entity
        public Pack Pack;
    }

MultiOffer

Is offer with more than one pack that user can purcase

public class MultiOffer: Offer
    {
        // Pack entity
        public Packs List<Pack>;
    }

Offers Dispatcher

Object that informs game about offers that game should show for the user. \ Analytics client has includes instance of this object

OffersDispatcher.RegisterHandler

Description: Method that registers specific handler for further offers processing \ Parameter: handler, implementation of the OfferHandlerBase

OffersDispatcher.Start

Description: Tells dispatcher to "start" dispatching offers Returns: Task that is resolved when initial offers are resolved

Pack

Entity containing products for the user, along with pertinent instructions on how to facilitate its sale.

public class Pack
{
    public long Id => id;
    
    // The name of the pack, intended for client-facing display to the user
    public string Name;
    
    // Field contains information about how to sell particular pack 
    public CostPackage CostPackage;
    
    // A list of the products contained within this pack, essentially items to be used as rewards after purchase
    public List<Product> Products;
    
    // The type of the pack, with possible values being PackType.Regular and PackType.Subscription
    public PackType Type;
    
    // Relevant only for PackType.Subscription, representing units of duration
    public DurationType DurationType;
    
    // Relevant only for PackType.Subscription, indicating the duration for which the subscription should be applied
    public int Duration;
    
    // Custom keys and values that are filled in during pack creation
    // Could be usefull for customization of specific pack 
    public Dictionary Meta;
    
    // A URL pointing to the image assigned to the pack
    public string? ImageUrl;
}

Cost Package

It's easier to think of the Cost Package as similar to a 'Price Tag' in a retail store.

public class CostPackage
    {
        // Product id from the store. Should be used to show the price and execute purchase
        public string ProductId;
    }

Product

public class Product
{
    // Identifier for the product, consistent with its use in TrackBalanceUpdate and SetInventoryItem. 
    // Particularly necessary for awarding users
    public long Id;

    // The name of the product
    public string Name;

    // A flag set from the admin application. Used to identify the product's category and may require custom logic
    public bool Special;

    // Either "HARD" or "SOFT." This field allows for custom logic based on these two categories
    public string CurrencyType;

    // Either "CONSUMABLE" or "NON_CONSUMABLE." This field allows for custom logic based on these two categories
    public string ConsumeType;

    // Quantity of products in the parent pack
    public int Quantity;
    
    // Custom string of the product assigned during pack creation in the admin app
    public string CustomProperty;

#nullable enable

    // Image associated with the specific product in the "Elevatix Settings" file
    public Sprite? Image;

    // String associated with the specific product in "Elevatix Settings".
    // It might be used to display the sprite image with rich text
    public string? Sprite;

    // URL pointing to the image assigned to the product
    public string? ImageUrl;

#nullable disable
}

PurchasedItem

Entity that represents goods that user received as one of rewards to purchase.

  class PurchasedItem {
      
      /// <summary>
      /// Entity that represents goods that user received as one of rewards to purchase
      /// </summary>
      /// <param name="productId">Product Identifier registered in elevatix admin app</param>
      /// <param name="amount">Amount for items granted to the user</param>
      /// <param name="customProperty">Custom value of that most likely would be some kind of "type"</param>
      public PurchasedItem(long productId, double amount, string customProperty = null)
  }

UserDataService

Object for defining player data. Instantiated in the AnalyticsClient.UserData field

SetRegistrationDate

!Important note: This method should be called before AnalyticsClient.Init call, otherwise is ignored Description: Notifies Elevatix about user registration date \ Parameter: long timestamp of the moment when user got registered or installed the app

2.3.1

13 days ago

2.3.0

16 days ago

2.2.1

18 days ago

2.2.0

29 days ago

2.1.4

2 months ago

2.1.3

2 months ago

2.1.2

3 months ago

2.1.1

4 months ago

2.1.0

5 months ago

2.0.2

5 months ago

2.0.1

5 months ago

2.0.0

5 months ago

1.1.0

6 months ago

1.0.121

10 months ago

1.0.120

10 months ago

1.0.123

10 months ago

1.0.122

10 months ago

1.0.129

8 months ago

1.0.128

8 months ago

1.0.125

9 months ago

1.0.124

9 months ago

1.0.127

8 months ago

1.0.126

8 months ago

1.0.118

10 months ago

1.0.119

10 months ago

1.0.117

12 months ago

1.0.114

1 year ago

1.0.116

12 months ago

1.0.115

12 months ago

1.0.112

1 year ago

1.0.113

1 year ago

1.0.101

1 year ago

1.0.107

1 year ago

1.0.106

1 year ago

1.0.109

1 year ago

1.0.108

1 year ago

1.0.103

1 year ago

1.0.102

1 year ago

1.0.105

1 year ago

1.0.110

1 year ago

1.0.111

1 year ago

1.0.100

1 year ago

1.0.76

1 year ago

1.0.79

1 year ago

1.0.78

1 year ago

1.0.80

1 year ago

1.0.84

1 year ago

1.0.83

1 year ago

1.0.82

1 year ago

1.0.81

1 year ago

1.0.88

1 year ago

1.0.87

1 year ago

1.0.86

1 year ago

1.0.89

1 year ago

1.0.90

1 year ago

1.0.95

1 year ago

1.0.94

1 year ago

1.0.93

1 year ago

1.0.92

1 year ago

1.0.99

1 year ago

1.0.98

1 year ago

1.0.97

1 year ago

1.0.96

1 year ago

1.0.73

1 year ago

1.0.72

1 year ago

1.0.75

1 year ago

1.0.74

1 year ago

1.0.71

1 year ago

1.0.60

1 year ago

1.0.66

1 year ago

1.0.65

1 year ago

1.0.64

1 year ago

1.0.63

1 year ago

1.0.69

1 year ago

1.0.68

1 year ago

1.0.67

1 year ago

1.0.70

1 year ago

1.0.59

1 year ago

1.0.55

1 year ago

1.0.54

1 year ago

1.0.53

1 year ago

1.0.52

1 year ago

1.0.58

1 year ago

1.0.56

1 year ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.39

2 years ago

1.0.17

2 years ago

1.0.38

2 years ago

1.0.16

2 years ago

1.0.40

2 years ago

1.0.44

2 years ago

1.0.22

2 years ago

1.0.43

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.48

2 years ago

1.0.47

2 years ago

1.0.46

2 years ago

1.0.45

2 years ago

1.0.23

2 years ago

1.0.28

2 years ago

1.0.49

2 years ago

1.0.27

2 years ago

1.0.51

1 year ago

1.0.50

1 year ago

1.0.33

2 years ago

1.0.32

2 years ago

1.0.37

2 years ago

1.0.15

2 years ago

1.0.36

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.34

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

0.0.0

2 years ago