{"action":"created","issue":{"url":"https://api.github.com/repos/ampproject/amphtml/issues/11194","repository_url":"https://api.github.com/repos/ampproject/amphtml","labels_url":"https://api.github.com/repos/ampproject/amphtml/issues/11194/labels{/name}","comments_url":"https://api.github.com/repos/ampproject/amphtml/issues/11194/comments","events_url":"https://api.github.com/repos/ampproject/amphtml/issues/11194/events","html_url":"https://github.com/ampproject/amphtml/issues/11194","id":255772340,"number":11194,"title":"I2I: TIMER function for analytics URL substitution","user":{"login":"lannka","id":8496897,"avatar_url":"https://avatars3.githubusercontent.com/u/8496897?v=4","gravatar_id":"","url":"https://api.github.com/users/lannka","html_url":"https://github.com/lannka","followers_url":"https://api.github.com/users/lannka/followers","following_url":"https://api.github.com/users/lannka/following{/other_user}","gists_url":"https://api.github.com/users/lannka/gists{/gist_id}","starred_url":"https://api.github.com/users/lannka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lannka/subscriptions","organizations_url":"https://api.github.com/users/lannka/orgs","repos_url":"https://api.github.com/users/lannka/repos","events_url":"https://api.github.com/users/lannka/events{/privacy}","received_events_url":"https://api.github.com/users/lannka/received_events","type":"User","site_admin":false},"labels":[{"id":284397641,"url":"https://api.github.com/repos/ampproject/amphtml/labels/Category:%20Analytics","name":"Category: Analytics","color":"1d76db","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/ampproject/amphtml/milestones/20","html_url":"https://github.com/ampproject/amphtml/milestone/20","labels_url":"https://api.github.com/repos/ampproject/amphtml/milestones/20/labels","id":1884542,"number":20,"title":"Pending Triage","description":"These issues need to get put into another milestone. They should be assigned to the person who can best decide the appropriate milestone. Optionally, the issue can then be assigned to the most likely implementer.","creator":{"login":"rudygalfi","id":3888212,"avatar_url":"https://avatars3.githubusercontent.com/u/3888212?v=4","gravatar_id":"","url":"https://api.github.com/users/rudygalfi","html_url":"https://github.com/rudygalfi","followers_url":"https://api.github.com/users/rudygalfi/followers","following_url":"https://api.github.com/users/rudygalfi/following{/other_user}","gists_url":"https://api.github.com/users/rudygalfi/gists{/gist_id}","starred_url":"https://api.github.com/users/rudygalfi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rudygalfi/subscriptions","organizations_url":"https://api.github.com/users/rudygalfi/orgs","repos_url":"https://api.github.com/users/rudygalfi/repos","events_url":"https://api.github.com/users/rudygalfi/events{/privacy}","received_events_url":"https://api.github.com/users/rudygalfi/received_events","type":"User","site_admin":false},"open_issues":209,"closed_issues":278,"state":"open","created_at":"2016-07-14T23:13:22Z","updated_at":"2017-09-13T21:05:22Z","due_on":null,"closed_at":null},"comments":6,"created_at":"2017-09-06T23:34:51Z","updated_at":"2017-09-14T17:10:08Z","closed_at":null,"author_association":"COLLABORATOR","body":"Sample config to time the video play duration. (to quickly illustrate the idea, the video trigger spec is made up).\r\n```js\r\ntrigger: {\r\n  videoStarted: {\r\n    on: \"video-started\",\r\n    selector: \"#video-id\";\r\n    request: \"https://example.com/collect?video-started=TIMER(timer-id)\"\r\n  }\r\n  videoEnded: {\r\n    on: \"video-ended\",\r\n    selector: \"#video-id\";\r\n    request: \"https://example.com/collect?video-ended=TIMER(timer-id)\"\r\n  }\r\n}\r\n```\r\n\r\nIn the above example, an in-memory timer with ID `counter-id` is started on the videoPlayed trigger.\r\n\r\nThe request URLs will be resolved to\r\n```\r\nhttps://example.com/collect?video-started=0  // start trigger\r\nhttps://example.com/collect?video-ended=1025 // end trigger\r\n```\r\n\r\nIf needed, the function can have one extra optional param to pause/resume/reset the timer.\r\n```\r\nTIMER(id)            // to read the timer. \r\nTIMER(id,pause) // to pause the timer.\r\nTIMER(id,resume) // to resume the timer.\r\nTIMER(id,reset)    // to reset the timer.\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ampproject/amphtml/issues/comments/329548028","html_url":"https://github.com/ampproject/amphtml/issues/11194#issuecomment-329548028","issue_url":"https://api.github.com/repos/ampproject/amphtml/issues/11194","id":329548028,"user":{"login":"pomeroyr","id":31904167,"avatar_url":"https://avatars1.githubusercontent.com/u/31904167?v=4","gravatar_id":"","url":"https://api.github.com/users/pomeroyr","html_url":"https://github.com/pomeroyr","followers_url":"https://api.github.com/users/pomeroyr/followers","following_url":"https://api.github.com/users/pomeroyr/following{/other_user}","gists_url":"https://api.github.com/users/pomeroyr/gists{/gist_id}","starred_url":"https://api.github.com/users/pomeroyr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pomeroyr/subscriptions","organizations_url":"https://api.github.com/users/pomeroyr/orgs","repos_url":"https://api.github.com/users/pomeroyr/repos","events_url":"https://api.github.com/users/pomeroyr/events{/privacy}","received_events_url":"https://api.github.com/users/pomeroyr/received_events","type":"User","site_admin":false},"created_at":"2017-09-14T17:10:08Z","updated_at":"2017-09-14T17:10:08Z","author_association":"NONE","body":"@lannka Yes, we need client-side clock, and then only durations after that. What is the usecase for these variables you are proposing? Are we talking about writing pings like:\r\n\r\n<pre>\r\n'requests': {\r\n  'timerStart': 'https://mypingurl.com?timer=${timestamp}',\r\n  'timerContinue': 'https://mypingurl.com?timer=${batchInterval}',\r\n  'timerStop': 'https://mypingurl.com...' // how do we get intervals of timers which start and stop between the start and stop of the current batchInterval? Also, how do we know when to use which request?\r\n}\r\n</pre>\r\n\r\nSomething still needs to hold the state of the timer since batchInterval represents the state of the batch, not the timer. We A) need something that can change the ping parameters on timer state and B) need to do a tiny bit of math that would translate into (currentTime - lastBatchFlushTime) every batch flush.\r\n\r\nPerhaps doing this inside the URL is not the best place, but I don't think the batchSpec is the best place either. I would put this ability to query timer intervals in amp-analytics itself and the concept of timers, or simply its own component instead.\r\n\r\nMind you, a timer that can be turned on and off isn't necessarily dependent on a batching config. Some use cases may be happy with a constant interval and no batching."}}
{"actor":{"display_login":"pomeroyr"}}