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-535] Revisit angular repo #61

Merged
merged 20 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
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
16 changes: 0 additions & 16 deletions .browserslistrc

This file was deleted.

17 changes: 2 additions & 15 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,12 @@ module.exports = {
es6: true,
node: true,
},
extends: ['plugin:@typescript-eslint/eslint-recommended'],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parser: '@typescript-eslint/parser',
extends: ['plugin:@typescript-eslint/eslint-recommended', '@fingerprintjs/eslint-config-dx-team'],
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
// project: ['./tsconfig.app.json'],
},
settings: {},
plugins: ['@typescript-eslint', 'prettier', '@angular-eslint/eslint-plugin'],
ignorePatterns: ['build/*'],
rules: {
'linebreak-style': ['error', 'unix'],
'prefer-const': 'error',
'@typescript-eslint/no-unused-vars': ['error'],
curly: [2, 'all'],
'prettier/prettier': 'error',
},
};
}
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ jobs:
name: Build project and run CI checks
uses: fingerprintjs/dx-team-toolkit/.github/workflows/build-typescript-project.yml@v1
with:
runAfterInstall: yarn generate:version
runAfterInstall: pnpm generate:version
2 changes: 1 addition & 1 deletion .github/workflows/coverage-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ jobs:
pull-requests: write
uses: fingerprintjs/dx-team-toolkit/.github/workflows/coverage-diff.yml@v1
with:
runAfterInstall: yarn generate:version
runAfterInstall: pnpm generate:version
2 changes: 1 addition & 1 deletion .github/workflows/docs-and-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ jobs:
name: Generate docs and coverage report
uses: fingerprintjs/dx-team-toolkit/.github/workflows/docs-and-coverage.yml@v1
with:
run-after-install: yarn generate:version
run-after-install: pnpm generate:version
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
name: 'Build project, run CI checks and publish new release'
uses: fingerprintjs/dx-team-toolkit/.github/workflows/release-typescript-project.yml@v1
with:
runAfterInstall: yarn generate:version
runAfterInstall: pnpm generate:version
distFolderNeedForRelease: true
secrets:
GH_RELEASE_TOKEN: ${{ secrets.GH_RELEASE_TOKEN }}
Expand Down
9 changes: 1 addition & 8 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
{
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"arrowParens": "always"
}
"@fingerprintjs/prettier-config-dx-team"
84 changes: 3 additions & 81 deletions .releaserc
Original file line number Diff line number Diff line change
Expand Up @@ -16,93 +16,15 @@
[
"@semantic-release/commit-analyzer",
{
"releaseRules": [
{
"type": "build",
"scope": "deps",
"release": "patch"
},
{
"type": "docs",
"scope": "README",
"release": "patch"
}
]
"config": "@fingerprintjs/conventional-changelog-dx-team",
"releaseRules": "@fingerprintjs/conventional-changelog-dx-team/release-rules"
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalCommits",
"presetConfig": {
"types": [
{
"type": "feat",
"section": "Features"
},
{
"type": "feature",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "perf",
"section": "Performance Improvements"
},
{
"type": "revert",
"section": "Reverts"
},
{
"type": "docs",
"scope": "README",
"section": "Documentation"
},
{
"type": "build",
"scope": "deps",
"section": "Build System"
},
{
"type": "docs",
"section": "Documentation",
"hidden": true
},
{
"type": "style",
"section": "Styles",
"hidden": true
},
{
"type": "chore",
"section": "Miscellaneous Chores",
"hidden": true
},
{
"type": "refactor",
"section": "Code Refactoring",
"hidden": true
},
{
"type": "test",
"section": "Tests",
"hidden": true
},
{
"type": "build",
"section": "Build System",
"hidden": true
},
{
"type": "ci",
"section": "Continuous Integration",
"hidden": true
}
]
}
"config": "@fingerprintjs/conventional-changelog-dx-team"
}
],
"@semantic-release/changelog",
Expand Down
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ The following dependencies are required:

- TypeScript >=4.6
- Node 16+
- Angular 13+
- Angular 15+

## Installation

ilfa marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -135,6 +135,39 @@ export class HomeComponent {

The library can be used with Angular Universal. Keep in mind that visitor identification is only possible in the browser, so your visitor identification code should only run client-side. See the example implementation for more details.

## Linking and tagging information
The `visitorId` provided by Fingerprint Identification is especially useful when combined with information you already know about your users, for example, account IDs, order IDs, etc. To learn more about various applications of the `linkedId` and `tag`, see [Linking and tagging information](https://dev.fingerprint.com/docs/tagging-information).

Associate your data with a visitor ID using the `linkedId` or `tag` parameter of the options object passed into the `useVisitorData()` hook or the `getData` function:
```ts
// ...

import { Component } from '@angular/core';
import { FingerprintjsProAngularService } from '@fingerprintjs/fingerprintjs-pro-angular';

@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.css']
})
export class HomeComponent {

constructor(private fingerprintjsProAngularService: FingerprintjsProAngularService) {}

async onIdentifyButtonClick() : Promise<void> {
const data = await this.fingerprintjsProAngularService.getVisitorData({
linkedId: "user_1234",
tag: {
userAction: "login",
analyticsId: "UA-5555-1111-1"
}
});

// ...
}
}
```

## Caching strategy

Fingerprint Pro usage is billed per API call. To avoid unnecessary API calls, it is a good practice to [cache identification results](https://dev.fingerprint.com/docs/caching-visitor-information). By default, the SDK uses `sessionStorage` to cache results.
Expand Down
7 changes: 4 additions & 3 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"version": 1,
"cli": {
"analytics": "a6cb7b38-1d2c-43d9-ad01-261b71d9a104",
"defaultCollection": "@angular-eslint/schematics"
"schematicCollections": [
"@angular-eslint/schematics"
]
},
"newProjectRoot": "projects",
"projects": {
Expand Down Expand Up @@ -206,6 +208,5 @@
}
}
}
},
"defaultProject": "fingerprintjs-pro-angular-demo"
}
}
21 changes: 10 additions & 11 deletions bin/generate-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,20 @@
* So if we will try to import package.json that is situated outside the src folder, we will get an error
* Similar problem is described here https://stackoverflow.com/questions/51850063/rootdir-is-expected-to-contain-all-source-files
*/
const { writeFileSync, readFileSync } = require('fs');
const { writeFileSync, readFileSync } = require('fs')

const packageFilePath = './projects/fingerprintjs-pro-angular/package.json';
const versionFilePath =
'./projects/fingerprintjs-pro-angular/src/lib/version.ts';
const packageFilePath = './projects/fingerprintjs-pro-angular/package.json'
const versionFilePath = './projects/fingerprintjs-pro-angular/src/lib/version.ts'

const packageInfo = JSON.parse(readFileSync(packageFilePath).toString());
const packageInfo = JSON.parse(readFileSync(packageFilePath).toString())

const newVersion = process.argv[2] || packageInfo.version;
const newVersion = process.argv[2] || packageInfo.version

packageInfo.version = newVersion;
writeFileSync(packageFilePath, JSON.stringify(packageInfo, null, ' '));
packageInfo.version = newVersion
writeFileSync(packageFilePath, JSON.stringify(packageInfo, null, ' '))

const versionContent = `export const packageVersion = '${packageInfo.version}';\n`;
const versionContent = `export const packageVersion = '${packageInfo.version}'\n`

writeFileSync(versionFilePath, versionContent);
writeFileSync(versionFilePath, versionContent)

console.log('Version generated successfully');
console.log('Version generated successfully')
2 changes: 1 addition & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = { extends: ['@commitlint/config-conventional'] };
module.exports = { extends: ['@fingerprintjs/commit-lint-dx-team'] }
8 changes: 2 additions & 6 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,5 @@ module.exports = {
setupFilesAfterEnv: ['./test.ts'],
testRegex: '.+spec.ts$',
collectCoverageFrom: ['projects/fingerprintjs-pro-angular/**/**.{ts,tsx}'],
coverageReporters: [
'lcov',
'json-summary',
['text', { file: 'coverage.txt', path: './' }],
],
};
coverageReporters: ['lcov', 'json-summary', ['text', { file: 'coverage.txt', path: './' }]],
}
62 changes: 31 additions & 31 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,60 +15,60 @@
"generate:version": "node bin/generate-version.js",
"lint": "eslint --ext .js,.ts --ignore-path .gitignore --max-warnings 0 .",
"lint:fix": "eslint --ext .js,.ts --ignore-path .gitignore --max-warnings 0 --fix .",
"test:dts": "tsc --noEmit --isolatedModules dist/fingerprintjs-pro-angular/fingerprintjs-fingerprintjs-pro-angular.d.ts",
"test:dts": "tsc --noEmit --isolatedModules dist/fingerprintjs-pro-angular/index.d.ts",
"test": "jest",
"test:coverage": "jest --coverage",
"docs": "typedoc projects/fingerprintjs-pro-angular/src/public-api.ts --out docs"
},
"private": true,
"dependencies": {
"@angular/animations": "~13.3.0",
"@angular/common": "~13.3.0",
"@angular/compiler": "~13.3.0",
"@angular/core": "~13.3.0",
"@angular/forms": "~13.3.0",
"@angular/platform-browser": "~13.3.0",
"@angular/platform-browser-dynamic": "~13.3.0",
"@angular/platform-server": "~13.3.0",
"@angular/router": "~13.3.0",
"@nguniversal/express-engine": "13.1.1",
"@angular/animations": "^15.2.10",
"@angular/common": "^15.2.10",
"@angular/compiler": "^15.2.10",
"@angular/core": "^15.2.10",
"@angular/forms": "^15.2.10",
"@angular/platform-browser": "^15.2.10",
"@angular/platform-browser-dynamic": "^15.2.10",
"@angular/platform-server": "^15.2.10",
"@angular/router": "^15.2.10",
"@fingerprintjs/fingerprintjs-pro-spa": "^1.3.1",
"@nguniversal/express-engine": "^15.2.1",
"express": "^4.15.2",
"rxjs": "~7.5.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~13.3.6",
"@angular-eslint/schematics": "^13.2.1",
"@angular/cli": "~13.3.6",
"@angular/compiler-cli": "~13.3.0",
"@angular-devkit/build-angular": "^15.2.10",
"@angular-eslint/schematics": "^15.2.1",
"@angular/cli": "^15.2.10",
ilfa marked this conversation as resolved.
Show resolved Hide resolved
"@angular/compiler-cli": "^15.2.10",
"@commitlint/cli": "^17.2.0",
"@commitlint/config-conventional": "^17.2.0",
"@nguniversal/builders": "^13.1.1",
"@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/prettier-config-dx-team": "^0.1.0",
"@nguniversal/builders": "^15.2.1",
"@types/express": "^4.17.0",
"@types/jest": "^27.5.1",
"@types/jest": "^29.5.12",
"@types/node": "^12.11.1",
"@typescript-eslint/eslint-plugin": "^5.27.0",
"@typescript-eslint/parser": "^5.27.0",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"commitizen": "^4.2.5",
"conventional-changelog-conventionalcommits": "^5.0.0",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.16.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"husky": "^8.0.2",
"jasmine-core": "~4.0.0",
"jest": "^28.1.0",
"jest-preset-angular": "^12.0.1",
"jest": "^29.7.0",
"jest-preset-angular": "^14.0.3",
"lint-staged": "^13.0.3",
"ng-packagr": "^13.0.0",
"prettier": "^2.6.2",
"ng-packagr": "^15.2.2",
"prettier": "^3.2.4",
"typedoc": "^0.24.8",
"typescript": "~4.6.2"
"typescript": "~4.9.5"
},
"lint-staged": {
"*.ts": "yarn run lint:fix",
"*.tsx": "yarn run lint:fix"
"*.ts": "pnpm lint:fix",
"*.tsx": "pnpm lint:fix"
},
"config": {
"commitizen": {
Expand Down
Loading
Loading