diff --git a/README.md b/README.md index 1f00935..23d036b 100755 --- a/README.md +++ b/README.md @@ -40,21 +40,21 @@ Below are a few examples; see the API documentation for a complete list. ## Simulate a native crash ```javascript -window.fabric.crashlytics.addLog("about to send a crash for testing!"); -window.fabric.crashlytics.sendCrash(); +window.fabric.Crashlytics.addLog("about to send a crash for testing!"); +window.fabric.Crashlytics.sendCrash(); ``` ## Set information for crash reports ```javascript -window.fabric.crashlytics.setUserIdentifier("123"); -window.fabric.crashlytics.setUserName("Some Guy"); -window.fabric.crashlytics.setUserEmail("some.guy@email.com"); -window.fabric.crashlytics.setStringValueForKey("bar", "foo"); +window.fabric.Crashlytics.setUserIdentifier("123"); +window.fabric.Crashlytics.setUserName("Some Guy"); +window.fabric.Crashlytics.setUserEmail("some.guy@email.com"); +window.fabric.Crashlytics.setStringValueForKey("bar", "foo"); ``` ## Send a Sign Up event ```javascript -window.fabric.answers.sendSignUp("Facebook", true); +window.fabric.Answers.sendSignUp("Facebook", true); ``` ## Send a Sign Up event (with custom attributes) @@ -64,12 +64,12 @@ var attributes = { bar: true, }; -window.fabric.answers.sendSignUp("Facebook", true, attributes); +window.fabric.Answers.sendSignUp("Facebook", true, attributes); ``` ## Send a Add To Cart event ```javascript -window.fabric.answers.sendAddToCart(29.95, "USD", "Foo Bar Shirt", "apparel", "123"); +window.fabric.Answers.sendAddToCart(29.95, "USD", "Foo Bar Shirt", "apparel", "123"); ``` # Notes diff --git a/typings/cordova-fabric-plugin-tests.ts b/typings/cordova-fabric-plugin-tests.ts new file mode 100644 index 0000000..1a4aed5 --- /dev/null +++ b/typings/cordova-fabric-plugin-tests.ts @@ -0,0 +1,95 @@ +/// + +var fabricApi: FabricPlugin.FabricPluginStatic = fabric; +var answersApi: FabricPlugin.Answers = fabric.Answers; +var crashlyticsApi: FabricPlugin.Crashlytics = fabric.Crashlytics; + +fabric.Crashlytics.addLog("Message"); + +fabric.Crashlytics.sendCrash(); + +fabric.Crashlytics.sendNonFatalCrash("Error"); + +fabric.Crashlytics.setUserIdentifier("123"); + +fabric.Crashlytics.setUserName("bob"); + +fabric.Crashlytics.setUserEmail("bob@email.com"); + +fabric.Crashlytics.setStringValueForKey("value", "key"); + +fabric.Crashlytics.setIntValueForKey(1, "key"); + +fabric.Crashlytics.setBoolValueForKey(true, "key"); + +fabric.Crashlytics.setFloatValueForKey(1.1, "key"); + +fabric.Answers.sendPurchase(); +fabric.Answers.sendPurchase(24.95); +fabric.Answers.sendPurchase(24.95, "USD"); +fabric.Answers.sendPurchase(24.95, "USD", true); +fabric.Answers.sendPurchase(24.95, "USD", true, "Foo Bar Shirt"); +fabric.Answers.sendPurchase(24.95, "USD", true, "Foo Bar Shirt", "apparel"); +fabric.Answers.sendPurchase(24.95, "USD", true, "Foo Bar Shirt", "apparel", "123"); +fabric.Answers.sendPurchase(24.95, "USD", true, "Foo Bar Shirt", "apparel", "123", { "key": "value" }); + +fabric.Answers.sendAddToCart(); +fabric.Answers.sendAddToCart(24.95); +fabric.Answers.sendAddToCart(24.95, "USD"); +fabric.Answers.sendAddToCart(24.95, "USD", "Foo Bar Shirt"); +fabric.Answers.sendAddToCart(24.95, "USD", "Foo Bar Shirt", "apparel"); +fabric.Answers.sendAddToCart(24.95, "USD", "Foo Bar Shirt", "apparel", "123"); +fabric.Answers.sendAddToCart(24.95, "USD", "Foo Bar Shirt", "apparel", "123", { "key": "value" }); + +fabric.Answers.sendStartCheckout(); +fabric.Answers.sendStartCheckout(24.95); +fabric.Answers.sendStartCheckout(24.95, "USD", 2); +fabric.Answers.sendStartCheckout(24.95, "USD", 2, { "key": "value" }); + +fabric.Answers.sendSearch("query"); +fabric.Answers.sendSearch("query", { "key": "value" }); + +fabric.Answers.sendShare(); +fabric.Answers.sendShare("Facebook"); +fabric.Answers.sendShare("Facebook", "Foo Bar Shirt"); +fabric.Answers.sendShare("Facebook", "Foo Bar Shirt", "apparel"); +fabric.Answers.sendShare("Facebook", "Foo Bar Shirt", "apparel", "123"); +fabric.Answers.sendShare("Facebook", "Foo Bar Shirt", "apparel", "123", { "key": "value" }); + +fabric.Answers.sendRatedContent(); +fabric.Answers.sendRatedContent(5); +fabric.Answers.sendRatedContent(5, "Foo Bar Shirt"); +fabric.Answers.sendRatedContent(5, "Foo Bar Shirt", "apparel"); +fabric.Answers.sendRatedContent(5, "Foo Bar Shirt", "apparel", "123", { "key": "value" }); + +fabric.Answers.sendSignUp(); +fabric.Answers.sendSignUp("Facebook"); +fabric.Answers.sendSignUp("Facebook", true); +fabric.Answers.sendSignUp("Facebook", true, { "key": "value" }); + +fabric.Answers.sendLogIn(); +fabric.Answers.sendLogIn("Facebook"); +fabric.Answers.sendLogIn("Facebook", true); +fabric.Answers.sendLogIn("Facebook", true, { "key": "value" }); + +fabric.Answers.sendInvite(); +fabric.Answers.sendInvite("Facebook"); +fabric.Answers.sendInvite("Facebook", { "key": "value" }); + +fabric.Answers.sendLevelStart(); +fabric.Answers.sendLevelStart("Chemical Plant Zone - Act 1"); +fabric.Answers.sendLevelStart("Chemical Plant Zone - Act 1", { "key": "value" }); + +fabric.Answers.sendLevelEnd(); +fabric.Answers.sendLevelEnd(""); +fabric.Answers.sendLevelEnd("", 9000); +fabric.Answers.sendLevelEnd("", 9000, true); +fabric.Answers.sendLevelEnd("", 9000, true, { "key": "value" }); + +fabric.Answers.sendContentView("Home"); +fabric.Answers.sendContentView("Home", "Page"); +fabric.Answers.sendContentView("Home", "Page", "123"); +fabric.Answers.sendContentView("Home", "Page", "123", { "key": "value" }); + +fabric.Answers.sendCustomEvent("My Event"); +fabric.Answers.sendCustomEvent("My Event", { "key": "value" }); diff --git a/typings/cordova-fabric-plugin.d.ts b/typings/cordova-fabric-plugin.d.ts index c55f4db..67b81ef 100644 --- a/typings/cordova-fabric-plugin.d.ts +++ b/typings/cordova-fabric-plugin.d.ts @@ -244,19 +244,19 @@ declare module FabricPlugin { * * https://docs.fabric.io/android/answers/answers-events.html#content-view */ - sendContentView(name: string, type: string, id: string, attributes: Attributes): void; + sendContentView(name: string, type?: string, id?: string, attributes?: Attributes): void; /** * Shortcut for sendContentView(...) using type of "Screen". */ - sendScreenView(name: string, id: string, attributes: Attributes): void; + sendScreenView(name: string, id: string, attributes?: Attributes): void; /** * Send a custom tracking event with the given name. * * https://docs.fabric.io/android/answers/answers-events.html#custom-event */ - sendCustomEvent(name: string, attributes: Attributes): void; + sendCustomEvent(name: string, attributes?: Attributes): void; } /**