I would like to be able to generate Google analytics data that will show me number of startups of my application but also the time it tool for each starup and the average time for all startups. Something like:
Startups 1296
Startup Times
40ms
27ms
128ms
700ms
42ms
82ms
...
...
127ms (Average)
I know it is possible to get the Startups but not sure if it is possible to also get Startup Times. Is it possible to do this and how from a C# desktop application?
I am developing a lib called gappalytics, it allows you to log analytics events for desktop apps. Link to package nuget.org/Gappalytics.
Usage sample: github.org/gapalytics
As long as you can sent http request in realtime (or a narrowly defined offset window) you can use the measurement protocol. I don't think there is a C# client library, but this is basically just a http request with the parameters and and such its language agnostic.
There are a few required parameters - the protocol version (always v1 for now), Google Account ID, a unique Client ID per user or device and a hit type (pageview, screen, event, transaction etc.). Also depending on the hit type you need additional parameters (document location/page title, event category/action/label etc.).
There is a parameter reference with all possible fields, and you can construct hits for testing via the hit builder.
Google Analytics has a "user timings" hit type (basically you pass a description and a duration in microseconds), so the report from your example should be very easily doable.
I don't know C#, but I'm reasonably certain is has a way to format a string as an url with parameters and send an http request, and in the end that's really all you need for data collection with GA.
Related
I am new to StackOverflow, struggling to find a solution to my problem: I am trying to synchornize my asp.net app with the calendly api.
So far, I have managed to create a webhook subscription and I saw that the webhooks are being registered to https://calendly.com/api/v1/hooks/ and I was able to acces a specific webhook using its id (I used Postman to see all this, as I am currently local developing). I am having a lot of trouble since I am not able to understand what call should I make in order to get the webhooks and be able to use their data in my app.
https://developer.calendly.com/docs/sample-webhook-data
This is what I should be parsing, according to Calendly documentation.
I want to get data such as the emails of those participing into the event, also the date and status of the event. How can I do this?
From your question, it seems to me there might be a lack of conceptual understanding of what webhooks are.
As you mention, you had already subscribed to be notified if some event happens in Calendly (I assume invitee.created event).
This means, that
when this event actually happens on Calendly (you may need to make a test scheduling request in the Calendly UI), the notification about this event is sent to the URL you had registered (subscribed).
This registered URL has to be reachable for the notification call. In other words, if the URL is in your local environment (and you mentioned it is so), it's impossible for the notification to reach the registered (subscribed) destination. So this might be the issue you're experiencing.
You need to read incoming raw data. In my script, with PHP, I do it using file_get_contents('php://input')
You need to parse the data. With PHP I use json_decode($inputData). In your language you've got to use whatever tools you have for JSON parsing.
Basically, that's it. In my case, I read invitee email using $parsedData->payload->invitee->email.
Hope it helps.
Let's assume we have a RESTful web service that will calculate UK Royal Mail postage charges.
There would be a number of essential input parameters:
weight of item (grams, int),
length of item (cm, int),
width of item (cm, int),
category of item (letter/parcel, string/enum),
service required (first class/second class/special delivery/etc, string/enum),
destination (domestic/international/maybe further specify the latter, string/enum)
Such an application would be easy to create as a WebAPI. It could be called via a URL such as ...
http://myserver.com/api/mailcharges?weight=150&length=15&width=10&category=letter&service=first&destination=domestic
The web service would then do a simple lookup on its internal tables and return the postage in its response payload.
The beauty of this is that it could then be utilised by a variety of applications within an organisation (or even outside it!). However, this requires that each application that calls the web service needs to be able to populate these parameters; the integers are OK, they are just that - numbers. But the strings or enums are more difficult. The logic for entering and validating these needs to be replicated in every client application. Wouldn't it be nicer if the web service could prompt the user for any which are not passed in or passed as nulls or invalid values. In fact wouldn't it be nicer still if the web service had a user interface which allowed a user to enter any or all of the parameters.
What I am looking for is a cross between a web site and a web service. A web application which can be called via a simple RESTful http request, which pops up a user dialogue, accepts user input, and when the user clicks on a suitable button, does its calculation and returns its answers as a JSON/XML response.
Does anyone have any ideas on how to implement such an architecture? I have tried calling MVC actions/views from within a web api controller but the response is the html for the MVC view, and is returned to the api controller directly rather than being rendered and POSTing back its user input.
I hope I am just being thick, and that the answer is obvious, but all my experiments have so far failed, and any suggestions, no matter how far fetched or outrageous, would be very welcome.
I realize that this is a fairly trivial example, but the same argument goes for much more complicated web services where the replication of user input forms, input validation, complex processing logic etc. across multiple client applications would be far more of an issue than with this example.
if the web service could prompt the user is essentially missing the point of a service. It is no longer a webservice, but a webpage.
In order for internal/external applications/websites to utilize your service, they essentially need to know three things:
where to ask - this is your http://myserver.com/api/mailcharges
what are the arguments - that is weight, length…
what are accepted argument values
While 1. and 2. are usually mere API documentation you seem to have a problem with p. 3 - you want the user to be somehow prompted to choose among possible values and not guess. But you also want the user application not to be responsible for maintaining/validating the list of possible values.
Guess what? You simply need another API. :) An API to describe your arguments.
Let's concentrate on category field. Your API could be extended with a new URL: http://myserver.com/api/getCategories which essentially returns a list of available (currently understood by API) possible category values. This can be JSON, or comma separated string or whatever reliable. Now your end-user GUI-enabled application calls the API, asks for categories, and creates UI accordingly - populating ComboBox or whatever with obtained values. The same is done for other fields. You can. i.e. obtain acceptable ranges of weight or length.
The important thing you mention in your question is validation: logic for entering and validating these needs to be replicated in every client application. This is somehow true, as it essentially depends on the technology used in the end-user application. On the other hand it is very important, that the API performs validation itself! You can never know who is going to use your API. And it is always better to check twice then never.
This is my first time developing this kind of system, so many of these concepts are very new to me. Any and all help would be appreciated. I'll try to sum up what I'm doing as efficiently as possible.
Background: I have a web application running AngularJS with Bootstrap. The app communicates with the server and DB through a web service programmed using C#. On the site, users can upload files and reference them later using direct links. There's no restriction to file type (yet), so just about anything is allowed.
My Goal: Having direct links creates a big security problem for me, since the documents/images are supposed to be private data. What I would prefer to do is validate a user's credentials when the link is clicked, then load the file in the browser using a more generic url path.
--Example--
"mysite.com/attachments/1" ---> (Image)
--instead of--
"mysite.com/data/files/importantImg.jpg"
Where I'm At: Not very far. My first thought was to add a page that sends the server request and receives a file byte stream along with mime type that I can reassemble and present to the user. However, I have no idea if this is possible using a web service that sends JSON requests, nor do I have a clue about how the reassembling process would work client-side.
Like I said, I'll take any and all advice. I'd love to learn more about this subject for future projects as well, but for now I just need to be pointed in the right direction.
Your first thought is correct, for it, you need to use the Response object, and more specifically the AddHeader and Write functions. Of course this will be a different page that will only handle file downloads, so it will be perfectly fine in your JSON web service.
I don't think you want to do this with a web service. Just use a regular IHttpHandler to perform the validation and return the data. So you would have the URL "attachments/1" get rewritten to "attachments/download.ashx?id=1". When you've verified access, write the data to the response stream. You can use the Content Disposition header to set the file name.
I have a problem here. Assume there's a basic calculator implemented in javascript hosted on a website ( I have googled it and to find an example and found this one: http://www.unitsconverter.net/calculator/ ). What I want to do is make a program that opens this website, enters some value and gets the return value. So, in our website calculator, the program:
- open the website
- enters an operand
- enters an operation
- enters an operand
- retrieve the result
Note: things should be done without the need to show anything to the user ( the browser for example ).
I did some search and found about HttpWebRequest and HttpWebRespond. But I think those can be used to post data to the server, which means, The file I'm sending data to must be php, aspx or jsp. But Javascript is client side. So, I think they are kind of useless to me in this case.
Any help?
Update:
I have managed to develop the web bot using WebBrowser Control tool ( found in System.Windows.Forms )
Here's a sample of the code:
webBrowser1.Navigate("LinkOfTheSiteYouWant"); // this will load the page specified in the string. You can add webBrowser1.ScriptErrorsSuppressed = true; to disable the script in a page
webBrowser1.Document.GetElementById("ElementId").SetAttribute("HTMLattrbute", "valueToBeSet");
Those are the main methods I have used to do what I wanted to.
I have found this video useful: http://www.youtube.com/watch?v=5P2KvFN_aLY
I guess you could use something like WatiN to pipe the user's input/output from your app to the website and return the results, but as another commenter pointed out, the value of this sort of thing when you could just write your own calculator fairly escapes me.
You'll need a JavaScript interpreter (engine) to parse all the JavaScript code on the page.
https://www.google.com/search?q=c%23+javascript+engine
What you're looking for is something more akin to a web service. The page you provided doesn't seem like it accepts any data in an HTTP POST and doesn't have any meaningful information in the source that you could scrape. If for example you wanted to programmatically make searches for eBay auctions, you could figure out how to correctly post data to it eg:
http://www.ebay.com/sch/i.html?_nkw=http+for+dummies&_sacat=267&_odkw=http+for+dummies&_osacat=0
and then look through the http response for the information you're looking for. You'd probably need to create a regular expression to match the markup you're looking for like if you wanted to know how many results, you'd search the http response for this bit of markup:
<div class="alt w"><div class="cnt">Your search returned <b>0 items.</b></div></div>
As far as clientside/javascript stuff, you just plain aren't going to be able to do anything like what you're going for.
It is a matter of API: "Does the remote website expose any API for the required functionality?".
Well web resources that expose interactive API are called web service. There are tons of examples (Google Maps for istance).
You can access the API -depending on the Terms & Conditions of the service- through a client. The nature of the client depends on the kind of web service you are accessing.
A SOAP based service is based on SOAP protocol.
A REST based service is based on REST principles.
So, if there is an accessible web service called "Calculator", then you can access the service and, for istance, invoke the sum method.
In your example, the calculator is a Javascript implementation, so it is not a web service and it cannot be accessed via HTTP requests. Though, its implementation is still accessible: it is the javascript file where the calculator is implemented. You can always include the file in your website and access its functions via javascript (always mind terms and conditions!!).
A very common example is the jQuery library stored in Google Libraries.
I got the following exception from the Social Graph API:
(OAuthException) Block! You are engaging in behavior that may be
considered annoying or abusive by other users.: You have been blocked
from Body of an error/warning message. Title is: Block! You are
engaging in behavior that may be considered annoying or abusive by
other users. because you repeatedly misused this feature. This block
will last anywhere from a few hours to a few days. When you are
allowed to reuse this feature, please proceed with caution. Further
misuse may result in your account being permanently disabled. For
further information, please visit our {= FAQ page}.
My program makes thousands of calls, but the call that threw the exception was like this:
graph.facebook.com/search?q=6511+club&access_token=...
I'm not writing anything back to the API, so I don't see how I could be violating any abuse/annoyance rules. At first I thought I might have gone over the rate limit but this thread says the exception message for that would look like this:
Facebook.GraphAPIError: (#613) Calls to stream have exceeded the rate of 600 calls per 600 seconds.
My program is calling the above Event search endpoint with a new value for the q parameter repeatedly. For each event returned, my program:
(calls /eventId) Gets the Event detail
(calls /pageId) Get place Page of the Event's location if the Event's location references a Facebook place Page
(calls /eventId/attending) Get the ids of the User profiles who are attending or maybe attending
(calls /?ids=...) Get the User profiles of the Users who are attending or maybe attending.
I'm using the Facebook C# SDK. All my calls include an access token (from my personal User profile).
It's not your app which is blocked, it's your user which is blocked. Your user was identified by Facebook's automated system as a bot (which it really is actually). Next step - your user will be banned from Facebook. You're making too many calls harvesting data from Facebook by a single user. You need to rethink your app purpose and whther you need to call this data to store or your users can get it on demand from the API. Most offensive calls here are /eventId/attending and ids per each event. Call it thousand times on thousand events and the user will be blocked.