0.2.3 • Published 3 years ago

@kaitaku/kaitaku-web-sdk v0.2.3

Weekly downloads
-
License
-
Repository
-
Last release
3 years ago

Kaitaku Web SDK

CircleCI

codecov

Install

Getting Started

You can integrate this into your application as a module or a global varibale.

Install as a module in UI framework

To implement this as a module, run:

npm install @kaitaku/kaitaku-web-sdk 

Setup a container

The SDK will render in a HTML element. This container must have a specified height and width to show the elements properly. We recommend a minimum height of 400px and minimum width of 400px.

<!doctype html>
<html>

<head>
    <script type="text/javascript" src="./../build/browser/main.js"></script>

    <title>Vanilla JS Example</title>
    <style>
        #feedback-container {
            position: absolute;
            top: 50px;
            left: 50px;
            height: 400px;
            width: 400px;
        }
    </style>
</head>

<body>
    <div id="feedback-container"></div>
    <button id="app-button" type="button">Show Feedback </button>
</body>

<script>
    const container = document.getElementById('feedback-container')
    const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiWmdOS0NBalVIbERoak85bms1bW4iLCJjcmVhdGVkX2F0IjoiMjAyMi0wNC0xN1QxODo1MTo1Ni41OTI2OCswOTowMCJ9.lL2kmWdoAhCfZOe1r7yl-7k4n-5EVdcwj6QhuB-tEek'
    const projectId = 'mVhuSeRl9UXjJevV0sTy'
    const user1 = 'user1'

    document.getElementById('app-button').onclick = function () {
        //click me function!
        console.log("app-button clicked")

        new Kaitaku(container, {
            onError: (err) => {
                console.error(err)
            },
            projectId: projectId,
            token: token,
            userId: user1,
        })
    }
</script>

</html>

API Options

NameRequiredTypeDescriptionDefault Value
onErrorYesFunctionCalled when error occurs.
projectYesStringproject ID
tokenYesStringToken for the account
userIdYesStringUnique user id
showFeedbackButtonNoBooleanWhether to show the default feedback buttontrue
showFeedbackUINoBooleanWhether to show the default feedback UIfalse

Contributing

Develop

To run this library and make it viewable, it must integrate into an example application.

# 1. clone this repository
git clone git@github.com:kaitakuhq/kaitaku-web-sdk.git

# 2. Go into the project root
cd kaitaku-web-sdk

# 3. Install dependencies
yarn

# 4. To watch and generate CSS builds (if updating Tailwind CSS classes)
yarn run css:build:watch

# 5. To watch and generate a UMD build
yarn run build:watch

# 6a. To watch and serve the UMD build to the application
./node_modules/.bin/serve dist

# alternatively,
yarn add global serve
serve dist

# 7a. To run an example app in ReactJS
cd example/reactjs
yarn
yarn start

# 7b. To run an example app in Vanilla JS
cd example/vanillajs
open index.html

When Tailwind CSS is generated, it creates src/style/generated.css, which is required to be committed to this repository along with the appropriate changed files.

The build will be created from src/lib folder.

Build

Running yarn build generates a UMD file and typings in the dist folder.

Deploy

This will be deployed as a NPM package when a tag is created, and not when merged to main. Please view the Circle CI configuration under publish job for details.

0.2.1

3 years ago

0.2.0

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.9

3 years ago

0.2.3

3 years ago

0.1.4

3 years ago

0.2.2

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.0

3 years ago

0.1.0-test

3 years ago