Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit cf1858d

Browse files
#65 Feature: Crash Reporting
1 parent 89a3a22 commit cf1858d

File tree

10 files changed

+137
-117
lines changed

10 files changed

+137
-117
lines changed

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
<img src="docs/images/firebase-logo.png" width="116px" height="32px" alt="Firebase"/>
22

3+
## 3.4.2 (2016, July 14)
4+
5+
[Full changelog](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/compare/3.4.0...3.4.2)
6+
7+
### SDK versions
8+
If version numbers changed clean your platform folders to avoid build errors.
9+
10+
- iOS: 3.3.x
11+
- Android: 9.2.0
12+
13+
### New
14+
- [#61](#61) Added `keepInSync` for enhanced offline support.
15+
- [#65](#65) Crash Reporting, which is automatically enabled for you.
16+
17+
### Fixes
18+
- [#68](#68) Fix an issue where you'd log in on Android before `application.start()`.
19+
- [#70](#70) Added a TypeScript definition for `getCurrentUser()`.
20+
- [#71](#71) Added a TypeScript definition for LoginResult.email.
21+
22+
23+
324
## 3.4.0 (2016, July 7)
425

526
[Full changelog](https://github.com/EddyVerbruggen/nativescript-plugin-firebase/compare/3.3.0...3.4.0)

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ For readability the supported features have been moved to their own README's:
1111
* [Authentication](docs/AUTHENTICATION.md)
1212
* [Remote Config](docs/REMOTECONFIG.md)
1313
* [Cloud Messaging](docs/MESSAGING.md)
14-
* [Storage ](docs/STORAGE.md)
14+
* [Storage](docs/STORAGE.md)
15+
* [Crash Reporting](docs/CRASHREPORTING.md)
1516

1617
## Prerequisites
1718
Head on over to [https://console.firebase.google.com/](https://console.firebase.google.com/) and sign up for a free account.

docs/CRASHREPORTING.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<img src="images/firebase-logo.png" width="116px" height="32px" alt="Firebase"/>
2+
3+
## Enabling Remote Config
4+
Since plugin version 3.2.0 you can retrieve _Remote Config_ properties.
5+
This feature lets you configure parameters in your Firebase instance like these:
6+
7+
<img src="images/remote-config.png" width="500px" height="482px" alt="Remote Config"/>
8+
9+
To enable support for Remote Config you need to manually adjust
10+
[Podfile](../platforms/ios/Podfile) and [include.gradle](../platforms/android/include.gradle).
11+
12+
Just uncomment the relevant lines (one for each platform) to add the SDK's to your app.
13+
14+
## Functions
15+
16+
### getRemoteConfig
17+
Using this function you can retrieve the current values of the remote properties so you can change app behavior on the fly easily (feature toggles for instance).
18+
19+
```js
20+
firebase.getRemoteConfig({
21+
developerMode: false, // play with this boolean to get more frequent updates during development
22+
cacheExpirationSeconds: 600, // 10 minutes, default is 12 hours.. set to a lower value during dev
23+
properties: [{
24+
key: "holiday_promo_enabled",
25+
default: false
26+
},
27+
{
28+
key: "coupons_left",
29+
default: 100
30+
},
31+
{
32+
key: "double_or_nothing",
33+
default: 9.99
34+
}]
35+
}).then(
36+
function (result) {
37+
console.log("Remote Config last fetched at " + result.lastFetch);
38+
console.log("Remote Config: " + JSON.stringify(result.properties));
39+
console.log("Remote Config property 'coupons_left': " + result.properties.coupons_left);
40+
}
41+
);
42+
```

docs/STORAGE.md

Lines changed: 9 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,118 +1,13 @@
11
<img src="images/firebase-logo.png" width="116px" height="32px" alt="Firebase"/>
22

3-
## Enabling Storage
4-
Since plugin version 3.4.0 you can use Firebase _Storage_ features.
3+
## Enabling Crash Reporting
4+
Nothing to do - since plugin version 3.4.2 this plugin automatically uploads
5+
crashes to your Firebase Console. Just check the 'Crash' menu item every now and then.
56

6-
_Storage_ lets you upload and download files to/from Google Cloud Storage which is connected to your Firebase instance.
7+
## Making sense of the stacktraces
8+
Please read [the official docs](https://firebase.google.com/docs/crash/)
9+
on what Crash reporting is and what you can do to have a better experience.
710

8-
To enable support for Remote Config you need to manually adjust
9-
[Podfile](../platforms/ios/Podfile) and [include.gradle](../platforms/android/include.gradle).
10-
11-
Just uncomment the relevant lines (one for each platform) to add the SDK's to your app.
12-
13-
### Setting the storage bucket
14-
You need to tell Firebase what your storage bucket is. You can retrieve it
15-
from the Firebase console by pressing 'Storage' in the menu.
16-
17-
You can either pass it to the `init()` function as shown below,
18-
or pass it as a property any time you're using a storage feature.
19-
In theory the former is a little more efficient because it's cached by the plugin.
20-
21-
```js
22-
firebase.init({
23-
storageBucket: 'gs://n-plugin-test.appspot.com'
24-
// any other options
25-
});
26-
```
27-
28-
## Functions
29-
30-
### uploadFile
31-
You can either pass in a full local path to a file, or (as a convenience) use the `file-system` module that comes shipped with {N} as standard.
32-
33-
```js
34-
// init the file-system module
35-
var fs = require("file-system");
36-
37-
// grab a reference to the app folder
38-
var appPath = fs.knownFolders.currentApp().path;
39-
40-
// determine the path to a file in the app/res folder
41-
var logoPath = appPath + "/res/telerik-logo.png";
42-
43-
// now upload the file with either of the options below:
44-
firebase.uploadFile({
45-
// optional, can also be passed during init() as 'storageBucket' param so we can cache it (find it in the Firebase console)
46-
bucket: 'gs://n-plugin-test.appspot.com',
47-
// the full path of the file in your Firebase storage (folders will be created)
48-
remoteFullPath: 'uploads/images/telerik-logo-uploaded.png',
49-
// option 1: a file-system module File object
50-
localFile: fs.File.fromPath(logoPath),
51-
// option 2: a full file path (ignored if 'localFile' is set)
52-
localFullPath: logoPath
53-
}).then(
54-
function (uploadedFile)
55-
console.log("File uploaded: " + JSON.stringify(uploadedFile));
56-
},
57-
function (error) {
58-
console.log("File upload error: " + error);
59-
};
60-
);
61-
```
62-
63-
### downloadFile
64-
As with `uploadFile` you can either pass in a full local path to a file, or (as a convenience) use the `file-system` module that comes shipped with {N} as standard.
65-
66-
In this example we'll download the previously uploaded file to a certain path on the local filesystem.
67-
68-
```js
69-
// init the file-system module
70-
var fs = require("file-system");
71-
72-
// let's first determine where we'll create the file using the 'file-system' module
73-
var documents = fs.knownFolders.documents();
74-
var logoPath = documents.path + "/telerik-logo-downloaded.png";
75-
76-
// this will create or overwrite a local file in the app's documents folder
77-
var localLogoFile = documents.getFile("telerik-logo-downloaded.png");
78-
79-
// now download the file with either of the options below:
80-
firebase.downloadFile({
81-
// optional, can also be passed during init() as 'storageBucket' param so we can cache it
82-
bucket: 'gs://n-plugin-test.appspot.com',
83-
// the full path of an existing file in your Firebase storage
84-
remoteFullPath: 'uploads/images/telerik-logo-uploaded.png',
85-
// option 1: a file-system module File object
86-
localFile: fs.File.fromPath(logoPath),
87-
// option 2: a full file path (ignored if 'localFile' is set)
88-
localFullPath: logoPath
89-
}).then(
90-
function (uploadedFile)
91-
console.log("File downloaded to the requested location");
92-
},
93-
function (error) {
94-
console.log("File download error: " + error);
95-
};
96-
);
97-
```
98-
99-
### getDownloadUrl
100-
If you just want to know the remote URL of a file in remote storage so you can either share it or download the file by any other means than `downloadFile` then use this method.
101-
102-
In this example we'll determine the remote URL of the previously uploaded file.
103-
104-
```js
105-
firebase.getDownloadUrl({
106-
// optional, can also be passed during init() as 'storageBucket' param so we can cache it
107-
bucket: 'gs://n-plugin-test.appspot.com',
108-
// the full path of an existing file in your Firebase storage
109-
remoteFullPath: 'uploads/images/telerik-logo-uploaded.png'
110-
}).then(
111-
function (url)
112-
console.log("Remote URL: " + url);
113-
},
114-
function (error) {
115-
console.log("Error: " + error);
116-
};
117-
);
118-
```
11+
## Future work
12+
There's an option to send logs to Firebase along with the crash in order
13+
to add some context. This is however currently problematic on iOS but we'll keep an eye out.

firebase.android.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,4 +1040,29 @@ firebase.getDownloadUrl = function (arg) {
10401040
});
10411041
};
10421042

1043+
/*
1044+
firebase.sendCrashLog = function (arg) {
1045+
return new Promise(function (resolve, reject) {
1046+
try {
1047+
1048+
if (typeof(com.google.firebase.crash) === "undefined") {
1049+
reject("Make sure firebase-crash is in the plugin's include.gradle");
1050+
return;
1051+
}
1052+
1053+
if (!arg.log) {
1054+
reject("The mandatory 'log' argument is missing");
1055+
return;
1056+
}
1057+
1058+
com.google.firebase.crash.FirebaseCrash.log(arg.log);
1059+
resolve();
1060+
} catch (ex) {
1061+
console.log("Error in firebase.sendCrashLog: " + ex);
1062+
reject(ex);
1063+
}
1064+
});
1065+
};
1066+
*/
1067+
10431068
module.exports = firebase;

firebase.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,4 +344,7 @@ declare module "nativescript-plugin-firebase" {
344344
export function uploadFile(options: UploadFileOptions): Promise<UploadFileResult>;
345345
export function downloadFile(options: DownloadFileOptions): Promise<any>;
346346
export function getDownloadUrl(options: GetDownloadUrlOptions): Promise<string>;
347+
348+
// crash logging
349+
// export function sendCrashLog(options: SendCrashLogOptions): Promise<any>;
347350
}

firebase.ios.js

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ firebase.getCurrentUser = function (arg) {
423423
email: user.email,
424424
emailVerified: user.emailVerified,
425425
name: user.displayName,
426-
refreshToken: user.refreshToken
426+
refreshToken: user.refreshToken,
427427
});
428428
} else {
429429
reject();
@@ -462,6 +462,7 @@ function toLoginResult(user) {
462462

463463
firebase.login = function (arg) {
464464
return new Promise(function (resolve, reject) {
465+
465466
try {
466467
var onCompletion = function(user, error) {
467468
if (error) {
@@ -1029,4 +1030,34 @@ firebase.getDownloadUrl = function (arg) {
10291030
});
10301031
};
10311032

1033+
/* disabled since FIRCrashLog is always undefined
1034+
firebase.sendCrashLog = function (arg) {
1035+
return new Promise(function (resolve, reject) {
1036+
try {
1037+
1038+
if (typeof(FIRCrashLog) === "undefined") {
1039+
reject("Make sure 'Firebase/Crash' is in the plugin's Podfile");
1040+
return;
1041+
}
1042+
1043+
if (!arg.log) {
1044+
reject("The mandatory 'log' argument is missing");
1045+
return;
1046+
}
1047+
1048+
if (showInConsole) {
1049+
FIRCrashNSLog(arg.log);
1050+
} else {
1051+
FIRCrashLog(arg.log);
1052+
}
1053+
1054+
resolve();
1055+
} catch (ex) {
1056+
console.log("Error in firebase.sendCrashLog: " + ex);
1057+
reject(ex);
1058+
}
1059+
});
1060+
};
1061+
*/
1062+
10321063
module.exports = firebase;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-plugin-firebase",
3-
"version": "3.4.1",
3+
"version": "3.4.2",
44
"description" : "Fire. Base. Firebase!",
55
"main" : "firebase.js",
66
"nativescript": {

platforms/android/include.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ dependencies {
1717
compile "com.google.firebase:firebase-core:9.2.0"
1818
compile "com.google.firebase:firebase-database:9.2.0"
1919
compile "com.google.firebase:firebase-auth:9.2.0"
20+
compile "com.google.firebase:firebase-crash:9.2.0"
2021

2122
// for reading google-services.json and configuration
2223
compile "com.google.android.gms:play-services-base:9.2.0"

platforms/ios/Podfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
pod 'Firebase', '~> 3.3.0'
33
pod 'Firebase/Database'
44
pod 'Firebase/Auth'
5+
pod 'Firebase/Crash'
56

67
# Uncomment if you want to enable Remote Config
78
#pod 'Firebase/RemoteConfig'

0 commit comments

Comments
 (0)