From 56472754896d6e02a746b27f303f4345ebf6bf1f Mon Sep 17 00:00:00 2001 From: Philip Johnson Date: Fri, 19 Apr 2024 15:54:01 -0700 Subject: [PATCH] Add documentation for Javascript SDK This adds a number of new documents related to instructions for the JavaScript SDK. each has usage and installation docs. I also updated the routing for the menu so they are available. --- docs/browser/index.md | 7 +++ docs/browser/web-apps/index.md | 7 +++ docs/browser/web-apps/installation.md | 21 +++++++++ docs/browser/web-apps/usage.md | 55 ++++++++++++++++++++++ docs/browser/web-pages/index.md | 7 +++ docs/browser/web-pages/installation.md | 64 ++++++++++++++++++++++++++ docs/browser/web-pages/usage.md | 15 ++++++ docs/node/index.md | 7 +++ docs/node/installation.md | 21 +++++++++ docs/node/usage.md | 51 ++++++++++++++++++++ mkdocs.yml | 19 ++++++++ 11 files changed, 274 insertions(+) create mode 100644 docs/browser/index.md create mode 100644 docs/browser/web-apps/index.md create mode 100644 docs/browser/web-apps/installation.md create mode 100644 docs/browser/web-apps/usage.md create mode 100644 docs/browser/web-pages/index.md create mode 100644 docs/browser/web-pages/installation.md create mode 100644 docs/browser/web-pages/usage.md create mode 100644 docs/node/index.md create mode 100644 docs/node/installation.md create mode 100644 docs/node/usage.md diff --git a/docs/browser/index.md b/docs/browser/index.md new file mode 100644 index 0000000..72caf64 --- /dev/null +++ b/docs/browser/index.md @@ -0,0 +1,7 @@ +# AppFit for the Browser + +The Flutter SDK allows you to drop-in analytic tracking, direct to your AppFit project. + +## Getting Started + +Before you can start tracking events, you have to grab your API Key from your AppFit Dashboard diff --git a/docs/browser/web-apps/index.md b/docs/browser/web-apps/index.md new file mode 100644 index 0000000..c0cd999 --- /dev/null +++ b/docs/browser/web-apps/index.md @@ -0,0 +1,7 @@ +# AppFit for the Browser + +The AppFit Browser SDK allows you to drop-in analytic tracking, direct to your AppFit project. + +## Getting Started + +Before you can start tracking events, you have to grab your API Key from your AppFit Dashboard diff --git a/docs/browser/web-apps/installation.md b/docs/browser/web-apps/installation.md new file mode 100644 index 0000000..98254d4 --- /dev/null +++ b/docs/browser/web-apps/installation.md @@ -0,0 +1,21 @@ +# AppFit for JavaScript + +The JavaScript SDK allows you to drop-in analytic tracking, direct to your AppFit project. + +## Installation + +Install the SDK using NPM or Yarn. + +=== "NPM" + ```shell + npm install @uptechworks/appfit-browser-sdk + ``` + +=== "Yarn" + ```shell + yarn add @uptechworks/appfit-browser-sdk + ``` + +--- + +The AppFit SDK is Open Source. Find it on [GitHub here](https://github.com/uptech/appfit-javascript-sdk) diff --git a/docs/browser/web-apps/usage.md b/docs/browser/web-apps/usage.md new file mode 100644 index 0000000..88ba598 --- /dev/null +++ b/docs/browser/web-apps/usage.md @@ -0,0 +1,55 @@ +# Usage + +## Configuration & Tracking + +To configure the AppFit SDK, simply construct an `AppFitBrowserConfiguration` class and insert your API Key. + +Your API Key can be obtained from your AppFit Dashboard. + +```javascript +const appFitConfig = new AppFitBrowserConfiguration('API_KEY'); +``` + +This configuration should be passed to a new `AppFit` client: +```javascript +const appFitClient = new AppFit(appFitConfig); +``` + +Once you have the client constructed, tracking an event is as simple as calling `trackEvent`. + +A full example can be found below. + +```javascript +import { + AppFit, + AppFitBrowserConfiguration, +} from '@uptechworks/appfit-browser-sdk'; + +// Create the AppFitBrowserConfiguration +const config = new AppFitBrowserConfiguration("API_KEY"); + +// Create the AppFit Client +const appFitClient = new AppFit(config); + +// Use the client to track events +await appFitClient.trackEvent("event_name", { example: 'property' }); +``` + +## Identifying Users + +The AppFit SDK includes an identify call that you can use to identify users in your analytic events. +This method supports any String-based identifier. + +```javascript +appFitClient.identifyUser("USER_ID"); +``` + +Leaving out the user ID will remove all future events from including the id. + +```javascript +appFitClient.identifyUser(); +``` + +## Cached Events + +We cache all events locally in the SDK. This allows us to retry failed events. If a device is experiencing network issues, we will retry the saved events later to help avoid losing any metrics. diff --git a/docs/browser/web-pages/index.md b/docs/browser/web-pages/index.md new file mode 100644 index 0000000..936c3f9 --- /dev/null +++ b/docs/browser/web-pages/index.md @@ -0,0 +1,7 @@ +# AppFit for the Browser + +The JavaScript SDK allows you to drop-in analytic tracking, direct to your AppFit project. + +## Getting Started + +Before you can start tracking events, you have to grab your API Key from your AppFit Dashboard diff --git a/docs/browser/web-pages/installation.md b/docs/browser/web-pages/installation.md new file mode 100644 index 0000000..aaf42c7 --- /dev/null +++ b/docs/browser/web-pages/installation.md @@ -0,0 +1,64 @@ +# AppFit for JavaScript + +The JavaScript SDK allows you to drop-in analytic tracking, direct to your AppFit project. + +## How to install + +1. Install AppFit by pasting the following ` + ``` + +2. Be sure to **replace `YOUR_WRITE_KEY` with your API secret**, leaving in the quotation marks. Your API Key can be obtained from your AppFit Dashboard. + +3. Put any other AppFit ` + + + + + + + + +
+

Welcome to My Website

+
+ + +``` + +### How does it work? + +A ` +``` diff --git a/docs/node/index.md b/docs/node/index.md new file mode 100644 index 0000000..9202485 --- /dev/null +++ b/docs/node/index.md @@ -0,0 +1,7 @@ +# AppFit for Node + +The AppFit Node SDK allows you to drop-in analytic tracking, direct to your AppFit project. + +## Getting Started + +Before you can start tracking events, you have to grab your API Key from your AppFit Dashboard diff --git a/docs/node/installation.md b/docs/node/installation.md new file mode 100644 index 0000000..1d0651d --- /dev/null +++ b/docs/node/installation.md @@ -0,0 +1,21 @@ +# AppFit for JavaScript + +The JavaScript SDK allows you to drop-in analytic tracking, direct to your AppFit project. + +## Installing + +Install the SDK using NPM or Yarn. + +=== "NPM" + ```shell + npm install @uptechworks/appfit-browser-sdk + ``` + +=== "Yarn" + ```shell + yarn add @uptechworks/appfit-browser-sdk + ``` + +--- + +The AppFit SDK is Open Source. Find it on [GitHub here](https://github.com/uptech/appfit-javascript-sdk) diff --git a/docs/node/usage.md b/docs/node/usage.md new file mode 100644 index 0000000..9d69c09 --- /dev/null +++ b/docs/node/usage.md @@ -0,0 +1,51 @@ +# Usage + +## Configuration & Tracking + +To configure the AppFit SDK, simply construct an `AppFitServerConfiguration` class and insert your API Key. + +Your API Key can be obtained from your AppFit Dashboard. + +```javascript +const appFitConfig = new AppFitServerConfiguration('API_KEY'); +``` + +This configuration should be passed to a new `AppFit` client: +```javascript +const appFitClient = new AppFit(appFitConfig); +``` + +Once you have the client constructed, tracking an event is as simple as calling `trackEvent`. + +A full example can be found below. + +```javascript +import { + AppFit, + AppFitServerConfiguration, +} from '@uptechworks/appfit-node-sdk'; + +// Create the AppFitServerConfiguration +const config = new AppFitServerConfiguration("API_KEY"); + +// Create the AppFit Client +const appFitClient = new AppFit(config); + +// Use the client to track events +await appFitClient.trackEvent("event_name", { example: 'property' }); +``` + +## Identifying Users + +The AppFit SDK includes an identify call that you can use to identify users in your analytic events. +This method supports any String-based identifier. + +```javascript +appFitClient.identifyUser("USER_ID"); +``` + +Leaving out the user ID will remove all future events from including the id. + +```javascript +appFitClient.identifyUser(); +``` diff --git a/mkdocs.yml b/mkdocs.yml index c7d226a..d7cc168 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -36,11 +36,30 @@ nav: - kotlin/index.md - Installation: kotlin/installation.md - Usage: kotlin/usage.md + + # Browser + - Browser: + - browser/index.md + - Web Pages: + - browser/web-pages/index.md + - Installation: browser/web-pages/installation.md + - Usage: browser/web-pages/usage.md + - Web Apps: + - browser/web-apps/index.md + - Installation: browser/web-apps/installation.md + - Usage: browser/web-apps/usage.md + + # Node + - Node: + - node/index.md + - Installation: node/installation.md + - Usage: node/usage.md # SDK Links - Swift SDK: 'https://github.com/uptech/appfit-swift-sdk' - Flutter SDK: 'https://github.com/uptech/appfit-flutter-sdk' - Kotlin SDK: 'https://github.com/uptech/appfit-kotlin-sdk' + - JavaScript SDK: 'https://github.com/uptech/appfit-javascript-sdk' # Configuration theme: