# 연동 이벤트

## 1. 인앱 이벤트 데이터 전송 ( DOT.logEvent 에 대한 처리 )

SDK 사용 시에 DOT.logEvent API 함수를 사용하여 처리되던 내용을 Server-to-server에서 처리하는 방법은 다음과 같습니다. 다만, SDK에서 제공하는 API에 의한 요청과 차이점은 사용자의 단말기에서 관리되던 데이터가 Server-to-server에서는 제공될 수 없는 정보들이 있기 때문에 데이터의 처리 항목에 일부 차이가 있습니다. 아래의 2가지 예시는 "회원가입" 에 처리를 기준으로 작성된 예시이며, 다른 이벤트에 대해서도 같은 형태를 가지고 사용이 가능합니다.

{% tabs %}
{% tab title="S2S" %}

```java
curl -X POST https://trk.analytics.wisetracker.co.kr/s2s/v1/s2sDataRcv.do 
-H "Content-Type:application/json" 
-H "authToken:<SERVICE-ACCESS-TOKEN>" 
-d '{
        "SESSION":{ 
            "vtTz":  <unix time>,                               // required, current time  
            "_wtno": <SERVICE_NUMBER>,                          // required
            "advtId":"12D9505B-A48E-410A-8787-75BF39DA82F5",    // required, ADID/IDFA  
            "dSource":"SDK",                                    // required, "SDK" or "Website" ( Reserved text ) 
            "plat":"IOS"                                        // required, "AOS" or "IOS"     ( Reserved text ) 
        },
        "GOAL":{
            "vtTz":1620693013341,                                // required, current time          
            "signupTp":"email",
            "event":"w_signup_complete"
        }      
}'
```

{% endtab %}

{% tab title="Native" %}

```java
Map<String, Object> eventMap = new HashMap<>();
eventMap.put("event", "w_signup_complete");
eventMap.put("signupTp", "email");
DOT.logEvent(eventMap);
```

{% endtab %}
{% endtabs %}

## 2. 구매 이벤트 데이터 전송 ( DOT.logPurchase 에 대한 처리 )

SDK 사용 시에 DOT.logPurchase API 함수를 사용하여 처리되던 내용을 Server-to-server에서 처리하는 방법은 다음과 같습니다. 아래의 2가지 예시는 "구매" 이벤트 처리를 기준으로 작성된 예시입니다.

{% tabs %}
{% tab title="S2S (1개 상품)" %}

```java
curl -X POST https://trk.analytics.wisetracker.co.kr/s2s/v1/s2sDataRcv.do 
-H "Content-Type:application/json" 
-H "authToken:<SERVICE-ACCESS-TOKEN>" 
-d '{
        "SESSION":{ 
            "vtTz":  <unix time>,                               // required, current time  
            "_wtno": <SERVICE_NUMBER>,                          // required
            "advtId":"12D9505B-A48E-410A-8787-75BF39DA82F5",    // required, ADID/IDFA  
            "dSource":"SDK",                                    // required, "SDK" or "Website" ( Reserved text ) 
            "plat":"IOS"                                        // required, "AOS" or "IOS"     ( Reserved text ) 
        },
       "REVENUE":{
               "vtTz":1620702642346,                            // required, current time
               "event":"w_purchase",                            // required, "w_purchase" or "w_first_purchase" ( Reserved text )
               "transaction_id":"TR2020111129424",              // required, Order Number     
               "currency":"KRW",                                // required, Currency    
               "product":{                                      // required
                   "product_id":"2007291158",
                   "product_name":"Leia Pleats Bag Black",
                   "quantity":2,
                   "revenue":566200
               }
       }   
}'
```

{% endtab %}

{% tab title="S2S (1개 이상의 상품)" %}

```java
curl -X POST https://trk.analytics.wisetracker.co.kr/s2s/v1/s2sDataRcv.do 
-H "Content-Type:application/json" 
-H "authToken:<SERVICE-ACCESS-TOKEN>" 
-d '{
        "SESSION":{ 
            "vtTz":  <unix time>,                               // required, current time  
            "_wtno": <SERVICE_NUMBER>,                          // required
            "advtId":"12D9505B-A48E-410A-8787-75BF39DA82F5",    // required, ADID/IDFA  
            "dSource":"SDK",                                    // required, "SDK" or "Website" ( Reserved text ) 
            "plat":"IOS"                                        // required, "AOS" or "IOS"     ( Reserved text ) 
        },
       "REVENUE":{
               "vtTz":1620702642346,                            // required, current time  
               "event":"w_purchase",                            // required, "w_purchase" or "w_first_purchase" ( Reserved text )
               "transaction_id":"TR2020111129424",              // required, Order Number  
               "currency":"KRW",                                // required, Currency   
               "product":[{                                     // required   
                   "product_id":"2007291158",
                   "product_name":"Leia Pleats Bag Black",
                   "quantity":2,
                   "revenue":566200
               },{
                   "product_id":"2007291159",
                   "product_name":"Leia Pleats Bag Blue",
                   "quantity":1,
                   "revenue":1566200
               }]
       }   
}'
```

{% endtab %}

{% tab title="Native" %}

```java
// 1개 상품 구매시 
Map<String, Object> purchaseMap = new HashMap<>();
purchaseMap.put("transaction_id", "TR2020111129420");
purchaseMap.put("currency", "KRW");
Map<String, Object> productMap = new HashMap<>();
productMap.put("product_id", "2007291158");
productMap.put("product_name", "Leia Pleats Bag Black");
productMap.put("quantity", 2);
productMap.put("revenue", 283100);
purchaseMap.put("product", productMap);
DOT.logPurchase(purchaseMap);
 
// 1개 이상 상품 구매시 
Map<String, Object> purchaseMap = new HashMap<>();
purchaseMap.put("transaction_id", "TR2020111129421");
purchaseMap.put("currency", "KRW");
Map<String, Object> productMap1 = new HashMap<>();
productMap1.put("product_id", "2007291158");
productMap1.put("product_name", "Leia Pleats Bag Black");
productMap1.put("quantity", 2);
productMap1.put("revenue", 566200);
Map<String, Object> productMap2 = new HashMap<>();
productMap2.put("product_id", "2005268849");
productMap2.put("product_name", "페이 스몰 숄더백 (FAYE)");
productMap2.put("quantity", 1);
productMap2.put("revenue", 1323000);
List<Map<String, Object>> productList = new ArrayList<>();
productList.add(productMap1);
productList.add(productMap2);
purchaseMap.put("product", productList);
DOT.logPurchase(purchaseMap);   
```

{% endtab %}
{% endtabs %}
