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

[INTER-549] Revisit #24

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
34 changes: 1 addition & 33 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,3 @@
module.exports = {
env: {
browser: true,
es6: true,
node: true,
},
extends: ['plugin:@typescript-eslint/eslint-recommended'],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2020,
sourceType: 'module',
},
settings: {
react: {
version: 'detect',
},
},
plugins: ['@typescript-eslint', 'prettier'],
ignorePatterns: ['build/*'],
rules: {
semi: ['error', 'never'],
'linebreak-style': ['error', 'unix'],
'prefer-const': 'error',
'prettier/prettier': 'error',
'@typescript-eslint/no-unused-vars': ['error'],
curly: [2, 'all'],
},
extends: ['@fingerprintjs/eslint-config-dx-team'],
}
11 changes: 11 additions & 0 deletions .github/workflows/analyze-commits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Analyze Commit Messages
on:
pull_request:

permissions:
pull-requests: write
contents: write
jobs:
analyze-commits:
name: Analyze commits
uses: fingerprintjs/dx-team-toolkit/.github/workflows/analyze-commits.yml@v1
33 changes: 0 additions & 33 deletions .github/workflows/build.yml

This file was deleted.

12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: ci
on:
push:
branches-ignore:
- main
paths-ignore:
- '**.md'

jobs:
build-and-check:
name: Build project and run CI checks
uses: fingerprintjs/dx-team-toolkit/.github/workflows/build-typescript-project.yml@v1
12 changes: 12 additions & 0 deletions .github/workflows/coverage-diff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Check coverage for PR

on:
pull_request:

jobs:
run-tests-check-coverage:
name: Run tests & check coverage
permissions:
checks: write
pull-requests: write
uses: fingerprintjs/dx-team-toolkit/.github/workflows/coverage-diff.yml@v1
13 changes: 13 additions & 0 deletions .github/workflows/docs-and-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Generate docs and coverage report

on:
push:
branches:
- main

jobs:
skip-docs-step:
name: Generate coverage report
uses: fingerprintjs/dx-team-toolkit/.github/workflows/docs-and-coverage.yml@v1
with:
skip-docs-setp: true
ilfa marked this conversation as resolved.
Show resolved Hide resolved
41 changes: 9 additions & 32 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,14 @@ on:
push:
branches:
- main
paths-ignore:
- '**.md'
- test

jobs:
npm-publish:
name: npm-publish
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cache
uses: actions/cache@v2
with:
path: node_modules
key: nodemodules-${{ hashFiles('yarn.lock') }}
restore-keys: nodemodules-
- name: Install Node packages
run: yarn install
- name: Build
run: yarn build
- name: Run tests
run: yarn test
- name: Publish if version has been updated
uses: pascalgn/npm-publish-action@374314eadce0ca5353387666469a949f69414752
with:
tag_name: "v%s"
tag_message: "v%s"
commit_pattern: "^v?(\\d+\\.\\d+\\.\\d+(?:-(?:alpha|beta)\\.\\d+)?)$"
publish_command: "yarn"
publish_args: "--non-interactive --access=public --new-version"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
build-and-release:
name: 'Build project, run CI checks and publish new release'
uses: fingerprintjs/dx-team-toolkit/.github/workflows/release-typescript-project.yml@v1
with:
appId: ${{ vars.APP_ID }}
secrets:
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
12 changes: 12 additions & 0 deletions .github/workflows/reset-prerelease-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Reset Prerelease Branch
on:
workflow_dispatch:

jobs:
reset-feature-branch:
uses: fingerprintjs/dx-team-toolkit/.github/workflows/reset-prerelease-branch.yml@v1
with:
branch_name: 'test'
appId: ${{ vars.APP_ID }}
secrets:
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx commitlint --edit $1
13 changes: 1 addition & 12 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,12 +1 @@
{
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true,
"jsxSingleQuote": true,
"trailingComma": "es5",
"bracketSpacing": true,
"bracketSameLine": false,
"arrowParens": "always"
}
"@fingerprintjs/prettier-config-dx-team"
51 changes: 51 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"branches": [
"main",
{
"name": "test",
"prerelease": true
}
],
"tagFormat": "v${version}",
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"config": "@fingerprintjs/conventional-changelog-dx-team",
"releaseRules": "@fingerprintjs/conventional-changelog-dx-team/release-rules"
}
],
[
"@semantic-release/release-notes-generator",
{
"config": "@fingerprintjs/conventional-changelog-dx-team"
}
],
"@semantic-release/changelog",
"@semantic-release/npm",
[
"@semantic-release/exec",
{
"prepareCmd": "pnpm build && tsx scripts/updateMetadata.ts ${nextRelease.gitHead} ${nextRelease.notes}"
}
],
[
"@semantic-release/git",
{
"assets": [
"CHANGELOG.md",
"package.json"
]
}
],
[
"@semantic-release/github",
{
"assets": [
{ "path": "template.tpl", "label": "GTM Template" },
{ "path": "dist/fpjs-pro-gtm.esm.js", "label": "JS distribution" }
]
}
]
]
}
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<p align="center">
<a href="https://fingerprint.com">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="resources/logo_light.svg" />
<source media="(prefers-color-scheme: light)" srcset="resources/logo_dark.svg" />
<img src="resources/logo_dark.svg" alt="Fingerprint logo" width="312px" />
</picture>
<source media="(prefers-color-scheme: dark)" srcset="https://fingerprintjs.github.io/home/resources/logo_light.svg" />
<source media="(prefers-color-scheme: light)" srcset="https://fingerprintjs.github.io/home/resources/logo_dark.svg" />
<img src="https://raw.githubusercontent.com/fingerprintjs/fingerprint-pro-server-api-go-sdk/main/res/logo_dark.svg" alt="Fingerprint logo" width="312px" />
</picture>
</a>
</p>
<p align="center">
Expand All @@ -23,7 +23,7 @@ For step-by-step instructions on using this integration, see the full [Google Ta
## Usage

1. [Sign up](https://dashboard.fingerprint.com/signup) for a Fingerprint Pro account if you haven't already.
2. Import this [template](https://github.com/fingerprintjs/fingerprintjs-pro-gtm/blob/main/template.tpl) into your Google Tag Manager workspace.
2. Import this `template.tpl` from [latest release](https://github.com/fingerprintjs/fingerprintjs-pro-gtm/releases) into your Google Tag Manager workspace.
3. Add a Fingerprint Pro tag to your website. You will need your public API key and application region.
4. Use the `FingerprintJSProResult` or your own *Custom result name* to access the Fingerprint Pro result in GTM's `dataLayer`.
5. Use `FingerprintJSPro.loaded` and `FingerprintJSPro.identified` to create custom events and trigger actions after the JS agent is loaded or the visitor is identified.
Expand Down
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ['@fingerprintjs/commit-lint-dx-team'] }
17 changes: 11 additions & 6 deletions contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ More information about CDN you can get in [CDN repository](https://github.com/fi

The following dependencies are required:

- Node 16+
- Typescript 4.5+
- Node 20+
- Typescript 5+

## Example of usage

Expand Down Expand Up @@ -86,10 +86,15 @@ yarn typecheck
```

### How to publish
- Create a new branch
- Run `yarn release:(major|minor|patch)` depending on the version you need
- Make a pull request
- After merging the pull request into the main branch and after successful tests, GitHub Action will publish a new version to the npm
The library is automatically released and published on every push to the main branch if there are relevant changes using [semantic-release](https://github.com/semantic-release/semantic-release) with following plugins:
* [@semantic-release/commit-analyzer](https://github.com/semantic-release/commit-analyzer)
* [@semantic-release/release-notes-generator](https://github.com/semantic-release/release-notes-generator)
* [@semantic-release/changelog](https://github.com/semantic-release/changelog)
* [@semantic-release/npm](https://github.com/semantic-release/npm)
* [@semantic-release/exec](https://github.com/semantic-release/exec)
* [@semantic-release/github](https://github.com/semantic-release/github)

The workflow must be approved by one of the maintainers, first.

# Contributing to Fingerprint Pro Google Tag Manager template

Expand Down
2 changes: 2 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ module.exports = {
preset: 'ts-jest',
testEnvironment: 'jsdom',
testRegex: '/__tests__/.+test.tsx?$',
collectCoverageFrom: ['./src/**/**.{ts,tsx}'],
coverageReporters: ['lcov', 'json-summary', ['text', { file: 'coverage.txt', path: './' }]],
}
52 changes: 32 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,54 @@
"description": "FingerprintJS pro version adapter for Google Tag Manager",
"author": "FingerprintJS, Inc (https://fingerprint.com)",
"license": "MIT",
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/fingerprintjs/fingerprintjs-pro-gtm.git"
},
"scripts": {
"build": "rimraf dist && rollup -c",
"build": "rimraf dist && rollup -c --bundleConfigAsCjs",
"lint": "eslint --ext .js,.ts --ignore-path .gitignore --max-warnings 0 .",
"lint:fix": "yarn lint --fix",
"typecheck": "tsc --noEmit",
"test:dts": "tsc --noEmit",
"test": "jest",
"release:major": "changelog -M && git add CHANGELOG.md && yarn version --major --no-git-tag-version",
"release:minor": "changelog -m && git add CHANGELOG.md && yarn version --minor --no-git-tag-version",
"release:patch": "changelog -p && git add CHANGELOG.md && yarn version --patch --no-git-tag-version"
"test:coverage": "jest --coverage",
"prepare": "husky"
},
"module": "dist/fpjs-pro-gtm.esm.js",
"files": [
"dist"
],
"devDependencies": {
"@commitlint/cli": "^16.2.4",
"@commitlint/config-conventional": "^16.2.4",
"@fingerprintjs/commit-lint-dx-team": "^0.0.2",
"@fingerprintjs/conventional-changelog-dx-team": "^0.1.0",
"@fingerprintjs/eslint-config-dx-team": "^0.1.0",
"@fingerprintjs/fingerprintjs-pro": "^3.6.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.1.3",
"@rollup/plugin-typescript": "^8.3.1",
"@types/jest": "^27.4.0",
"@typescript-eslint/eslint-plugin": "^5.12.0",
"@typescript-eslint/parser": "^5.12.0",
"@fingerprintjs/prettier-config-dx-team": "^0.1.0",
"@fingerprintjs/tsconfig-dx-team": "^0.0.2",
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-typescript": "^11.1.6",
"@types/jest": "^29.5.12",
"@types/node": "^20.11.30",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"eslint": "^8.9.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"generate-changelog": "^1.8.0",
"jest": "^27.5.1",
"prettier": "^2.5.1",
"rollup": "^2.70.1",
"rollup-plugin-license": "^2.7.0",
"husky": "^9.0.11",
"jest": "^29.7.0",
"rimraf": "^5.0.5",
"rollup": "^4.13.0",
"rollup-plugin-license": "^3.3.1",
"rollup-plugin-peer-deps-external": "^2.2.4",
"ts-jest": "^27.1.3",
"typescript": "^4.5.5"
"ts-jest": "^29.1.2",
"tslib": "^2.6.2",
"tsx": "^4.7.1",
"typescript": "^5.4.3",
"yaml": "^2.4.1"
},
"dependencies": {
"jest-environment-jsdom": "^29.7.0"
}
}
Loading
Loading