-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from TelemetryDeck/initial-release
Initial release
- Loading branch information
Showing
18 changed files
with
6,011 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module.exports = { | ||
env: { | ||
browser: true, | ||
}, | ||
plugins: ['prettier', 'unicorn', 'jest'], | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:prettier/recommended', | ||
'plugin:unicorn/recommended', | ||
'plugin:jest/recommended', | ||
], | ||
|
||
overrides: [ | ||
{ | ||
files: ['.eslintrc.js', 'jest.config.js', 'jest.setup.js'], | ||
env: { | ||
browser: false, | ||
node: true, | ||
}, | ||
rules: { | ||
'unicorn/prefer-module': 'off', | ||
}, | ||
}, | ||
{ | ||
files: ['tests/**/*'], | ||
env: { | ||
jest: true, | ||
}, | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- 'v*' | ||
pull_request: {} | ||
|
||
env: | ||
PNPM_VERSION: 6.19.0 | ||
|
||
jobs: | ||
lint: | ||
name: Linting | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: pnpm/action-setup@v2.0.1 | ||
with: | ||
version: ${{ env.PNPM_VERSION }} | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16.x | ||
cache: pnpm | ||
- run: pnpm install | ||
- run: pnpm run lint | ||
|
||
test: | ||
name: Testing | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: pnpm/action-setup@v2.0.1 | ||
with: | ||
version: ${{ env.PNPM_VERSION }} | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16.x | ||
cache: pnpm | ||
- run: pnpm install | ||
- run: pnpm run test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 14.x | ||
registry-url: 'https://registry.npmjs.org' | ||
|
||
- run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.gitignore | ||
.pnpm-lock.yaml | ||
.prettierignore | ||
.prettierrc.js | ||
.release-it.js | ||
node_modules | ||
RELEASE.md | ||
rollup.config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# compiled output | ||
/dist/ | ||
|
||
# dependencies | ||
/node_modules/ | ||
|
||
# misc | ||
/coverage/ | ||
!.* | ||
.eslintcache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
singleQuote: true, | ||
printWidth: 100, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module.exports = { | ||
plugins: { | ||
'release-it-lerna-changelog': { | ||
infile: 'CHANGELOG.md', | ||
}, | ||
}, | ||
git: { | ||
commitMessage: 'v${version}', | ||
tagName: 'v${version}', | ||
}, | ||
github: { | ||
release: true, | ||
releaseName: 'v${version}', | ||
tokenRef: 'GITHUB_AUTH', | ||
}, | ||
npm: { | ||
publish: false, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,93 @@ | ||
# JavaScriptSDK | ||
JavaScript Package to send TelemetryDeck signals | ||
# Telemetry Deck JavaScript SDK | ||
|
||
This package allows you to send signals to [TelemetryDeck](https://telemetrydeck.com) from your JavaScript code. | ||
|
||
It has no package dependencies and supports modern evergreen browsers which support [cryptography](https://caniuse.com/cryptography). | ||
|
||
Signals sent with this version of the SDK automatically send the following payload items: | ||
|
||
- url | ||
- useragent | ||
- locale | ||
- platform | ||
|
||
You can filter and show these values in the TelemetryDeck dashboard. | ||
|
||
Test Mode is currently not supported. | ||
|
||
## Usage | ||
|
||
### 📄 Usage via Script Tag | ||
|
||
For regular websites and to try out the code quickly, you can use [UNPKG](https://unpkg.com), a free CDN which allows you to load files from any npm package. | ||
|
||
Include the following snippet in your page header: | ||
|
||
```html | ||
<script src="https://unpkg.com/@telemtrydeck/sdk/dist/telemetrydeck.min.js"> | ||
``` | ||
then include a script tag at the bottom of your page like this to send a signal once every time the page loads: | ||
```html | ||
<script> | ||
signal( | ||
// required options to identify your app and the user | ||
{ | ||
appID: 'YOUR_APP_ID', | ||
userIdentifier: 'ANONYMOUS', | ||
}, | ||
// optional: custom payload stored with the signal | ||
{ | ||
route: 'some/page/path', | ||
} | ||
); | ||
</script> | ||
``` | ||
|
||
Please replace `YOUR_APP_ID` with the app ID you received from TelemetryDeck, and set a user identifier if possible. | ||
|
||
### 📦 Usage for applications that use a bundler (like Webpack, Rollup, …) | ||
|
||
After installing the package via NPM, use it like this: | ||
|
||
```js | ||
import { signal } from 'telemetry-deck'; | ||
|
||
// | ||
signal( | ||
// required options to identify your app and the user | ||
{ | ||
appID: 'YOUR_APP_ID', | ||
userIdentifier: 'ANONYMOUS', | ||
}, | ||
// custom payload stored with the signal | ||
{ | ||
route: 'some/page/path', | ||
} | ||
); | ||
``` | ||
|
||
Please replace `YOUR_APP_ID` with the app ID you received from TelemetryDeck. If you have any string that identifies your user, such as an email address, pass it into `userIdentifier` – it will be cryptographically anonymized with a hash function. | ||
|
||
If you want to pass optional parameters to the signal being sent, add them to the optional paylaod object. | ||
|
||
## More Info | ||
|
||
### 📱 You need an App ID | ||
|
||
Every application and website registered to TelemetryDeck has its own unique ID that we use to assign incoming signals to the correct app. To get started, create a new app in the TelemetryDeck UI and copy its ID. | ||
|
||
### 👤 Optional: User Identifiers | ||
|
||
TelemetryDeck can count users if you assign it a unique identifier for each user that doesn't change. This identifier can be any string that is unique to the user, such as their email address, or a randomly generated UUID. | ||
|
||
Feel free to use personally identifiable information as the user identifier: We use a cryptographically secure double-hasing process on client and server to make sure the data that arrives at our servers is anonymized and can not be traced back to individual users via their identifiers. A user's identifier is hashed inside the library, and then salted+hashed again on arrival at the server. This way the data is anonymized as defined by the GDPR and you don't have to ask for user consent for procesing or storing this data. | ||
|
||
### 🚛 Optional: Payload | ||
|
||
You can optionally attach an object with string values to the signal. This will allow you to filter and aggregate signal by these values in the dashboard. | ||
|
||
### 📚 Full Docs | ||
|
||
Go to [docs.telemetrydeck.com](https://docs.telemetrydeck.com) to see all documentation articles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Release | ||
|
||
Releases are mostly automated using | ||
[release-it](https://github.com/release-it/release-it/) and | ||
[lerna-changelog](https://github.com/lerna/lerna-changelog/). | ||
|
||
## Preparation | ||
|
||
Since the majority of the actual release process is automated, the primary | ||
remaining task prior to releasing is confirming that all pull requests that | ||
have been merged since the last release have been labeled with the appropriate | ||
`lerna-changelog` labels and the titles have been updated to ensure they | ||
represent something that would make sense to our users. Some great information | ||
on why this is important can be found at | ||
[keepachangelog.com](https://keepachangelog.com/en/1.0.0/), but the overall | ||
guiding principle here is that changelogs are for humans, not machines. | ||
|
||
When reviewing merged PR's the labels to be used are: | ||
|
||
- breaking - Used when the PR is considered a breaking change. | ||
- enhancement - Used when the PR adds a new feature or enhancement. | ||
- bug - Used when the PR fixes a bug included in a previous release. | ||
- documentation - Used when the PR adds or updates documentation. | ||
- internal - Used for internal changes that still require a mention in the | ||
changelog/release notes. | ||
|
||
## Release | ||
|
||
Once the prep work is completed, the actual release is straight forward: | ||
|
||
- First, ensure that you have an environment variable with your GitHub token | ||
setup as `GITHUB_AUTH`. This token will be used for generating your changelog | ||
(unauthenticated requests to the GitHub API are heavily throttled) and for | ||
creating the GitHub release. Only "repo" access is needed; no "admin" | ||
or other scopes are required. | ||
|
||
- Next, ensure that you have installed your projects dependencies: | ||
|
||
``` | ||
pnpm install | ||
``` | ||
|
||
- And last (but not least 😁) do your release: | ||
|
||
``` | ||
pnpm release | ||
``` | ||
|
||
[release-it](https://github.com/release-it/release-it/) manages the actual | ||
release process. It will prompt you to to choose the version number after which | ||
you will have the chance to hand tweak the changelog to be used (for the | ||
`CHANGELOG.md` and GitHub release), then `release-it` continues on to tagging, | ||
pushing the tag and commits, etc. Finally GitHub Actions will build the commit | ||
and push the release to npm. | ||
|
||
### Credits | ||
|
||
Thie initial version of this document was copied from [ember-test-selectors](https://github.com/simplabs/ember-test-selectors/blob/master/RELEASE.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* For a detailed explanation regarding each configuration property, visit: | ||
* https://jestjs.io/docs/configuration | ||
*/ | ||
|
||
const { defaults } = require('jest-config'); | ||
const crypto = require('crypto'); | ||
const { TextEncoder } = require('util'); | ||
|
||
module.exports = { | ||
clearMocks: true, | ||
collectCoverage: false, | ||
globals: { | ||
...defaults.globals, | ||
crypto: { | ||
subtle: { | ||
digest: crypto.webcrypto.subtle.digest, | ||
}, | ||
}, | ||
TextEncoder, | ||
}, | ||
moduleFileExtensions: ['mjs', 'js', 'json'], | ||
preset: 'rollup-jest', | ||
setupFiles: ['./jest.setup.js'], | ||
testEnvironment: 'jsdom', | ||
testPathIgnorePatterns: ['/node_modules/'], | ||
testRegex: '((\\.|/)(test|spec))\\.(mjs?|js?|tsx?|ts?)$', | ||
transformIgnorePatterns: ['\\.pnp\\.[^\\/]+$'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const jestFetchMock = require('jest-fetch-mock'); | ||
|
||
jestFetchMock.enableMocks(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"name": "@telemetrydeck/sdk", | ||
"version": "0.1.0", | ||
"description": "JavaScript package to send TelemetryDeck signals", | ||
"main": "dist/telemetrydeck.js", | ||
"module": "src/telemetrydeck.mjs", | ||
"scripts": { | ||
"build": "rollup -c", | ||
"changelog": "lerna-changelog", | ||
"lint": "eslint . --cache", | ||
"lint:fix": "eslint . --fix", | ||
"release": "release-it", | ||
"test": "jest", | ||
"test:watch": "jest --watch" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/TelemetryDeck/JavaScriptSDK.git" | ||
}, | ||
"keywords": [ | ||
"TelemetryDeck", | ||
"tracking", | ||
"analytics", | ||
"sdk" | ||
], | ||
"author": "Daniel Jilg <daniel@telemetrydeck.com>", | ||
"contributors": [ | ||
"Florian Pichler <florian.pichler@simplabs.com> (https://florian.pichler.de)" | ||
], | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/TelemetryDeck/JavaScriptSDK/issues" | ||
}, | ||
"homepage": "https://github.com/TelemetryDeck/JavaScriptSDK#readme", | ||
"devDependencies": { | ||
"@rollup/plugin-json": "^4.1.0", | ||
"eslint": "^8.6.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-jest": "^25.3.4", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"eslint-plugin-unicorn": "^40.0.0", | ||
"jest": "^27.4.7", | ||
"jest-fetch-mock": "^3.0.3", | ||
"lerna-changelog": "^2.2.0", | ||
"prettier": "^2.5.1", | ||
"release-it": "^14.12.1", | ||
"release-it-lerna-changelog": "^4.0.1", | ||
"rollup": "^2.63.0", | ||
"rollup-jest": "^1.1.3", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"typescript": "^4.5.4" | ||
} | ||
} |
Oops, something went wrong.