Skip to content

Commit 00907a2

Browse files
author
CRA Keishi Kawada
committed
ci: publish
1 parent 0fb9b69 commit 00907a2

File tree

6 files changed

+114
-74
lines changed

6 files changed

+114
-74
lines changed

.github/workflows/publish.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Publish Package to npmjs
2+
on:
3+
release:
4+
types: [published]
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
# Setup .npmrc file to publish to npm
11+
- uses: actions/setup-node@v3
12+
with:
13+
node-version: "18.x"
14+
registry-url: "https://registry.npmjs.org"
15+
- name: Check version consistency
16+
run: |
17+
PKG_VERSION=$(npm -p -c 'require("./package.json").version')
18+
RELEASE_VERSION=${{ github.event.release.tag_name }}
19+
if [ "v$PKG_VERSION" != "$RELEASE_VERSION" ]; then
20+
echo "Error: Package version ($PKG_VERSION) does not match release version ($RELEASE_VERSION)"
21+
exit 1
22+
fi
23+
working-directory: ./packages/hooks
24+
- run: npm ci
25+
- run: npm publish --access public
26+
env:
27+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
28+
working-directory: ./packages/hooks

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
registry=https://registry.npmjs.org/
2+
always-auth=true

CHANGELOG/v0_1/v0_1_3.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Changelog
2+
3+
## Fixes
4+
5+
- add README.md in hooks
6+
7+
## CI
8+
9+
- add npm publish step

README.md

Lines changed: 0 additions & 73 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages/hooks/README.md

packages/hooks/README.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<p align="center">
2+
<h1 align="center">react-hook-observability</h1>
3+
</p>
4+
5+
## About
6+
7+
**react-hook-observability** is a library that provides Observability as React Hooks in React.
8+
9+
**react-hook-observability** provides the following React Hooks.
10+
11+
| Hook Name | Description | README |
12+
| :----------------------- | :--------------------------------------- | :------------------------------------------------------------------------------- |
13+
| `useBrowserEventSpans` | Get spans when web browser event occurs. | [useBrowserEventSpans](./packages/hooks/use-browser-event-spans/README.md) |
14+
| `useClientConsoleTracer` | Get tracer in web browser console. | [useClientConsoleTracer](./packages/hooks/use-client-console-exporter/README.md) |
15+
16+
## Getting Started
17+
18+
Install the library.
19+
20+
### npm
21+
22+
```bash
23+
npm install @react-hook-observability/hooks
24+
```
25+
26+
### yarn
27+
28+
```bash
29+
yarn add @react-hook-observability/hooks
30+
```
31+
32+
### pnpm
33+
34+
```bash
35+
pnpm add @react-hook-observability/hooks
36+
```
37+
38+
### bun
39+
40+
```bash
41+
bun add @react-hook-observability/hooks
42+
```
43+
44+
## Usage
45+
46+
### useBrowserEventSpans + useClientConsoleExporter
47+
48+
```tsx
49+
export default function RootLayout({
50+
children,
51+
}: {
52+
children: React.ReactNode;
53+
}) {
54+
// 1. Setup Interactor and return following properties.
55+
// - watchRef: <html> tag ref
56+
// - spans: trace spans
57+
// - resetSpans: reset trace spans
58+
const { watchRef, spans, resetSpans } = useBrowserEventSpans({
59+
eventKinds: ["click"],
60+
batchConfig: {
61+
scheduledDelayMillis: 100,
62+
},
63+
});
64+
// 2. Setup Exporter. In this case, useClientConsoleExporter.
65+
useClientConsoleExporter({ spans, resetSpans, intervalDuration: 100 });
66+
// 3. Rendering html tag with watchRef.
67+
return (
68+
<html lang="en" ref={watchRef}>
69+
<body className={inter.className}>{children}</body>
70+
</html>
71+
);
72+
}
73+
```

packages/hooks/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@react-hook-observability/hooks",
3-
"version": "0.1.2",
3+
"version": "0.1.3",
44
"description": "provides Observability as React Hooks in React.",
55
"main": "dist/index.js",
66
"private": false,

0 commit comments

Comments
 (0)