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 all 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
6 changes: 4 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ 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
appId: ${{ vars.APP_ID }}
secrets:
GH_RELEASE_TOKEN: ${{ secrets.GH_RELEASE_TOKEN }}
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

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
12 changes: 8 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ Run `yarn test` to execute the unit tests via [Jest](https://jestjs.io/).
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.

### 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 to NPM 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/github](https://github.com/semantic-release/github)

The workflow must be approved by one of the maintainers, first.
41 changes: 37 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<p align="center">
<a href="https://fingerprint.com">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/fingerprintjs/fingerprintjs-pro-angular/main/res/logo_light.svg" />
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/fingerprintjs/fingerprintjs-pro-angular/main/res/logo_dark.svg" />
<img src="https://raw.githubusercontent.com/fingerprintjs/fingerprintjs-pro-angular/main/res/logo_dark.svg" alt="Fingerprint logo" width="312px" />
<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 align="center">
Expand Down 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: './' }]],
}
Loading
Loading