Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

How to retrieve the results from js and how store those values in sobject? #50

Open
wants to merge 1,589 commits into
base: master
Choose a base branch
from

Conversation

vijaykumarvemula
Copy link

I wrote the small javascript code in visualforce page by using boomerang tool. It shows the result in same page. I want to store the result in sobject. can any one tell me how to store the data? here i am giving my sample code.

<apex:page >

<title>Boomerang Exp</title> <script src="/resource/1427268234000/boomeranexp"></script> <script type="text/javascript"> BOOMR.init({ beacon_url: "https://sfdc.com/resource/1427275857000/beaconresult", site_domain: "https://sfdc.com", user_ip: "203.129.222.211", }); BOOMR.subscribe('before_beacon', function (o) { var html = "", t_name, t_other, others = []; if (!o.t_other) o.t_other = ""; for (var k in o) { if (!k.match(/^(t_done|t_other|bw|lat|bw_err|lat_err|u|r2?)$/)) { if (k.match(/^t_/)) { o.t_other += "," + k + "|" + o[k]; } else { others.push(k + " = " + o[k]); } } } if (o.t_done) { html += "This page took " + o.t_done + " ms to load
"; } if (o.t_other) { t_other = o.t_other.replace(/^,/, '').replace(/\|/g, ' = ').split(','); html += "Other timers measured:
"; for (var i = 0; i < t_other.length; i++) { html += "   " + t_other[i] + " ms
"; } } if (o.bw) { html += "Your bandwidth to this server is " + parseInt(o.bw * 8 / 1024) + "kbps (±" + parseInt(o.bw_err * 100 / o.bw) + "%)
"; } if (o.lat) { html += "Your latency to this server is " + parseInt(o.lat) + "±" + o.lat_err + "ms
"; } var r = document.getElementById('results'); r.innerHTML = html; if (others.length) { r.innerHTML += "Other parameters:
"; for (var i = 0; i < others.length; i++) { var t = document.createTextNode(others[i]); r.innerHTML += "   "; r.appendChild(t); r.innerHTML += "
"; } } }); </script>

Boomerang Example:

/apex:page

my result is

This page took 21 ms to load
Other timers measured:
boomerang = 2 ms
boomr_fb = 16 ms
t_resp = 0 ms
t_page = 21 ms
Your latency to this server is 1±0.32ms
Other parameters:
rt.start = navigation
rt.bstart = 1427280303553
rt.end = 1427280303558
bw_time = 1427280304

I want to store at-least one value, example page loading time.

bluesmoon added a commit to bluesmoon/boomerang that referenced this pull request Apr 2, 2015
Optional parameter to await completion in bandwidth plugin before sending beacon
Conflicts:
	doc/api/BW.html
Charles Vazac and others added 29 commits August 7, 2015 14:18
bluesmoon pushed a commit to bluesmoon/boomerang that referenced this pull request Mar 8, 2017
nicjansma and others added 21 commits May 2, 2017 09:30
Without the compression plugin, you can't directly try to access
Compression.jsUrl and must first check for Compression itself. And
getErrorsForUrl should return the serialized errors.
When using the User Timing API plugin, only the first beacon sent will
include User Timing API data. Susbsequent beacons will not collect newly
set User Timing API data due to comparing incorrect timestamps.

To reproduce:

1. Add code to a test page running Boomerang. Something like the
   following would suffice:

   ```
   performance.mark('pre-load-mark');

   addEventListener('load', () => {
     setTimeout(() => {
       console.log('marking');
       performance.mark('post-load-mark');
     }, 5000);
   });
   ```

2. Load the page with Boomerang, the User Timing API plugin and the sample
   code

3. After the `load` event fires, inspect the Network tab to see that a
   beacon was sent with the User Timing API data, including the
   'pre-load-mark' mark. The 'post-load-mark' should not be present.

4. Fire another beacon from the console  with:
   `BOOMR.requestStart('test').loaded();`

5. Notice that the expected 'post-load-mark' is not present in the
   beacon.

On line [41 in plugins/usertiming.js](https://github.com/SOASTA/boomerang/blob/master/plugins/usertiming.js#L41),
the `from` value is set to `BOOMR.now()`. This value is a millisecond
timestamp derived from `Date.now()`. When subsequent beacons are fired,
the mark/measure's `startTime + `duration` is [compared](https://github.com/nicjansma/usertiming-compression.js/blob/master/src/usertiming-compression.js#L388)
to the `from` timestamp. Since the mark/measure is using
`performance.now()` instead of `Date.now()` to set the time, the value
will always be less than the `Date.now()` timestamp. Thus, the data is
considered old and is removed from the compressed data.

The fix for the issue is to use `performance.now()` instead of
`Date.now()` when setting the `from` value. Since this function isn't
called unless the User Timing API is available, it should be safe to
directly call `performance.now()` without any defensive coding.
* Add support for Network Information API

The Network API is a revision of the `navigator.connection` interface
that attempts to provide a standard, cross-browser interface to access
information about network conditions. This commit updates the mobile
plugin to source network information from the newer source where
available.

This plugin works by first trying to find connection information from
various places depending on the browser. It then tries to map data from
the identified interface to variables that have historically been used
by Boomerang. Effectively, this commit simply makes Boomerang aware of
the new locations of information from the Network Information API.

Credit for this work goes to @bluesmoon, with assistance from @tollmanz
to verify and write tests.

* Rewrite mobile.js as a Boomerang plugin

The mobile.js plugin was not previously written as a plugin. This
commit updates the code to make it a plugin and implement the same
interface as other plugins. This allows for disabling the plugin as
needed and initializing the plugin in a consistent manner.

This commit also adds the `saveData` value from the Network Information
API if it is available.

* Use bind to set correct this

* Remove bind for cross-browser compat

* Validate type of variable before adding to beacon
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet