@libo11y/webext 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/content.js +16 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worker.js +20 -20
- package/package.json +5 -5
package/dist/content.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* setupContentScript for content scripts and extension pages.
|
|
3
3
|
*/
|
|
4
4
|
import { createTelemetryWith, setupWith, } from "@libo11y/core";
|
|
5
|
+
import { setPropagationConfig } from "@libo11y/core/internal";
|
|
5
6
|
import { installXhrInstrumentation, recordDocumentLoad, } from "@libo11y/web";
|
|
6
|
-
import { activeConsent, createConsentController, createDelivery, createMemoryQueue, installFetchInstrumentation, installFlushOnHide, setActiveConsent, shutdownWithin, webPlatform, } from "@libo11y/web/internal";
|
|
7
|
+
import { activeConsent, createConsentController, createDelivery, createMemoryQueue, installFetchInstrumentation, installFlushOnHide, isIgnored, pristineFetch, setActiveConsent, shouldPropagate, shutdownWithin, webPlatform, } from "@libo11y/web/internal";
|
|
7
8
|
import { flushInBackground } from "@libo11y/web/portable";
|
|
8
9
|
import { diag } from "@opentelemetry/api";
|
|
9
10
|
import { getChrome } from "./chrome.js";
|
|
@@ -142,6 +143,18 @@ export async function setupContentScriptWith(options, deps, install = true) {
|
|
|
142
143
|
const handle = core;
|
|
143
144
|
Object.defineProperty(handle, "consent", { value: controller.consent, enumerable: true });
|
|
144
145
|
Object.assign(handle, { onMessage: messaging.onMessage, sendMessage: messaging.sendMessage });
|
|
146
|
+
const hermetic = options.hermetic === true;
|
|
147
|
+
const sdkDisabled = !hermetic && (options.env?.OTEL_SDK_DISABLED ?? "").trim().toLowerCase() === "true";
|
|
148
|
+
const instr = options.instrumentations ?? {};
|
|
149
|
+
const propagateTo = instr.propagateTo ?? [];
|
|
150
|
+
const ignoreUrls = instr.ignoreUrls ?? [];
|
|
151
|
+
setPropagationConfig(handle, {
|
|
152
|
+
runtime: "browser",
|
|
153
|
+
isRecording: () => !sdkDisabled && controller.recording(),
|
|
154
|
+
shouldPropagate: (url) => shouldPropagate(url, propagateTo),
|
|
155
|
+
isIgnored: (url) => isIgnored(url, ignoreUrls),
|
|
156
|
+
...(pristineFetch === undefined ? {} : { fetch: pristineFetch }),
|
|
157
|
+
});
|
|
145
158
|
const coreShutdown = core.shutdown.bind(core);
|
|
146
159
|
let shutdownPromise;
|
|
147
160
|
handle.shutdown = (opts) => {
|
|
@@ -165,11 +178,10 @@ export async function setupContentScriptWith(options, deps, install = true) {
|
|
|
165
178
|
return handle;
|
|
166
179
|
try {
|
|
167
180
|
setActiveConsent(controller.consent);
|
|
168
|
-
const instr = options.instrumentations ?? {};
|
|
169
181
|
const http = {
|
|
170
182
|
telemetry: handle,
|
|
171
|
-
propagateTo
|
|
172
|
-
ignoreUrls
|
|
183
|
+
propagateTo,
|
|
184
|
+
ignoreUrls,
|
|
173
185
|
};
|
|
174
186
|
if (instr.fetch !== false)
|
|
175
187
|
uninstalls.push(deps.installFetchInstrumentation(http));
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** The @libo11y/webext package version. scripts/release.ts keeps it equal to package.json. */
|
|
2
|
-
export declare const VERSION = "0.
|
|
2
|
+
export declare const VERSION = "0.9.0";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** The @libo11y/webext package version. scripts/release.ts keeps it equal to package.json. */
|
|
2
|
-
export const VERSION = "0.
|
|
2
|
+
export const VERSION = "0.9.0";
|
package/dist/worker.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* setupWorker for a Manifest V3 service worker.
|
|
3
3
|
*/
|
|
4
4
|
import { setupWith, } from "@libo11y/core";
|
|
5
|
-
import {
|
|
5
|
+
import { setPropagationConfig } from "@libo11y/core/internal";
|
|
6
|
+
import { activeConsent, createConsentController, createDelivery, createHttpTransport, installFetchInstrumentation, isIgnored, leaseForTimeout, OTLP_SIGNALS, openQueue, pristineFetch, resolveEndpoints, resolveTransportOptions, setActiveConsent, shouldPropagate, shutdownWithin, webPlatform, } from "@libo11y/web/internal";
|
|
6
7
|
import { diag } from "@opentelemetry/api";
|
|
7
8
|
import { getChrome } from "./chrome.js";
|
|
8
9
|
import { CONSENT_STORAGE_KEY, consentWriteListener, QUEUE_REVOCATION_KEY, readConsentSnapshot, syncConsent, writeRevocation, } from "./consent-sync.js";
|
|
@@ -64,14 +65,6 @@ export function defaultWorkerDeps() {
|
|
|
64
65
|
export function setupWorker(options = {}) {
|
|
65
66
|
return setupWorkerWith(options, defaultWorkerDeps());
|
|
66
67
|
}
|
|
67
|
-
/**
|
|
68
|
-
* The delivery lease for a transport timeout: three times it, never less than the delivery's
|
|
69
|
-
* 30-second default. As leaseForTimeout in @libo11y/web, whose internal entry point does not
|
|
70
|
-
* export it.
|
|
71
|
-
*/
|
|
72
|
-
function leaseForTimeout(timeoutMillis) {
|
|
73
|
-
return Math.max(30_000, 3 * timeoutMillis);
|
|
74
|
-
}
|
|
75
68
|
/**
|
|
76
69
|
* platform with the manifest version as a detected service.version, so OTEL_RESOURCE_ATTRIBUTES and
|
|
77
70
|
* the serviceVersion option both beat it, as core merges the layers.
|
|
@@ -309,12 +302,10 @@ export async function setupWorkerWith(options, deps) {
|
|
|
309
302
|
};
|
|
310
303
|
const endpoints = deps.resolveEndpoints(options, hermetic);
|
|
311
304
|
const t = options.transport ?? {};
|
|
305
|
+
const { transport: httpTransportOpts, leaseTimeoutMillis } = resolveTransportOptions(options, endpoints, hermetic);
|
|
312
306
|
const transport = deps.createHttpTransport({
|
|
313
|
-
|
|
307
|
+
...httpTransportOpts,
|
|
314
308
|
sendBeacon: undefined,
|
|
315
|
-
...(options.headers === undefined ? {} : { headers: options.headers }),
|
|
316
|
-
...(t.compression === undefined ? {} : { compression: t.compression }),
|
|
317
|
-
...(t.timeoutMillis === undefined ? {} : { timeoutMillis: t.timeoutMillis }),
|
|
318
309
|
});
|
|
319
310
|
const delivery = deps.createDelivery({
|
|
320
311
|
transport,
|
|
@@ -326,7 +317,7 @@ export async function setupWorkerWith(options, deps) {
|
|
|
326
317
|
...(t.initialBackoffMillis === undefined ? {} : { initialBackoffMillis: t.initialBackoffMillis }),
|
|
327
318
|
...(t.maxBackoffMillis === undefined ? {} : { maxBackoffMillis: t.maxBackoffMillis }),
|
|
328
319
|
// A lease shorter than a send could let the next drain claim the entry mid-send and resend it.
|
|
329
|
-
...(
|
|
320
|
+
...(leaseTimeoutMillis === undefined ? {} : { leaseMillis: leaseForTimeout(leaseTimeoutMillis) }),
|
|
330
321
|
});
|
|
331
322
|
stopDelivery = () => delivery.shutdown();
|
|
332
323
|
const web = deps.webPlatform({
|
|
@@ -391,6 +382,19 @@ export async function setupWorkerWith(options, deps) {
|
|
|
391
382
|
sendMessage: messaging.sendMessage,
|
|
392
383
|
sendTabMessage: (tabId, payload) => sendTracedTabMessage(chrome, telemetry.propagator, tabId, payload),
|
|
393
384
|
});
|
|
385
|
+
const fetchOpts = typeof options.fetch === "object" ? options.fetch : {};
|
|
386
|
+
const propagateTo = fetchOpts.propagateTo ?? [];
|
|
387
|
+
const ignoreUrls = [
|
|
388
|
+
...(fetchOpts.ignoreUrls ?? []),
|
|
389
|
+
...OTLP_SIGNALS.flatMap((s) => (endpoints[s] === undefined ? [] : [endpoints[s]])),
|
|
390
|
+
];
|
|
391
|
+
setPropagationConfig(handle, {
|
|
392
|
+
runtime: "browser",
|
|
393
|
+
isRecording: () => !sdkDisabled && controller.recording(),
|
|
394
|
+
shouldPropagate: (url) => shouldPropagate(url, propagateTo),
|
|
395
|
+
isIgnored: (url) => isIgnored(url, ignoreUrls),
|
|
396
|
+
...(pristineFetch === undefined ? {} : { fetch: pristineFetch }),
|
|
397
|
+
});
|
|
394
398
|
const coreShutdown = telemetry.shutdown.bind(telemetry);
|
|
395
399
|
let shutdownPromise;
|
|
396
400
|
handle.shutdown = (opts) => {
|
|
@@ -419,14 +423,10 @@ export async function setupWorkerWith(options, deps) {
|
|
|
419
423
|
refreshed = await sync.refresh();
|
|
420
424
|
setActiveConsent(controller.consent);
|
|
421
425
|
if (options.fetch !== false) {
|
|
422
|
-
const f = typeof options.fetch === "object" ? options.fetch : {};
|
|
423
426
|
uninstalls.push(deps.installFetchInstrumentation({
|
|
424
427
|
telemetry: handle,
|
|
425
|
-
propagateTo
|
|
426
|
-
ignoreUrls
|
|
427
|
-
...(f.ignoreUrls ?? []),
|
|
428
|
-
...OTLP_SIGNALS.flatMap((s) => (endpoints[s] === undefined ? [] : [endpoints[s]])),
|
|
429
|
-
],
|
|
428
|
+
propagateTo,
|
|
429
|
+
ignoreUrls,
|
|
430
430
|
}));
|
|
431
431
|
}
|
|
432
432
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libo11y/webext",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "The libo11y Manifest V3 extension platform for TypeScript: setup for the service worker with a queue persisted to IndexedDB on every batch, setup for content scripts and extension pages that forward their records to the worker by runtime messaging, and trace context that crosses with every message.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"directory": "ts/packages/webext"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@libo11y/core": "0.
|
|
25
|
-
"@libo11y/spec": "0.
|
|
26
|
-
"@libo11y/web": "0.
|
|
24
|
+
"@libo11y/core": "0.9.0",
|
|
25
|
+
"@libo11y/spec": "0.9.0",
|
|
26
|
+
"@libo11y/web": "0.9.0",
|
|
27
27
|
"@opentelemetry/sdk-logs": "3.1.1",
|
|
28
28
|
"@opentelemetry/sdk-metrics": "3.1.1",
|
|
29
29
|
"@opentelemetry/sdk-trace": "3.1.1"
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@opentelemetry/api": ">=1.10.0 <1.11.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@libo11y/test": "0.
|
|
35
|
+
"@libo11y/test": "0.9.0",
|
|
36
36
|
"@opentelemetry/api": "1.10.0",
|
|
37
37
|
"fake-indexeddb": "6.2.7"
|
|
38
38
|
},
|