Skip to content

Commit

Permalink
0.5.1 🐨
Browse files Browse the repository at this point in the history
  • Loading branch information
louis amstutz committed Dec 6, 2018
1 parent cd500dc commit bb3fafa
Show file tree
Hide file tree
Showing 18 changed files with 229 additions and 320 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -25,3 +25,4 @@ UserInterfaceState.xcuserstate
.env

./init.js
./appendCore.js
97 changes: 66 additions & 31 deletions README.md
Expand Up @@ -48,18 +48,37 @@ And we do no data retention at all about those feedbacks 👏

# Getting started

<a href="https://bruit.io/"><button>start on bruit.io</button></a>
<a href="https://bruit.io/"><button style="min-height: 3em;
background-color: #579b83;
color: #fff; box-shadow: 0 3px 1px -2px rgba(0,0,0,.2), 0 2px 2px 0 rgba(0,0,0,.14), 0 1px 5px 0 rgba(0,0,0,.12);
border: none; text-align: center; padding: 0 16px;
border-radius: 4px; cursor: pointer;">start on bruit.io</button></a>

bruit.io component uses bruit.io servers by default. If you wish, It can be connected with your own server.

bruit.io servers allow to transmit feedbacks for free on tools such as

<p align="left">
<img alt="Mail" src="https://cdn.icon-icons.com/icons2/614/PNG/512/mail-black-envelope-symbol_icon-icons.com_56519.png" height="30px">
<img alt="GitLab" src="https://bruit.io/assets/imgs/GitLab.png" height="30px">
<img alt="Trello" src="https://bruit.io/assets/imgs/trello.png" height="30px">
<img alt="GitHub" src="https://banner2.kisspng.com/20180716/tza/kisspng-github-computer-icons-clip-art-gits-5b4d20ab1f4131.145288281531781291128.jpg" height="30px">
<img alt="Slack" src="https://img.icons8.com/office/1600/slack.png" height="30px">
<img alt="Basecamp" src="https://bruit.io/assets/imgs/basecamp-icon.png" height="30px">

</p>

# Table of Contents

**[Installation](#install)**<br>
**[Usage](#usage)**<br>
**[Configuration](#Configuration)**<br>
&nbsp;&nbsp;&nbsp;&nbsp;**[BrtConfig](#BrtConfig)**<br>
&nbsp;&nbsp;&nbsp;&nbsp;**[BrtCoreConfig](#BrtCoreConfig)**<br>
&nbsp;&nbsp;&nbsp;&nbsp;**[BrtField](#BrtField)**<br>
&nbsp;&nbsp;&nbsp;&nbsp;**[BrtLabels](#BrtLabels)**<br>
&nbsp;&nbsp;&nbsp;&nbsp;**[BrtColors](#BrtColors)**<br>
&nbsp;&nbsp;&nbsp;&nbsp;**[BrtLogLevels](#BrtLogLevels)**<br>
&nbsp;&nbsp;&nbsp;&nbsp;**[BrtLogCacheLength](#BrtLogCacheLength)**<br>
**[Add data in feedbacks](#add-data-in-feedback)**<br>
**[Handle errors](#handle-errors)**<br>
**[Frameworks integration](#Framework-integrations)**<br>
Expand Down Expand Up @@ -125,6 +144,8 @@ Integration code examples are available for these platforms:

> `bruit-io` Web Component has a `config` attribute, which takes a value of [BrtConfig](#brtconfig) type.
> `defineBruitElements` function which takes a value of [BrtCoreConfig](#brtcoreconfig) type.
### _BrtConfig_

Describes the options for the `bruit-io` component
Expand All @@ -134,31 +155,47 @@ interface BrtConfig {
apiKey?: string;
form: Array<BrtField>;
labels?: BrtLabels;
logLevels?: BrtLogLevels;
maxLogLines?: number;
colors?: BrtColors;
closeModalOnSubmit?: boolean;
apiUrl?: string;
}
```

| Attribute | Type | Description | Mandatory | Default value |
| ------------------ | ----------------------------- | ---------------------------------------------------------------------------------- | --------- | ------------------------------- |
| apiKey | string | your personal api key [(create an api key)](https://bruit.io/get-started) | no | - |
| **form** | array<[BrtField](#brtfield)> | inputs list for the generated form | **yes** | - |
| labels | [BrtLabels](#brtlabels) | describes the labels of the modal (title / button / ...) | no | [see](#brtlabels) |
| logLevels | [BrtLogLevels](#BrtLogLevels) | Used to filter the logs to send by their level (debug, warn, error, etc) | no | [see](#BrtLogLevels) |
| maxLogLines | number | Defines the number of log lines to send in the feedback | no | 100 |
| colors | [BrtColors](#BrtColors) | Allows to pick your colors in the modal theming | no | [see](#BrtColors) |
| closeModalOnSubmit | boolean | true to have modal closed automatically on submit (feedback is sent in background) | no | false |
| apiUrl | string | Allows to use some third party backend for feedback processing | no | <https://api.bruit.io/feedback> |
| Attribute | Type | Description | Mandatory | Default value |
| ------------------ | ---------------------------- | ---------------------------------------------------------------------------------- | --------- | ------------------------------- |
| apiKey | string | your personal api key [(create an api key)](https://bruit.io/get-started) | no | - |
| **form** | array<[BrtField](#brtfield)> | inputs list for the generated form | **yes** | - |
| labels | [BrtLabels](#brtlabels) | describes the labels of the modal (title / button / ...) | no | [see](#brtlabels) |
| colors | [BrtColors](#BrtColors) | Allows to pick your colors in the modal theming | no | [see](#BrtColors) |
| closeModalOnSubmit | boolean | true to have modal closed automatically on submit (feedback is sent in background) | no | false |
| apiUrl | string | Allows to use some third party backend for feedback processing | no | <https://api.bruit.io/feedback> |

Typescript import :

```javascript
import { BrtConfig } from '@bruit/component';
```

### _BrtCoreConfig_

Describes the options for the bruit core

```ts
interface BrtCoreConfig {
logCacheLength?: BrtLogCacheLength;
}
```

| Attribute | Type | Description | Mandatory | Default value |
| -------------- | --------------------------------------- | -------------------------------------------------------- | --------- | ------------------------- |
| logCacheLength | [BrtLogCacheLength](#brtlogcachelength) | describes the labels of the modal (title / button / ...) | no | [see](#brtlogcachelength) |

Typescript import :

```javascript
import { BrtCoreConfig } from '@bruit/component';
```

### _BrtField_

Describes both the fields displayed in the popup form and the users' answers.
Expand Down Expand Up @@ -250,33 +287,31 @@ Typescript import:
import { BrtColors } from '@bruit/component';
```

### _BrtLogLevels_
### _BrtLogCacheLength_

By default, all log levels (log, warn, errors, ...) are sent in the feedback. `BrtLogLevels` allows to disable specific ones.
By default, all log levels (log, warn, errors, ...) are sent in the feedback. `BrtLogCacheLength` allows to disable specific ones.

To disable a type, just set the related type to false in the logLevels section:
To disable a type, just set the related type to 0 in the logCacheLength section of core configuration:

```json
{
"apiKey": "xxxxxxxxxx",
"form": ["..."],
"logLevels": {
"log": false,
"logCacheLength": {
"log": 0,
...
}
}
```

```ts
interface BrtLogLevels {
log?: boolean;
debug?: boolean;
info?: boolean;
warn?: boolean;
error?: boolean;
network?: boolean;
click?: boolean;
url?: boolean;
interface BrtLogCacheLength {
log?: number;
debug?: number;
info?: number;
warn?: number;
error?: number;
network?: number;
click?: number;
url?: number;
}
```

Expand All @@ -289,7 +324,7 @@ bruit.io adds special types of logs:
Typescript import:

```javascript
import { BrtLogLevels } from '@bruit/component';
import { BrtLogCacheLength } from '@bruit/component';
```

# Add data to the feedback
Expand Down
10 changes: 10 additions & 0 deletions appendCore.js
@@ -0,0 +1,10 @@
export function appendCore(brtCoreConfig) {
var modal = document.getElementsByTagName('bruit-core');
if (modal.length <= 0) {
var bruitCore = document.createElement('bruit-core');
if (brtCoreConfig) {
bruitCore.config = brtCoreConfig;
}
document.body.appendChild(bruitCore);
}
}
12 changes: 4 additions & 8 deletions init.js
@@ -1,19 +1,15 @@
import {
defineCustomElements
} from './esm/es5/bruit.define.js';
import {
appendCore
} from './appendCore';


export function defineBruitElements(brtCoreConfig, opts) {
var r = defineCustomElements(window, opts);
window.addEventListener('load', function () {
var modal = document.getElementsByTagName('bruit-core');
if (modal.length <= 0) {
var bruitCore = document.createElement('bruit-core');
if (brtCoreConfig) {
bruitCore.config = brtCoreConfig;
}
document.body.appendChild(bruitCore);
}
appendCore(brtCoreConfig);
}, false);
return r;
}
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@bruit/component",
"version": "0.5.0",
"version": "0.5.1",
"description": "send your feedbacks with bruit.io",
"private": false,
"module": "dist/esm/index.js",
Expand Down
9 changes: 5 additions & 4 deletions src/api/feedback.ts
Expand Up @@ -30,10 +30,11 @@ export class Feedback implements BrtFeedback {

init(): Promise<void> {
// take screenShot
return ScreenTool.getScreenshot().then(screenshot => {
this.canvas = screenshot;
return;
});
return Promise.resolve();
// return ScreenTool.getScreenshot().then(screenshot => {
// this.canvas = screenshot;
// return;
// });
}

/**
Expand Down
10 changes: 10 additions & 0 deletions src/appendCore.js
@@ -0,0 +1,10 @@
export function appendCore(brtCoreConfig) {
var modal = document.getElementsByTagName('bruit-core');
if (modal.length <= 0) {
var bruitCore = document.createElement('bruit-core');
if (brtCoreConfig) {
bruitCore.config = brtCoreConfig;
}
document.body.appendChild(bruitCore);
}
}
58 changes: 29 additions & 29 deletions src/components.d.ts
Expand Up @@ -8,18 +8,33 @@
import '@stencil/core';


import {
BruitIoConfig,
} from './models/bruit-io-config.class';
import {
BrtConfig,
BrtCoreConfig,
BrtData,
} from '@bruit/types';
import {
BruitIoConfig,
} from './models/bruit-io-config.class';


export namespace Components {

interface BruitCore {
'config': BrtCoreConfig | string;
/**
* called on click on component init a feedback, wait user submit, send feedback
*/
'newFeedback': (bruitIoConfig: BruitIoConfig, data?: BrtData[], dataFn?: () => BrtData[] | Promise<BrtData[]>) => Promise<void>;
}
interface BruitCoreAttributes extends StencilHTMLAttributes {
'config'?: BrtCoreConfig | string;
/**
* emit bruit-error on internal error or config error ex : BruitIo.addEventListener('onError',error=>...)
*/
'onOnError'?: (event: CustomEvent) => void;
}

interface BruitIo {
'config': BrtConfig | string;
/**
Expand All @@ -30,7 +45,7 @@ export namespace Components {
* FN or PROMISE return field array to add in feedback
*/
'dataFn': () => Array<BrtData> | Promise<Array<BrtData>>;
'start': (brtCoreConfig: any) => void;
'start': (brtCoreConfig: BrtCoreConfig) => void;
}
interface BruitIoAttributes extends StencilHTMLAttributes {
'config'?: BrtConfig | string;
Expand All @@ -48,55 +63,40 @@ export namespace Components {
'onOnError'?: (event: CustomEvent) => void;
'onOnReady'?: (event: CustomEvent) => void;
}

interface BruitCore {
'config': BrtCoreConfig | string;
/**
* called on click on component init a feedback, wait user submit, send feedback
*/
'newFeedback': (bruitIoConfig: BruitIoConfig, data?: BrtData[], dataFn?: () => BrtData[] | Promise<BrtData[]>) => void;
}
interface BruitCoreAttributes extends StencilHTMLAttributes {
'config'?: BrtCoreConfig | string;
/**
* emit bruit-error on internal error or config error ex : BruitIo.addEventListener('onError',error=>...)
*/
'onOnError'?: (event: CustomEvent) => void;
}
}

declare global {
interface StencilElementInterfaces {
'BruitIo': Components.BruitIo;
'BruitCore': Components.BruitCore;
'BruitIo': Components.BruitIo;
}

interface StencilIntrinsicElements {
'bruit-io': Components.BruitIoAttributes;
'bruit-core': Components.BruitCoreAttributes;
'bruit-io': Components.BruitIoAttributes;
}


interface HTMLBruitIoElement extends Components.BruitIo, HTMLStencilElement {}
var HTMLBruitIoElement: {
prototype: HTMLBruitIoElement;
new (): HTMLBruitIoElement;
};

interface HTMLBruitCoreElement extends Components.BruitCore, HTMLStencilElement {}
var HTMLBruitCoreElement: {
prototype: HTMLBruitCoreElement;
new (): HTMLBruitCoreElement;
};

interface HTMLBruitIoElement extends Components.BruitIo, HTMLStencilElement {}
var HTMLBruitIoElement: {
prototype: HTMLBruitIoElement;
new (): HTMLBruitIoElement;
};

interface HTMLElementTagNameMap {
'bruit-io': HTMLBruitIoElement
'bruit-core': HTMLBruitCoreElement
'bruit-io': HTMLBruitIoElement
}

interface ElementTagNameMap {
'bruit-io': HTMLBruitIoElement;
'bruit-core': HTMLBruitCoreElement;
'bruit-io': HTMLBruitIoElement;
}


Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit bb3fafa

Please sign in to comment.