Skip to content

Commit e88c04e

Browse files
committed
Updates README and events specific public API functions
1 parent 3795f24 commit e88c04e

8 files changed

+73
-7
lines changed

README.md

+35-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Store the bugsense.js file along with you other Javascript files. Alternatively you can use the BugSense hosted version (see the following snippet). Then, instanciate the plugin with the API key from your project:
88

99
```html
10-
<script src="http://www.bugsense.com/static/js/global/bugsense.js" type='text/javascript'></script>
10+
<script src="path/to/vendor/bugsense.js" type='text/javascript'></script>
1111
<script type="text/javascript">
1212
// You will find the API KEY in your BugSense Dashboard
1313
Bugsense.initAndStartSession({ apiKey: 'YOUR_API_KEY' });
@@ -43,7 +43,7 @@ default: ```{String} null```
4343

4444
default: ```{Boolean} false```
4545

46-
**```sessionTimeout```** - The expiration time after each sessios expire.
46+
**```sessionTimeout```** - The time after each sessios expire.
4747

4848
default: ```{Number} 300000```
4949

@@ -99,18 +99,48 @@ Bugsense.clearBreadcrumbs();
9999

100100
----
101101

102-
## Registering events
102+
## Sending Events
103+
104+
Bugsense.js can help you gather insights about your application. You can send events to BugSense service and analyze them using our Dashboard (Insights, Realtime page etc.)
105+
106+
### Ping event
107+
108+
You can use the following method the send a `ping` event (start of session) to BugSense.
109+
110+
```js
111+
Bugsense.startSession();
112+
```
113+
114+
### Gnip event
115+
116+
You can use the following method the send a `gnip` event (end of session) to BugSense.
117+
```js
118+
Bugsense.closeSession();
119+
```
120+
121+
> **Important!** We suggest that you let bugsense.js handle `ping` and `gnip` events, or if you need to configure how often your sessions last, customize SDK's behaviour by setting the `sessionTimeout` option in `Bugsense.initAndStartSession` function.
122+
123+
### Custom events
124+
125+
If you want to log custom events, use the `sendEvent(String)` as following:
126+
127+
```js
128+
Bugsense.sendEvent("button clicked");
129+
Bugsense.sendEvent("shopping cart empty");
130+
```
131+
132+
## Registering crash callback
103133
Bugsense.js provides an easy way for developers to use events in order to handle crashes more effectively.
104134

105135
```js
106136
function ooops() {
107137
alert('Ooops! Our app just crashed. Please send us an email at [email protected]');
108138
}
109-
bugsense.on("crash", ooops);
139+
Bugsense.on("crash", ooops);
110140
```
111141
When this is done, you can unregister the event to avoid spamming your users with countless alerts of notifications.
112142
```js
113-
bugsense.off("crash", ooops);
143+
Bugsense.off("crash", ooops);
114144
```
115145

116146
----

lib/amd/bugsense.js

+6
Original file line numberDiff line numberDiff line change
@@ -1664,9 +1664,15 @@
16641664
Bugsense.Sessions.ping();
16651665
document.addEventListener("pause", this.closeSession, false);
16661666
},
1667+
startSession: function () {
1668+
return Bugsense.Sessions.ping();
1669+
},
16671670
closeSession: function () {
16681671
return BugSense.Sessions.gnip();
16691672
},
1673+
sendEvent: function (type) {
1674+
return Bugsense.event(type);
1675+
},
16701676
get: function(attribute) {
16711677
return Bugsense.config[attribute] || 'unknown';
16721678
},

lib/amd/bugsense.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/bugsense.js

+6
Original file line numberDiff line numberDiff line change
@@ -1654,9 +1654,15 @@ window.Bugsense = (function(){
16541654
Bugsense.Sessions.ping();
16551655
document.addEventListener("pause", this.closeSession, false);
16561656
},
1657+
startSession: function () {
1658+
return Bugsense.Sessions.ping();
1659+
},
16571660
closeSession: function () {
16581661
return BugSense.Sessions.gnip();
16591662
},
1663+
sendEvent: function (type) {
1664+
return Bugsense.event(type);
1665+
},
16601666
get: function(attribute) {
16611667
return Bugsense.config[attribute] || 'unknown';
16621668
},

lib/bugsense.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

specs/build/specs.js

+9
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ describe('Bugsense::Instance', function () {
1010
expect(typeof(Bugsense.addExtraData)).toBe('function');
1111
expect(typeof(Bugsense.clearBreadcrumbs)).toBe('function');
1212
expect(typeof(Bugsense.clearExtraData)).toBe('function');
13+
expect(typeof(Bugsense.startSession)).toBe('function');
14+
expect(typeof(Bugsense.closeSession)).toBe('function');
15+
expect(typeof(Bugsense.sendEvent)).toBe('function');
1316
expect(typeof(Bugsense.Network.getCrashURL)).toBe('function');
1417
expect(typeof(Bugsense.Network.getTicksURL)).toBe('function');
1518
expect(typeof(Bugsense.leaveBreadcrumb)).toBe('function');
@@ -20,6 +23,12 @@ describe('Bugsense::Instance', function () {
2023
expect(typeof(Bugsense.Cache.update)).toBe('function');
2124
expect(typeof(Bugsense.Cache.save)).toBe('function');
2225
expect(typeof(Bugsense.Cache.retrieve)).toBe('function');
26+
expect(typeof(Bugsense.Sessions.ping)).toBe('function');
27+
expect(typeof(Bugsense.Sessions.gnip)).toBe('function');
28+
expect(typeof(Bugsense.Sessions.event)).toBe('function');
29+
expect(typeof(Bugsense.Sessions.createFlatline)).toBe('function');
30+
expect(typeof(Bugsense.Sessions.validSession)).toBe('function');
31+
expect(typeof(Bugsense.Sessions.generateUid)).toBe('function');
2332
});
2433
})
2534
describe('Bugsense::Configuration', function () {

specs/instanceSpecs.js

+9
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ describe('Bugsense::Instance', function () {
1010
expect(typeof(Bugsense.addExtraData)).toBe('function');
1111
expect(typeof(Bugsense.clearBreadcrumbs)).toBe('function');
1212
expect(typeof(Bugsense.clearExtraData)).toBe('function');
13+
expect(typeof(Bugsense.startSession)).toBe('function');
14+
expect(typeof(Bugsense.closeSession)).toBe('function');
15+
expect(typeof(Bugsense.sendEvent)).toBe('function');
1316
expect(typeof(Bugsense.Network.getCrashURL)).toBe('function');
1417
expect(typeof(Bugsense.Network.getTicksURL)).toBe('function');
1518
expect(typeof(Bugsense.leaveBreadcrumb)).toBe('function');
@@ -20,6 +23,12 @@ describe('Bugsense::Instance', function () {
2023
expect(typeof(Bugsense.Cache.update)).toBe('function');
2124
expect(typeof(Bugsense.Cache.save)).toBe('function');
2225
expect(typeof(Bugsense.Cache.retrieve)).toBe('function');
26+
expect(typeof(Bugsense.Sessions.ping)).toBe('function');
27+
expect(typeof(Bugsense.Sessions.gnip)).toBe('function');
28+
expect(typeof(Bugsense.Sessions.event)).toBe('function');
29+
expect(typeof(Bugsense.Sessions.createFlatline)).toBe('function');
30+
expect(typeof(Bugsense.Sessions.validSession)).toBe('function');
31+
expect(typeof(Bugsense.Sessions.generateUid)).toBe('function');
2332
});
2433
})
2534
describe('Bugsense::Configuration', function () {

src/core.js

+6
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,15 @@ window.Bugsense = (function(){
2525
Bugsense.Sessions.ping();
2626
document.addEventListener("pause", this.closeSession, false);
2727
},
28+
startSession: function () {
29+
return Bugsense.Sessions.ping();
30+
},
2831
closeSession: function () {
2932
return BugSense.Sessions.gnip();
3033
},
34+
sendEvent: function (type) {
35+
return Bugsense.event(type);
36+
},
3137
get: function(attribute) {
3238
return Bugsense.config[attribute] || 'unknown';
3339
},

0 commit comments

Comments
 (0)