Implementing Google Analytics 2 in IOS 6 - ios6

While updating an app to ios 6, I found google analytics also needs update.
Following this method, I discovered it needs a ViewController which extends GAITrackedViewController class
https://developers.google.com/analytics/devguides/collection/ios/v2/
The guide mentions the following code in ViewDidLoad method, whereas I want it in some specific method. It doesn't seems to work. Kindly advise.
self.trackedViewName = #"My App";

Using GAITrackedViewController means giving up control over when [tracker trackView:viewName] gets called. Setting the trackedViewName allows GAITrackedViewController to call [tracker trackView:self.trackedViewName] whenever it wants (presumably in viewDidAppear).
Also, GAITrackedViewController uses a KVO on this property, so view tracking doesn't get turned on until self.trackedViewName = #"view name" is performed.
Calling this in viewDidLoad assures that it's setup correctly by the time the first viewDidAppear gets called.

Related

Why does react empty attributes when using a web component?

I am pretty new to react and trying to use a web component in the template and there are is a thing i dont understand.
It can be seen in this example below if you run the page (may need to hit reload once). Then watch the console. You will see the log in the constructor() the outerHTML is not "ready" yet its missing all attributes in the markup and they arrive only later on (in the connectedCallback) which is the second log.
https://stackblitz.com/edit/react-ts-jcjuvs?file=App.tsx,index.tsx
Whats happening here? Is there anyway to force the attributes to be available initially? Or not taken off and then put back on?
Note that doing this in a normal page does not have the same effect.
https://stackblitz.com/edit/js-l4uh4f?file=index.js,index.html
a) whats happening?
b) can i make this not happen?
Thanks!
There no no guarantee that a web component will have access to attributes in the constructor and attribute values can change at anytime. You should use the attributeChangedCallback lifecycle callback to know when values are set.
The element's attributes and children must not be inspected, as in the non-upgrade case none will be present, and relying on upgrades makes the element less usable.
Requirements for custom element constructors and reactions

Angular seems to fire on its own

I have a $http.put function that updates my database, this happens on a button click. After I update the database once, and stay on the page, with no interaction at all the update function gets called and will update the database with the last information that was inputted.
I've triple checked my code, there is only one occurrence of my update function being called. And the $http.put is inside $scope.update that is an anonymous function that calls the $http.put.
If I update information and then leave the page, and then come back the function does not fire on it's own.
Here is my Github for the project. I will pull out any specific code that you want to see, but I'm not sure what to show because there are 4 files involved. Those files are
(client/scripts/app.js)
(routes/products.js)
(public/views/routes/adminIndex.html)
(public/views/routes/modProduct.html)
Code is Here
Add a console.trace() just before the $http call to see what is calling it.
You can also use the developper console of your browser and add a breakpoint that will stop the code execution and let you inspect everything (stack trace, current context, etc). Chrome is particularly good at that.

<f:view> beforePhase method called twice when page loads

I am trying to capture url parameters when page is loaded. I am using the beforePhase attribute inside the tag to call the backing bean method which handles the PhaseEvent. I am able to read the parameters but there seems to be some problem. The backing bean method is executed twice. First time I am getting all the url paramters but second time I am getting null.
This is the output in the console I get (The line "BeforePhase ONLOAD" is my SOP statement inside the method. As you can see the SOP is printed twice (below is the console output) -
* <_checkTimestamp> Apache Trinidad is running with time-stamp checking enabled. This should not be used in a production environment. See the org.apache.myfaces.trinidad.CHECK_FILE_MODIFICATION property in WEB-INF/web.xml
beforePhase ONLOAD
<_isBeanValidationAvailable> A Bean Validation provider is not present, therefore bean validation is disabled
beforePhase ONLOAD***
I have to use these url parameters to bind it to the view object and retrieve the data for the page. But if the method is called twice like it has been called here then the second will cause some database error or ultimately i will not see any records on screen.
Is there a way to handle this ?
I actually followed the Approach 1 example seen on this page - http://jneelmani.blogspot.com/2013/01/adf-how-to-call-method-on-page-load.html. In this example, he shows how to avoid beforePhase being called multiple times, I have done that but still the method is called twice.
Any suggestions here will be helpful.
Thanks.
Of course you know ADF supports a mechanism already for bookmarkable pages & URL parameters?
http://myadfnotebook.blogspot.pt/2010/11/bookmarking-with-adf.html

Calling .Net function on UI test instance in TestComplete

I have a simple wpf app which has a button that increments a value on clicking. I also have a function that returns the latest value. The default value is 5. I also have a UI test in testcomplete that clicks the button 3 times (so 8). I need to call the .Net function to get this value and assert it. Below is my test code.
After some search I figured out the CLRbridge details and implemented it. However, As you can see below, the UI test instance and the instance on which I am claling the function are different. So, the function returns 5.
My question is, how do I invoke the function from the same instance loaded by testcomplete. Or am I going completely the wrong way for this? I tried both script and UI test with if..then, nothing worked. I have tried both direct instance and calling on the appdomain, both doesnt seem to work.
NOTE: I do understand that I can display the value in a UI control and validate the control. However, i am specifically trying this out for a more complex testing functionality we need in a project.
function Test2()
{
var Increment;
Increment = 0;
//Runs the "TCompTest" tested application.
TestedApps.TCompTest.Run();
//Clicks the 'button1' button.
Aliases.TCompTest.HwndSource_MainWindow.MainWindow.Grid.button1.ClickButton();
//Clicks the 'button1' button.
Aliases.TCompTest.HwndSource_MainWindow.MainWindow.Grid.button1.ClickButton();
//Clicks the 'button1' button.
Aliases.TCompTest.HwndSource_MainWindow.MainWindow.Grid.button1.ClickButton();
//Increment = dotNET.Incrementer.Incr1.zctor().IntValue(true);
Increment = dotNET.Incrementer.Incr1.zctor().IntValue(true);
**OR**
Increment = Sys.Process("TCompTest").AppDomain("TCompTest.exe").dotNET.Incrementer.Incr1.zctor().IntValue(true)
// if(Increment == 8)
// {//Posts an information message to the test log.
Log.Message(Increment);
// }
//Closes the 'HwndSource_MainWindow' window.
Aliases.TCompTest.HwndSource_MainWindow.Close();
}
It should be possible to do what you need from TestComplete. But first of all, to avoid misunderstanding, let me explain the problems with the approaches you tried:
Addressing a class through the "dotNET" object.
When you do this, TestComplete initializes .NET in its service process, loads the specified assembly into it, and works with the classes of this assembly loaded to TestComplete's AppDomain (though living in a separate process). This means that this instance of your assembly has nothing to do with your tested application. So, you can't access your application's data through the dotNET object.
Addressing the Incrementer assembly through the tested application's AppDomain.
OK, in this case you are closer to a solution - you work with the AppDomain of the tested application, so you can access the application's data. However, in your code, you create a new instance of the Incr1 class (via calling zctor). This means that the new class instance will initialize its counter in the constructor, and it will be 5. And this is the value you are getting in your code.
So, the right approach:
Unless the counter field of the Incr1 class containing the current counter value is a static field, you need to address an existing object of the Incr1 class to get the current value of the property, not to create a new class instance. The actual implementation will depend on where you are storing the Incr1 class instance reference in your application. Let's suppose, you store the reference in the Counter property of the MainWindow object:
// Creating an instance of the class somewhere in your code
MainWindow.Counter = new Incr1();
// ...
// And this line of code is in the button click handler
MainWindow.Counter.Increment();
In the described case, you will be able to get the current counter value in your TestComplete script as follows:
var MainWnd = Aliases.TCompTest.HwndSource_MainWindow.MainWindow;
Log.Message(MainWnd.Counter.IntValue(true));
If your setup is different, please describe it - I will try to help accordingly.

Event Aggregation...What exactly is going on?

I have often times wondered about it but now that I have encountered a piece of logic that incorporates it, I thought I should go ahead and get some help on deciphering the fundamentals. The problem is as follows, I am looking at a WPF application that is utilizing the Composite Application Library. Within the source of the application I came across the following line of code in the Presentation of a view. For the sake of convinience I will call it Presentation A:
private void OnSomethingChanged(SomeArgumentType arguement)
{
UnityImplementation.EventAggregator.GetEvent<EventA>().Publish(null);
}
When I saw the method Publish in the above given method, my gut told me there must be a Subscribe somewhere and in another class, I will call it Presentation B there was the following:
UnityImplementation.EventAggregator.GetEvent(Of EventA).Subscribe(AddressOf OnSomeEventA)
There was a private function in the same class called OnSomeEventA that had some logic in it.
My question here is that how is everything wired over here? What exactly is achieved by the 'Publish' 'Subscribe' here? When 'something' changes, how does the compiler know it has to follow the logic in OnSomethingChanged that will 'Publish' an event that is 'Subscribed' by another class where the logic of the event handler has been described? It will be great to understand the underlying wiring of this process.
Thanks
The first time GetEvent<T> is called for each event (identified by the type parameter T) the EventAggregator creates an empty list of methods to call when that event is published. Typically, this will happen immediately before the first call to Publish or Subscribe (as in your examples).
Then:
Whenever Subscribe is called a method is added to the list.
Whenever Publish is called it walks through the list and makes those calls.
So, the call to Publish() in Presentation A results in all of the methods that have been registered by calling Subscribe being called, which in your example would include Presentation B's OnSomeEventA method.
Try setting a breakpoint in the OnSomeEventA method and take a look at the stack, and don't forget the source is available, too!

Resources