myClientId = $theClientId; $this->myAppId = $theAppId; $this->myPasswrd = $thePasswrd; foreach ($_SERVER as $key_name => $key_value) { if ($key_name == 'SERVER_SOFTWARE') { $this->myServerSoftwareStr = $key_value; break; } } if (!$this->myServerSoftwareStr) { $this->myServerSoftwareStr = 'PHP/' . phpversion(); } } /** * creates an ISO8601 timestamp string from the UTC timezone. optionally * pass a previously generated time object to base string from. * only down to seconds granularity. * * @param bool $theTime \ \DateTime $theTime * @return string */ public static function getISO8601UTCString($theTime = false) { if (!$theTime) { $theTime = time(); } //append a seconds fraction $aMicroTimeArray = explode(' ', microtime()); if (sizeof($aMicroTimeArray) > 1) { $aSecondRawFracStr = $aMicroTimeArray[0]; $aRoundedSecondFraction = round($aSecondRawFracStr, 3); $aRoundedSecondFractionArray = explode('.', $aRoundedSecondFraction); $aSecondFracStr = $aRoundedSecondFractionArray[1]; while (strlen($aSecondFracStr) < 3) { $aSecondFracStr = "0$aSecondFracStr"; } } else { $aSecondFracStr = "000"; } return gmdate("Y-m-d", $theTime) . 'T' . gmdate("H:i:s", $theTime) . '.' . $aSecondFracStr . 'Z'; } /** * Logs an Account Create event- Information regarding when the account was created as well as information * about the demographics of the account and the balance at the time of account * creation. This must be run once per Account Id, before referencing * said Account Id in any other logging statements. * * * @param DateTime $theEventTs When was the Account created? * @param string $theAccountId Account UUID to initialize * @param string $theAccountType Acceptable values are: Free, Paid, Premium * Default set = Free * @param string $theAccLang Case sensitive IETF language tag. Default set = "N0" * @param string $theAccCountry ISO-3166 alpha2 from geonames.org/countries * @param string $theAccGender Acceptable values are: "M", "F", "N". * @param DateTime|string $theAccDateOfBirth The reported DOB of the Account user. * Default could be null/empty field or '1900-01-01 00:00:00.0000000' * @param float|string $theAccCurrencyBal Default set = 0.00 * @param string $thePlatform What platform was the Account created on, Acceptable values are: Web-Facebook * Mobile-Facebook, Android-Facebook, iOS-Facebook, Web-GooglePlus, Mobile-GooglePlus, * Android-GooglePlus, iOS-GooglePlus,PC, Desktop, Other-Social, Other. * Default set = "Other" * @param string $theOldAccountId Default = "". * @param bool $isTest * * @return bool|string */ public function loadAccountCreate( $theEventTs, $theAccountId, $theAccountType = "Free", $theAccLang = "N0", $theAccCountry = "N0", $theAccGender = "N", $theAccDateOfBirth = '1900-01-01 00:00:00.0000000', $theAccCurrencyBal = '0.00', $thePlatform = "Other", $theOldAccountId = "", $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '9', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskAccountSubType => $theAccountType, KApi::$kDataMapKeyskAccountLanguage => $theAccLang, KApi::$kDataMapKeyskAccountCountry => $theAccCountry, KApi::$kDataMapKeyskAccountGender => $theAccGender, KApi::$kDataMapKeyskAccountDateOfBirth => $theAccDateOfBirth, KApi::$kDataMapKeyskAccountCurrencyBalance => $theAccCurrencyBal, KApi::$kDataMapKeyskPlatform => $thePlatform, KApi::$kDataMapKeyskOldAccountId => $theOldAccountId ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Delete Account event * * Information regarding account delete as well as reason regarding account * deletion in terms of churn, farming or account compromise. This must be run * once per Account Id life cycle, to properly keep application metrics in-sync. * * * @param DateTime $theEventTs When did the Account deletion occur? * @param string $theAccountId The Account UUID that was deleted - Required * @param string $theChurnType Acceptable values are: Active, Stopped, Expired, Failed, Cancelled * @param bool $isTest * * @return bool|string */ public function loadAccountDelete($theEventTs, $theAccountId, $theChurnType, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '10', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskAccountStatus => $theChurnType ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Character Create event * * Many games allow the user to create multiple characters or aliases. * The attributes of these characters need not be the same as the attributes of the person * in the real world e.g., age or gender. The attributes of the characters are usually fixed * once created. This event captures information regarding the creation time and the attributes * of a user's character. This must be run once per Character Id before referencing said * Character Id in any other logging statements. * * @param DateTime $theEventTs When did the character creation happen? * @param string $theAccountId Previously initialized Account UUID * @param string $theCharacterId The Account unique Character Id to initialize * Default: AccountId should be used as default if there's no CharacterId * @param string $theCharClass Higher-level Character Class. open-ended, but be consistent * @param string $theCharSubClass Further specific classification * @param string $theCharGender The Character's gender acceptable values are: "M", "F", "T". * Default should be "N" * @param string $theCharRace Character's in-game race * @param string $theCharName The name of the in-game Character * @param float $theShardId A particular db the Character is associated with. * Default - Use 0 if unused or does not have a value * @param bool $isTest * * @return bool|string */ public function loadCharacterCreate($theEventTs, $theAccountId, $theCharacterId, $theCharClass, $theCharSubClass, $theCharGender, $theCharRace, $theCharName, $theShardId, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '11', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskCharacterClass => $theCharClass, KApi::$kDataMapKeyskCharacterSubClass => $theCharSubClass, KApi::$kDataMapKeyskCharacterGender => $theCharGender, KApi::$kDataMapKeyskCharacterRace => $theCharRace, KApi::$kDataMapKeyskCharacterName => $theCharName, KApi::$kDataMapKeyskShardId => $theShardId ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Character Delete event * * This event refers to the character deletion info and * the characters that are referred to here are the same as in event (11). * This must be at the end of a Character lifecycle, to properly keep application metrics in-sync. * * @param DateTime $theEventTs When was the Character deleted? * @param string $theAccountId Previously initialized Account UUID * @param string $theCharacterId Identifier of Character that was deleted from the Account * Default: AccountId should be used as default if there's no CharacterId * @param bool $isTest * * @return bool|string */ public function loadCharacterDelete($theEventTs, $theAccountId, $theCharacterId, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '12', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs an Item Initialize event * * This event capture information regarding virtual items in the game. * These items may be available by non-player characters in the game or they may * be created by other players. Since this event initializes the items it can be thought * of as initializing the dimension table for the items which is then referred to by all * other item related events. This must be used before referencing an item id in any other command. * * @param DateTime $theEventTs When was the item created? * @param float $theItemId The item's application unique id. Default - Use 0 for default value * @param string $theItemName Examples: "the ban hammer", "FISH", "KITTEN" * Default - send "NA", if does not have a meaningful value * @param string $theItemType examples: "raw materials", "Armor", "tools" * @param string $theItemSegment Acceptable values are : "UGC" or "INGAME" * @param string $createAccountId If theItemSegment = "UGC", set this must * @param string $createCharacterId If a particular character created the item. * Default: createAccountId should be used as default if there's no CharacterId * @param bool $isTest * * @return bool|string */ public function loadItem($theEventTs, $theItemId, $theItemName, $theItemType, $theItemSegment, $createAccountId, $createCharacterId, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '15', KApi::$kDataMapKeyskItemId => $theItemId, KApi::$kDataMapKeyskItemName => $theItemName, KApi::$kDataMapKeyskItemType => $theItemType, KApi::$kDataMapKeyskItemSegment => $theItemSegment, KApi::$kDataMapKeyskAccountId => $createAccountId, KApi::$kDataMapKeyskCharacterId => $createCharacterId ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs Shard Initialize event * * Many games and environment have multiple instances of the games * which are running in parallel. These are referred to as shard in our schema. * These are the same as running multiple instances of the game or other environments * on different servers. This must occur before any logger or load command references the Shard Id. * * @param DateTime $theEventTs When was the Shard created? * @param float $theShardId Numeric UUID of the Shard * @param string $theShardDesc Text description of the Shard * @param bool $isTest * * @return bool|string */ public function loadShardCreate($theEventTs, $theShardId, $theShardDesc, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '13', KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskShardDesc => $theShardDesc ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs Virtual Currency Set event * Many games have one or more virtual currencies which the * players can use to exchange in game virtual items or other in-game resources. * In most cases these virtual currencies have an exchange rate that captures their * corresponding value in real world currency e.g., US Dollar, Yen, Euro etc.initialize * a virtual currency for application reporting. This can be used to create a virtual currency * and update an exchange rate of an existing currency. * * @param DateTime $theEventTs When was the event created? * @param string $theCurrencyLabel (MANDATORY Field) - application unique string identifier * @param bool $isTest * * @return bool|string */ public function loadVirtualCurrency($theEventTs, $theCurrencyLabel, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '14', KApi::$kDataMapKeyskVirtualCurrencyLabel => $theCurrencyLabel ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Currency Transaction event- Covers all types of transaction in the game or any other environment where * real world money was used * * @param DateTime $theEventTs * @param string $theAccountId * @param string $theCharacterId * @param float $theShardId * @param int $theTransactionType * @param int $theCurrencyType * @param theVirtualCurrencyCount Integer (OPTIONAL Field) - how many units of virtual currency were used * Default - null * @param float $theCurrencyValue * @param string $theTransactionDesc * @param int $theVirtualCurrencyCount * @param bool $isTest * @return bool|string */ public function logCurrencyTransaction($theEventTs, $theAccountId, $theCharacterId, $theShardId, $theTransactionType, $theCurrencyType, $theVirtualCurrencyLabel, $theCurrencyValue, $theTransactionDesc, $theVirtualCurrencyCount, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '18', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskTransactionType => $theTransactionType, KApi::$kDataMapKeyskCurrencyType => $theCurrencyType, KApi::$kDataMapKeyskVirtualCurrencyLabel => $theVirtualCurrencyLabel, KApi::$kDataMapKeyskCurrencyValue => $theCurrencyValue, KApi::$kDataMapKeyskTransactionDesc => $theTransactionDesc, KApi::$kDataMapKeyskVirtualCurrencyCount => $theVirtualCurrencyCount ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a UGC Rating event * * Some games allow players to create in-game items or other artifacts. * This event covers such items and how such items are rated by other players. * * @param DateTime $theEventTs When did the rating occur? * @param string $theAccountId The UUID associated with a particular user/player - email, number * @param string $theCharacterId Does an account have multiple characters associated with it? * use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theShardId A particular db the Character is associated with. * Default - Use 0 if unused or does not have a value * @param float $theItemId The application unique numeric id * Default - Use 0 for default value * @param string $theItemName Example: "crafty button", "GMO grain" * @param float $theUgcRating Score given to UGC item by other players. Player may rate any item, * owned or not - similar to FB like. * @param bool $isTest * * @return bool|string */ public function loadUgcRating($theEventTs, $theAccountId, $theCharacterId, $theShardId, $theItemId, $theItemName, $theUgcRating, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '19', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskItemId => $theItemId, KApi::$kDataMapKeyskItemName => $theItemName, KApi::$kDataMapKeyskUgcRating => $theUgcRating ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Group Entry event * * The time at which a user joins a group. The group in this case are likely to be impermanent. * Grouping is not applicable to solo games * * @param DateTime $theEventTs When did the user/player enter the Group? * @param string $theAccountId The UUID associated with a particular user/player - email, number * @param string $theCharacterId Does an account have multiple characters associated with it? * use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theCharacterLvl The numeric level identifier the character currently is at. * @param float $theShardId A particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param float $theGroupId The id number of the group that was entered * @param bool $isTest * * @return bool|string */ public function logEnterGroup($theEventTs, $theAccountId, $theCharacterId, $theCharacterLvl, $theShardId, $theGroupId, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '4', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskCharacterLvl => $theCharacterLvl, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskGroupId => $theGroupId ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Group Exit event * * The time at which a user leaves a group. The semantics of the group are the * same as event (4) * * @param DateTime $theEventTs When did the user/player exit the Group? * @param string $theAccountId The UUID associated with a particular user/player - email, number * @param string $theCharacterId Does an account have multiple characters associated with it? * use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theCharacterLvl The numeric level identifier the character currently is at. * @param float $theShardId A particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param float $theGroupId The id number of the group that was left * @param bool $isTest * * @return bool|string */ public function logExitGroup($theEventTs, $theAccountId, $theCharacterId, $theCharacterLvl, $theShardId, $theGroupId, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '5', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskCharacterLvl => $theCharacterLvl, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskGroupId => $theGroupId ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs an Item Used event- This item captures usage of items in the game, additional information regarding * the account and character of the user who used the item as well as location of the * character that used the item is also recorded. * * @param DateTime $theEventTs When was the item used? * @param string $theAccountId The UUID associated with a particular user/player - email, number * @param string $theCharacterId Does an account have multiple characters associated with it? * use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theCharacterLvl The numeric level identifier the character currently is at. * @param float $theShardId A particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param float $theItemId Ahe item's application unique id * Default - Use 0 for default value * @param string $theItemName Example: "crafty button", "GMO grain" * Default - send "NA", if does not have a value * @param int $theItemCount Number of times the item is used in this particular location. useful for spells, bullets. * @param float $theAreaId * @param float $theX * @param float $theY * @param float $theZ * @param bool $isTest * * @return bool|string */ public function logItem($theEventTs, $theAccountId, $theCharacterId, $theCharacterLvl, $theShardId, $theItemId, $theItemName, $theItemCount, $theAreaId, $theX, $theY, $theZ, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '16', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskCharacterLvl => $theCharacterLvl, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskItemId => $theItemId, KApi::$kDataMapKeyskItemName => $theItemName, KApi::$kDataMapKeyskItemCount => $theItemCount, KApi::$kDataMapKeyskAreaId => $theAreaId, KApi::$kDataMapKeyskPositionX => $theX, KApi::$kDataMapKeyskPositionY => $theY, KApi::$kDataMapKeyskPositionZ => $theZ ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs an Item Transaction event- Information regarding purchase of items in the game. Depending upon the game, * an item may be bought using real world money or virtual currency which may be exclusive * to the game. * Multiple logItemTransaction events might need to be called for a single transaction if * multiple currencies are used, example: 4 gold, 5 silver, 3 copper for a fish trap. * * @param DateTime $theEventTs When did the transaction occur? * @param string $theAccountId The UUID associated with a particular user/player - email, number * @param string $theCharacterId Does an account have multiple characters associated with it? * use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theShardId a particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param float $theItemId The item's application unique id * Default - Use 0 for default value * @param string $theItemName Example: "crafty button", "GMO grain" * Default - send "NA", if does not have a value * @param float $theItemPrice * @param int $theTransactionType Acceptable values are: 0 = SPENT or 1 = ACQUIRED currency * @param int $theCurrencyType Acceptable values are: 0 = real world, 1 = virtual * @param string $theVirtualCurrencyLbl A virtual currency previously initialized from Event #14. * If theCurrencyType = 1, setting this is MANDATORY else send "" as default * @param float $theCurrencyValue How much of a particular currency was used for this transaction * @param bool $isTest * * @return bool|string */ public function logItemTransaction($theEventTs, $theAccountId, $theCharacterId, $theShardId, $theItemId, $theItemName, $theItemPrice, $theTransactionType, $theCurrencyType, $theVirtualCurrencyLbl, $theCurrencyValue, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '17', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskItemId => $theItemId, KApi::$kDataMapKeyskItemName => $theItemName, KApi::$kDataMapKeyskItemPrice => $theItemPrice, KApi::$kDataMapKeyskTransactionType => $theTransactionType, KApi::$kDataMapKeyskCurrencyType => $theCurrencyType, KApi::$kDataMapKeyskVirtualCurrencyLabel => $theVirtualCurrencyLbl, KApi::$kDataMapKeyskCurrencyValue => $theCurrencyValue ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Login event- The time at which the user logged into the system where the * system may be a website, game, software etc * * @param DateTime $theEventTs What time did the login occur at? * @param string $theAccountId The UUID associated with a particular user/player - email, number * @param string $theCharacterId Does an account have multiple characters associated with it? * use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theShardId A particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param string $thePlatform What platform was the Account created on, Acceptable values are * user-agent string: "mobile" or, "desktop". * Default should be "Other" * @param float $theAreaId An in-app/game location id the user/player started in. * Default - Use 0 if unused or does not have a AreaId * @param string $theAreaName The name of the in-app/game location the user/player started in. * Default - Empty string * @param bool $isTest * * @return bool|string */ public function logLogin($theEventTs, $theAccountId, $theCharacterId, $theShardId, $thePlatform, $theAreaId, $theAreaName, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '1', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskPlatform => $thePlatform, KApi::$kDataMapKeyskAreaId => $theAreaId, KApi::$kDataMapKeyskAreaName => $theAreaName ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Logout event- The time at which the user logged out of the system where * the system may be a website, game, software etc * * @param DateTime $theEventTs What time did the logout occur at? * @param string $theAccountId * @param string $theCharacterId Does an account have multiple characters associated with it? * use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param bool $isTest * * @return bool|string */ public function logLogout($theEventTs, $theAccountId, $theCharacterId, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '2', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Logout event indirectly - This event is meant to get a continuous heartbeat from the user/player to know * that the user is still active, otherwise calls the Logout event to end the session * * @param DateTime $theEventTs What time did the logout occur at? * @param string $theAccountId The UUID associated with a particular user/player - email, number * @param string $theCharacterId Does an account have multiple characters associated with it? * use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theShardId A particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param string $thePlatform what platform did the Event happen on, acceptable values are * user-agent string: "mobile" or, "desktop". * Default should be "Other" * @param float $theAreaId (OPTIONAL Field) - an in-app/game location id the user/player exited from * Default - Use 0 if unused or does not have a AreaId * @param bool $isTest */ public function logHeartbeat($theEventTs, $theAccountId, $theCharacterId, $theShardId, $thePlatform, $theAreaId, $isTest = false) { if (KApi::$kDataMapHeartbeatFlag == 0) { KApi::$kDataMapHeartbeatFlag = 1; } else { // no log event has been fired between two heartbeats...no FLAG change between the current heartbeat and the previous heartBeat $this->logLogout($theEventTs, $theAccountId, $theCharacterId, $isTest); } } /** * Logs a Message event- A common feature in many games in the ability of players to message one another. * Depending upon the game, multiple channels of communication may be used e.g., it may be * in the form of in-game chat, in-game mail, message broadcast to players in a group etc. * * * @param DateTime $theEventTs when did the message occur? * @param string $sendAccId the sender's account id * @param string $sendCharId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - sendAccId should be used as default if there's no sendCharId * @param string $recvAccId the reciever's account id * @param string $recvCharId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - recvAccId should be used as default if there's no recvCharId * @param float $theShardId a particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param string $theChannelLbl should be a unique string identifier for the particular medium the * message is transferred, examples: "chat", "im", "teamspeak" * @param string $theMessageDesc Default - Use "NA" when not used * @param float $theMessageCharCount * @param bool $isTest * * @return bool|string */ public function logMessage($theEventTs, $sendAccId, $sendCharId, $recvAccId, $recvCharId, $theShardId, $theChannelLbl, $theMessageDesc, $theMessageCharCount, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '20', KApi::$kDataMapKeyskSenderAccountId => $sendAccId, KApi::$kDataMapKeyskSenderCharacterId => $sendCharId, KApi::$kDataMapKeyskReceiverAccountId => $recvAccId, KApi::$kDataMapKeyskReceiverCharacterId => $recvCharId, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskMessageChLabel => $theChannelLbl, KApi::$kDataMapKeyskMessageDesc => $theMessageDesc, KApi::$kDataMapKeyskMessageCharCount => $theMessageCharCount ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs OGI Receiver Event- This event is the counterpart to event (7) but with the additional information regarding * how the receiver acted with respect to the invite e.g., did he/she accept the invite or * did he/she refused it. Logs the end (receiving) of a social transaction outside of the * application or an Off-Game Interaction * * @param DateTime $theEventTs what time did the event occur at? * @param string $sendAccId the UUID associated with a particular user/player - email, number * @param string $sendCharId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - sendAccId should be used as default if there's no sendCharId * @param string $recvAccId the UUID associated with a particular user/player - email, number * @param string $recvCharId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - recvAccId should be used as default if there's no recvCharId. * @param float $theShardId a particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param string $theOgiLocation a unique identifier for the location, preferably a URI * @param string $theOgiCategory examples: "gift", "forum post", "click" * @param string $theRecvAction examples: "repost", "RT", "forum reply" * @param bool $isTest * * @return bool|string */ public function logOgiRecv($theEventTs, $sendAccId, $sendCharId, $recvAccId, $recvCharId, $theShardId, $theOgiLocation, $theOgiCategory, $theRecvAction, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '8', KApi::$kDataMapKeyskSenderAccountId => $sendAccId, KApi::$kDataMapKeyskSenderCharacterId => $sendCharId, KApi::$kDataMapKeyskReceiverAccountId => $recvAccId, KApi::$kDataMapKeyskReceiverCharacterId => $recvCharId, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskOgiLocation => $theOgiLocation, KApi::$kDataMapKeyskOgiCategory => $theOgiCategory, KApi::$kDataMapKeyskOgiReceiverAction => $theRecvAction ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs OGI Sender event- Interaction between people outside the environment of the game e.g., when one person who * is already playing the game sends an invite to another person not player of the game * Logs the start (sending) of a social transaction outside of the application or an Off-Game Interaction * * @param DateTime $theEventTs what time did the event occur at? * @param string $sendAccId the UUID associated with a particular user/player - email, number * @param string $sendCharId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - sendAccId should be used as default if there's no sendCharId * @param string $recvAccId the UUID associated with a particular user/player - email, number * @param string $recvCharId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - recvAccId should be used as default if there's no recvCharId. * @param float $theShardId a particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param string $theOgiLocation a unique identifier for the location, preferably a URI * @param string $theOgiCategory examples: "gift", "forum post", "click" * @param bool $isTest * * @return bool|string */ public function logOgiSend($theEventTs, $sendAccId, $sendCharId, $recvAccId, $recvCharId, $theShardId, $theOgiLocation, $theOgiCategory, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '7', KApi::$kDataMapKeyskSenderAccountId => $sendAccId, KApi::$kDataMapKeyskSenderCharacterId => $sendCharId, KApi::$kDataMapKeyskReceiverAccountId => $recvAccId, KApi::$kDataMapKeyskReceiverCharacterId => $recvCharId, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskOgiLocation => $theOgiLocation, KApi::$kDataMapKeyskOgiCategory => $theOgiCategory ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Social event- Social events involving two people. This event include all the events which are not covered * separately under Group events (4,5), Friend (43, 44). * DO NOT USE for game invites, messages, group enter/exit, store gifts, or clan enter/exit. * This should be used for social events not already explicitly called out. * * @param DateTime $theEventTs what time did the event occur at? * @param string $sendAccId the UUID associated with a particular user/player - email, number * @param string $sendCharId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - sendAccId should be used as default if there's no sendCharId * @param int $sendCharLvl the character's level/XP. * @param string $recvAccId the UUID associated with a particular user/player - email, number * @param string $recvCharId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - recvAccId should be used as default if there's no recvCharId. * @param int $recvCharLvl the character's level/XP. * @param float $theShardId a particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param string $theEventName the name of the in-game social event. * consistently names these - MANDATORY Field * @param string $theEventType examples: "clan invite", "group invite", "barter" * @param bool $isTest * * @return bool|string */ public function logSocialEvent($theEventTs, $sendAccId, $sendCharId, $sendCharLvl, $recvAccId, $recvCharId, $recvCharLvl, $theShardId, $theEventName, $theEventType, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '6', KApi::$kDataMapKeyskSenderAccountId => $sendAccId, KApi::$kDataMapKeyskSenderCharacterId => $sendCharId, KApi::$kDataMapKeyskSenderCharacterLevel => $sendCharLvl, KApi::$kDataMapKeyskReceiverAccountId => $recvAccId, KApi::$kDataMapKeyskReceiverCharacterId => $recvCharId, KApi::$kDataMapKeyskReceiverCharacterLevel => $recvCharLvl, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskSocialEventName => $theEventName, KApi::$kDataMapKeyskSocialEventType => $theEventType ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Subscription Change event- Change of subscription type e.g., from free play to paid subscriber or to a premium player. * This is only applicable to games with subscription and not to free-to-play (F2P) games * * * @param DateTime $theEventTs when did the subscription start? * @param string $theAccountId the UUID associated with a particular user/player - email, number * @param string $theSubStatus acceptable values are: Active, Stopped, Expired, Failed, Cancelled * @param string $theSubType acceptable values are: Free, Paid, Premium * @param float $theSubValue amount paid by the user for the subscription for the relevant/current pay period. * Example: 7.34 (for June) * @param DateTime $theExpireTs when does the subscription expire? * @param bool $isTest * * @return bool|string */ public function putSubChange($theEventTs, $theAccountId, $theSubStatus, $theSubType, $theSubValue, $theExpireTs, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '3', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskAccountStatus => $theSubStatus, KApi::$kDataMapKeyskAccountSubType => $theSubType, KApi::$kDataMapKeyskAccountSubValue => $theSubValue, KApi::$kDataMapKeysAccountExpiresTs => $theExpireTs ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Begin Combat event- This event refers to the start of combat between a player and a * non-player character (NPC)kick off the beginning of combat * * @param DateTime $theEventTs when did combat start? * @param string $theAccountId the UUID associated with a particular user/player - email, number * @param string $theCharacterId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theShardId a particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param float $theNpcId the id of the NPC being fought * @param float $theAreaId * @param float $theX * @param float $theY * @param float $theZ * @param string $theAreaName the name of the area where combat began * Default - NA * @param bool $isTest * * @return bool|string */ public function combatStart($theEventTs, $theAccountId, $theCharacterId, $theShardId, $theNpcId, $theAreaId, $theX, $theY, $theZ, $theAreaName, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '21', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskNpcId => $theNpcId, KApi::$kDataMapKeyskAreaId => $theAreaId, KApi::$kDataMapKeyskPositionX => $theX, KApi::$kDataMapKeyskPositionY => $theY, KApi::$kDataMapKeyskPositionZ => $theZ, KApi::$kDataMapKeyskAreaName => $theAreaName ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs an End Combat event- This event refers to the end of combat between a player and a non-player character (NPC) * * @param DateTime $theEventTs when did combat end? * @param string $theAccountId the UUID associated with a particular user/player - email, number * @param string $theCharacterId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theShardId a particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param float $theNpcId the id of the NPC fought * @param float $theAreaId * @param float $theX * @param float $theY * @param float $theZ * @param string $theAreaName the name of the area where combat ended * Default - NA * @param bool $isTest * * @return bool|string */ public function combatEnd($theEventTs, $theAccountId, $theCharacterId, $theShardId, $theNpcId, $theAreaId, $theX, $theY, $theZ, $theAreaName, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '22', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskNpcId => $theNpcId, KApi::$kDataMapKeyskAreaId => $theAreaId, KApi::$kDataMapKeyskPositionX => $theX, KApi::$kDataMapKeyskPositionY => $theY, KApi::$kDataMapKeyskPositionZ => $theZ, KApi::$kDataMapKeyskAreaName => $theAreaName ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Kill NPC event - Refers to an event when a non-player character (NPC) is killed by a player in the game. * * * @param DateTime $theEventTs when did the kill happen? * @param string $theAccountId the UUID associated with a particular user/player - email, number * @param string $theCharacterId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theShardId a particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param float $theCharacterLvl the numeric level identifier the character currently is at. * @param float $theNpcId the id of the NPC fought * @param bool $isTest * * @return bool|string */ public function logKillNpc($theEventTs, $theAccountId, $theCharacterId, $theShardId, $theCharacterLvl, $theNpcId, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '23', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskCharacterLvl => $theCharacterLvl, KApi::$kDataMapKeyskNpcId => $theNpcId ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Player Points event - Information regarding when a player gains experience points in the game. * In many games experience points are used as an indicator of how well the player is * doing in the game and much has she progressed. In many games gaining enough experience * points leads the player to level up to a higher level. * * @param DateTime $theEventTs when did the XP get bestowed? * @param string $theAccountId the UUID associated with a particular user/player - email, number * @param string $theCharacterId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theShardId a particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param float $theCharacterLvl the numeric level identifier the character currently is at. * @param float $theXpAmount * @param bool $isGrouped did the XP result from a group event? * @param string $thePointType * @param bool $isTest * * @return bool|string */ public function playerPoints($theEventTs, $theAccountId, $theCharacterId, $theShardId, $theCharacterLvl, $theXpAmount, $isGrouped, $thePointType, $isTest = false) { if ($isGrouped) { $grpFlag = "Y"; } else { $grpFlag = "N"; } $aEventMap = array( KApi::$kDataMapKeyskType => '24', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskCharacterLvl => $theCharacterLvl, KApi::$kDataMapKeyskXpAmount => $theXpAmount, KApi::$kDataMapKeyskGroupedFlag => $grpFlag, KApi::$kDataMapKeyskPointType => $thePointType ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a PVP Duel event- Information regarding when a player enters a combat against another player. * This type of event is only applicable to environments or games, where a player is * allowed to fight against another player since not all environments are competitive in nature. * * @param DateTime $theEventTs when did the duel occur? * @param string $theAccountId the UUID associated with a particular user/player - email, number * @param string $theCharacterId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theShardId a particular db the Character is associated with * Default - Use 0 if unused or does not have a value. * @param bool $isWinner did this player win? True or False * @param bool $isTest * * @return bool|string */ public function logPvpDuel($theEventTs, $theAccountId, $theCharacterId, $theShardId, $isWinner, $isTest = false) { if ($isWinner) { $winnrFlag = "Y"; } else { $winnrFlag = "N"; } $aEventMap = array( KApi::$kDataMapKeyskType => '25', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskWinFlag => $winnrFlag ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Player Death event- Information regarding the death of player by a non-player character (NPC) * * @param DateTime $theEventTs when did the player death occur? * @param string $theAccountId the UUID associated with a particular user/player - email, number * @param string $theCharacterId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theShardId a particular db the Character is associated with * Default - Use 0 if unused or does not have a value. * @param float $theKillerNpcId the NPC that killed the player * @param string $theDeathType Default - use "NA" if unused * @param float $theAreaId * @param float $theX * @param float $theY * @param float $theZ * @param bool $isTest * * @return bool|string */ public function logPlayerDeath($theEventTs, $theAccountId, $theCharacterId, $theShardId, $theKillerNpcId, $theDeathType, $theAreaId, $theX, $theY, $theZ, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '26', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskNpcId => $theKillerNpcId, KApi::$kDataMapKeyskDeathType => $theDeathType, KApi::$kDataMapKeyskAreaId => $theAreaId, KApi::$kDataMapKeyskPositionX => $theX, KApi::$kDataMapKeyskPositionY => $theY, KApi::$kDataMapKeyskPositionZ => $theZ ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a level Begin event- A large number of games are organized in terms of levels which reflect the * difficultly of game play. This event captures the time at which a player begins * a level * * @param DateTime $theEventTs when did the player begin? * @param string $theAccountId the UUID associated with a particular user/player - email, number * @param string $theCharacterId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theCharacterLvl the numeric level identifier the character currently is at. * @param float $theShardId a particular db the Character is associated with * Default - Use 0 if unused or does not have a value. * @param float $theLevelId the AreaId * @param float $theX * @param float $theY * @param float $theZ * @param string $theAreaName the name of the area where the level began * Default - NA * @param bool $isTest * * @return bool|string */ public function levelBegin($theEventTs, $theAccountId, $theCharacterId, $theCharacterLvl, $theShardId, $theLevelId, $theX, $theY, $theZ, $theAreaName, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '27', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskCharacterLvl => $theCharacterLvl, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskAreaId => $theLevelId, KApi::$kDataMapKeyskPositionX => $theX, KApi::$kDataMapKeyskPositionY => $theY, KApi::$kDataMapKeyskPositionZ => $theZ, KApi::$kDataMapKeyskAreaName => $theAreaName ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Level End event- Refers to the level in event (27) but instead of the beginning of levels * it refers to the end of levels. Log the player completing a level * * @param theAreaName String (OPTIONAL Field) - the name of the area where the level ended * Default - NA * @param string $theAccountId * @param string $theCharacterId * @param float $theCharacterLvl * @param float $theShardId * @param float $theLevelId * @param float $theX * @param float $theY * @param float $theZ * @param string $theAreaName * @param bool $isTest * @return bool|string */ public function levelEnd($theEventTs, $theAccountId, $theCharacterId, $theCharacterLvl, $theShardId, $theLevelId, $theX, $theY, $theZ, $theAreaName, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '28', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskCharacterLvl => $theCharacterLvl, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskAreaId => $theLevelId, KApi::$kDataMapKeyskPositionX => $theX, KApi::$kDataMapKeyskPositionY => $theY, KApi::$kDataMapKeyskPositionZ => $theZ, KApi::$kDataMapKeyskAreaName => $theAreaName ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs an Area Enter event- Many games are organized in the form of virtual worlds where there are many * geographical areas. This event refers to the time when a player enters such an area * * @param DateTime $theEventTs when did the player enter the area? * @param string $theAccountId the UUID associated with a particular user/player - email, number * @param string $theCharacterId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theCharacterLvl the numeric level identifier the character currently is at. * @param float $theShardId a particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param float $theAreaId the Enter Area ID. It is necessary to pass either AreaId or AreaName * Default - Empty/Blank "" if does not makes sense/already have passed * AreaName * @param float $theX * @param float $theY * @param float $theZ * @param string $theAreaName the Enter Area Name. It is necessary to pass either AreaId or AreaName * Default - Empty/Blank "" if does not makes sense/already have passed AreaId * @param bool $isTest * * @return bool|string */ public function areaEnter($theEventTs, $theAccountId, $theCharacterId, $theCharacterLvl, $theShardId, $theAreaId, $theX, $theY, $theZ, $theAreaName, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '29', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskCharacterLvl => $theCharacterLvl, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskAreaId => $theAreaId, KApi::$kDataMapKeyskPositionX => $theX, KApi::$kDataMapKeyskPositionY => $theY, KApi::$kDataMapKeyskPositionZ => $theZ, KApi::$kDataMapKeyskAreaName => $theAreaName ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs an Area Exit event- Similar to event (29) but with the difference that it refers to the time when a * player exits an area. Logs the player exiting an area * * @param DateTime $theEventTs when did the player leave the area? * @param string $theAccountId the UUID associated with a particular user/player - email, number * @param string $theCharacterId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theCharacterLvl the numeric level identifier the character currently is at. * @param float $theShardId a particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param float $theAreaId the Exited Area ID. It is necessary to pass either AreaId or AreaName * Default - Empty/Blank "" if does not makes sense/already have passed * AreaName * @param float $theX * @param float $theY * @param float $theZ * @param string $theAreaName the Exited Area Name. It is necessary to pass either AreaId or AreaName * Default - Empty/Blank "" if does not makes sense/already have passed AreaId * @param bool $isTest * * @return bool|string */ public function areaExit($theEventTs, $theAccountId, $theCharacterId, $theCharacterLvl, $theShardId, $theAreaId, $theX, $theY, $theZ, $theAreaName, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '30', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskCharacterLvl => $theCharacterLvl, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskAreaId => $theAreaId, KApi::$kDataMapKeyskPositionX => $theX, KApi::$kDataMapKeyskPositionY => $theY, KApi::$kDataMapKeyskPositionZ => $theZ, KApi::$kDataMapKeyskAreaName => $theAreaName ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a NPC Interaction event- A large class of games have non-player characters (NPCs) which interact with the player * in the gaming environment. They have different levels of difficulty and may be friendly * or aggressive. This event is used to populate the dimension tables for NPCs and is referred * to by all the other events that refer to NPCs.Logs the interaction between an in-game NPC * and a player * * @param DateTime $theEventTs when did the interaction take place? * @param string $theAccountId the UUID associated with a particular user/player - email, number * @param string $theCharacterId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theShardId a particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param string $npcEventName examples: "Combat", "Purchase", "quest" * @param string $npcEventType * @param float $npcId * @param string $npcName examples: "the Mort of T", "Duque de Zeta" * @param string $npcType examples: "Vendor", "Quest Giver", "Enemy" * @param int $theMinLevel the lowest level this NPC occurs on * @param int $theMaxLevel the highest level this NPC occurs on * @param int $theToughness a numeric representation of the NPC's ability, example: 0.25 * @param string $theToughnessEnum a textual representation of the NPC's toughness, example: quarter * @param bool $isTest * * @return bool|string */ public function logNpcInteraction($theEventTs, $theAccountId, $theCharacterId, $theShardId, $npcEventName, $npcEventType, $npcId, $npcName, $npcType, $theMinLevel, $theMaxLevel, $theToughness, $theToughnessEnum, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '31', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskNpcEventName => $npcEventName, KApi::$kDataMapKeyskNpcEventType => $npcEventType, KApi::$kDataMapKeyskNpcId => $npcId, KApi::$kDataMapKeyskNpcName => $npcName, KApi::$kDataMapKeyskNpcType => $npcType, KApi::$kDataMapKeyskNpcLevelMin => $theMinLevel, KApi::$kDataMapKeyskNpcLevelMax => $theMaxLevel, KApi::$kDataMapKeyskNpcToughness => $theToughness, KApi::$kDataMapKeyskNpcToughnessEnum => $theToughnessEnum ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Challenge event- Challenges are elements of games where a player or even a group of players can perform * a tasks or a set of tasks to get some reward within the game. Alternatively completing a * challenge may be necessary to level up in the games. In some genres of games e.g., MMORPGs * a challenge may be referred to as a quest. Logs a player challenge - starting/working/done * * @param DateTime $theEventTs timestamp of updates to challenge * @param string $theAccountId the UUID associated with a particular user/player - email, number * @param string $theCharacterId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theShardId a particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param string $challengeId * @param string $challengeType examples: "item search", "kill NPC" * @param string $challengeStatus acceptable values are ONLY: Accepted, Completed, Abandonded * @param bool $isTest * * @return bool|string */ public function logChallenge($theEventTs, $theAccountId, $theCharacterId, $theShardId, $challengeId, $challengeType, $challengeStatus, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '32', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskChallengeId => $challengeId, KApi::$kDataMapKeyskChallengeType => $challengeType, KApi::$kDataMapKeyskChallengeStatus => $challengeStatus ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Recruitment Send event- There are certian types of activities or interactions in games where a player * may invite other players to join him/her in finishing a certain task. This event captures * such events where a person may recruit others to join them in those activities. * Logs that a recruitment message was sent * * @param DateTime $theEventTs when was the recruitment message sent? * @param string $sendAccId the UUID associated with a particular user/player - email, number * @param string $sendCharId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - sendAccId should be used as default if there's no sendCharId * @param string $recvAccId the UUID associated with a particular user/player - email, number * @param string $recvCharId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - recvAccId should be used as default if there's no recvCharId * @param string $theRecruitmentType open ended String field * some suggested options are: "mobile ad", "banner", "promotion" * @param bool $isTest * * @return bool|string */ public function recruitmentSend($theEventTs, $sendAccId, $sendCharId, $recvAccId, $recvCharId, $theRecruitmentType, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '33', KApi::$kDataMapKeyskSenderAccountId => $sendAccId, KApi::$kDataMapKeyskSenderCharacterId => $sendCharId, KApi::$kDataMapKeyskReceiverAccountId => $recvAccId, KApi::$kDataMapKeyskReceiverCharacterId => $recvCharId, KApi::$kDataMapKeyskRecruitmentType => $theRecruitmentType ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Recruitment Receive event- This event refers to the result of the recuritment action from event (33) i.e., * if the person to whom the message was sent accepted the invite or declined it. * Logs that a recruitment message was responded to. * * @param DateTime $theEventTs when was the response received? * @param string $sendAccId the UUID associated with a particular user/player - email, number * @param string $sendCharId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - sendAccId should be used as default if there's no sendCharId * @param string $recvAccId the UUID associated with a particular user/player - email, number * @param string $recvCharId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - recvAccId should be used as default if there's no recvCharId * @param string $theRecruitmentType open ended String field. * some suggested options are: "mobile ad", "banner", "promotion" * @param string $theRecruitmentOutcome open ended String field. * some suggested options are: "sign-up", "blocked", "click" * @param bool $isTest * * @return bool|string */ public function recruitmentReceive($theEventTs, $sendAccId, $sendCharId, $recvAccId, $recvCharId, $theRecruitmentType, $theRecruitmentOutcome, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '34', KApi::$kDataMapKeyskSenderAccountId => $sendAccId, KApi::$kDataMapKeyskSenderCharacterId => $sendCharId, KApi::$kDataMapKeyskReceiverAccountId => $recvAccId, KApi::$kDataMapKeyskReceiverCharacterId => $recvCharId, KApi::$kDataMapKeyskRecruitmentType => $theRecruitmentType, KApi::$kDataMapKeyskRecruitmentOutcome => $theRecruitmentOutcome ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Store Create event- Some games allow players to set up in-game stores where they can sell items. * This event refers to the creation of such stores * * @param DateTime $theEventTs * @param float $theStoreId * @param string $theStoreDesc * @param string $theStreetAddr * @param string $theCity * @param string $theState * @param string $theCountry * @param string $thePostalCode * @param bool $isTest * * @return bool|string */ public function storeCreate($theEventTs, $theStoreId, $theStoreDesc, $theStreetAddr, $theCity, $theState, $theCountry, $thePostalCode, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '35', KApi::$kDataMapKeyskStoreId => $theStoreId, KApi::$kDataMapKeyskStoreDesc => $theStoreDesc, KApi::$kDataMapKeyskMapRealAddress => $theStreetAddr, KApi::$kDataMapKeyskMapRealCity => $theCity, KApi::$kDataMapKeyskMapRealState => $theState, KApi::$kDataMapKeyskMapRealCountry => $theCountry, KApi::$kDataMapKeyskMapRealPostalCode => $thePostalCode ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Store Delete event- This event refers to scenarios where the stores from event (35) are deleted * * * @param DateTime $theEventTs * @param float $theStoreId Unique ID associated with the store * @param bool $isTest * * @return bool|string */ public function storeDelete($theEventTs, $theStoreId, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '36', KApi::$kDataMapKeyskStoreId => $theStoreId ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Store Buy Item event- This event refers to transactions which involve items which are bought from a store. * This includes information about the type of currency which is used to buy these items * i.e., real world currency or virtual currency. * * @param DateTime $theEventTs when was the item bought? * @param string $sendAccId the UUID associated with a particular user/player - email, number * @param string $sendCharId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - sendAccId should be used as default if there's no sendCharId * @param string $recvAccId the UUID associated with a particular user/player - email, number * @param string $recvCharId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - recvAccId should be used as default if there's no recvCharId * @param float $theShardId a particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param float $theStoreId previously initialized app unique id * @param float $theItemId previously initialized app unique id * @param string $theItemName Name of the item bought * @param float $theItemPrice Price of the item * @param int $theCurrencyType Accepted values are ONLY: 0 = real world currency, 1 = virtual currency * @param string $theVirtualCurrencyLbl a virtual currency previously initialized from Event# 14. * If CurrencyType=1, set this Mandatory, else send " ". * @param float $theCurrencyValue how much of a particular currency was used for this transaction * Default - Use 0 as default case and if does not have a value * @param int $theVirtualCurrencyCount how many units of virtual currency were used * Default - null * @param bool $isTest * * @return bool|string */ public function storeBuyItem($theEventTs, $sendAccId, $sendCharId, $recvAccId, $recvCharId, $theShardId, $theStoreId, $theItemId, $theItemName, $theItemPrice, $theCurrencyType, $theVirtualCurrencyLbl, $theCurrencyValue, $theVirtualCurrencyCount, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '37', KApi::$kDataMapKeyskSenderAccountId => $sendAccId, KApi::$kDataMapKeyskSenderCharacterId => $sendCharId, KApi::$kDataMapKeyskReceiverAccountId => $recvAccId, KApi::$kDataMapKeyskReceiverCharacterId => $recvCharId, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskStoreId => $theStoreId, KApi::$kDataMapKeyskItemId => $theItemId, KApi::$kDataMapKeyskItemName => $theItemName, KApi::$kDataMapKeyskItemPrice => $theItemPrice, KApi::$kDataMapKeyskCurrencyType => $theCurrencyType, KApi::$kDataMapKeyskVirtualCurrencyLabel => $theVirtualCurrencyLbl, KApi::$kDataMapKeyskCurrencyValue => $theCurrencyValue, KApi::$kDataMapKeyskVirtualCurrencyCount => $theVirtualCurrencyCount ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Store Login event- The time at which a player logs into a virtual store. * Logs a store login occurrence * * @param DateTime $theEventTs when did the user log into the store? * @param string $theAccountId the UUID associated with a particular user/player - email, number * @param string $theCharacterId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theShardId a particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param float $theStoreId previously initialized app unique id * @param bool $isTest * * @return bool|string */ public function storeLogin($theEventTs, $theAccountId, $theCharacterId, $theShardId, $theStoreId, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '38', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskStoreId => $theStoreId ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Store Logout event- The time at which a player logs out from a virtual store * Logs a store logout occurrence * * @param $theEventTs * @param string $theAccountId * @param string $theCharacterId * @param float $theShardId * @param float $theStoreId * @param bool $isTest * @return bool|string */ public function storeLogout($theEventTs, $theAccountId, $theCharacterId, $theShardId, $theStoreId, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '39', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskStoreId => $theStoreId ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Store Add To Cart event- This event refers to the case when the user adds an item to his/her cart. * It should be noted that this event is not the same as buying an item but it is only * about selecting an item. In some games selection may be a prerequisite for buying an * item. Logs an add to cart event * * @param DateTime $theEventTs when was the item added to the "cart"? * @param string $theAccountId the UUID associated with a particular user/player - email, number * @param string $theCharacterId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theStoreId previously initialized app unique id * @param float $theItemId It is necessary to pass either ItemId or ItemName * Default - Empty/Blank "" if does not makes sense/already have passed * ItemName * @param string $theItemName It is necessary to pass either ItemId or ItemName * Default - Empty/Blank "" if does not makes sense/already have passed ItemId * @param string $theItemType examples: "raw materials", "Armor", "Tools" * @param bool $isTest * * @return bool|string */ public function storeAddToCart($theEventTs, $theAccountId, $theCharacterId, $theStoreId, $theItemId, $theItemName, $theItemType, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '40', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskStoreId => $theStoreId, KApi::$kDataMapKeyskItemId => $theItemId, KApi::$kDataMapKeyskItemName => $theItemName, KApi::$kDataMapKeyskItemType => $theItemType ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Guild Enter event- Guilds are analogous to organizations in many online games. * This event records information regarding when a player becomes part of a guild * and if he/she is the leader of the guild * * @param DateTime $theEventTs when did the player enter the guild? * @param string $theAccountId the UUID associated with a particular user/player - email, number * @param string $theCharacterId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theCharacterLvl the numeric level identifier the character currently is at * @param float $theShardId a particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param float $theGuildId * @param bool $isTest * * @return bool|string */ public function logEnterGuild($theEventTs, $theAccountId, $theCharacterId, $theCharacterLvl, $theShardId, $theGuildId, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '41', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskCharacterLvl => $theCharacterLvl, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskGuildId => $theGuildId ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Guild Exit event- The event records information regarding exiting a guild (see event 41) * and the reason for leaving a guild e.g., leaving volunterily, being evicted etc * * @param DateTime $theEventTs when did the player exit the guild? * @param string $theAccountId the UUID associated with a particular user/player - email, number * @param string $theCharacterId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theCharacterLvl the numeric level identifier the character currently is at * @param float $theShardId a particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param float $theGuildId * @param string $theExitReason examples: "hacking", "bad team" * @param bool $isTest * * @return bool|string */ public function logExitGuild($theEventTs, $theAccountId, $theCharacterId, $theCharacterLvl, $theShardId, $theGuildId, $theExitReason, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '42', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskCharacterLvl => $theCharacterLvl, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskGuildId => $theGuildId, KApi::$kDataMapKeyskGuildExitReason => $theExitReason ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Friend Addition event- Many online games also allow adding other players as friends. * This event captures information about friending other players. * It should be noted that this relationship may or may not be reciprocated. * * @param DateTime $theEventTs when did the sender add the receiver? * @param string $sendAccId the UUID associated with a particular user/player - email, number * @param string $sendCharId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - sendAccId should be used as default if there's no sendCharId * @param string $recvAccId the UUID associated with a particular user/player - email, number * @param string $recvCharId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - recvAccId should be used as default if there's no recvCharId * @param bool $isTest * * @return bool|string */ public function logFriendAdd($theEventTs, $sendAccId, $sendCharId, $recvAccId, $recvCharId, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '43', KApi::$kDataMapKeyskSenderAccountId => $sendAccId, KApi::$kDataMapKeyskSenderCharacterId => $sendCharId, KApi::$kDataMapKeyskReceiverAccountId => $recvAccId, KApi::$kDataMapKeyskReceiverCharacterId => $recvCharId ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Friend Delete event- This event captures information about the end of a friend relationship (see event 43). * * @param recvCharId String (MANDATORY Field) - does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - recvAccId should be used as default if there's no recvCharId * @param string $sendAccId * @param string $sendCharId * @param string $recvAccId * @param string $recvCharId * @param bool $isTest * @return bool|string */ public function logFriendDelete($theEventTs, $sendAccId, $sendCharId, $recvAccId, $recvCharId, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '44', KApi::$kDataMapKeyskSenderAccountId => $sendAccId, KApi::$kDataMapKeyskSenderCharacterId => $sendCharId, KApi::$kDataMapKeyskReceiverAccountId => $recvAccId, KApi::$kDataMapKeyskReceiverCharacterId => $recvCharId ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Guild Leader event- Information regarding whether the player is the leader of the guild with the given guild id * * @param DateTime $theEventTs when did the player exit the guild? * @param string $theAccountId the UUID associated with a particular user/player - email, number * @param string $theCharacterId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theGuildId * @param bool $isTest * * @return bool|string */ public function putGuildLeader($theEventTs, $theAccountId, $theCharacterId, $theGuildId, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '45', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskGuildId => $theGuildId ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a UGC Copy event- Information regarding copying of an item that was created by a player. This event is * not applicable to items that are built in by the gaming company. * Tracks when User Generated Content is copied to another account * * @param DateTime $theEventTs when did the copy occur? * @param string $theAccountId the UUID associated with a particular user/player - email, number * @param string $theCharacterId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theShardId a particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param float $theItemId the application unique numeric id * It is necessary to pass either ItemId or ItemName * Default - Empty/Blank "" if does not makes sense/already have passed * ItemName * @param string $theItemName example: "crafty button", "GMO grain" * It is necessary to pass either ItemId or ItemName * Default - Empty/Blank "" if does not makes sense/already have passed ItemId * @param bool $isTest * * @return bool|string */ public function trackUgcCopy($theEventTs, $theAccountId, $theCharacterId, $theShardId, $theItemId, $theItemName, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '46', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskItemId => $theItemId, KApi::$kDataMapKeyskItemName => $theItemName ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs FARMER event- Indicates whether the player is a gold farmer and if so what type of gold farmer is he * * @param DateTime $theEventTs when did the event occurred * @param string $theAccountId the UUID associated with a particular user/player - email, number * @param string $theCharacterId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theShardId a particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param string $theFarmerType some examples are:Banker, Gatherer, Mule, Spammer * @param bool $isTest * * @return bool|string */ public function logFarmer($theEventTs, $theAccountId, $theCharacterId, $theShardId, $theFarmerType, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '47', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskFarmerType => $theFarmerType ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a INTEGRITY event- Indiates whether this account was compromised and if so when was this account * compromised and the type of integrity violation that resulted in compromising this account * * @param DateTime $theEventTs when did the event occurred * @param string $theAccountId the UUID associated with a particular user/player - email, number * @param float $theShardId a particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param string $theIntegrityType possible examples are: Credit card fraud, cheating etc. * @param bool $isTest * * @return bool|string */ public function logIntegrity($theEventTs, $theAccountId, $theShardId, $theIntegrityType, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '48', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskIntegrityType => $theIntegrityType ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * logs a Reward event - relates to where a player may be awarded a certain reward for * completeing a certain task or a reward given based on seniority or some other reason. * * @param DateTime $theEventTs * @param theRewardCount Float (MANDATORY Field) - Real money value, when Reward Type = 0 * count of the virtual currency, when Reward Type = 1 * Item Count, when Reward Type = 2 * @param string $theCharacterId * @param float $theShardId * @param float $theRewardType * @param string $theRewardId * @param float $theItemType * @param float $theRewardCount * @param bool $isTest * @return bool|string */ public function logReward($theEventTs, $theAccountId, $theCharacterId, $theShardId, $theRewardType, $theRewardId, $theItemType, $theRewardCount, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '49', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskRewardType => $theRewardType, KApi::$kDataMapKeyskRewardId => $theRewardId, KApi::$kDataMapKeyskItemType => $theItemType, KApi::$kDataMapKeyskRewardCount => $theRewardCount ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * logs a Area DIM event - Some games have maps associated with them. * This event saves the dimension information about these maps. * * @param DateTime $theEventTs when did the event occur? * @param string $theAreaName It is necessary to pass either AreaId or AreaName * Default - Empty/Blank "" if does not makes sense/already have passed AreaId * @param float $theAreaId It is necessary to pass either AreaId or AreaName * Default - Empty/Blank "" if does not makes sense/already have passed * AreaName * @param float $theMapId It is necessary to pass either MapId or MapLabel * Default - Empty/Blank "" if does not makes sense/already have passed * MapLabel * @param string $theMapLabel It is necessary to pass either MapId or MapLabel * Default - Empty/Blank "" if does not makes sense/already have passed MapId * @param float $theMinX * @param float $theMinY * @param float $theMinZ * @param float $theMaxX * @param float $theMaxY * @param float $theMaxZ * @param bool $isTest * * @return bool|string */ public function logAreaDim($theEventTs, $theAreaName, $theAreaId, $theMapId, $theMapLabel, $theMinX, $theMinY, $theMinZ, $theMaxX, $theMaxY, $theMaxZ, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '50', KApi::$kDataMapKeyskAreaName => $theAreaName, KApi::$kDataMapKeyskAreaId => $theAreaId, KApi::$kDataMapKeyskMapId => $theMapId, KApi::$kDataMapKeyskMapLabel => $theMapLabel, KApi::$kDataMapKeyskMinX => $theMinX, KApi::$kDataMapKeyskMinY => $theMinY, KApi::$kDataMapKeyskMinZ => $theMinZ, KApi::$kDataMapKeyskMaxX => $theMaxX, KApi::$kDataMapKeyskMaxY => $theMaxY, KApi::$kDataMapKeyskMaxZ => $theMaxZ ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a MOB event - Mobs refers to groupings of non-player characters (NPCs). This event captures the cases * when the player confronts a mobs and kills that mob. This event captures the cases when the * player confronts a mob and kills that mob * * @param DateTime $theEventTs when did the event occur? * @param string $theAccountId the UUID associated with a particular user/player - email, number * @param string $theCharacterId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theShardId a particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param string $theMobDesc * @param bool $isTest * * @return bool|string */ public function logMob($theEventTs, $theAccountId, $theCharacterId, $theShardId, $theMobDesc, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '51', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskMobDesc => $theMobDesc ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a CRM Action event- This is generic field for CRM (Customer Relationshop management) action that may be taken * by a CRM person in the gaming company. Information regarding how the customer responded to * the action is also saved * * @param DateTime $theEventTs when did the event occur? * @param string $theAccountId the UUID associated with a particular user/player - email, number * @param string $theCharacterId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theShardId a particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param string $theCrmAction * @param string $theCrmActionType * @param string $theCrmFulfilledStatus * @param DateTime $theCrmFulfilledTs when does the CRM action fulfilled? * @param bool $isTest * * @return bool|string */ public function logCrmAction($theEventTs, $theAccountId, $theCharacterId, $theShardId, $theCrmAction, $theCrmActionType, $theCrmFulfilledStatus, $theCrmFulfilledTs, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '52', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskCrmAction => $theCrmAction, KApi::$kDataMapKeyskCrmActionType => $theCrmActionType, KApi::$kDataMapKeyskCrmFulfilledStatus => $theCrmFulfilledStatus, KApi::$kDataMapKeyskCrmFulfilledTs => $theCrmFulfilledTs ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * logs a Custom Slot Action event - This event captures all the events which are not described in any of the other * events but still events which are within the game. * * @param DateTime $theEventTs when did the event occur? * @param string $theAccountId the UUID associated with a particular user/player - email, number * @param string $theCharacterId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theShardId a particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param string $theCsAction * @param string $theCsActionType * @param bool $isTest * * @return bool|string */ public function logCustomerServiceAction($theEventTs, $theAccountId, $theCharacterId, $theShardId, $theCsAction, $theCsActionType, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '53', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskCsAction => $theCsAction, KApi::$kDataMapKeyskCsActionType => $theCsActionType ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * logs a Custom Action event - This event captures all the events which are not described in any of the other events * and the events are not with respect to actions in the game. Any Ninja Metrics customer * has the freedom to define this event in any way that they want given the fields described here * * @param DateTime $theEventTs when did the event occur? * @param string $theAccountId the UUID associated with a particular user/player - email, number * @param string $theCharacterId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param string $theCustomAction * @param string $theCustomActionType * @param string $theCustomActionValue * @param bool $isTest * * @return bool|string */ public function logCustomAction($theEventTs, $theAccountId, $theCharacterId, $theCustomAction, $theCustomActionType, $theCustomActionValue, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '54', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskCustomAction => $theCustomAction, KApi::$kDataMapKeyskCustomActionType => $theCustomActionType, KApi::$kDataMapKeyskCustomActionValue => $theCustomActionValue ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * logs a Productivity event - This event refers to a scenario where any time a player crafts, harvests * etc an item within the game. * * @param DateTime $theEventTs when did the event occur? * @param string $theAccountId the UUID associated with a particular user/player - email, number * @param string $theCharacterId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theShardId a particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param string $theProductivityType * @param bool $isTest * * @return bool|string */ public function logProductivity($theEventTs, $theAccountId, $theCharacterId, $theShardId, $theProductivityType, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '55', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskProductivityType => $theProductivityType ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * logs a Resource event - Refers to events where any time a player acquires a non-item resource, * e.g. coins, gold, power, etc. * * @param DateTime $theEventTs when did the event occur? * @param string $theAccountId the UUID associated with a particular user/player - email, number * @param string $theCharacterId does an account have multiple characters associated with it? * Use this field to track such identifiers. * Default - AccountId should be used as default if there's no CharacterId * @param float $theShardId a particular db the Character is associated with * Default - Use 0 if unused or does not have a value * @param string $theResourceType acceptable values are: 0 = Real Currency, 1 = Virtual Currency, 2 = item * @param string $theResourceId acceptable values are: "1", when ResourceType = 0(Real Currency), * "virtual item name", when ResourceType = 1(Virtual Currency), * "item name", when ResourceType = 2(item) * @param float $theResourceCount Real money value, when ResourceType = 0 * count of the virtual currency, when ResourceType = 1 * Item Count, when ResourceType = 2 * @param bool $isTest * * @return bool|string */ public function logResource($theEventTs, $theAccountId, $theCharacterId, $theShardId, $theResourceType, $theResourceId, $theResourceCount, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '56', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskCharacterId => $theCharacterId, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskResourceType => $theResourceType, KApi::$kDataMapKeyskResourceId => $theResourceId, KApi::$kDataMapKeyskResourceCount => $theResourceCount ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Account Ad event - This event is a record of the user who either clicks an ad or had already clicked * the ad and then taking some subsequent action. * * @param DateTime $theEventTs when did the event occur? * @param string $theAccountId the UUID associated with a particular user/player - email, number * @param string $theAdTagName Possible values - In-App,Google, Facebook, Ad-Words, Other, or free text, Ad4Game, * Addictive Mobility, Adelphic, Adknowledge, AdTheorent, Altrooz, AppFlood, Appia, AppLift, AppLovin, AppNexus, AppTap, * Aquto (MoVE), Clickky, CrowdMob, Drawbridge, Eclipse-io, Geenapp, Greystripe, HeyZap, Iconpeak, InMobi, Jampp, JumpTap, * Kickbit, LiveIntent, madnet, Manage.com, MdotM, Millennial, mNectar, Mobile Theory, Moblin, Moboqo, mobpartner, Motive Interactive, * motrixi, MyLikes, Nexage, Pandora, RadiumOne, Rocket Fuel, Rovio, SessionM, SponsorPay, StrikeAd, Surikate, TapIt, Taptica, TrialPay, * Velti, Verve, Voltari, YieldMo * Default - In-App * @param DateTime $theAdActionTs * @param bool $isTest * * @return bool|string */ public function logAccountAd($theEventTs, $theAccountId, $theAdTagName = "In-App", $theAdActionTs, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '57', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskAdTagName => $theAdTagName, KApi::$kDataMapKeyskAdActionTs => $theAdActionTs ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * logs a Economic event - This item refers TO Economic Type: Buy item, Sell item, Trade away item * Trade acquire item, Create item * * @param DateTime $theEventTs * @param float $sendAccId * @param float $sendCharId * @param float $recvAccId * @param float $recvCharId * @param float $theShardId * @param float $theItemId * @param string $theItemName * @param string $theEconomicType * @param float $theEconomicValue * @param int $theCurrencyType * @param string $theVirtualCurrencyLbl * @param theVirtualCurrencyCount Integer (OPTIONAL Field) - how many units of virtual currency were used * Default - null * * @param int $theVirtualCurrencyCount * @param bool $isTest * @return bool|string */ public function logEconomic($theEventTs, $sendAccId, $sendCharId, $recvAccId, $recvCharId, $theShardId, $theItemId, $theItemName, $theEconomicType, $theEconomicValue, $theCurrencyType, $theVirtualCurrencyLbl, $theCurrencyValues, $theVirtualCurrencyCount, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '58', KApi::$kDataMapKeyskSenderAccountId => $sendAccId, KApi::$kDataMapKeyskSenderCharacterId => $sendCharId, KApi::$kDataMapKeyskReceiverAccountId => $recvAccId, KApi::$kDataMapKeyskReceiverCharacterId => $recvCharId, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskItemId => $theItemId, KApi::$kDataMapKeyskItemName => $theItemName, KApi::$kDataMapKeyskEconomicType => $theEconomicType, KApi::$kDataMapKeyskEconomicValue => $theEconomicValue, KApi::$kDataMapKeyskCurrencyType => $theCurrencyType, KApi::$kDataMapKeyskVirtualCurrencyLabel => $theVirtualCurrencyLbl, KApi::$kDataMapKeyskCurrencyValue => $theCurrencyValues, KApi::$kDataMapKeyskVirtualCurrencyCount => $theVirtualCurrencyCount ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * Logs a Traffic Source event - . * * @param theTrafficSourceType String (MANDATORY Field) * @param string $theAccountId * @param string $theTrafficSource * @param float $theShardId * @param string $theTrafficSourceType * @param bool $isTest * @return bool|string */ public function logTrafficSource($theEventTs, $theAccountId, $theTrafficSource, $theShardId, $theTrafficSourceType, $isTest = false) { $aEventMap = array( KApi::$kDataMapKeyskType => '59', KApi::$kDataMapKeyskAccountId => $theAccountId, KApi::$kDataMapKeyskTrafficSource => $theTrafficSource, KApi::$kDataMapKeyskShardId => $theShardId, KApi::$kDataMapKeyskTrafficSourceType => $theTrafficSourceType ); if ($isTest) { return $this->JsonEchoEvent(json_encode($aEventMap)); } else { return $this->logEvent($aEventMap, $theEventTs); } } /** * logs an Event comprised of related key-value pairs, and an optional * ISO-8601 date string (from UTC) * * @see http://www.w3schools.com/jsref/jsref_tojson.asp * @param array $theEventMap * @param null $theEventTs * @internal param string $theDate * @return boolean - was the Event logged? */ private function logEvent($theEventMap, $theEventTs = null) { if (!(isset($this->myClientId) && isset($this->myAppId) && isset($this->myPasswrd))) { return false; } if (!$theEventTs) { $theEventTs = $this->getISO8601UTCString(); } if (isset($theEventMap) && (count($theEventMap) > 0) && isset($theEventTs)) { $aEventObj = array( KApi::$kMapTimeStampKeyStr => $theEventTs, KApi::$kMapDataKeyStr => $theEventMap ); $aEventObjAsJson = json_encode($aEventObj); $aRetData = $this->doPostRequest(KApi::$kApiBaseUrl . KApi::$kApiEventBase, $aEventObjAsJson, false); if ($aRetData) { $aImportStatusResp = json_decode($aRetData, true); $aRespStatusCode = $aImportStatusResp[KApi::$kApiRespStatusArgStr]; if ($aRespStatusCode != KApi::$kApiRespStatusCodeOkStr) { return false; } } else { return false; } } else { return false; } return true; } /** * input a JSON formatted string, POST it to the Event end-point, * the same JSON string should be parsed and echoed back * --> method for testing purposes <-- * * @param string $theJson * @return string */ public function JsonEchoEvent($theJson) { return $this->doPostRequest(KApi::$kApiBaseUrl . KApi::$kApiEventBase, $theJson, true); } /** * HTTP POST $thePostData to $thePostUrl with echo-test=true header * if $isEchoTest is true * * @param string $thePostUrl * @param variable -type $thePostData * @param boolean $isEchoTest * @return string - the response body, boolean - false on error */ private function doPostRequest($thePostUrl, $thePostData, $isEchoTest) { if (!$isEchoTest) { if (strstr($thePostUrl, '?')) { $thePostUrl .= "&client_id=$this->myClientId&app_id=$this->myAppId&app_pwd=$this->myPasswrd"; } else { $thePostUrl .= "?client_id=$this->myClientId&app_id=$this->myAppId&app_pwd=$this->myPasswrd"; } } if (strstr($thePostUrl, '?')) { $thePostUrl .= '&api_client=php_1.2.6'; } else { $thePostUrl .= '?api_client=php_1.2.6'; } if ($isEchoTest) { $aHeaderArray = array( 'User-Agent: ' . $this->myServerSoftwareStr, 'echo-test: true', 'Content-Type: application/json', 'Content-Length: ' . strlen($thePostData) ); } else { $aHeaderArray = array( 'User-Agent: ' . $this->myServerSoftwareStr, 'Content-Type: application/json', 'Content-Length: ' . strlen($thePostData) ); } $params = array( 'http' => array( 'method' => 'POST', 'content' => $thePostData ) ); $aHeaderStr = implode("\r\n", $aHeaderArray) . "\r\n"; if ($aHeaderArray) { $params['http']['header'] = $aHeaderStr; } $ctx = stream_context_create($params); $fp = fopen($thePostUrl, 'rb', false, $ctx); if (!$fp) { return false; } $result = stream_get_contents($fp); return $result; } }