Skip to content

Commit d335eba

Browse files
Add PokiSDK.measure() (#24)
* Add PokiSDK.measure() A new feature to track game events that will be released to all developers soon. * Add missing doc
1 parent f79f184 commit d335eba

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,5 @@ poki_sdk.set_debug(value) -- in JS it's PokiSDK.setDebug(value)
156156
poki_sdk.capture_error(error_string) -- in JS it's PokiSDK.captureError(error_string)
157157
poki_sdk.shareable_url(params, callback) -- in JS it's PokiSDK.shareableURL({}).then(url => {})
158158
local value = poki_sdk.get_url_param(key) -- in JS it's PokiSDK.getURLParam('id')
159+
poki_sdk.measure(category, what, action) -- in JS it's PokiSDK.measure(category, what, action)
159160
```

poki-sdk/api/poki-sdk.script_api

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,19 @@
9191
- name: value
9292
type: string
9393

94+
#*****************************************************************************************************
95+
96+
- name: measure
97+
type: function
98+
99+
parameters:
100+
- name: category
101+
type: string
102+
- name: what
103+
type: string
104+
- name: action
105+
type: string
106+
94107
#*****************************************************************************************************
95108

96109
- name: REWARDED_BREAK_ERROR

poki-sdk/lib/web/lib_pokisdk.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ var LibPokiSdk = {
9797
var key = UTF8ToString(key);
9898
var value = PokiSDK.getURLParam(key);
9999
return stringToUTF8OnStack(value);
100-
}
100+
},
101+
102+
PokiSdkJs_Measure: function(category, what, action) {
103+
PokiSDK.measure(UTF8ToString(category), UTF8ToString(what), UTF8ToString(action));
104+
},
101105
}
102106

103107
autoAddDeps(LibPokiSdk, '$PokiSdk');

poki-sdk/src/pokisdk.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ extern "C" {
4040
void PokiSdkJs_AddParameterForURL(const char* key, const char* value);
4141
void PokiSdkJs_ShareableURL(ShareableURLCallback callback);
4242
const char* PokiSdkJs_GetURLParam(const char* key);
43+
44+
void PokiSdkJs_Measure(const char* category, const char* what, const char* action);
4345
}
4446

4547
static dmScript::LuaCallbackInfo* pokiSdk_Callback = 0x0;
@@ -260,6 +262,18 @@ static int PokiSdk_GetURLParam(lua_State* L)
260262
return 1;
261263
}
262264

265+
static int PokiSdk_Measure(lua_State* L)
266+
{
267+
DM_LUA_STACK_CHECK(L, 0);
268+
const char* category = luaL_checkstring(L, 1);
269+
// what is optional and defaults to an empty string
270+
const char* what = luaL_optstring(L, 2, "");
271+
// action is optional and defaults to an empty string
272+
const char* action = luaL_optstring(L, 3, "");
273+
PokiSdkJs_Measure(category, what, action);
274+
return 0;
275+
}
276+
263277
// Functions exposed to Lua
264278
static const luaL_reg Module_methods[] =
265279
{
@@ -272,6 +286,7 @@ static const luaL_reg Module_methods[] =
272286
{"is_ad_blocked", PokiSdk_IsAdBlocked},
273287
{"shareable_url", PokiSdk_ShareableURL},
274288
{"get_url_param", PokiSdk_GetURLParam},
289+
{"measure", PokiSdk_Measure},
275290
{0, 0}
276291
};
277292

0 commit comments

Comments
 (0)