When I subscribe to all changes of my Drive account, sometimes I receive changes with wrong id. According to my observations changes of specific file are aggregated in last change with some time period.
For example:
If I change file in my drive and if I have received 3 notifications with ids: "#21, #22, #23", I expected that I can get change of "#23", if there is no more changes to that file. But sometimes I receive last change with id greater than it exists. When I use API changes list, I get lastlargestChangeId = receivedChangesId - 1.
I have tested it with google examples and I get the same results:
push notifications test
{"notification_id": "xxxxxxxxxxx", "resource_state": "change", "expiration": "Mon, 07 Jul 2014 13:58:37 GMT", "self_link": "https://www.googleapis.com/drive/v2/changes/3387"}
{
"kind": "drive#changeList",
"etag": "xxxxxxxxxxx",
"selfLink": ".../changes?startChangeId=3340",
"largestChangeId": "3386",
"items": [
...
]
}
Am I wrong?
It seems that Google categorized it as a bug:
https://code.google.com/a/google.com/p/apps-api-issues/issues/detail?id=3706
Star it so Google can prioritize it.
Here is the official answer:
After talking with our engineers, this actually is working as
intended. The change ID given in the push notification (the ID and the
self link that contains that same ID) remain valid only as long as
there are no newer changes on a particular resource. Take the
following example scenario on a user's drive with push notifications
being sent for all changes. 1) Resource A (a file or folder, etc)
changes. 2) Drive API sends a push notification with a change ID
(example 1234). 3) This change ID (and the selflink) can be used now
to successfully pull up the change. 4) Resource A changes again. 5)
Drive API sends a push notification with change ID 1235. Note that
change IDs are monotonically increasing. 6) Accessing the earlier
change ID (1234) through a changes.get or the self link will 404 now
because there is a newer change on the same resource. 7) You can still
access change ID 1235 here.
In general, you should not expect to be able to get a particular
change ID with changes.get. Any resource is only in the changes stream
once. So as soon as the resource has a newer change, the old change ID
is invalid. Some commenters have noted that you can do changeID - 1 to
get this change. However, this will not always work. In my testing, I
have gotten a 404 on both the change ID and for change ID - 1.
Instead, you should sync a given set of resources and note the largest
change ID of that set. Then, when you get push notifications in the
future, see if the change ID you get in the push notification is newer
than the largest you stored. If so, use changes.list in order to get
all of the resource changes between the last change ID you have seen /
stored and the one you just received.
tldr; Do not count on change IDs existing with changes.get. Use
changes.list instead to get all changes from a base change ID to the
change ID you get in the push notification.
https://code.google.com/a/google.com/p/apps-api-issues/issues/detail?id=3706
Related
I have created a watch Channel on my calender and I am successfully receiving all updates from Google PUSH Notifcation.
But I am not able to use that response to get craeted/updated events.
I read few docs and SO questions that I need to use X-Goog-Resource-ID from the response and hit events list API.
But value of this X-Goog-Resource-ID is neither a calender id and neither it is a event id so how can I use this in events list API ?
I am using Python and Service Account for the integration.
Documentaion :
https://googleapis.github.io/google-api-python-client/docs/dyn/calendar_v3.events.html#list
https://developers.google.com/calendar/api/guides/push#making-watch-requests
Response from PUSH :
"X-Goog-Channel-Expiration": "",
"X-Goog-Channel-ID": "",
"X-Goog-Channel-Token": "",
"X-Goog-Message-Number": "",
"X-Goog-Resource-ID": <resource id>,
"X-Goog-Resource-State": "exists",
"X-Goog-Resource-URI": <calender UI>
Google Functions I tried using :
service = build('calendar', 'v3', credentials=credentials)
service.calendars().get(calendarId=X-Goog-Resource-ID).execute()
service.events().list(calendarId=calenderId', eventId=X-Goog-Resource-ID).execute()
Is their any ref Python Example of using digesting Calender PUSH Notification or which API/Function I need to call with what oaarms to get the created/updated events ?
The X-Goog-Resource-ID header holds a value that identifies that particular resource across the APIs. The whole push notifications basically informs you that something has changed on that calendar.
Now if you want to know exactly what changed, I strongly advise you to perform a synchronisation. One way to do this is to perform a full synchronisation and store the nextSyncToken. Then, when you receive a push notification telling you about a change in the calendar, you only have to use the syncToken to know what has changed since your last synchronisation. You can see a working full example on the linked docs.
UPDATE
If you are watching multiple calendars through push notifications, you will need a system in place to track which calendar is being modified at a time. The X-Goog-Resource-ID header maps with the Calendar ID, and it can be used along syncToken to run a events.list() request to receive the updated events.
Below url is used for fetching analytics data related to firebase dynamic links:
https://firebasedynamiclinks.googleapis.com/v1/SHORT_DYNAMIC_LINK/linkStats?durationDays=DURATION
(Please note that the above url is an API that needs authentication/token. You can't open it in a browser. Also, SHORT_DYNAMIC_LINK and DURATION are just placeholders not actual parameter values.
The reason I have added a link is because my question is about the value of the placeholder - DURATION present in the link)
DURATION tells how many days(going backwards) worth data needs to be fetched.
My requirement is to fetch data from the start(when the dynamic link was created). So, what value should I set for durationDays to achieve that?
As a workaround I can set a big number(like 1000 days) but wanted to know a proper way.
Based on what I tried, the parameter durationDays must be present in the url, otherwise the request would return 400 INVALID ARGUMENT. Even setting DURATION values to 0 or -1 return a similar error.
Firebase Analytics API Doc: https://firebase.google.com/docs/reference/dynamic-links/analytics
Our exact same endpoint demo query request using Freemium plan is different than the HERE API demo api endpoint results. As you can see, we do not have Address or contacts. I'm not sure why the results vary on same exact query and endpoint. Any ideas?
We have expanded the initial search/explore response based for the Demo App ID in order to enable users do some testing, but it is not turned on for the Freemium App ID. If you need specific details (like address and contact) then you can use places/lookup api like shown below (you search with source: sharing, id: id for the place you can get this from your above query).
We do this because we expect the end-user to select an item to get additional information. When selected, we receive that request, and it is a signal to us that the result is relevant and important to the query.
https://places.demo.api.here.com/places/v1/places/124aabd1-0aef738f80350f8bebb5ed7539bd19a8;context=Zmxvdy1pZD1lNjIyNjczZS0xNDRmLTViMzctYjY3Mi1hNWQ5MmRkNWU4NzRfMTU0MTc4NDk3MzYzOV8wXzU1NDcmc2l6ZT01JlgtRldELUFQUC1JRD1LTnZIaDlhZ0E2WGxKbElDRWhOZiZYLU5MUC1UZXN0aW5nPTE?app_id=xxx&app_code=xxx
I've been attempting to log activity on a mobile-like device using the Google Analytics Measurement Protocol. All of these attempts have validated using the validation URL, and I can see activity when I look at the real-time reports on the Analytics website. But when I look at the Home or Overview reports for the day - no activity is shown.
The view is set for "All Mobile App Data".
The POST body looks something like this:
v=1&tid=UA-000000000-1&ds=app&qt=1601&uid=uid-zzzzz&t=screenview&cd=Foo&an=Foo%20App%20Name&aid=com.example.foo&aiid=com.example.foo&av=0.0.1&ua=Mozilla%2F5.0%20(Linux%3B%20Android%207.0%3B%20SM-G930V%20Build%2FNRD90M)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F59.0.3071.125%20Mobile%20Safari%2F537.36
The ua field is just a pre-defined string. I found that if I omitted it, the Real Time monitoring listed the hits as desktop hits, although I was in a Mobile report and the ds field was "app".
Am I missing a field that is required? Is there some reason why it is showing up in the real-time report, but not in a daily report? Is there some other way to diagnose why the data is vanishing, or confirm the data is actually being captured?
When i check the debug endpoint the hit is valid
Request:
https://www.google-analytics.com/debug/collect?v=1&tid=UA-XXX-1&ds=app&qt=1601&uid=uid-zzzzz&t=screenview&cd=Foo&an=Foo%20App%20Name&aid=com.example.foo&aiid=com.example.foo&av=0.0.1&ua=Mozilla%2F5.0%20(Linux%3B%20Android%207.0%3B%20SM-G930V%20Build%2FNRD90M)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F59.0.3071.125%20Mobile%20Safari%2F537.36
Response
{
"hitParsingResult": [ {
"valid": true,
"parserMessage": [ ],
"hit": "/debug/collect?v=1\u0026tid=UA-53766825-1\u0026ds=app\u0026qt=1601\u0026uid=uid-zzzzz\u0026t=screenview\u0026cd=Foo\u0026an=Foo%20App%20Name\u0026aid=com.example.foo\u0026aiid=com.example.foo\u0026av=0.0.1\u0026ua=Mozilla%2F5.0%20(Linux%3B%20Android%207.0%3B%20SM-G930V%20Build%2FNRD90M)%20AppleWebKit%2F537.36%20(KHTML%2C%20like%20Gecko)%20Chrome%2F59.0.3071.125%20Mobile%20Safari%2F537.36"
} ],
"parserMessage": [ {
"messageType": "INFO",
"description": "Found 1 hit in the request."
} ]
}
I cannot use one of the mobile libraries from Firebase - this is not one of the platforms they support. I do not wish to pretend this is a web page - there is no associated hostname or path. I do not wish to use Events since I can't do event Behavior Flow, which is one of the things I'm interested in seeing.
I'm aware that it can sometimes take "a day or so" for results to first appear. The site was setup over five days ago at this point, and has received data during that time.
Good thought about the anti-spam setting, however the setting appears to be correct:
I've also tried using GET instead of POST - no change, it still shows the hit in real-time, but then it vanishes.
However, I know that it can record hits permanently. There were two hits from a spammer in Russia that have shown up in the daily report (I wasn't there to see it show up in real-time). I don't know what they did, but would love to find out since it might help figure out how I can add a record.
In the real-time reports, it correctly points out the data center all the hits are coming from. Perhaps that is filtering it out somewhere out of my control?
Try adding Cid I know it says this is an optional parameter but for mobile accounts I belive it may be required.
Client ID
Optional.
This field is required if User ID (uid) is not specified in the request. This anonymously identifies a particular user, device, or browser instance. For the web, this is generally stored as a first-party cookie with a two-year expiration. For mobile apps, this is randomly generated for each particular instance of an application install. The value of this field should be a random UUID (version 4) as described in http://www.ietf.org/rfc/rfc4122.txt.
Example value: 35009a79-1a05-49d7-b876-2b884d0f825b
Although this says it needs to be a UUIDv4, it does work with other UUIDs (I've tested it with a v5, which is a hash against the value used for the uid parameter).
I have not seen any discussion or awareness so far that Firebase does in fact make available a unique identifier--in fact the full URL--to each specific data record via their "snapshot" which they return, i.e. the wrapper around the data record (accessed via snapshot.val()). By doing a basic property examination of the snapshot I discovered that the unique URL is available (see examples below). However, it seems that, for some reason, Firebase keeps changing the name of the key every few days, causing my application to break. I have to go in and re-discover the new URL property key and change it so that it will work again.
Here are three examples of how I have seen the key change so far. Each value is the same, but the key keeps changing over time (i.e.: "Wb", "Xb", "bc").:
getMemberBySnapshot - snapshot has prop Wb with value https://prototype1.firebaseio.com/users/-IwohKfw1l5F3gFqyJJ5
getMemberBySnapshot - snapshot has prop Xb with value https://prototype1.firebaseio.com/users/-IwohKfw1l5F3gFqyJJ5
getMemberBySnapshot - snapshot has prop bc with value https://prototype1.firebaseio.com/users/-IwohKfw1l5F3gFqyJJ5
I have read Firebase's suggestions that developers should use an email address if they want a unique key (what if my model does not use an email field? What if a user wants to change their email?), or Firebase suggests altenatively to retrieve all existing records and then search through them on the client. Neither of these solutions are satisfying. But I'm seeing that they do provide the unique URL to each data record in the 'snapshot'. Why do they not provide a stabilized key so that a developer can call it consistently???
Firebase.js is a compiled script. The names of internal variables will change every time we compile it and release a new version, so you should definitely not be relying on any properties that are not documented on our website.
For your specific case, you should be using:
snapshot.ref().toString()
in order to get the URL.