From 438f0c28b6a998094eda544b0514f3b3a67de4d7 Mon Sep 17 00:00:00 2001 From: Leonid Date: Mon, 14 Dec 2020 23:51:11 +0100 Subject: [PATCH] minor fixes to handle parameters --- README.md | 6 ++++ modules/adjust-config-temp.php | 55 ++++++++++++++++++++++++++++++---- modules/adjust-params.php | 27 ++++++++++++----- modules/adjust-utils.php | 4 --- 4 files changed, 75 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 21214f3..89e35e0 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,12 @@ You are all set now. #### Logging your results #### +If you want to store logs you need to create relevant directory: + +``` +$ mkdir logs +``` + To disable logs just set it so in `adjust-config.php` ``` diff --git a/modules/adjust-config-temp.php b/modules/adjust-config-temp.php index 59a7128..0d818fb 100644 --- a/modules/adjust-config-temp.php +++ b/modules/adjust-config-temp.php @@ -24,15 +24,58 @@ function config () { ], 'include_user' => - [ 'ip_address', 'id' ], - - 'clean_keys' => - [ 'user_id', 'transaction', 'sentry:user' ], + [ + 'ip_address', + 'id' + ], 'default_params' => - [ + [ 'event_token' => 'adjust_event_token', 'app_token' => 'adjust_app_token', 's2s' => 1 - ] + 'environment' => 'production' + ], + + 'callback_params' => + [ + 'user_id' => 'userID', + 'release' => 'app_version', + 'level' => 'error_level', + 'transaction' => 'controller', + 'os' => 'os_version', + 'device' => 'device_version', + 'user_email' => 'email' + ], + + 'partner_params' => + [ + 'release' => 'app_version' + ], + + 'clean_keys' => + [ + 'user_id', + 'sentry:user', + 'browser', + 'browser.name', + 'os.name', + 'id', + 'app.device', + 'device', + 'device.family', + 'dist', + 'handled', + 'level', + 'mechanism', + 'os', + 'os.name', + 'os.rooted', + 'push_token', + 'release', + 'transaction', + 'user', + 'user_id', + 'email' + ], ]; \ No newline at end of file diff --git a/modules/adjust-params.php b/modules/adjust-params.php index 4b72b96..1a8259c 100644 --- a/modules/adjust-params.php +++ b/modules/adjust-params.php @@ -32,13 +32,26 @@ function extract_user( &$params, $user ) { function modify_params( &$params ) { $params['sentry_user'] = explode( ':', $params['sentry:user'] )[1]; - $params['callback_params'] = [ - 'user_id' => $params['user_id'], - ]; + $params['idfa'] = $params['ios_idfa']; - $params['partner_params'] = [ - 'push_token' => $params['push_token'], - ]; + callback_params( $params ); + partner_params( $params ); +} + +function callback_params( &$params ) { + $params['callback_params'] = []; + + foreach( config()->callback_params as $key => $value ) { + $params['callback_params'][$value] = $params[$key]; + } +} + +function partner_params( &$params ) { + $params['partner_params'] = []; + + foreach( config()->partner_params as $key => $value ) { + $params['partner_params'][$value] = $params[$key]; + } } function clean ( &$params ) { @@ -47,7 +60,7 @@ function clean ( &$params ) { } foreach ( $params as $key => $value ) { - if ( empty( $value ) ) { + if ( empty( $value ) || $value === 'null' ) { unset( $params[$key] ); } } diff --git a/modules/adjust-utils.php b/modules/adjust-utils.php index 872dc04..7c6ef50 100644 --- a/modules/adjust-utils.php +++ b/modules/adjust-utils.php @@ -6,10 +6,6 @@ function prep_url ( $url ) { $res= $url; - - if ( substr( $res, -1 ) !== '/' ) { - $res .= '/'; - } $res .= '?';