@opentelemetry/opentelemetry-browser-detector 0.57.2 → 0.200.0-dev.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/README.md +2 -2
- package/build/esm/BrowserDetector.d.ts +3 -3
- package/build/esm/BrowserDetector.js +18 -63
- package/build/esm/BrowserDetector.js.map +1 -1
- package/build/esm/types.d.ts +1 -1
- package/build/esm/types.js +1 -1
- package/build/esm/types.js.map +1 -1
- package/build/esm/version.d.ts +1 -1
- package/build/esm/version.js +1 -1
- package/build/esm/version.js.map +1 -1
- package/build/esnext/BrowserDetector.d.ts +3 -3
- package/build/esnext/BrowserDetector.js +6 -7
- package/build/esnext/BrowserDetector.js.map +1 -1
- package/build/esnext/types.d.ts +1 -1
- package/build/esnext/version.d.ts +1 -1
- package/build/esnext/version.js +1 -1
- package/build/esnext/version.js.map +1 -1
- package/build/src/BrowserDetector.d.ts +3 -3
- package/build/src/BrowserDetector.js +5 -6
- package/build/src/BrowserDetector.js.map +1 -1
- package/build/src/types.d.ts +1 -1
- package/build/src/version.d.ts +1 -1
- package/build/src/version.js +1 -1
- package/build/src/version.js.map +1 -1
- package/package.json +12 -13
package/README.md
CHANGED
|
@@ -13,12 +13,12 @@ npm install --save @opentelemetry/opentelemetry-browser-detector
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
15
|
```js
|
|
16
|
-
import {
|
|
16
|
+
import { resourceFromAttributes, detectResources } from '@opentelemetry/resources';
|
|
17
17
|
import { SEMRESATTRS_SERVICE_NAME } from '@opentelemetry/semantic-conventions';
|
|
18
18
|
import { browserDetector } from '@opentelemetry/opentelemetry-browser-detector';
|
|
19
19
|
|
|
20
20
|
async function start(){
|
|
21
|
-
let resource=
|
|
21
|
+
let resource = resourceFromAttributes({
|
|
22
22
|
[SEMRESATTRS_SERVICE_NAME]: 'Test App Name',
|
|
23
23
|
});
|
|
24
24
|
let detectedResources= await detectResources({detectors:[browserDetector]});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DetectedResource, ResourceDetector, ResourceDetectionConfig } from '@opentelemetry/resources';
|
|
2
2
|
/**
|
|
3
3
|
* BrowserDetector will be used to detect the resources related to browser.
|
|
4
4
|
*/
|
|
5
|
-
declare class BrowserDetector implements
|
|
6
|
-
detect(config?: ResourceDetectionConfig):
|
|
5
|
+
declare class BrowserDetector implements ResourceDetector {
|
|
6
|
+
detect(config?: ResourceDetectionConfig): DetectedResource;
|
|
7
7
|
/**
|
|
8
8
|
* Validates browser resource attribute map from browser variables
|
|
9
9
|
*
|
|
@@ -13,64 +13,21 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
26
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
27
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
28
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
29
|
-
function step(op) {
|
|
30
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
31
|
-
while (_) try {
|
|
32
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
33
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
34
|
-
switch (op[0]) {
|
|
35
|
-
case 0: case 1: t = op; break;
|
|
36
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
37
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
38
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
39
|
-
default:
|
|
40
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
41
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
42
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
43
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
44
|
-
if (t[2]) _.ops.pop();
|
|
45
|
-
_.trys.pop(); continue;
|
|
46
|
-
}
|
|
47
|
-
op = body.call(thisArg, _);
|
|
48
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
49
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
16
|
import { diag } from '@opentelemetry/api';
|
|
53
|
-
import {
|
|
17
|
+
import { emptyResource, } from '@opentelemetry/resources';
|
|
54
18
|
import { BROWSER_ATTRIBUTES } from './types';
|
|
55
19
|
/**
|
|
56
20
|
* BrowserDetector will be used to detect the resources related to browser.
|
|
57
21
|
*/
|
|
58
|
-
|
|
59
|
-
|
|
22
|
+
class BrowserDetector {
|
|
23
|
+
detect(config) {
|
|
24
|
+
const isBrowser = typeof navigator !== 'undefined';
|
|
25
|
+
if (!isBrowser) {
|
|
26
|
+
return emptyResource();
|
|
27
|
+
}
|
|
28
|
+
const browserResource = getBrowserAttributes();
|
|
29
|
+
return this._getResourceAttributes(browserResource, config);
|
|
60
30
|
}
|
|
61
|
-
BrowserDetector.prototype.detect = function (config) {
|
|
62
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
63
|
-
var isBrowser, browserResource;
|
|
64
|
-
return __generator(this, function (_a) {
|
|
65
|
-
isBrowser = typeof navigator !== 'undefined';
|
|
66
|
-
if (!isBrowser) {
|
|
67
|
-
return [2 /*return*/, Resource.empty()];
|
|
68
|
-
}
|
|
69
|
-
browserResource = getBrowserAttributes();
|
|
70
|
-
return [2 /*return*/, this._getResourceAttributes(browserResource, config)];
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
};
|
|
74
31
|
/**
|
|
75
32
|
* Validates browser resource attribute map from browser variables
|
|
76
33
|
*
|
|
@@ -78,26 +35,24 @@ var BrowserDetector = /** @class */ (function () {
|
|
|
78
35
|
* @param config: Config
|
|
79
36
|
* @returns The sanitized resource attributes.
|
|
80
37
|
*/
|
|
81
|
-
|
|
38
|
+
_getResourceAttributes(browserResource, _config) {
|
|
82
39
|
if (!browserResource[BROWSER_ATTRIBUTES.USER_AGENT] &&
|
|
83
40
|
!browserResource[BROWSER_ATTRIBUTES.PLATFORM]) {
|
|
84
41
|
diag.debug('BrowserDetector failed: Unable to find required browser resources. ');
|
|
85
|
-
return
|
|
42
|
+
return emptyResource();
|
|
86
43
|
}
|
|
87
44
|
else {
|
|
88
|
-
return
|
|
45
|
+
return { attributes: browserResource };
|
|
89
46
|
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
}());
|
|
47
|
+
}
|
|
48
|
+
}
|
|
93
49
|
// Add Browser related attributes to resources
|
|
94
50
|
function getBrowserAttributes() {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
.userAgentData;
|
|
51
|
+
const browserAttribs = {};
|
|
52
|
+
const userAgentData = navigator.userAgentData;
|
|
98
53
|
if (userAgentData) {
|
|
99
54
|
browserAttribs[BROWSER_ATTRIBUTES.PLATFORM] = userAgentData.platform;
|
|
100
|
-
browserAttribs[BROWSER_ATTRIBUTES.BRANDS] = userAgentData.brands.map(
|
|
55
|
+
browserAttribs[BROWSER_ATTRIBUTES.BRANDS] = userAgentData.brands.map(b => `${b.brand} ${b.version}`);
|
|
101
56
|
browserAttribs[BROWSER_ATTRIBUTES.MOBILE] = userAgentData.mobile;
|
|
102
57
|
}
|
|
103
58
|
else {
|
|
@@ -106,5 +61,5 @@ function getBrowserAttributes() {
|
|
|
106
61
|
browserAttribs[BROWSER_ATTRIBUTES.LANGUAGE] = navigator.language;
|
|
107
62
|
return browserAttribs;
|
|
108
63
|
}
|
|
109
|
-
export
|
|
64
|
+
export const browserDetector = new BrowserDetector();
|
|
110
65
|
//# sourceMappingURL=BrowserDetector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BrowserDetector.js","sourceRoot":"","sources":["../../src/BrowserDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG
|
|
1
|
+
{"version":3,"file":"BrowserDetector.js","sourceRoot":"","sources":["../../src/BrowserDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAc,IAAI,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAIL,aAAa,GACd,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAiB,MAAM,SAAS,CAAC;AAE5D;;GAEG;AACH,MAAM,eAAe;IACnB,MAAM,CAAC,MAAgC;QACrC,MAAM,SAAS,GAAG,OAAO,SAAS,KAAK,WAAW,CAAC;QACnD,IAAI,CAAC,SAAS,EAAE;YACd,OAAO,aAAa,EAAE,CAAC;SACxB;QACD,MAAM,eAAe,GAAe,oBAAoB,EAAE,CAAC;QAC3D,OAAO,IAAI,CAAC,sBAAsB,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IAC9D,CAAC;IACD;;;;;;OAMG;IACK,sBAAsB,CAC5B,eAA2B,EAC3B,OAAiC;QAEjC,IACE,CAAC,eAAe,CAAC,kBAAkB,CAAC,UAAU,CAAC;YAC/C,CAAC,eAAe,CAAC,kBAAkB,CAAC,QAAQ,CAAC,EAC7C;YACA,IAAI,CAAC,KAAK,CACR,qEAAqE,CACtE,CAAC;YACF,OAAO,aAAa,EAAE,CAAC;SACxB;aAAM;YACL,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC;SACxC;IACH,CAAC;CACF;AAED,8CAA8C;AAC9C,SAAS,oBAAoB;IAC3B,MAAM,cAAc,GAAe,EAAE,CAAC;IACtC,MAAM,aAAa,GACjB,SACD,CAAC,aAAa,CAAC;IAChB,IAAI,aAAa,EAAE;QACjB,cAAc,CAAC,kBAAkB,CAAC,QAAQ,CAAC,GAAG,aAAa,CAAC,QAAQ,CAAC;QACrE,cAAc,CAAC,kBAAkB,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,GAAG,CAClE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,OAAO,EAAE,CAC/B,CAAC;QACF,cAAc,CAAC,kBAAkB,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC;KAClE;SAAM;QACL,cAAc,CAAC,kBAAkB,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC,SAAS,CAAC;KACrE;IACD,cAAc,CAAC,kBAAkB,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC;IACjE,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Attributes, diag } from '@opentelemetry/api';\nimport {\n DetectedResource,\n ResourceDetector,\n ResourceDetectionConfig,\n emptyResource,\n} from '@opentelemetry/resources';\nimport { BROWSER_ATTRIBUTES, UserAgentData } from './types';\n\n/**\n * BrowserDetector will be used to detect the resources related to browser.\n */\nclass BrowserDetector implements ResourceDetector {\n detect(config?: ResourceDetectionConfig): DetectedResource {\n const isBrowser = typeof navigator !== 'undefined';\n if (!isBrowser) {\n return emptyResource();\n }\n const browserResource: Attributes = getBrowserAttributes();\n return this._getResourceAttributes(browserResource, config);\n }\n /**\n * Validates browser resource attribute map from browser variables\n *\n * @param browserResource The un-sanitized resource attributes from browser as key/value pairs.\n * @param config: Config\n * @returns The sanitized resource attributes.\n */\n private _getResourceAttributes(\n browserResource: Attributes,\n _config?: ResourceDetectionConfig\n ): DetectedResource {\n if (\n !browserResource[BROWSER_ATTRIBUTES.USER_AGENT] &&\n !browserResource[BROWSER_ATTRIBUTES.PLATFORM]\n ) {\n diag.debug(\n 'BrowserDetector failed: Unable to find required browser resources. '\n );\n return emptyResource();\n } else {\n return { attributes: browserResource };\n }\n }\n}\n\n// Add Browser related attributes to resources\nfunction getBrowserAttributes(): Attributes {\n const browserAttribs: Attributes = {};\n const userAgentData = (\n navigator as Navigator & { userAgentData?: UserAgentData }\n ).userAgentData;\n if (userAgentData) {\n browserAttribs[BROWSER_ATTRIBUTES.PLATFORM] = userAgentData.platform;\n browserAttribs[BROWSER_ATTRIBUTES.BRANDS] = userAgentData.brands.map(\n b => `${b.brand} ${b.version}`\n );\n browserAttribs[BROWSER_ATTRIBUTES.MOBILE] = userAgentData.mobile;\n } else {\n browserAttribs[BROWSER_ATTRIBUTES.USER_AGENT] = navigator.userAgent;\n }\n browserAttribs[BROWSER_ATTRIBUTES.LANGUAGE] = navigator.language;\n return browserAttribs;\n}\n\nexport const browserDetector = new BrowserDetector();\n"]}
|
package/build/esm/types.d.ts
CHANGED
package/build/esm/types.js
CHANGED
package/build/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAqBA,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAqBA,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,QAAQ,EAAE,kBAAkB;IAC5B,MAAM,EAAE,gBAAgB;IACxB,MAAM,EAAE,gBAAgB;IACxB,QAAQ,EAAE,kBAAkB;IAC5B,UAAU,EAAE,oBAAoB;CACjC,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport type UserAgentData = {\n brands: { brand: string; version: string }[];\n platform: string;\n mobile: boolean;\n};\n\nexport const BROWSER_ATTRIBUTES = {\n PLATFORM: 'browser.platform', //TODO replace with SemanticConventions attribute when available\n BRANDS: 'browser.brands',\n MOBILE: 'browser.mobile',\n LANGUAGE: 'browser.language',\n USER_AGENT: 'browser.user_agent',\n};\n"]}
|
package/build/esm/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.200.0-dev.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/build/esm/version.js
CHANGED
package/build/esm/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.200.0-dev.0';\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DetectedResource, ResourceDetector, ResourceDetectionConfig } from '@opentelemetry/resources';
|
|
2
2
|
/**
|
|
3
3
|
* BrowserDetector will be used to detect the resources related to browser.
|
|
4
4
|
*/
|
|
5
|
-
declare class BrowserDetector implements
|
|
6
|
-
detect(config?: ResourceDetectionConfig):
|
|
5
|
+
declare class BrowserDetector implements ResourceDetector {
|
|
6
|
+
detect(config?: ResourceDetectionConfig): DetectedResource;
|
|
7
7
|
/**
|
|
8
8
|
* Validates browser resource attribute map from browser variables
|
|
9
9
|
*
|
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { diag } from '@opentelemetry/api';
|
|
17
|
-
import {
|
|
17
|
+
import { emptyResource, } from '@opentelemetry/resources';
|
|
18
18
|
import { BROWSER_ATTRIBUTES } from './types';
|
|
19
19
|
/**
|
|
20
20
|
* BrowserDetector will be used to detect the resources related to browser.
|
|
21
21
|
*/
|
|
22
22
|
class BrowserDetector {
|
|
23
|
-
|
|
23
|
+
detect(config) {
|
|
24
24
|
const isBrowser = typeof navigator !== 'undefined';
|
|
25
25
|
if (!isBrowser) {
|
|
26
|
-
return
|
|
26
|
+
return emptyResource();
|
|
27
27
|
}
|
|
28
28
|
const browserResource = getBrowserAttributes();
|
|
29
29
|
return this._getResourceAttributes(browserResource, config);
|
|
@@ -39,18 +39,17 @@ class BrowserDetector {
|
|
|
39
39
|
if (!browserResource[BROWSER_ATTRIBUTES.USER_AGENT] &&
|
|
40
40
|
!browserResource[BROWSER_ATTRIBUTES.PLATFORM]) {
|
|
41
41
|
diag.debug('BrowserDetector failed: Unable to find required browser resources. ');
|
|
42
|
-
return
|
|
42
|
+
return emptyResource();
|
|
43
43
|
}
|
|
44
44
|
else {
|
|
45
|
-
return
|
|
45
|
+
return { attributes: browserResource };
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
// Add Browser related attributes to resources
|
|
50
50
|
function getBrowserAttributes() {
|
|
51
51
|
const browserAttribs = {};
|
|
52
|
-
const userAgentData = navigator
|
|
53
|
-
.userAgentData;
|
|
52
|
+
const userAgentData = navigator.userAgentData;
|
|
54
53
|
if (userAgentData) {
|
|
55
54
|
browserAttribs[BROWSER_ATTRIBUTES.PLATFORM] = userAgentData.platform;
|
|
56
55
|
browserAttribs[BROWSER_ATTRIBUTES.BRANDS] = userAgentData.brands.map(b => `${b.brand} ${b.version}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BrowserDetector.js","sourceRoot":"","sources":["../../src/BrowserDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAc,IAAI,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,
|
|
1
|
+
{"version":3,"file":"BrowserDetector.js","sourceRoot":"","sources":["../../src/BrowserDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAc,IAAI,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAIL,aAAa,GACd,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAiB,MAAM,SAAS,CAAC;AAE5D;;GAEG;AACH,MAAM,eAAe;IACnB,MAAM,CAAC,MAAgC;QACrC,MAAM,SAAS,GAAG,OAAO,SAAS,KAAK,WAAW,CAAC;QACnD,IAAI,CAAC,SAAS,EAAE;YACd,OAAO,aAAa,EAAE,CAAC;SACxB;QACD,MAAM,eAAe,GAAe,oBAAoB,EAAE,CAAC;QAC3D,OAAO,IAAI,CAAC,sBAAsB,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IAC9D,CAAC;IACD;;;;;;OAMG;IACK,sBAAsB,CAC5B,eAA2B,EAC3B,OAAiC;QAEjC,IACE,CAAC,eAAe,CAAC,kBAAkB,CAAC,UAAU,CAAC;YAC/C,CAAC,eAAe,CAAC,kBAAkB,CAAC,QAAQ,CAAC,EAC7C;YACA,IAAI,CAAC,KAAK,CACR,qEAAqE,CACtE,CAAC;YACF,OAAO,aAAa,EAAE,CAAC;SACxB;aAAM;YACL,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC;SACxC;IACH,CAAC;CACF;AAED,8CAA8C;AAC9C,SAAS,oBAAoB;IAC3B,MAAM,cAAc,GAAe,EAAE,CAAC;IACtC,MAAM,aAAa,GACjB,SACD,CAAC,aAAa,CAAC;IAChB,IAAI,aAAa,EAAE;QACjB,cAAc,CAAC,kBAAkB,CAAC,QAAQ,CAAC,GAAG,aAAa,CAAC,QAAQ,CAAC;QACrE,cAAc,CAAC,kBAAkB,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,GAAG,CAClE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,OAAO,EAAE,CAC/B,CAAC;QACF,cAAc,CAAC,kBAAkB,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC;KAClE;SAAM;QACL,cAAc,CAAC,kBAAkB,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC,SAAS,CAAC;KACrE;IACD,cAAc,CAAC,kBAAkB,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC;IACjE,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Attributes, diag } from '@opentelemetry/api';\nimport {\n DetectedResource,\n ResourceDetector,\n ResourceDetectionConfig,\n emptyResource,\n} from '@opentelemetry/resources';\nimport { BROWSER_ATTRIBUTES, UserAgentData } from './types';\n\n/**\n * BrowserDetector will be used to detect the resources related to browser.\n */\nclass BrowserDetector implements ResourceDetector {\n detect(config?: ResourceDetectionConfig): DetectedResource {\n const isBrowser = typeof navigator !== 'undefined';\n if (!isBrowser) {\n return emptyResource();\n }\n const browserResource: Attributes = getBrowserAttributes();\n return this._getResourceAttributes(browserResource, config);\n }\n /**\n * Validates browser resource attribute map from browser variables\n *\n * @param browserResource The un-sanitized resource attributes from browser as key/value pairs.\n * @param config: Config\n * @returns The sanitized resource attributes.\n */\n private _getResourceAttributes(\n browserResource: Attributes,\n _config?: ResourceDetectionConfig\n ): DetectedResource {\n if (\n !browserResource[BROWSER_ATTRIBUTES.USER_AGENT] &&\n !browserResource[BROWSER_ATTRIBUTES.PLATFORM]\n ) {\n diag.debug(\n 'BrowserDetector failed: Unable to find required browser resources. '\n );\n return emptyResource();\n } else {\n return { attributes: browserResource };\n }\n }\n}\n\n// Add Browser related attributes to resources\nfunction getBrowserAttributes(): Attributes {\n const browserAttribs: Attributes = {};\n const userAgentData = (\n navigator as Navigator & { userAgentData?: UserAgentData }\n ).userAgentData;\n if (userAgentData) {\n browserAttribs[BROWSER_ATTRIBUTES.PLATFORM] = userAgentData.platform;\n browserAttribs[BROWSER_ATTRIBUTES.BRANDS] = userAgentData.brands.map(\n b => `${b.brand} ${b.version}`\n );\n browserAttribs[BROWSER_ATTRIBUTES.MOBILE] = userAgentData.mobile;\n } else {\n browserAttribs[BROWSER_ATTRIBUTES.USER_AGENT] = navigator.userAgent;\n }\n browserAttribs[BROWSER_ATTRIBUTES.LANGUAGE] = navigator.language;\n return browserAttribs;\n}\n\nexport const browserDetector = new BrowserDetector();\n"]}
|
package/build/esnext/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.200.0-dev.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/build/esnext/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,eAAe,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.200.0-dev.0';\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DetectedResource, ResourceDetector, ResourceDetectionConfig } from '@opentelemetry/resources';
|
|
2
2
|
/**
|
|
3
3
|
* BrowserDetector will be used to detect the resources related to browser.
|
|
4
4
|
*/
|
|
5
|
-
declare class BrowserDetector implements
|
|
6
|
-
detect(config?: ResourceDetectionConfig):
|
|
5
|
+
declare class BrowserDetector implements ResourceDetector {
|
|
6
|
+
detect(config?: ResourceDetectionConfig): DetectedResource;
|
|
7
7
|
/**
|
|
8
8
|
* Validates browser resource attribute map from browser variables
|
|
9
9
|
*
|
|
@@ -23,10 +23,10 @@ const types_1 = require("./types");
|
|
|
23
23
|
* BrowserDetector will be used to detect the resources related to browser.
|
|
24
24
|
*/
|
|
25
25
|
class BrowserDetector {
|
|
26
|
-
|
|
26
|
+
detect(config) {
|
|
27
27
|
const isBrowser = typeof navigator !== 'undefined';
|
|
28
28
|
if (!isBrowser) {
|
|
29
|
-
return resources_1.
|
|
29
|
+
return (0, resources_1.emptyResource)();
|
|
30
30
|
}
|
|
31
31
|
const browserResource = getBrowserAttributes();
|
|
32
32
|
return this._getResourceAttributes(browserResource, config);
|
|
@@ -42,18 +42,17 @@ class BrowserDetector {
|
|
|
42
42
|
if (!browserResource[types_1.BROWSER_ATTRIBUTES.USER_AGENT] &&
|
|
43
43
|
!browserResource[types_1.BROWSER_ATTRIBUTES.PLATFORM]) {
|
|
44
44
|
api_1.diag.debug('BrowserDetector failed: Unable to find required browser resources. ');
|
|
45
|
-
return resources_1.
|
|
45
|
+
return (0, resources_1.emptyResource)();
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
48
|
-
return
|
|
48
|
+
return { attributes: browserResource };
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
// Add Browser related attributes to resources
|
|
53
53
|
function getBrowserAttributes() {
|
|
54
54
|
const browserAttribs = {};
|
|
55
|
-
const userAgentData = navigator
|
|
56
|
-
.userAgentData;
|
|
55
|
+
const userAgentData = navigator.userAgentData;
|
|
57
56
|
if (userAgentData) {
|
|
58
57
|
browserAttribs[types_1.BROWSER_ATTRIBUTES.PLATFORM] = userAgentData.platform;
|
|
59
58
|
browserAttribs[types_1.BROWSER_ATTRIBUTES.BRANDS] = userAgentData.brands.map(b => `${b.brand} ${b.version}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BrowserDetector.js","sourceRoot":"","sources":["../../src/BrowserDetector.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAAsD;AACtD,wDAKkC;AAClC,mCAA4D;AAE5D;;GAEG;AACH,MAAM,eAAe;IACnB,
|
|
1
|
+
{"version":3,"file":"BrowserDetector.js","sourceRoot":"","sources":["../../src/BrowserDetector.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAAsD;AACtD,wDAKkC;AAClC,mCAA4D;AAE5D;;GAEG;AACH,MAAM,eAAe;IACnB,MAAM,CAAC,MAAgC;QACrC,MAAM,SAAS,GAAG,OAAO,SAAS,KAAK,WAAW,CAAC;QACnD,IAAI,CAAC,SAAS,EAAE;YACd,OAAO,IAAA,yBAAa,GAAE,CAAC;SACxB;QACD,MAAM,eAAe,GAAe,oBAAoB,EAAE,CAAC;QAC3D,OAAO,IAAI,CAAC,sBAAsB,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IAC9D,CAAC;IACD;;;;;;OAMG;IACK,sBAAsB,CAC5B,eAA2B,EAC3B,OAAiC;QAEjC,IACE,CAAC,eAAe,CAAC,0BAAkB,CAAC,UAAU,CAAC;YAC/C,CAAC,eAAe,CAAC,0BAAkB,CAAC,QAAQ,CAAC,EAC7C;YACA,UAAI,CAAC,KAAK,CACR,qEAAqE,CACtE,CAAC;YACF,OAAO,IAAA,yBAAa,GAAE,CAAC;SACxB;aAAM;YACL,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC;SACxC;IACH,CAAC;CACF;AAED,8CAA8C;AAC9C,SAAS,oBAAoB;IAC3B,MAAM,cAAc,GAAe,EAAE,CAAC;IACtC,MAAM,aAAa,GACjB,SACD,CAAC,aAAa,CAAC;IAChB,IAAI,aAAa,EAAE;QACjB,cAAc,CAAC,0BAAkB,CAAC,QAAQ,CAAC,GAAG,aAAa,CAAC,QAAQ,CAAC;QACrE,cAAc,CAAC,0BAAkB,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,GAAG,CAClE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,OAAO,EAAE,CAC/B,CAAC;QACF,cAAc,CAAC,0BAAkB,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC;KAClE;SAAM;QACL,cAAc,CAAC,0BAAkB,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC,SAAS,CAAC;KACrE;IACD,cAAc,CAAC,0BAAkB,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC;IACjE,OAAO,cAAc,CAAC;AACxB,CAAC;AAEY,QAAA,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Attributes, diag } from '@opentelemetry/api';\nimport {\n DetectedResource,\n ResourceDetector,\n ResourceDetectionConfig,\n emptyResource,\n} from '@opentelemetry/resources';\nimport { BROWSER_ATTRIBUTES, UserAgentData } from './types';\n\n/**\n * BrowserDetector will be used to detect the resources related to browser.\n */\nclass BrowserDetector implements ResourceDetector {\n detect(config?: ResourceDetectionConfig): DetectedResource {\n const isBrowser = typeof navigator !== 'undefined';\n if (!isBrowser) {\n return emptyResource();\n }\n const browserResource: Attributes = getBrowserAttributes();\n return this._getResourceAttributes(browserResource, config);\n }\n /**\n * Validates browser resource attribute map from browser variables\n *\n * @param browserResource The un-sanitized resource attributes from browser as key/value pairs.\n * @param config: Config\n * @returns The sanitized resource attributes.\n */\n private _getResourceAttributes(\n browserResource: Attributes,\n _config?: ResourceDetectionConfig\n ): DetectedResource {\n if (\n !browserResource[BROWSER_ATTRIBUTES.USER_AGENT] &&\n !browserResource[BROWSER_ATTRIBUTES.PLATFORM]\n ) {\n diag.debug(\n 'BrowserDetector failed: Unable to find required browser resources. '\n );\n return emptyResource();\n } else {\n return { attributes: browserResource };\n }\n }\n}\n\n// Add Browser related attributes to resources\nfunction getBrowserAttributes(): Attributes {\n const browserAttribs: Attributes = {};\n const userAgentData = (\n navigator as Navigator & { userAgentData?: UserAgentData }\n ).userAgentData;\n if (userAgentData) {\n browserAttribs[BROWSER_ATTRIBUTES.PLATFORM] = userAgentData.platform;\n browserAttribs[BROWSER_ATTRIBUTES.BRANDS] = userAgentData.brands.map(\n b => `${b.brand} ${b.version}`\n );\n browserAttribs[BROWSER_ATTRIBUTES.MOBILE] = userAgentData.mobile;\n } else {\n browserAttribs[BROWSER_ATTRIBUTES.USER_AGENT] = navigator.userAgent;\n }\n browserAttribs[BROWSER_ATTRIBUTES.LANGUAGE] = navigator.language;\n return browserAttribs;\n}\n\nexport const browserDetector = new BrowserDetector();\n"]}
|
package/build/src/types.d.ts
CHANGED
package/build/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.200.0-dev.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/build/src/version.js
CHANGED
|
@@ -17,5 +17,5 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.VERSION = void 0;
|
|
19
19
|
// this is autogenerated file, see scripts/version-update.js
|
|
20
|
-
exports.VERSION = '0.
|
|
20
|
+
exports.VERSION = '0.200.0-dev.0';
|
|
21
21
|
//# sourceMappingURL=version.js.map
|
package/build/src/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,eAAe,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.200.0-dev.0';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentelemetry/opentelemetry-browser-detector",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.200.0-dev.0",
|
|
4
4
|
"description": "OpenTelemetry Resource Detector for Browser",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"module": "build/esm/index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"author": "OpenTelemetry Authors",
|
|
34
34
|
"license": "Apache-2.0",
|
|
35
35
|
"engines": {
|
|
36
|
-
"node": ">=
|
|
36
|
+
"node": "^18.19.0 || >=20.6.0"
|
|
37
37
|
},
|
|
38
38
|
"files": [
|
|
39
39
|
"build/esm/**/*.js",
|
|
@@ -53,12 +53,12 @@
|
|
|
53
53
|
"access": "public"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@babel/core": "7.26.
|
|
57
|
-
"@babel/preset-env": "7.26.
|
|
56
|
+
"@babel/core": "7.26.9",
|
|
57
|
+
"@babel/preset-env": "7.26.9",
|
|
58
58
|
"@opentelemetry/api": "1.9.0",
|
|
59
59
|
"@types/mocha": "10.0.10",
|
|
60
60
|
"@types/node": "18.6.5",
|
|
61
|
-
"@types/sinon": "17.0.
|
|
61
|
+
"@types/sinon": "17.0.4",
|
|
62
62
|
"babel-plugin-istanbul": "7.0.0",
|
|
63
63
|
"cross-var": "1.1.0",
|
|
64
64
|
"karma": "6.4.4",
|
|
@@ -68,21 +68,20 @@
|
|
|
68
68
|
"karma-spec-reporter": "0.0.36",
|
|
69
69
|
"karma-webpack": "5.0.1",
|
|
70
70
|
"lerna": "6.6.2",
|
|
71
|
-
"mocha": "
|
|
72
|
-
"nyc": "
|
|
71
|
+
"mocha": "11.1.0",
|
|
72
|
+
"nyc": "17.1.0",
|
|
73
73
|
"sinon": "15.1.2",
|
|
74
|
-
"ts-loader": "9.5.
|
|
75
|
-
"typescript": "
|
|
74
|
+
"ts-loader": "9.5.2",
|
|
75
|
+
"typescript": "5.0.4",
|
|
76
76
|
"webpack": "5.96.1",
|
|
77
|
-
"webpack-cli": "
|
|
78
|
-
"webpack-merge": "5.10.0"
|
|
77
|
+
"webpack-cli": "6.0.1"
|
|
79
78
|
},
|
|
80
79
|
"peerDependencies": {
|
|
81
80
|
"@opentelemetry/api": "^1.3.0"
|
|
82
81
|
},
|
|
83
82
|
"dependencies": {
|
|
84
|
-
"@opentelemetry/resources": "
|
|
83
|
+
"@opentelemetry/resources": "2.0.0-dev.0"
|
|
85
84
|
},
|
|
86
85
|
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/browser-detector",
|
|
87
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "544c40984797dd2e2cccb92cce0e88b30f235b02"
|
|
88
87
|
}
|