Steam C++
리포지토리에 연결
GitHub
앱스플라이어 스팀 C++ SDK 연동
앱스플라이어는 크로스 플랫폼 어트리뷰션, 모바일 및 웹 분석, 딥링킹, 사기 탐지, 개인 정보 관리 및 보존 등을 포함하여 실제 문제를 해결하는 강력한 도구를 제공하여 게임 마케터가 더 나은 결정을 내릴 수 있도록 지원합니다.
게임 어트리뷰션을 위해서는 게임이 HTTPS를 통해 앱스플라이어 API와 통신하고 첫 번째 열기, 연속 세션 및 인앱이벤트와 같은 사용자 활동을 리포트해야 합니다. 예를 들어 구매 이벤트입니다.
C++에서 사용자 활동을 리포트하는 코드를 통합하기 위한 참조로 이 샘플 앱을 사용하는 것이 좋습니다. 참고: 다음 샘플 코드는 현재 Windows 환경에서만 지원됩니다.
Prerequisites
- Steamworks SDK - 프로젝트에 연동되었습니다.
- vcpkg openssl & nlohmann-json packages:
vcpkg install curl:x86-windows
vcpkg install nlohmann-json:x86-windows
vcpkg install openssl:x86-windows
AppsflyerSteamModule - 인터페이스
AppsflyerSteamModule.h”, appsflyer-module
폴더에 있으며 앱스플라이어 서버에 연결하고 이벤트를 리포트하는 데 필요한 코드 및 논리가 포함되어 있습니다.
Init
이 메서드는 API 키와 앱 ID를 수신하고 앱스플라이어 모듈을 초기화합니다.
Method signature
void Init(const char* devkey, const char* appID, bool collectSteamUid = true)
Usage:
// for regular init
AppsflyerSteamModule()->Init(<< DEV_KEY >>, << STEAM_APP_ID >>);
// for init without reporting steam_uid
AppsflyerSteamModule()->Init(<< DEV_KEY >>, << STEAM_APP_ID >>, false);
Arguments:
string STEAM_APP_ID
: SteamDB에서 찾을 수 있습니다.string DEV_KEY
: 마케터 또는 앱스플라이어 본사에서 얻을 수 있습니다.bool collectSteamUid
: Whether to collect Steam UID or not. True by default.
Start
이 메서드는 앱스플라이어에 first open 및 /session 요청을 보냅니다.
Method signature
void Start(bool skipFirst = false)
Usage:
// without the flag
AppsflyerSteamModule()->Start();
// with the flag
bool skipFirst = [SOME_CONDITION];
AppsflyerSteamModule()->Start(skipFirst);
Stop
Once this method is invoked, our SDK no longer communicates with our servers and stops functioning.
Useful when implementing user opt-in/opt-out.
Method signature
void Stop()
Usage:
// Starting the SDK
AppsflyerSteamModule()->Start();
// ...
// Stopping the SDK, preventing further communication with AppsFlyer
AppsflyerSteamModule()->Stop();
LogEvent
이 메서드는 이벤트 이름과 JSON 객체를 수신하고 앱스플라이어에 인앱이벤트를 보냅니다.
Method signature
void LogEvent(std::string event_name, json event_parameters)
Usage:
json event_parameters = { {"af_currency", "USD"}, {"af_price", 6.66}, {"af_revenue", 24.12} };
std::string event_name = "af_purchase";
AppsflyerSteamModule()->LogEvent(event_name, event_parameters);
참고: JSON을 사용하려면 다음 가져오기를 사용해야 합니다.
#include <nlohmann/json.hpp>
using json = nlohmann::json;
SetCustomerUserId
Setting your own customer ID enables you to cross-reference your own unique ID with AppsFlyer’s unique ID and other devices’ IDs.
This ID is available in raw-data reports and in the Postback APIs for cross-referencing with your internal IDs.
Can be used only before calling Start()
.
Method signature
void SetCustomerUserId(std::string cuid)
Usage:
AppsflyerSteamModule()->Init(DEV_KEY, STEAM_APP_ID);
AppsflyerSteamModule()->SetCustomerUserId("Test-18-9-23");
AppsflyerSteamModule()->Start();
OnCallbackSuccess, OnCallbackFailure
상기의 메서드는 성공/실패 시 원하는 작업에 대한 자리 표시자입니다.
각 함수 내에서 컨텍스트의 switch case를 사용하여 다양한 유형의 이벤트를 처리할 수 있습니다("FIRST_OPEN_REQUEST", "SESSION_REQUEST", "INAPP_EVENT_REQUEST").
Method signature
void OnCallbackSuccess(long responseCode, uint64 context)
void OnCallbackFailure(long responseCode, uint64 context)
GetAppsFlyerUID
앱스플라이어의 고유 기기 ID를 가져옵니다. SDK는 앱 설치 시 앱스플라이어의 고유 기기 ID를 생성합니다. SDK가 시작되면 이 ID가 첫 번째 앱 인스톨의 ID로 기록됩니다.
Method signature
std::string GetAppsFlyerUID()
Usage:
AppsflyerSteamModule()->GetAppsFlyerUID();
IsInstallOlderThanDate
이 메서드는 날짜 문자열을 수신하고 게임 폴더 수정 날짜가 날짜 문자열보다 오래된 경우 true를 반환합니다. 날짜 문자열 형식은 "2023-January-01 23:12:34"입니다.
Method signature
bool IsInstallOlderThanDate(std::string datestring)
Usage:
// the modification date in this example is "2023-January-23 08:30:00"
// will return false
bool dateBefore = AppsflyerSteamModule()->IsInstallOlderThanDate("2023-January-01 23:12:34");
// will return true
bool dateAfter = AppsflyerSteamModule()->IsInstallOlderThanDate("2023-April-10 23:12:34");
// example usage with skipFirst -
// skipping if the install date is NOT older than the given date
bool isInstallOlderThanDate = AppsflyerSteamModule()->IsInstallOlderThanDate("2023-January-10 23:12:34");
AppsflyerSteamModule()->Start(!isInstallOlderThanDate);
샘플 앱 실행
- Visual Studio를 설치합니다.
- 솔루션 열기
../appsflyer-steam-sample-app/steam-sample-app/steamworksexample/SteamworksExample.sln
. - 이
Source Files/Main.cpp
file. - 244라인에서
DEV_KEY
andSTEAM_APP_ID
을 앱 세부 정보로 교체합니다. - 상단 도구 모음에서 재생 (로컬 Windows 디버거)을 클릭하여 앱을 실행합니다. 모드가 디버그로 설정되어 있는지 확인하십시오.
- 24시간 후 대시보드가 업데이트되고 오가닉 및 논오가닉 인스톨과 인앱이벤트가 표시됩니다.
Steam 게임에서 앱스플라이어 구현하기
Setup
- 이
appsflyer-module
파일을 헤더 파일 > 앱스플라이어의 C++ 프로젝트로 복사합니다. - 모듈을 가져옵니다.
#include "AppsflyerSteamModule.h"
- 가져오기
nlohmann-json
.
#include <nlohmann/json.hpp>
using json = nlohmann::json;
- Initialize the AppsFlyer integration and call start.
- 인앱 이벤트를 리포트합니다.
스팀 클라우드 저장 삭제(어트리뷰션 재설정)
- 스팀 클라우드 비활성화.
- 로컬 파일 삭제.
- Remove the registry data from
SOFTWARE\Microsoft\Windows\CurrentVersion\Run
. The Registry keys areAF_counter_[APPID]
andAF_uuid_[APPID]
.
최신 데이터 12일 전