Skip to content

Commit

Permalink
Update Documentation
Browse files Browse the repository at this point in the history
This updates the documentation and cleans up some typos as well. This
also ensures we are using the same naming accross SDK's for things like
`API_KEY` and `USER_ID`.
  • Loading branch information
anthonycastelli committed Apr 24, 2024
1 parent c580d44 commit 32a952d
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 42 deletions.
2 changes: 1 addition & 1 deletion docs/browser/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# AppFit for the Browser

The Flutter SDK allows you to drop-in analytic tracking, direct to your AppFit project.
The Browser SDK allows you to drop-in analytic tracking, direct to your AppFit project.

## Getting Started

Expand Down
7 changes: 4 additions & 3 deletions docs/browser/web-apps/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ To configure the AppFit SDK, simply construct an `AppFitBrowserConfiguration` cl
Your API Key can be obtained from your AppFit Dashboard.

```javascript
const appFitConfig = new AppFitBrowserConfiguration('API_KEY');
const appFitConfig = new AppFitBrowserConfiguration("API_KEY");
```

This configuration should be passed to a new `AppFit` client:

```javascript
const appFitClient = new AppFit(appFitConfig);
```
Expand All @@ -23,7 +24,7 @@ A full example can be found below.
import {
AppFit,
AppFitBrowserConfiguration,
} from '@uptechworks/appfit-browser-sdk';
} from "@uptechworks/appfit-browser-sdk";

// Create the AppFitBrowserConfiguration
const config = new AppFitBrowserConfiguration("API_KEY");
Expand All @@ -32,7 +33,7 @@ const config = new AppFitBrowserConfiguration("API_KEY");
const appFitClient = new AppFit(config);

// Use the client to track events
await appFitClient.trackEvent("event_name", { example: 'property' });
await appFitClient.trackEvent("event_name", { example: "property" });
```

## Identifying Users
Expand Down
116 changes: 81 additions & 35 deletions docs/browser/web-pages/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,94 @@ The JavaScript SDK allows you to drop-in analytic tracking, direct to your AppFi

1. Install AppFit by pasting the following `<script>` tag into your webpage between the `<head>` tags.

```html
<script>
window.AppFit={cache:{},trackEvent:(e,t)=>(window.AppFit.cache||(window.AppFit.cache={}),window.AppFit.cache.events||(window.AppFit.cache.events=[]),window.AppFit.cache.events.push({eventName:e,payload:t}),Promise.resolve()),identifyUser(e){window.AppFit.cache||(window.AppFit.cache={}),window.AppFit.cache.identity=e}},window.startAppFit=e=>{window.AppFit.apiKey=e;var t=document.createElement("script");t.type="module",t.src="https://d1433kipn7zjh1.cloudfront.net/appfit.js";var p=document.createElement("script");p.noModule=!0,p.src="https://d1433kipn7zjh1.cloudfront.net/appfit-legacy.js";var i=document.getElementsByTagName("script")[0];i.parentNode.insertBefore(t,i),i.parentNode.insertBefore(p,i)},
window.startAppFit("YOUR_WRITE_KEY");
</script>
```

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 `<script>` tags for tracking (e.g. tracking a screen view) *after* the tag above.
```html
<script>
(window.AppFit = {
cache: {},
trackEvent: (e, t) => (
window.AppFit.cache || (window.AppFit.cache = {}),
window.AppFit.cache.events || (window.AppFit.cache.events = []),
window.AppFit.cache.events.push({ eventName: e, payload: t }),
Promise.resolve()
),
identifyUser(e) {
window.AppFit.cache || (window.AppFit.cache = {}),
(window.AppFit.cache.identity = e);
},
}),
(window.startAppFit = (e) => {
window.AppFit.apiKey = e;
var t = document.createElement("script");
(t.type = "module"),
(t.src = "https://d1433kipn7zjh1.cloudfront.net/appfit.js");
var p = document.createElement("script");
(p.noModule = !0),
(p.src = "https://d1433kipn7zjh1.cloudfront.net/appfit-legacy.js");
var i = document.getElementsByTagName("script")[0];
i.parentNode.insertBefore(t, i), i.parentNode.insertBefore(p, i);
}),
window.startAppFit("API_KEY");
</script>
```

2. Be sure to **replace `API_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 `<script>` tags for tracking (e.g. tracking a screen view) _after_ the tag above.

### Example

```html
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Website</title>
<!---------------->
<!-- Pasted tag -->
<!---------------->
<script>
window.AppFit={cache:{},trackEvent:(e,t)=>(window.AppFit.cache||(window.AppFit.cache={}),window.AppFit.cache.events||(window.AppFit.cache.events=[]),window.AppFit.cache.events.push({eventName:e,payload:t}),Promise.resolve()),identifyUser(e){window.AppFit.cache||(window.AppFit.cache={}),window.AppFit.cache.identity=e}},window.startAppFit=e=>{window.AppFit.apiKey=e;var t=document.createElement("script");t.type="module",t.src="https://d1433kipn7zjh1.cloudfront.net/appfit.js";var p=document.createElement("script");p.noModule=!0,p.src="https://d1433kipn7zjh1.cloudfront.net/appfit-legacy.js";var i=document.getElementsByTagName("script")[0];i.parentNode.insertBefore(t,i),i.parentNode.insertBefore(p,i)},
<head>
<title>My Website</title>

<!---------------->
<!-- Pasted tag -->
<!---------------->
<script>
(window.AppFit = {
cache: {},
trackEvent: (e, t) => (
window.AppFit.cache || (window.AppFit.cache = {}),
window.AppFit.cache.events || (window.AppFit.cache.events = []),
window.AppFit.cache.events.push({ eventName: e, payload: t }),
Promise.resolve()
),
identifyUser(e) {
window.AppFit.cache || (window.AppFit.cache = {}),
(window.AppFit.cache.identity = e);
},
}),
(window.startAppFit = (e) => {
window.AppFit.apiKey = e;
var t = document.createElement("script");
(t.type = "module"),
(t.src = "https://d1433kipn7zjh1.cloudfront.net/appfit.js");
var p = document.createElement("script");
(p.noModule = !0),
(p.src = "https://d1433kipn7zjh1.cloudfront.net/appfit-legacy.js");
var i = document.getElementsByTagName("script")[0];
i.parentNode.insertBefore(t, i), i.parentNode.insertBefore(p, i);
}),
window.startAppFit("my_secret_key_from_the_dashboard");
</script>

<!------------------->
<!-- Example usage -->
<!------------------->
<script>
window.AppFit.trackEvent("screen_viewed", { screen: window.location.pathname })
</script>
</head>

<body>
<main>
<h1>Welcome to My Website</h1>
</main>
</body>
</script>

<!------------------->
<!-- Example usage -->
<!------------------->
<script>
window.AppFit.trackEvent("screen_viewed", {
screen: window.location.pathname,
});
</script>
</head>

<body>
<main>
<h1>Welcome to My Website</h1>
</main>
</body>
</html>
```

Expand Down
28 changes: 27 additions & 1 deletion docs/flutter/installation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
# Installing

Add some notes here about installing
There are two ways to install the SDK. The first is to use the latest version from pub.dev, but you can always specify the direct git url in your pubspec.yaml file.

## Pub.dev

To install from pub.dev, simply fun the command

```shell
flutter pub add appfit
```

This will add a line like this to your package's pubspec.yaml

```yaml
dependencies:
appfit: ^1.0.0
```
## Git
To reference directly from git, you can add this to your pubspec.yaml file
```yaml
appfit:
git:
url: https://github.com/uptech/appfit-flutter-sdk.git
ref: main
```
---
Expand Down
2 changes: 1 addition & 1 deletion docs/kotlin/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ The AppFit SDK includes an `identify` call, that you can use to identify users i
This method supports any String-based identifier.

```kotlin
appfit.identifyUser("<id>")
appfit.identifyUser("USER_ID")
```

Setting this to null, will remove all events going forward from including the userId.
Expand Down
2 changes: 1 addition & 1 deletion docs/swift/installation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Installing

Use Swift Package Manager to install the AppFit Swift SDK.
Use Swift Package Manager to install the AppFit SDK.

Use Xcode and add this repository as a dependency.
Alternatively, add this repository as a dependency to your `Package.swift`.
Expand Down

0 comments on commit 32a952d

Please sign in to comment.