Skip to content

Commit 690b161

Browse files
committed
initial commit; based off of skylab-js-client 819b011
0 parents  commit 690b161

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+54385
-0
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/

.eslintrc.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
'use strict';
2+
3+
module.exports = {
4+
root: true,
5+
env: {
6+
browser: true,
7+
es6: true,
8+
jest: true,
9+
node: true,
10+
},
11+
parser: '@typescript-eslint/parser',
12+
plugins: ['@typescript-eslint', 'jest', 'import', 'prettier'],
13+
extends: [
14+
'eslint:recommended',
15+
'plugin:@typescript-eslint/recommended',
16+
'prettier',
17+
'prettier/@typescript-eslint',
18+
],
19+
rules: {
20+
'no-console': ['error', { allow: ['warn', 'error', 'debug'] }],
21+
22+
// eslint-plugin-import
23+
'import/order': [
24+
'error',
25+
{ 'newlines-between': 'always', alphabetize: { order: 'asc' } },
26+
],
27+
28+
// eslint-plugin-prettier
29+
'prettier/prettier': 'error',
30+
},
31+
};

.github/pull_request_template.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!--
2+
Thanks for contributing to the Amplitude Experiment Javascript Client SDK! 🎉
3+
4+
Please fill out the following sections to help us quickly review your pull request.
5+
-->
6+
7+
### Summary
8+
9+
<!-- What does the PR do? -->
10+
11+
### Checklist
12+
13+
* [ ] Does your PR title have the correct [title format](https://github.com/amplitude/skylab-js-client/blob/main/CONTRIBUTING.md#pr-commit-title-conventions)?
14+
* Does your PR have a breaking change?: <!-- Yes or no -->

.github/workflows/lint.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Lint
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-18.04
8+
steps:
9+
- name: Check out Git repository
10+
uses: actions/checkout@v2
11+
12+
- name: Cache Node Modules
13+
uses: actions/cache@v2
14+
with:
15+
path: '**/node_modules'
16+
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
17+
18+
- name: Use Node.js ${{ matrix.node-version }}
19+
uses: actions/setup-node@v2
20+
with:
21+
node-version: ${{ matrix.node-version }}
22+
23+
- name: Install
24+
run: yarn install --frozen-lockfile
25+
26+
- name: Lint
27+
run: yarn lint

.github/workflows/release.yml

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
dryRun:
7+
description: 'Do a dry run to preview instead of a real release'
8+
required: true
9+
default: 'true'
10+
11+
jobs:
12+
authorize:
13+
name: Authorize
14+
runs-on: ubuntu-18.04
15+
steps:
16+
- name: ${{ github.actor }} permission check to do a release
17+
uses: octokit/[email protected]
18+
with:
19+
route: GET /repos/:repository/collaborators/${{ github.actor }}
20+
repository: ${{ github.repository }}
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
24+
release:
25+
name: Release
26+
runs-on: ubuntu-18.04
27+
needs: [authorize]
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v2
31+
32+
# Needed for lerna version to determine last tag
33+
- name: Fetch
34+
run: git fetch --prune --unshallow --tags
35+
36+
- name: Cache Node Modules
37+
uses: actions/cache@v2
38+
with:
39+
path: '**/node_modules'
40+
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
41+
42+
- name: Setup Node
43+
uses: actions/setup-node@v2
44+
with:
45+
node-version: '10'
46+
47+
- name: Install
48+
run: yarn install --frozen-lockfile
49+
50+
- name: Build
51+
run: npx lerna exec yarn
52+
53+
- name: Test
54+
run: yarn test
55+
56+
- name: Configure Git User
57+
run: |
58+
git config --global user.name amplitude-sdk-bot
59+
git config --global user.email [email protected]
60+
61+
- name: Release (Dry Run)
62+
if: ${{ github.event.inputs.dryRun == 'true'}}
63+
env:
64+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
run: |
66+
yarn lerna version -m "chore(release): publish %s" \
67+
--conventional-commits \
68+
--no-push \
69+
--no-git-tag-version \
70+
--loglevel silly \
71+
--yes
72+
73+
- name: Setup NPM Token
74+
if: ${{ github.event.inputs.dryRun == 'false'}}
75+
env:
76+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
77+
run: echo //registry.npmjs.org/:_authToken=${NPM_TOKEN} > .npmrc
78+
79+
- name: Release
80+
if: ${{ github.event.inputs.dryRun == 'false'}}
81+
env:
82+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83+
run: |
84+
yarn lerna version -m "chore(release): publish %s" \
85+
--conventional-commits \
86+
--create-release github \
87+
--loglevel silly \
88+
--yes
89+
yarn lerna publish from-git --yes --loglevel silly

.github/workflows/semantic-pr.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Semantic PR Check
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, edited]
6+
7+
jobs:
8+
pr-title-check:
9+
runs-on: ubuntu-18.04
10+
steps:
11+
- name: PR title is valid
12+
if: >
13+
startsWith(github.event.pull_request.title, 'feat:') || startsWith(github.event.pull_request.title, 'feat(') ||
14+
startsWith(github.event.pull_request.title, 'fix:') || startsWith(github.event.pull_request.title, 'fix(') ||
15+
startsWith(github.event.pull_request.title, 'perf:') || startsWith(github.event.pull_request.title, 'perf(') ||
16+
startsWith(github.event.pull_request.title, 'docs:') || startsWith(github.event.pull_request.title, 'docs(') ||
17+
startsWith(github.event.pull_request.title, 'test:') || startsWith(github.event.pull_request.title, 'test(') ||
18+
startsWith(github.event.pull_request.title, 'refactor:') || startsWith(github.event.pull_request.title, 'refactor(') ||
19+
startsWith(github.event.pull_request.title, 'style:') || startsWith(github.event.pull_request.title, 'style(') ||
20+
startsWith(github.event.pull_request.title, 'build:') || startsWith(github.event.pull_request.title, 'build(') ||
21+
startsWith(github.event.pull_request.title, 'ci:') || startsWith(github.event.pull_request.title, 'ci(') ||
22+
startsWith(github.event.pull_request.title, 'chore:') || startsWith(github.event.pull_request.title, 'chore(') ||
23+
startsWith(github.event.pull_request.title, 'revert:') || startsWith(github.event.pull_request.title, 'revert(')
24+
run: |
25+
echo 'Title checks passed'
26+
27+
- name: PR title is invalid
28+
if: >
29+
!startsWith(github.event.pull_request.title, 'feat:') && !startsWith(github.event.pull_request.title, 'feat(') &&
30+
!startsWith(github.event.pull_request.title, 'fix:') && !startsWith(github.event.pull_request.title, 'fix(') &&
31+
!startsWith(github.event.pull_request.title, 'perf:') && !startsWith(github.event.pull_request.title, 'perf(') &&
32+
!startsWith(github.event.pull_request.title, 'docs:') && !startsWith(github.event.pull_request.title, 'docs(') &&
33+
!startsWith(github.event.pull_request.title, 'test:') && !startsWith(github.event.pull_request.title, 'test(') &&
34+
!startsWith(github.event.pull_request.title, 'refactor:') && !startsWith(github.event.pull_request.title, 'refactor(') &&
35+
!startsWith(github.event.pull_request.title, 'style:') && !startsWith(github.event.pull_request.title, 'style(') &&
36+
!startsWith(github.event.pull_request.title, 'build:') && !startsWith(github.event.pull_request.title, 'build(') &&
37+
!startsWith(github.event.pull_request.title, 'ci:') && !startsWith(github.event.pull_request.title, 'ci(') &&
38+
!startsWith(github.event.pull_request.title, 'chore:') && !startsWith(github.event.pull_request.title, 'chore(') &&
39+
!startsWith(github.event.pull_request.title, 'revert:') && !startsWith(github.event.pull_request.title, 'revert(')
40+
run: |
41+
echo 'Pull request title is not valid. Please check github.com/amplitude/Amplitude-JavaScript/blob/main/CONTRIBUTING.md#pr-commit-title-conventions'
42+
exit 1

.github/workflows/test.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
node-version: ['10', '12', '14']
11+
os: [macos-10.14, ubuntu-18.04]
12+
runs-on: ${{ matrix.os }}
13+
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
18+
- name: Cache Node Modules
19+
uses: actions/cache@v2
20+
with:
21+
path: '**/node_modules'
22+
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
23+
24+
- name: Setup Node
25+
uses: actions/setup-node@v2
26+
with:
27+
node-version: ${{ matrix.node-version }}
28+
29+
- name: Install
30+
run: yarn install --frozen-lockfile
31+
32+
- name: Build
33+
run: npx lerna exec yarn
34+
35+
- name: Test
36+
run: yarn test

.gitignore

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Modules
9+
node_modules/
10+
jspm_packages/
11+
12+
# Output folders
13+
build/
14+
dist/
15+
16+
# caches
17+
.cache
18+
19+
# MacOS
20+
.DS_Store

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/

.prettierrc.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"proseWrap": "always"
5+
}

CHANGELOG.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Change Log
2+
3+
All notable changes to this project will be documented in this file.
4+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5+
6+
# [1.1.0](https://github.com/amplitude/skylab-js-client/compare/v1.0.2...v1.1.0) (2021-05-21)
7+
8+
9+
### Bug Fixes
10+
11+
* change globalThis to a browser/node/script tag-safe version ([#9](https://github.com/amplitude/skylab-js-client/issues/9)) ([1e8e804](https://github.com/amplitude/skylab-js-client/commit/1e8e80444c4e1055eba9fb3405639201ef696823))
12+
13+
14+
### Features
15+
16+
* Implement fetch timeout and retries in SkylabClient ([#7](https://github.com/amplitude/skylab-js-client/issues/7)) ([2cd743e](https://github.com/amplitude/skylab-js-client/commit/2cd743efa7828166ff2ccfdd513e9277c01cd65a))

CONTRIBUTING.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
### PR Commit Title Conventions
2+
3+
PR titles should follow [conventional commit standards](https://www.conventionalcommits.org/en/v1.0.0/). This helps automate the [release](#release) process.
4+
5+
#### Commit Types ([related to release conditions](#release))
6+
7+
- **Special Case**: Any commit with `BREAKING CHANGES` in the body: Creates major release
8+
- `feat(<optional scope>)`: New features (minimum minor release)
9+
- `fix(<optional scope>)`: Bug fixes (minimum patch release)
10+
- `perf(<optional scope>)`: Performance improvement
11+
- `docs(<optional scope>)`: Documentation updates
12+
- `test(<optional scope>)`: Test updates
13+
- `refactor(<optional scope>)`: Code change that neither fixes a bug nor adds a feature
14+
- `style(<optional scope>)`: Code style changes (e.g. formatting, commas, semi-colons)
15+
- `build(<optional scope>)`: Changes that affect the build system or external dependencies (e.g. Yarn, Npm)
16+
- `ci(<optional scope>)`: Changes to our CI configuration files and scripts
17+
- `chore(<optional scope>)`: Other changes that don't modify src or test files
18+
- `revert(<optional scope>)`: Revert commit
19+
20+
### Release [Amplitude Internal]
21+
22+
Releases are managed by [semantic-release](https://github.com/semantic-release/semantic-release). It is a tool that will scan commits since the last release, determine the next [semantic version number](https://semver.org/), publish, and create changelogs.
23+
24+
#### Release Conditions [Amplitude Internal]
25+
26+
- `BREAKING CHANGES` in the body will do a major release
27+
```
28+
feat(cookies): Create new cookie format
29+
30+
BREAKING CHANGES: Breaks old cookie format
31+
```
32+
- Else `feat` in title will do a `minor` release
33+
`feat(cookies): some changes`
34+
- Else `fix` or `perf` in title will do a `patch` release
35+
`fix: null check bug`
36+
- Else no release
37+
`docs: update website`

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Amplitude Analytics
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Javascript Client (Browser) SDK for Skylab
2+
3+
## Overview
4+
5+
This is the Javascript client (web browser) SDK for Skylab, Amplitude's
6+
experimentation and feature management platform.
7+
8+
## Browser Compatibility
9+
10+
This SDK works with all major browsers and IE10+. The SDK does make use of
11+
Promises, so if you are targeting a browser that does not have native support
12+
for Promise (for example, IE), you should include a polyfill for Promise, (for
13+
example, [es6-promise](https://github.com/stefanpenner/es6-promise)).
14+
15+
## Getting Started
16+
17+
Refer to the [Javascript SDK Documentation](https://amplitude-lab.readme.io/docs/javascript-client-sdk) to get started.

babel.config.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
3+
module.exports = {
4+
presets: [
5+
[
6+
'@babel/preset-env',
7+
{
8+
targets: {
9+
browsers: ['ie >= 8'],
10+
},
11+
},
12+
],
13+
'@babel/preset-typescript',
14+
],
15+
};

0 commit comments

Comments
 (0)