Skip to content

Commit 41f09ec

Browse files
authored
Merge pull request #3 from AppsFlyerSDK/custom_event_params
added custom_event_parameters to LogEvent
2 parents c3e7d3a + d41a87f commit 41f09ec

File tree

3 files changed

+43
-14
lines changed

3 files changed

+43
-14
lines changed

Assets/AppsflyerModule.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,11 @@ public void Stop()
113113
}
114114

115115
// report inapp event to AppsFlyer
116-
public void LogEvent(string event_name, Dictionary<string, object> event_parameters)
116+
public void LogEvent(
117+
string event_name,
118+
Dictionary<string, object> event_parameters,
119+
Dictionary<string, object> event_custom_parameters = null
120+
)
117121
{
118122
if (isStopped)
119123
{
@@ -126,6 +130,7 @@ public void LogEvent(string event_name, Dictionary<string, object> event_paramet
126130
// setting the event name and value
127131
req.event_name = event_name;
128132
req.event_parameters = event_parameters;
133+
req.event_custom_parameters = event_custom_parameters;
129134

130135
// set request type
131136
AppsflyerRequestType REQ_TYPE = AppsflyerRequestType.INAPP_EVENT_REQUEST;
@@ -324,6 +329,7 @@ class RequestData
324329
public string customer_user_id;
325330
public string event_name;
326331
public Dictionary<string, object> event_parameters;
332+
public Dictionary<string, object> event_custom_parameters;
327333
}
328334

329335
[Serializable]

Assets/AppsflyerScript.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,28 @@ public class AppsflyerScript : MonoBehaviour
1212

1313
void Start()
1414
{
15+
// init the SDK
1516
AppsflyerModule afm = new AppsflyerModule(DEV_KEY, APP_ID, this, IS_SANDBOX);
17+
18+
// set CUID
1619
afm.SetCustomerUserId("testTEST12345");
20+
// start the SDK (send firstopen/session request)
1721
afm.Start();
1822

23+
// LogEvent example
1924
// set event name
2025
string event_name = "af_purchase";
2126
// set event values
2227
Dictionary<string, object> event_parameters = new Dictionary<string, object>();
2328
event_parameters.Add("af_currency", "USD");
2429
event_parameters.Add("af_price", 6.66);
2530
event_parameters.Add("af_revenue", 12.12);
26-
event_parameters.Add("goodsName", "新人邀约购物日");
2731
// send logEvent request
2832
afm.LogEvent(event_name, event_parameters);
29-
30-
// afm.SetCustomerUserId("test-willnotwork");
31-
// afm.Stop();
33+
// send logEvent request with custom params
34+
Dictionary<string, object> event_custom_parameters = new Dictionary<string, object>();
35+
event_custom_parameters.Add("goodsName", "新人邀约购物日");
36+
afm.LogEvent(event_name, event_parameters, event_custom_parameters);
3237

3338
// the creation date in this example is "2023-03-23T08:30:00+00:00"
3439
bool newerDate = afm.IsInstallOlderThanDate("2023-06-13T10:00:00+00:00");
@@ -38,6 +43,9 @@ void Start()
3843
Debug.Log("newerDate:" + (newerDate ? "true" : "false"));
3944
// will return false
4045
Debug.Log("olderDate:" + (olderDate ? "true" : "false"));
46+
47+
// stop the SDK
48+
afm.Stop();
4149
}
4250

4351
private void Update() { }

README.md

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ This method receives your API key, App ID, the parent MonoBehaviour and a sandbo
3333
AppsflyerModule(string devkey, string appid, MonoBehaviour mono, bool isSandbox = false)
3434
```
3535

36+
**Arguments**:
37+
38+
- `DEV_KEY`: Get from the marketer or [AppsFlyer HQ](https://support.appsflyer.com/hc/en-us/articles/211719806-App-settings-#general-app-settings).
39+
- `APP_ID`: The app id on Appsflyer HQ
40+
- `MonoBehaviour mono`: the parent MonoBehaviour.
41+
- `bool isSandbox`: Whether to activate sandbox mode. False by default. This option is for debugging. With the sandbox mode, AppsFlyer dashboard does not show the data.
42+
3643
**Usage**:
3744

3845
```c#
@@ -43,13 +50,6 @@ AppsflyerModule afm = new AppsflyerModule(<< DEV_KEY >>, << APP_ID >>, this);
4350
AppsflyerModule afm = new AppsflyerModule(<< DEV_KEY >>, << APP_ID >>, this, true);
4451
```
4552

46-
**Arguments**:
47-
48-
- `DEV_KEY`: Get from the marketer or [AppsFlyer HQ](https://support.appsflyer.com/hc/en-us/articles/211719806-App-settings-#general-app-settings).
49-
- `APP_ID`: The app id on Appsflyer HQ
50-
- `MonoBehaviour mono`: the parent MonoBehaviour.
51-
- `bool isSandbox`: Whether to activate sandbox mode. False by default. This option is for debugging. With the sandbox mode, AppsFlyer dashboard does not show the data.
52-
5353
### Start
5454

5555
This method sends first open/session requests to AppsFlyer.
@@ -98,9 +98,19 @@ This method receives an event name and JSON object and sends an in-app event to
9898

9999
**Method signature**
100100

101+
```c#
102+
void LogEvent(
103+
string event_name,
104+
Dictionary<string, object> event_parameters,
105+
Dictionary<string, object> event_custom_parameters = null
106+
)
101107
```
102-
void LogEvent(string event_name, Dictionary<string, object> event_parameters)
103-
```
108+
109+
**Arguments**:
110+
111+
- `string event_name`-
112+
- `Dictionary<string, object> event_parameters`: dictionary object which contains the [predefined event parameters](https://dev.appsflyer.com/hc/docs/ctv-log-event-event-parameters).
113+
- `Dictionary<string, object> event_custom_parameters` (non-mandatory): dictionary object which contains the any custom event parameters.
104114

105115
**Usage**:
106116

@@ -114,6 +124,11 @@ event_parameters.Add("af_price", 6.66);
114124
event_parameters.Add("af_revenue", 12.12);
115125
// send logEvent request
116126
afm.LogEvent(event_name, event_parameters);
127+
128+
// send logEvent request with custom params
129+
Dictionary<string, object> event_custom_parameters = new Dictionary<string, object>();
130+
event_custom_parameters.Add("goodsName", "新人邀约购物日");
131+
afm.LogEvent(event_name, event_parameters, event_custom_parameters);
117132
```
118133

119134
### IsInstallOlderThanDate

0 commit comments

Comments
 (0)