Skip to content

Commit

Permalink
feat(docs): init commit getting things setup
Browse files Browse the repository at this point in the history
  • Loading branch information
GoPro16 committed Sep 3, 2019
1 parent e76320f commit f525ff4
Show file tree
Hide file tree
Showing 9 changed files with 247 additions and 9 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"scripts": {
"codecov:ci": "codecov",
"lint": "eslint .",
"start:docs": "npm run start --prefix packages/docs",
"bootstrap": "lerna bootstrap --no-ci",
"link": "lerna link",
"updated": "lerna updated",
Expand Down
5 changes: 0 additions & 5 deletions packages/.eslintrc.yaml

This file was deleted.

4 changes: 0 additions & 4 deletions packages/analytics-core/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# Analytics Core

> A package providing a base Analytics class to track events and page views
[![Version](https://img.shields.io/npm/v/@availity/analytics-core.svg?style=for-the-badge)](https://www.npmjs.com/package/@availity/analytics-core)

## Install
Expand Down
2 changes: 2 additions & 0 deletions packages/docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.cache/
public/
21 changes: 21 additions & 0 deletions packages/docs/gatsby-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const themeOptions = require('@availity/gatsby-theme/theme-options');

module.exports = {
pathPrefix: '/sdk-js',
__experimentalThemes: [
{
resolve: '@availity/gatsby-theme',
options: {
...themeOptions,
root: __dirname,
subtitle: 'SDK Resources',
description: 'Documentation for Resources',
githubRepo: 'availity/sdk-js',
sidebarCategories: {
null: ['index', 'test'],
Analytics: ['packages/analytics'],
},
},
},
],
};
32 changes: 32 additions & 0 deletions packages/docs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"private": true,
"name": "@availity/docs",
"version": "1.0.0",
"license": "MIT",
"keywords": [
"react",
"availity"
],
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/Availity/sdk-js.git"
},
"bugs": {
"url": "https://github.com/Availity/sdk-js/issues"
},
"scripts": {
"build": "gatsby build",
"build:deploy": "gatsby build --prefix-paths",
"start": "gatsby develop",
"develop": "gatsby develop",
"clean": "gatsby clean"
},
"dependencies": {
"@availity/analytics-core": "^2.7.2",
"@availity/gatsby-theme": "^1.1.2",
"gatsby": "^2.13.83",
"react": "^16.8.3",
"react-dom": "^16.8.3",
"reactstrap": "^8.0.1"
}
}
55 changes: 55 additions & 0 deletions packages/docs/source/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
title: SDK
summary: Javascript SDK for Availity
---

[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=for-the-badge&logo=MIT)](http://opensource.org/licenses/MIT)
[![Dependency Status](https://img.shields.io/david/dev/Availity/sdk-js.svg?style=for-the-badge)](https://david-dm.org/Availity/sdk-js)
[![Build](https://img.shields.io/travis/Availity/sdk-js.svg?style=for-the-badge&label=build)](https://travis-ci.org/Availity/sdk-js)

## Supported Browsers

- Internet Explorer 11 and newer
- Google Chrome
- Mozilla Firefox

## Documentation

- [analytics-angular](packages/analytics-core/README.md) - Analytics core logic and auto-tracking.
- [api-core](packages/api-core/README.md) - Base API definitions used by [api-axios](packages/api-axios/README.md) and [api-angular](api-angular/README.md) for the Availity REST API.
- [api-axios](packages/api-axios/README.md) - A package wrapping [@av/api-core](../api-core/README.md) with [axios](https://github.com/axios/axios) and native ES6 Promise.
- [api-angular](packages/api-angular/README.md) - A package wrapping [@av/api-core](../api-core/README.md) with Angular `$http`.
- [localalstorage-core](packages/localstorage-core/README.md) - Wraps localStorage with utility functions.
- [message-core](packages/message-core/README.md) - Wraps postMessage function with helper functions and security checks.
- [upload-core](packages/upload-core/README.md) - > Wrapper for tus-js-client
- [dl-core](packages/dl-core/README.md) - > Wrapper for js-file-download

## Adding a new API Resource

1. Run `npm run new`
2. Select the "api resource" template
3. Follow the prompts

## Contributing

`skd-js` is a monorepo managed using [lerna](https://github.com/lerna/lerna) in independent mode (each packages is versioned and published individually).

- Run `npm install`
- Commits should use the [Angular Commit Format](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#type). Scope should one of un-prefixed name of the packages under `./packages/`. If a commit applies to multiple packages, leave out the scope.
- Release and publish using `npm run release`. The version is determined by analyzing the commit messages.

> Preview how lerna will version the packages by running:
```shell
npx lerna version --no-git-tag-version --no-push
```

> Determine why lerna choose a semver version for the packages by running:
```shell
npx lerna version --no-git-tag-version --no-push --loglevel silly
```

## License

[MIT](./LICENSE)
130 changes: 130 additions & 0 deletions packages/docs/source/packages/analytics.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
---
title: Analytics
summary: A package providing a base Analytics class to track events and page views
---

[![Version](https://img.shields.io/npm/v/@availity/analytics-core.svg?style=for-the-badge)](https://www.npmjs.com/package/@availity/analytics-core)

## Install
`npm install @availity/analytics-core`

## Configuration

`AvAnalytics` requires Plugins and a Promise lib.

```javascript
new AvAnalytics(plugins, promise);
```

`AvAnalytics` also has an optional 3rd parameter, a boolean to determine if pageTracking is enabled.
For page tracking to be used, `startPageTracking` and `stopPageTracking` functions must be defined to create listeners and call `trackPageView`.
`AvAnalytics` also has an optional 4th parameter, "autoTrack", a boolean which default to `true`.
When `true`, "autoTrack" will be enabled which will automatically log

```javascript
new AvAnalytics(plugins, promise, pageTracking, autoTrack, options);
```

### Options
- **attributePrefix** string. Overrides the default prefix for getting attributes.
- **recursive** boolean. If `true`, will add on all attributes from the clicke/focused node up to the root element. It requires one attribute to have contain `action`.

Example using the `recursive` option ( Will add all 3 attributes when the `anchor` tag is clicked. If the container is clicked nothing will happen ):
```html
<div class="container" data-analytics-app-name="app">
<a href="#" data-analytics-action="click" data-analytics-event-name="linking">Click me!</a>
</div>
```

## Plugins

Plugins can be one or an array of objects/classes:

A default class with functions defined and enabled logic is provided `AvAnalyticsPlugin`.

```javascript
import {AvAnalyticsPlugin} from '@availity/analytics-core';
```

### Plugin Methods

the functions/properties used by `AvAnalytics` are:

#### isEnabled
Determines if this plugin will be called at various points.
If this is a function, the return value will be used. Otherwise will be checked as boolean.

#### init

if defined, will be called when `AvAnalytics` is initialized.

#### trackEvent

if defined, called when `AvAnalytics` receives a trackEvent call.

#### trackPageView

if defined, called when `AvAnalytics` receives a trackPageView call.

### Defined Plugins

#### AvSplunkAnalytics

`AvSplunkAnalytics` is a plugin to track events with the `AvLogMessages` api.
It defaults the url and level before sending.

```javascript
import {AvSplunkAnalytics} from '@availity/analytics-core';

const exampleSplunkAnalytics = new AvSplunkAnalytics(new AvLogMessages({ http, promise, merge }), isEnabled);
```

## Methods

### `init()`

Initialize analytics pageTracking and plugins

### `setPageTracking(value)`

use parameter to set turn page tracking on/off. Always checks that pageTracking has been set up or torn down as needed.

### `trackEvent(properties)`

Send properties to each plugins `trackEvent` function.

### `trackPageView(url)`

Send url or `location.href` to each plugins `trackEvent` function.

## AutoTrack Logged events
With "autoTrack" enabled (enabled by default) you can add special `data-analytics-*` to any element which will be rendered to the DOM.
For native form elements (input, select, and textarea) with the special attribute, `focus` and `blur` events will trigger analytics to be logged.
For all other element with the special attribute, `click` events will trigger analytics to be logged.
You can have as many of the `data-analytics-*` attributes on an element as you which, all of the properties will be logged with the `data-analytics-` prefix removed and the remaining camelcased as the key and the value of the attribute as the logged value.
This works with all libraries such as angular, react, jquery, and pure HTML.

```jsx
<a
href="/some-place-cool"
data-analytics-variation="b"
data-analytics-organization-id={orgId}
data-analytics-page-num={currentPage}>
Go there now!
</a>
```

```jsx
import { Input } from 'reactstrap';
//...
<Input
data-analytics-variation="b"
data-analytics-organization-id={orgId} />
```

## Authors
**Kasey Powers**
* [kaseyepowers@gmail.com](kaseyepowers@gmail.com)

## License
[MIT](../../LICENSE)
6 changes: 6 additions & 0 deletions packages/docs/source/test.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: SDK Mdx
summary: Javascript SDK for Availity
---

Testing

0 comments on commit f525ff4

Please sign in to comment.