-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change content script -> background script communication mechanism (#19)
* Changes from relying on externally_connectable to CustomEvents (which will eventually work in Firefox) * Adds patch to @opentelemetry/instrumentation-user-interaction so specified event listeners are always registered, regardless of whether any other page code has already registered listeners (see: open-telemetry/opentelemetry-js-contrib#1749) * Adds .github workflow files for (some) CI/CD * Updates README.md
- Loading branch information
Showing
18 changed files
with
1,411 additions
and
706 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "pnpm" # See documentation for possible values | ||
directory: "/" # Location of package manifests | ||
schedule: | ||
interval: "weekly" | ||
labels: | ||
- automerge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
- uses: pnpm/action-setup@v4 | ||
name: Install pnpm | ||
with: | ||
run_install: false | ||
- name: Get pnpm store directory | ||
shell: bash | ||
run: | | ||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | ||
- uses: actions/cache@v4 | ||
name: Setup pnpm cache | ||
with: | ||
path: ${{ env.STORE_PATH }} | ||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-store- | ||
- run: pnpm install | ||
- run: pnpm build | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
path: build | ||
name: build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'Version to publish' | ||
required: true | ||
verbose: | ||
description: 'Verbose mode' | ||
required: false | ||
default: 'false' | ||
|
||
jobs: | ||
run-bpp: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download artifact | ||
uses: dawidd6/action-download-artifact@v3 | ||
with: | ||
workflow: build.yml | ||
workflow_conclusion: success | ||
branch: main | ||
event: push | ||
name: build | ||
path: build | ||
- name: Browser Platform Publish | ||
uses: PlasmoHQ/bpp@v3 | ||
with: | ||
keys: ${{ secrets.SUBMIT_KEYS }} | ||
chrome-file: 'build/chrome-mv3-prod.zip' | ||
firefox-file: 'build/firefox-mv3-prod.zip' | ||
edge-file: 'build/edge-mv3-prod.zip' | ||
edge-notes: "Publishing latest extension version (${{ inputs.version }}) to the Edge Store." | ||
# opera-file: 'build/opera-mv3-prod.zip' | ||
verbose: ${{ inputs.verbose }} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Unit tests | ||
on: | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
- uses: pnpm/action-setup@v4 | ||
name: Install pnpm | ||
with: | ||
run_install: false | ||
- name: Get pnpm store directory | ||
shell: bash | ||
run: | | ||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | ||
- uses: actions/cache@v4 | ||
name: Setup pnpm cache | ||
with: | ||
path: ${{ env.STORE_PATH }} | ||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pnpm-store- | ||
- run: pnpm install | ||
- run: pnpm test:unit | ||
- run: pnpm build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,24 @@ | ||
{ | ||
"name": "opentelemetry-browser-extension", | ||
"displayName": "OpenTelemetry Browser Extension", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "An extension for instrumenting webpages using OpenTelemetry", | ||
"author": "Theodore Brockman <[email protected]>", | ||
"packageManager": "[email protected]", | ||
"scripts": { | ||
"preinstall": "pnpm install:plasmo && pnpm build:run-p && pnpm build:vendored", | ||
"install:plasmo": "pnpm -C ./vendored/plasmo/ install", | ||
"build:run-p": "pnpm -C ./vendored/plasmo/packages/rps build", | ||
"dev": "plasmo dev", | ||
"build": "pnpm build:vendored && plasmo build", | ||
"clean": "rm -fr build", | ||
"build": "npm-run-all build:safari build:windows", | ||
"build:windows": "npm-run-all build:chrome build:edge build:opera", | ||
"build:chrome": "plasmo build --target=chrome-mv3 --zip --hoist", | ||
"build:firefox": "echo '\\033[1;31mwarning: firefox build is not currently functional due to its incomplete scripting.executeScript() functionality.\nproceeding to build anyways\\033[0m\n' && plasmo build --target=firefox-mv3 --zip --hoist", | ||
"build:edge": "plasmo build --target=edge-mv3 --zip --hoist", | ||
"build:safari": "plasmo build --target=safari-mv3 --zip --hoist", | ||
"convert:safari": "cd build && xcrun safari-web-extension-converter safari-mv3-prod", | ||
"build:opera": "plasmo build --target=opera-mv3 --zip --hoist", | ||
"build:vendored": "run-p build:plasmo:cli build:plasmo:storage build:plasmo:messaging", | ||
"build:plasmo:cli": "pnpm -C ./vendored/plasmo build:cli", | ||
"build:plasmo:storage": "pnpm -C ./vendored/plasmo/api/storage build", | ||
|
@@ -21,7 +30,7 @@ | |
"@mantine/core": "^7.6.1", | ||
"@mantine/hooks": "^7.6.1", | ||
"@opentelemetry/api-logs": "^0.49.1", | ||
"@opentelemetry/auto-instrumentations-web": "^0.37.0", | ||
"@opentelemetry/auto-instrumentations-web": "^0.36.0", | ||
"@opentelemetry/context-zone": "^1.22.0", | ||
"@opentelemetry/core": "^1.22.0", | ||
"@opentelemetry/exporter-logs-otlp-proto": "^0.49.1", | ||
|
@@ -46,14 +55,15 @@ | |
"deepmerge-ts": "^5.1.0", | ||
"plasmo": "workspace:*", | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0" | ||
"react-dom": "18.2.0", | ||
"uuidv7": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"@ianvs/prettier-plugin-sort-imports": "4.1.1", | ||
"@parcel/config-default": "^2.12.0", | ||
"@parcel/packager-ts": "2.12.0", | ||
"@plasmohq/rps": "workspace:*", | ||
"@plasmohq/parcel-config": "workspace:*", | ||
"@plasmohq/rps": "workspace:*", | ||
"@types/chrome": "0.0.262", | ||
"@types/jest": "^29.5.12", | ||
"@types/mocha": "^10.0.6", | ||
|
@@ -65,6 +75,7 @@ | |
"esbuild-plugin-polyfill-node": "^0.3.0", | ||
"mocha": "^10.4.0", | ||
"mocha-suppress-logs": "^0.5.1", | ||
"npm-run-all": "^4.1.5", | ||
"parcel": "^2.12.0", | ||
"postcss": "^8.4.35", | ||
"postcss-preset-mantine": "^1.13.0", | ||
|
@@ -85,13 +96,7 @@ | |
"permissions": [ | ||
"scripting", | ||
"storage" | ||
], | ||
"externally_connectable": { | ||
"matches": [ | ||
"https://*/*", | ||
"http://localhost/*" | ||
] | ||
} | ||
] | ||
}, | ||
"overrides": { | ||
"@opentelemetry/instrumentation-xml-http-request": "0.49.1", | ||
|
@@ -103,7 +108,8 @@ | |
"@protobufjs/[email protected]": "patches/@[email protected]", | ||
"@opentelemetry/[email protected]": "patches/@[email protected]", | ||
"@opentelemetry/[email protected]": "patches/@[email protected]", | ||
"@opentelemetry/[email protected]": "patches/@[email protected]" | ||
"@opentelemetry/[email protected]": "patches/@[email protected]", | ||
"@opentelemetry/[email protected]": "patches/@[email protected]" | ||
} | ||
}, | ||
"parcel-resolver-inlinefunc": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
diff --git a/build/esm/instrumentation.js b/build/esm/instrumentation.js | ||
index 928b559ffdafaea1832ec9b6a119656f8f091558..511a277175d888445b8e39e419027fc2f1a19158 100644 | ||
--- a/build/esm/instrumentation.js | ||
+++ b/build/esm/instrumentation.js | ||
@@ -63,9 +63,14 @@ var UserInteractionInstrumentation = /** @class */ (function (_super) { | ||
typeof (config === null || config === void 0 ? void 0 : config.shouldPreventSpanCreation) === 'function' | ||
? config.shouldPreventSpanCreation | ||
: defaultShouldPreventSpanCreation; | ||
+ _this.init(); | ||
return _this; | ||
} | ||
- UserInteractionInstrumentation.prototype.init = function () { }; | ||
+ UserInteractionInstrumentation.prototype.init = function () { | ||
+ this._eventNames.forEach(event => { | ||
+ window.addEventListener(event, () => { }); | ||
+ }); | ||
+ }; | ||
/** | ||
* This will check if last task was timeout and will save the time to | ||
* fix the user interaction when nothing happens |
Oops, something went wrong.