Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.4.0 #13

Merged
merged 41 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
25ecef5
Minor updates to CI & Node version
MilosRandelovic Jul 19, 2023
6e38cb9
Updated README
MilosRandelovic Jul 19, 2023
2aeeaf2
Added Changelog
MilosRandelovic Jul 19, 2023
cd8e693
Fixed trackingId edge case bug + expanded commentary
MilosRandelovic Jul 19, 2023
9d2f3f7
Dependency & version bump
MilosRandelovic Jul 19, 2023
7b88edf
GitHub Action to upload browser builds to GCS
MilosRandelovic Jul 19, 2023
9b3ef14
Test the upload action
MilosRandelovic Jul 19, 2023
0a21416
Fixed a bug in the upload to GCS GitHub action
MilosRandelovic Jul 19, 2023
d5db910
Fixed bugs in the upload to GCS action
MilosRandelovic Jul 19, 2023
80fe9f2
Fixed bugs in the upload to GCS action
MilosRandelovic Jul 19, 2023
9f926aa
Fixed bugs in upload to GCS action
MilosRandelovic Jul 19, 2023
d3fc091
Fixed bugs in Upload to GCS action
MilosRandelovic Jul 19, 2023
7d5f62e
Fixed bugs in Upload to GCS action
MilosRandelovic Jul 19, 2023
3fe9054
Fixed bugs in upload to GCS action
MilosRandelovic Jul 19, 2023
601ad82
Fixed bugs in Upload to GCS action
MilosRandelovic Jul 19, 2023
fa16f6a
Fixed bugs in upload to GCS action
MilosRandelovic Jul 19, 2023
67df05d
Fixed bugs in upload to GCS action
MilosRandelovic Jul 19, 2023
13c4a83
Revert action to only run on publish
MilosRandelovic Jul 19, 2023
d85f86a
Fix a security vulnerability in indirectly referenced package
MilosRandelovic Jul 20, 2023
2695ce8
Test change to GitHub action
MilosRandelovic Jul 20, 2023
c0e072c
Updated CHANGELOG, reverted GitHub action trigger
MilosRandelovic Jul 20, 2023
962b8bf
Added tests & fixed cloning issue
MilosRandelovic Jul 20, 2023
23db185
Updated comment
MilosRandelovic Jul 20, 2023
83e58c8
Updated test case names for more clarity
MilosRandelovic Jul 20, 2023
49a94aa
Expanded test coverage
MilosRandelovic Jul 20, 2023
029ea31
Updated folder when publishing to CDN
MilosRandelovic Jul 20, 2023
7b7a1ab
Fixed linter config and dependencies
MilosRandelovic Jul 24, 2023
8c30c8a
Fixed linter errors based on new config
MilosRandelovic Jul 24, 2023
2e310b5
Updated CHANGELOG
MilosRandelovic Jul 24, 2023
a2a1196
Added Node version to package.json
MilosRandelovic Jul 24, 2023
df2c1bb
Updated CI to test different node versions: LTS and latest
MilosRandelovic Jul 24, 2023
b6234a4
Updated .nvmrc to match CI builds
MilosRandelovic Jul 24, 2023
2dc1631
Updated Actions yaml files for consistency
MilosRandelovic Jul 24, 2023
2ac6a91
Updated CHANGELOG
MilosRandelovic Jul 24, 2023
459fa2e
Updated Publish workflow for consistency
MilosRandelovic Jul 24, 2023
3114cbd
Updated package.json
MilosRandelovic Jul 24, 2023
34daca2
Fixed build order
MilosRandelovic Jul 24, 2023
1b2a8b4
Bump version to 1.4.0
MilosRandelovic Jul 25, 2023
7c69ca6
Renamed browser builds to bundles
MilosRandelovic Jul 25, 2023
1a758b1
Updated README
MilosRandelovic Jul 25, 2023
b9e25a3
Updated README
MilosRandelovic Jul 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,38 @@
"browser": true,
"es2021": true
},
"extends": ["standard-with-typescript", "eslint:recommended", "eslint-config-prettier", "prettier"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"plugin:n/recommended",
"plugin:promise/recommended",
"plugin:vitest/recommended",
"eslint-config-prettier",
"prettier"
],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module",
"project": "tsconfig.eslint.json"
},
"plugins": ["prettier", "vitest"],
"plugins": [
"@typescript-eslint",
"import",
"n",
"prettier",
"promise",
"vitest"
],
"rules": {
"prettier/prettier": ["warn"]
"@typescript-eslint/no-explicit-any": "off",
"prettier/prettier": "warn"
},
"settings": {
"import/resolver": {
"typescript": true
}
}
}
36 changes: 18 additions & 18 deletions .github/workflows/ci.yaml
MilosRandelovic marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
name: Node.js CI
name: CI

on:
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest
name: CI build & test

strategy:
matrix:
node-version: [18.x]
node-version: [16, 18, latest]
os: [ubuntu-latest]

runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v3

- name: Using Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- name: Using Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'

- name: Install dependencies
run: yarn --network-concurrency 8 || yarn --check-files --cache-folder .ycache && rm -rf .ycache
- name: Install dependencies & Build output
run: yarn --network-concurrency 8 || yarn --check-files --cache-folder .ycache && rm -rf .ycache

- name: Run tests
run: yarn test
- name: Run tests
run: yarn test

- name: Check for lint errors
run: yarn lint

- name: Check for lint errors
run: yarn lint
10 changes: 6 additions & 4 deletions .github/workflows/publish-to-npm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ on:

jobs:
publish:
runs-on: ubuntu-latest
name: Publish to NPM

strategy:
matrix:
node-version: [18.x]
node-version: [18]
os: [ubuntu-latest]

runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -29,7 +31,7 @@ jobs:

- name: Publish to NPM
run: |
yarn config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}"
yarn config set '//registry.npmjs.org/:_authToken' "${NPMJS_ACCESS_TOKEN}"
yarn publish --verbose
env:
NODE_AUTH_TOKEN: ${{ secrets.NPMJS_ACCESS_TOKEN }}
NPMJS_ACCESS_TOKEN: ${{ secrets.NPMJS_ACCESS_TOKEN }}
74 changes: 74 additions & 0 deletions .github/workflows/upload-browser-builds-to-cdn.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Upload browser builds to CDN

on:
release:
types: [published]

jobs:
upload:
name: Upload Browser Builds to GCS

strategy:
matrix:
node-version: [18]
os: [ubuntu-latest]

runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Using Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'

- name: Install dependencies & build lib folder
run: yarn --network-concurrency 8 || yarn --check-files --cache-folder .ycache && rm -rf .ycache

- name: Debug - Output Browser Build Files To Be Copied
run: ls -la $GITHUB_WORKSPACE/lib/browser

- name: Check Google Cloud SDK Presence
id: check-gcloud-sdk
run: |
if command -v gcloud >/dev/null 2>&1; then
echo "Google Cloud SDK is already installed."
exit 0
else
echo "Google Cloud SDK not found. Proceeding with installation."
exit 1
fi

- name: Install Google Cloud SDK (optional - if not present)
if: steps.check-gcloud-sdk.outputs.result == '1'
run: |
curl https://sdk.cloud.google.com | bash
exec -l $SHELL

- name: Create Temporary Service Account Key File
id: create-key-file
run: |
echo "$GCP_CREDENTIALS" > /tmp/keyfile.json
env:
GCP_CREDENTIALS: ${{ secrets.GCP_SERVICE_ACCOUNT_CREDENTIALS }}

- name: Authenticate with Google Cloud
run: gcloud auth activate-service-account --key-file=/tmp/keyfile.json

- name: Delete Temporary Key File
run: rm /tmp/keyfile.json

- name: Extract Version from package.json
id: extract-version
run: |
VERSION=$(node -p "require('./package.json').version")
MAJOR_MINOR_VERSION=$(echo $VERSION | cut -d '.' -f 1-2)
echo "::set-output name=version::$MAJOR_MINOR_VERSION"
echo "Uploading browser libraries for version v$MAJOR_MINOR_VERSION"

- name: Upload Browser Build Files
run: |
VERSION=${{ steps.extract-version.outputs.version }}
gsutil -m cp -r $GITHUB_WORKSPACE/lib/browser/* gs://${{ secrets.GCS_BUCKET_NAME }}/lib/js/v${VERSION}/
3 changes: 2 additions & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
v18.16.0
# Supported Node.js versions: 16.x (LTS), 18.x (LTS) and 20.x (latest)
16
53 changes: 53 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Mini Digital SDK Changelog

## [v1.3.2](https://github.com/WunderbarNetwork/mini-digital-sdk-js/compare/v1.3.1...v1.3.2) (2023-07-24)

Added:

- Added the CHANGELOG.md file
- Dev: Greatly expanded the test coverage
- Dev: GitHub action which uploads browser builds to the Mini Digital CDN
- Dev: CI/Build runs on all supported Node versions - 16 (LTS), 18 (LTS) & 20 (latest)

Fixed:

- TrackingID was not set correctly in certain edge cases
- Updated dependency packages to fix vulnerability (CVE-2022-25883)
Note that the vulnerability only affected devDependency packages (i.e. does not affect production builds)
- Dev: ESLint wasn't loading all the plugins and configs before

## [v1.3.1](https://github.com/WunderbarNetwork/mini-digital-sdk-js/compare/v1.3.0...v1.3.1) (2023-07-06)

Fixed:

- Publishing to npm applied the wrong tag, now applies latest tag

## [v1.3.0](https://github.com/WunderbarNetwork/mini-digital-sdk-js/compare/v1.2.0...v1.3.0) (2023-07-06)

- Automatic retry on HTTP 500 errors returned from the server
- Better handling of HTTP errors, including a newly exported `HttpError` class
- New config options: `errorRetryIntervalMs`, `maxRetriesOn500`
- GitHub action to automatically publish to npm, fixed CI action
- Improved tests
- Minor refactoring

## [v1.2.0](https://github.com/WunderbarNetwork/mini-digital-sdk-js/compare/v1.1.0...v1.2.0) (2023-06-30)

- New config params: pauseTracking, useCookies
- Fixed a bug with setting cookie time
- Fixed a bug when 401 from the server (if the origin was missing) would not result in an error being thrown
- Added tests & GitHub CI Workflow to run them
- Updated README, package.json and .npmrc - ready for npm publish

## [v1.1.0](https://github.com/WunderbarNetwork/mini-digital-sdk-js/compare/v1.0.1...v1.1.0) (2023-06-16)

- Using cookies to store TrackingID and JWT tokens
- Bug fixes & documentation improvements

## [v1.0.1](https://github.com/WunderbarNetwork/mini-digital-sdk-js/compare/v1.0.0...v1.0.1) (2023-06-08)

- Changed internal API routes

## [v1.0.0](https://github.com/WunderbarNetwork/mini-digital-sdk-js/compare/v0.1.0...v1.0.0) (2023-06-07)

First public release of Mini Digital.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# @wunderbar-network/mini-digital-sdk

[![CI](https://github.com/WunderbarNetwork/mini-digital-sdk-js/actions/workflows/ci.yaml/badge.svg)](https://github.com/WunderbarNetwork/mini-digital-sdk-js/actions/workflows/ci.yaml)

Library that provides an interface to capture analytics events, and send them to [Mini Digital](https://mini.digital). This library can be used in either Node.js or browser-based TypeScript/JavaScript implementations (including frameworks like React or Vue).

## Installation
Expand Down Expand Up @@ -40,7 +42,7 @@ See our API reference to get a deeper understanding of the event schema.

### Browser builds

If you want a browser-friendly build to use directly into your HTML code, browser builds (CJS/ESM) can be found in the `lib/browser` folder.
If you want a browser-friendly build to use directly into your HTML code, browser builds (CJS/ESM/UMD) can be found in the `lib/browser` folder.

### Config

Expand Down
32 changes: 20 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "@wunderbar-network/mini-digital-sdk",
"version": "1.3.1",
"version": "1.3.2",
"description": "SDK for back-end (Node) and front-end (TypeScript/JavaScript) applications, to send analytics events to Mini.Digital",
"private": false,
"exports": {
".": {
"types": "./lib/node/types/index.d.ts",
Expand All @@ -19,9 +20,10 @@
"browser": "lib/browser/mini-digital-sdk.esm.js",
"scripts": {
"clean": "rm -rf ./lib",
"build": "npm run build:node && npm run build:browser",
"build:node": "npm run clean && tsc --build && mv lib/node/index.js lib/node/index.mjs && node post-build.js",
"build": "npm run build:node && npm run build:post && npm run build:browser",
"build:node": "npm run clean && tsc --build && mv lib/node/index.js lib/node/index.mjs",
"build:browser": "rollup -c",
"build:post": "node post-build.js",
"prepare": "npm run build",
"test": "vitest run",
"lint": "eslint . --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .gitignore"
Expand All @@ -31,29 +33,35 @@
"uuid": "^9.0.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.2",
"@rollup/plugin-commonjs": "^25.0.3",
"@rollup/plugin-node-resolve": "^15.1.0",
"@rollup/plugin-terser": "^0.4.3",
"@types/js-cookie": "^3.0.3",
"@types/jsdom": "^21.1.1",
"@types/uuid": "^9.0.2",
"@typescript-eslint/eslint-plugin": "^5.61.0",
"@typescript-eslint/parser": "^5.61.0",
"eslint": "^8.44.0",
"@typescript-eslint/eslint-plugin": "^6.1.0",
"@typescript-eslint/parser": "^6.1.0",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.8.0",
"eslint-config-standard-with-typescript": "^36.0.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-n": "^16.0.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-vitest": "^0.2.6",
"jsdom": "^22.1.0",
"prettier": "^2.8.8",
"rollup": "^3.26.1",
"prettier": "^3.0.0",
"rollup": "^3.26.3",
"typescript": "^5.1.6",
"vitest": "^0.32.4",
"vitest": "^0.33.0",
"vitest-fetch-mock": "^0.2.2"
},
"resolutions": {
"semver": "^7.5.4"
},
"engines": {
"node": ">=16.0.0, <17.0.0 || >=18.0.0, <19.0.0 || >=20.0.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/WunderbarNetwork/mini-digital-sdk-js.git"
Expand Down
Loading