Google analytics event tracking on the server side - google-analytics-api

I'm trying to track my events from server side and based on documentation it is possible. I found an example with node.js (link) but it is not working for me as well curl calls (response is 200 but the called event is not visible in the report or real time data).
When I'm using webbrowser url link with the same payload data "https://google-analytic.com/collect?v=1&t=event&tid=UA-xxxxxxxx-x&cid=cid555&ec=test&ea=test&el=test&ev=10 everything is ok.
Am I missing something ?

Related

Detect api changes flutter

Right now the app will need to detect whether a field from API got change or not
for example the api will return
{
successOrNot : false
}
when the field successOrNot become true, only then it will go to next page.
However the method that im doing right now is by using Timer.periodic, so it will call the api every 1 seconds, until the successOrNot become true then it will stop calling it. Is there another way on doing this since im afraid that it will affect the server because of api calling excessively.
You should use webSocket in this situation, sever will send message and client (flutter app) will listen to message from server, your current solution is ping the server by REST several times per minute, it maybe overloads the server in some case, e.g you have a lot of client but server resource is limited.
Link document about webSocket here: https://docs.flutter.dev/cookbook/networking/web-sockets
Beside websocket, you can also use SSE (Server Sent Events). But just like websockets, SSE require implementation on both server and client side. And depending on the situation both options may not be viable.

Listening to API changes in Flutter

assume I have an API that gives a JSON response that return an id and a name.
In a mobile application normally I would make an http GET response to get this data in a one time connection with the server and display the results in the app, however if the data changes over time and I want to keep listening to this data whenever it changes how is that possible ?
I have read about sockets and seen the socket_io_client and socket_io packages, but I did not get my head around it yet, is using sockets the only way to achieve this scenario ? or is it possible to do it in a normal http request ?
Thanks for your time
What you need is not an API but a Webhook:
An API can be used from an app to communicate with myapi.com. Through that communication, the API can List, Create, Edit or Delete items. The API needs to be given instructions, though.
Webhooks, on the other hand, are automated calls from myapi.com to an app. Those calls are triggered when a specific event happens on myapi.com. For example, if a new user signs up on myapi.com, the automated call may be configured to ask the app to add a new item to a list.
is using sockets the only way to achieve this scenario ? or is it possible to do it in a normal http request ?
Sockets is only one of the ways to achieve your goal. It is possible to do it using a normal http request. Here, for example, the docs explain how to update data over the internet using HTTP.
From the flutter docs:
In addition to normal HTTP requests, you can connect to servers using WebSockets. WebSockets allow for two-way communication with a server without polling.
You'll find what you need under the networking section.
You should also take a look at the Stream and StreamBuilder classes.

How to call Salesforce REST API from external web forms

I am a bit confused. The requirement is that we need to create a REST API in Salesforce(Apex class) that has one POST method. Right now, I have been testing it with POSTMAN tool in 2 steps:
Making a POST request first with username, password, client_id, client_secret(that are coming from connected app in Salesforce), grant_type to receive access token.
Then I make another POST request in POSTMAN to create a lead in Salesforce, using the access token I received before and the body.
However, the REST API that I have in Salesforce would be called from various different web forms. So once someone fills out the webform, on the backend it would call this REST API in Salesforce and submits lead request.
I am wondering how would that happen since we can't use POSTMAN for that.
Thanks
These "various different web forms" would have to send requests to Salesforce just like Postman does. You'd need two POST calls (one for login, one to call the service you've created). It'll be bit out of your control, you provided the SF code and proven it works, now it's for these website developers to pick it up.
What's exactly your question? There are tons of libraries to connect to SF from Java, Python, .NET, PHP... Or they could hand-craft these HTTP messages, just Google for "PHP HTTP POST" or something...
https://developer.salesforce.com/index.php?title=Getting_Started_with_the_Force.com_Toolkit_for_PHP&oldid=51397
https://github.com/developerforce/Force.com-Toolkit-for-NET
https://pypi.org/project/simple-salesforce/ / https://pypi.org/project/salesforce-python/
Depending how much time they'll have they can:
cache the session id (so they don't call login every time), try to reuse it, call login again only if session id is blank / got "session expired or invalid" error back
try to batch it somehow (do they need to save these Leads to SF asap or in say hourly intervals is OK? How did YOU write the service, accepts 1 lead or list of records?
be smart about storing the credentials to SF (some secure way, not hardcoded). Ideally in a way that it's easy to use the integration against sandbox or production changing just 1 config file or environment variables or something like that

How Burp exactly scans a request

I just started working with Burp professional suite 2.0.6 beta. After proxy recording, I just right-click and perform the scan with default configuration.
I want to know exactly what happens in that scan. It covers pen testing, but how?
Does it sends requests to the server and analyze the response, if so, take an example of POST API call. Does Burp replaces the input and sends the call to the server?, but in UI, I can't see any new thing(as POST method) created. Then how does Burp analyzes response?
In my application, if a Form is submitted, the response will be "Form Submitted. Submitted ID:9898" which is JSON output.
Some one please guide or teach me the correct things on how exactly Burp scans a request.
You can use the Logger++ extension from the BApp store to monitor activity from Burp Scanner:
https://portswigger.net/bappstore/470b7057b86f41c396a97903377f3d81

How to send permanently a request to my http server

I have a http server running on my pc that I developed using C++.
I need to send permanently a request from the browser to my server (every 1s) in order to refresh my web page's content.
How can I do it?
Thanks for your help :))
This is the kind of thing that AJAX was designed for. Client-side scripting can send requests, such as in a timer, to update specific areas of the page's content without reloading the entire page each time.
Otherwise, look at HTTP server-side pushing to push new data to the client whenever it changes.