Skip to content

Commit

Permalink
Added test file for the type definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Unterreiner committed Feb 18, 2016
1 parent 8ba69fa commit e52a92f
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 12 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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("[email protected]");
window.fabric.crashlytics.setStringValueForKey("bar", "foo");
window.fabric.Crashlytics.setUserIdentifier("123");
window.fabric.Crashlytics.setUserName("Some Guy");
window.fabric.Crashlytics.setUserEmail("[email protected]");
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)
Expand All @@ -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
Expand Down
95 changes: 95 additions & 0 deletions typings/cordova-fabric-plugin-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/// <reference path="cordova-fabric-plugin.d.ts" />

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("[email protected]");

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" });
6 changes: 3 additions & 3 deletions typings/cordova-fabric-plugin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit e52a92f

Please sign in to comment.