Crashlytics implementation in ionic project

I have install Fabric Plugin for Cordova in my ionic 3 project but am not able to access fabric variable in my ts file to send crash report to portal.

Please provide a link to what you installed.
What is the “fabric variable” that you can’t access?

https://www.npmjs.com/package/cordova-fabric-plugin

I have installed cordova-fabric-plugin provided in above link.

Great.

But:

What happens if you access it?

As describe in above link for sending crash report to portal
window.fabric.Crashlytics.addLog(“about to send a crash for testing!”);
window.fabric.Crashlytics.sendCrash();

so fabric variable is not accessible on window

1 Like

Yeah, please excuse that I don’t read all that. It is somehow expected from people asking for help to include such information. Thanks.

How and where are you testing?
What is your ionic info output?

cli packages:

@ionic/cli-plugin-cordova       : 1.5.0 (C:\IonicWorkspace\MyIonicProject\node_modules\@ionic\cli-plugin-cordova)
@ionic/cli-plugin-ionic-angular : 1.4.0 (C:\IonicWorkspace\MyIonicProject\node_modules\@ionic\cli-plugin-ionic-angular)
@ionic/cli-utils                : 1.6.0 (C:\IonicWorkspace\MyIonicProject\node_modules\@ionic\cli-utils)
ionic (Ionic CLI)               : 3.6.0 (C:\IonicWorkspace\MyIonicProject\node_modules\ionic)

global packages:

Cordova CLI : 7.0.1

local packages:

@ionic/app-scripts : 2.1.3
Cordova Platforms  : android 6.2.3 ios 4.4.0
Ionic Framework    : ionic-angular 3.6.0

System:

Node : v6.9.4
OS   : Windows 7
npm  : 3.10.10

I m using visual studio code & m getting error at compile time only. so not able to test.

What error are you getting?
Try to run ionic build on the command line.

I am getting error dat fabric variable is not accessible on window. Same error with ionic build

Please just post the complete error text. Your paraphrase is not enough.

fabric

Actually it is a custom cordova plugin used in cordova-fabric-plugin . so can u tell me how to call that plgin in typescript file?

Put this between your imports and @IonicPage:

declare var window: any;

This way TS knows that window exists and can be worked with.

PS: Next time please post real text, not a screenshot. Thanks.

declare var window: any;
After declaring this no compile time error but
Getting TypeError: Cannot read property ‘Crashlytics’ of undefined at run time

Where exactly do you get that error?

You should probably wrap the plugin call into platform.ready to make sure the plugin is actually loaded.

affter adding “files”: [ “plugins/cordova-fabric-plugin/typings/cordova-fabric-plugin.d.ts” ] in my tsconfig.json file, m able to see crash on portal.
Thanks for help.

this plugin is not able to send crash report of typescript file crashes. will u pls suggest in this ?

I have no idea what you tried and what you are actually trying to do.

In type script code if i write fabric.Crashlytics.addLog(“about to send a crash for testing!”);
fabric.Crashlytics.sendCrash(); den this crash will register at fabric portal but if some type script code error occur den that crash is not reporting at portal.

so non-fatal errors are not registering at portal

You have to find a way to “catch” these errors and then call that Crashlytics method with its information. I would look into other crash reporting plugins for Ionic/Angular/Cordova how they do it.