/// <summary> /// Send telemetry to report an instantaneous transaction, including any state properties which have been set. /// </summary> /// <param name="position">Overload the position of this event for Scene Explorer</param> /// <param name="result">CognitiveVR.Constants.TXN_SUCCESS, CognitiveVR.Constants.TXN_ERROR, or any application defined string describing the result</param> public void beginAndEnd(Vector3 position, string result = Constants.TXN_SUCCESS) { float[] pos = new float[3] { 0, 0, 0 }; pos[0] = position.x; pos[1] = position.y; pos[2] = position.z; InstrumentationSubsystem.endTransaction(_category, result, _transactionId, _state, pos); _state = new Dictionary <string, object>(); }
/// <summary> /// Update a collection balance for the current entity /// </summary> /// <param name="name">The application-supplied name for the collection</param> /// <param name="balance">Current balance</param> /// <param name="balanceModification">The amount that the balance is changing by (if known)</param> /// <param name="isCurrency">If set to <c>true</c> the collection is treated as an in-app virtual currency</param> public static void updateCollection(string name, double balance, double balanceModification, bool isCurrency) { InstrumentationSubsystem.updateCollection(name, balance, balanceModification, isCurrency); }
/// <summary> /// Updates state information about a user /// </summary> /// <param name="state">A key-value object representing the user state we want to update. This can be a nested object structure.</param> public static void updateUserState(Dictionary <string, object> state) { InstrumentationSubsystem.updateUserState(state); }
/// <summary> /// Initializes CognitiveVR Framework for use, including instrumentation and tuning. /// </summary> /// <param name="initParams">Initialization parameters</param> /// <param name="cb">Application defined callback which will occur on completion</param> public static void init(InitParams initParams, Callback cb) { Debug.Log("Core.init()"); // this should only be enabled during android development!!! //AndroidJNIHelper.debug = true; Error error = Error.Success; // Enable/disable logging Util.setLogEnabled(initParams.logEnabled); if (null == initParams) { Util.logError("No init parameters provided"); error = Error.InvalidArgs; } else if (null == cb) { Util.logError("Please provide a valid CognitiveVR.Callback"); error = Error.InvalidArgs; } else if (Constants.ENTITY_TYPE_USER != initParams.userInfo.type) { Util.logError("To provide intitial user settings, be sure to use createUserInfo"); error = Error.InvalidArgs; } else if (Constants.ENTITY_TYPE_DEVICE != initParams.deviceInfo.type) { Util.logError("To provide intitial device settings, be sure to use createDeviceInfo"); error = Error.InvalidArgs; } GameObject go = GameObject.Find(HUB_OBJECT); if (null == go) { go = new GameObject(HUB_OBJECT); } GameObject.DontDestroyOnLoad(go); if (Error.Success == error) { InstrumentationSubsystem.init(); // Builds targeting the web player need to be handled specially due to the security model // Unfortunately, there is no good way to determine that at run time within the plugin. #if UNITY_WEBPLAYER const bool isWebPlayer = true; #else const bool isWebPlayer = false; #endif TuningSubsystem.init(delegate(Error err) { CoreSubsystem.init(initParams.customerId, new TuningSubsystem.Updater(), initParams.userInfo.entityId, initParams.userInfo.properties, initParams.deviceInfo.entityId, initParams.deviceInfo.properties, initParams.requestTimeout, initParams.host, initParams.logEnabled, SDK_NAME_PREFIX, SDK_VERSION, cb, HUB_OBJECT, isWebPlayer); }); } else if (null != cb) { // Some argument error, just call the callback immediately cb(error); } }
/// <summary> /// Send telemetry to report an update to a transaction, including any state properties which have been set. /// </summary> /// <param name="progress">A value between 1 and 99, which should increase between subsequent calls to update</param> public void update(int progress) { InstrumentationSubsystem.updateTransaction(_category, progress, _transactionId, _state); _state = new Dictionary <string, object>(); }
/// <summary> /// Send telemetry to report the beginning of a transaction, including any state properties which have been set. /// </summary> /// <param name="timeout">How long to keep the transaction 'open' without new activity</param> /// <param name="mode">The type of activity which will keep the transaction open</param> public void begin(double timeout = 0, TimeoutMode mode = TimeoutMode.Transaction) { InstrumentationSubsystem.beginTransaction(_category, (TimeoutMode.Any == mode) ? "ANY" : "TXN", timeout, _transactionId, _state); _state = new Dictionary <string, object>(); }
/// <summary> /// Send telemetry to report an instantaneous transaction, including any state properties which have been set. /// </summary> /// <param name="result">CognitiveVR.Constants.TXN_SUCCESS, CognitiveVR.Constants.TXN_ERROR, or any application defined string describing the result</param> public void beginAndEnd(string result = Constants.TXN_SUCCESS) { InstrumentationSubsystem.endTransaction(_category, result, _transactionId, _state); _state = new Dictionary <string, object>(); }