Skip to content

Conversation

@JeanMeijer
Copy link
Collaborator

@JeanMeijer JeanMeijer commented Oct 10, 2025

Note

Introduce @simpleanalytics/react library and a Vite React example app demonstrating its usage.

  • Packages:
    • @simpleanalytics/react: New React package exposing SimpleAnalytics component plus trackEvent and trackPageview; injects SA script with configurable data-* props; includes utilities, types, build (tsup) and publish setup.
  • Examples:
    • examples/reactjs: New Vite + React (TS) example app integrating @simpleanalytics/react with basic UI; includes Vite, ESLint, TypeScript configs.
  • Tooling:
    • Adds build config (tsup), type declarations, and required project configs/deps for the new package and example.

Written by Cursor Bugbot for commit f5bd45b. This will update automatically on new commits. Configure here.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 10, 2025

Open in StackBlitz

npm i https://pkg.pr.new/simpleanalytics/next/@simpleanalytics/react@29

commit: a631bed

@adriaandotcom
Copy link
Collaborator

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no bugs!


Comment on lines 6 to 40

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 17 days ago

To fix the problem, add a permissions: block either at the workflow root (to affect all jobs) or to the specific job that requires it (in this case, the build job). The permissions should follow the principle of least privilege. Since the workflow appears to build and publish a package via a third-party tool and does not (in the shown steps) directly create pull requests, modify issues, or push to repo contents, it’s likely that only contents: read is needed. However, if the publishing tool requires broader GitHub permissions (e.g., contents: write or packages: write), those should be added, ideally after testing. For now, insert the minimal block for safety.

Insert the following block just below the workflow name: and before on: (affecting all jobs), or inside the job as shown in the background—here we will add it at the workflow root for clarity.

Suggested changeset 1
.github/workflows/publish-preview-next.yaml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/publish-preview-next.yaml b/.github/workflows/publish-preview-next.yaml
--- a/.github/workflows/publish-preview-next.yaml
+++ b/.github/workflows/publish-preview-next.yaml
@@ -1,4 +1,6 @@
 name: Publish Preview Package (Next.js)
+permissions:
+  contents: read
 on: [push, pull_request]
 
 jobs:
EOF
@@ -1,4 +1,6 @@
name: Publish Preview Package (Next.js)
permissions:
contents: read
on: [push, pull_request]

jobs:
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +6 to +40
name: Publish Preview Package (React.js)
runs-on: ubuntu-latest
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Enable Corepack
run: npm i -g corepack@latest && corepack enable

- name: Setup Node.js v22 LTS
uses: actions/setup-node@v4
with:
node-version: 22
cache: "pnpm"

- name: Cache Turborepo build setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-

- name: Install dependencies
run: pnpm install

- name: Build package
run: pnpm build --filter=@simpleanalytics/react

- name: Publish React preview package
run: pnpx pkg-pr-new publish './packages/react'

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 17 days ago

To resolve this issue, add an explicit permissions block to the workflow (just below the name or at the root, above on:) or specifically to the build job. Since the current workflow steps do not appear to require write access to repository contents or pull requests, the minimal safe permissions setting is contents: read. This restricts the automatic GITHUB_TOKEN to read-only access, significantly reducing risk. The edit should be made to the beginning of the .github/workflows/publish-preview-react.yaml file, either immediately after name: or within the build job definition.


Suggested changeset 1
.github/workflows/publish-preview-react.yaml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/publish-preview-react.yaml b/.github/workflows/publish-preview-react.yaml
--- a/.github/workflows/publish-preview-react.yaml
+++ b/.github/workflows/publish-preview-react.yaml
@@ -1,4 +1,6 @@
 name: Publish Preview Package (React.js)
+permissions:
+  contents: read
 on: [push, pull_request]
 
 jobs:
EOF
@@ -1,4 +1,6 @@
name: Publish Preview Package (React.js)
permissions:
contents: read
on: [push, pull_request]

jobs:
Copilot is powered by AI and may make mistakes. Always verify output.
Comment on lines +12 to +50
name: Release Package (React.js)
runs-on: ubuntu-latest
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Enable Corepack
run: npm i -g corepack@latest && corepack enable

- name: Setup Node.js v22 LTS
uses: actions/setup-node@v4
with:
node-version: 22
cache: "pnpm"
registry-url: https://registry.npmjs.org

- name: Cache Turborepo build setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-

- name: Install dependencies
run: pnpm install

- name: Build package
run: pnpm build --filter=@simpleanalytics/react

- name: Publish package
shell: bash
run: pnpm publish --filter=@simpleanalytics/react --access public --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 17 days ago

To fix the problem, you should add an explicit permissions block to the workflow, restricting the default token scope to the minimal required privileges. For this workflow, only read access to repository contents is necessary, since all publishing is handled with separate npm authentication and there are no steps that require write access to the repo, issues, or PRs. The best place to add this is right after the workflow name and on fields, before jobs, to apply it globally unless a job overrides it.

  • Edit .github/workflows/publish-react.yaml.
  • Insert the following lines:
    permissions:
      contents: read
    just after the on: section, before jobs:.
Suggested changeset 1
.github/workflows/publish-react.yaml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/publish-react.yaml b/.github/workflows/publish-react.yaml
--- a/.github/workflows/publish-react.yaml
+++ b/.github/workflows/publish-react.yaml
@@ -7,6 +7,9 @@
 
 concurrency: ${{ github.workflow }}-${{ github.ref }}
 
+permissions:
+  contents: read
+
 jobs:
   release:
     name: Release Package (React.js)
EOF
@@ -7,6 +7,9 @@

concurrency: ${{ github.workflow }}-${{ github.ref }}

permissions:
contents: read

jobs:
release:
name: Release Package (React.js)
Copilot is powered by AI and may make mistakes. Always verify output.
@JeanMeijer JeanMeijer marked this pull request as ready for review October 15, 2025 10:59
@JeanMeijer
Copy link
Collaborator Author

@adriaandotcom This one is ready. Are you fine with it being in the same repo as the Next.js plugin?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants