@opentelemetry/opentelemetry-browser-detector 0.34.0 → 0.35.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/build/esm/BrowserDetector.js +5 -3
- package/build/esm/BrowserDetector.js.map +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.js +5 -3
- package/build/esnext/BrowserDetector.js.map +1 -1
- package/build/esnext/types.js +1 -1
- package/build/esnext/types.js.map +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.js +4 -2
- package/build/src/BrowserDetector.js.map +1 -1
- package/build/src/types.js +1 -1
- package/build/src/types.js.map +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 +8 -8
|
@@ -50,7 +50,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
import { diag } from '@opentelemetry/api';
|
|
53
|
-
import { Resource } from '@opentelemetry/resources';
|
|
53
|
+
import { Resource, } from '@opentelemetry/resources';
|
|
54
54
|
import { BROWSER_ATTRIBUTES } from './types';
|
|
55
55
|
/**
|
|
56
56
|
* BrowserDetector will be used to detect the resources related to browser.
|
|
@@ -79,7 +79,8 @@ var BrowserDetector = /** @class */ (function () {
|
|
|
79
79
|
* @returns The sanitized resource attributes.
|
|
80
80
|
*/
|
|
81
81
|
BrowserDetector.prototype._getResourceAttributes = function (browserResource, _config) {
|
|
82
|
-
if (!browserResource[BROWSER_ATTRIBUTES.USER_AGENT] &&
|
|
82
|
+
if (!browserResource[BROWSER_ATTRIBUTES.USER_AGENT] &&
|
|
83
|
+
!browserResource[BROWSER_ATTRIBUTES.PLATFORM]) {
|
|
83
84
|
diag.debug('BrowserDetector failed: Unable to find required browser resources. ');
|
|
84
85
|
return Resource.empty();
|
|
85
86
|
}
|
|
@@ -92,7 +93,8 @@ var BrowserDetector = /** @class */ (function () {
|
|
|
92
93
|
// Add Browser related attributes to resources
|
|
93
94
|
function getBrowserAttributes() {
|
|
94
95
|
var browserAttribs = {};
|
|
95
|
-
var userAgentData = navigator
|
|
96
|
+
var userAgentData = navigator
|
|
97
|
+
.userAgentData;
|
|
96
98
|
if (userAgentData) {
|
|
97
99
|
browserAttribs[BROWSER_ATTRIBUTES.PLATFORM] = userAgentData.platform;
|
|
98
100
|
browserAttribs[BROWSER_ATTRIBUTES.BRANDS] = userAgentData.brands.map(function (b) { return b.brand + " " + b.version; });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BrowserDetector.js","sourceRoot":"","sources":["../../src/BrowserDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,
|
|
1
|
+
{"version":3,"file":"BrowserDetector.js","sourceRoot":"","sources":["../../src/BrowserDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAEL,QAAQ,GAET,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,kBAAkB,EAAiB,MAAM,SAAS,CAAC;AAE5D;;GAEG;AACH;IAAA;IAgCA,CAAC;IA/BO,gCAAM,GAAZ,UAAa,MAAgC;;;;gBACrC,SAAS,GAAG,OAAO,SAAS,KAAK,WAAW,CAAC;gBACnD,IAAI,CAAC,SAAS,EAAE;oBACd,sBAAO,QAAQ,CAAC,KAAK,EAAE,EAAC;iBACzB;gBAC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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 { diag } from '@opentelemetry/api';\nimport {\n Detector,\n Resource,\n ResourceDetectionConfig,\n} from '@opentelemetry/resources';\nimport { ResourceAttributes } 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 Detector {\n async detect(config?: ResourceDetectionConfig): Promise<Resource> {\n const isBrowser = typeof navigator !== 'undefined';\n if (!isBrowser) {\n return Resource.empty();\n }\n const browserResource: ResourceAttributes = 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: ResourceAttributes,\n _config?: ResourceDetectionConfig\n ) {\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 Resource.empty();\n } else {\n return new Resource(browserResource);\n }\n }\n}\n\n// Add Browser related attributes to resources\nfunction getBrowserAttributes(): ResourceAttributes {\n const browserAttribs: ResourceAttributes = {};\n const userAgentData: UserAgentData | undefined = (navigator as any)\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.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,IAAM,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
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAqBA,MAAM,CAAC,IAAM,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 SemantecConventions 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.35.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,IAAM,OAAO,GAAG,QAAQ,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.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,IAAM,OAAO,GAAG,QAAQ,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.35.0';\n"]}
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { diag } from '@opentelemetry/api';
|
|
17
|
-
import { Resource } from '@opentelemetry/resources';
|
|
17
|
+
import { Resource, } 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.
|
|
@@ -36,7 +36,8 @@ class BrowserDetector {
|
|
|
36
36
|
* @returns The sanitized resource attributes.
|
|
37
37
|
*/
|
|
38
38
|
_getResourceAttributes(browserResource, _config) {
|
|
39
|
-
if (!browserResource[BROWSER_ATTRIBUTES.USER_AGENT] &&
|
|
39
|
+
if (!browserResource[BROWSER_ATTRIBUTES.USER_AGENT] &&
|
|
40
|
+
!browserResource[BROWSER_ATTRIBUTES.PLATFORM]) {
|
|
40
41
|
diag.debug('BrowserDetector failed: Unable to find required browser resources. ');
|
|
41
42
|
return Resource.empty();
|
|
42
43
|
}
|
|
@@ -48,7 +49,8 @@ class BrowserDetector {
|
|
|
48
49
|
// Add Browser related attributes to resources
|
|
49
50
|
function getBrowserAttributes() {
|
|
50
51
|
const browserAttribs = {};
|
|
51
|
-
const userAgentData = navigator
|
|
52
|
+
const userAgentData = navigator
|
|
53
|
+
.userAgentData;
|
|
52
54
|
if (userAgentData) {
|
|
53
55
|
browserAttribs[BROWSER_ATTRIBUTES.PLATFORM] = userAgentData.platform;
|
|
54
56
|
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,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,
|
|
1
|
+
{"version":3,"file":"BrowserDetector.js","sourceRoot":"","sources":["../../src/BrowserDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAEL,QAAQ,GAET,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,kBAAkB,EAAiB,MAAM,SAAS,CAAC;AAE5D;;GAEG;AACH,MAAM,eAAe;IACnB,KAAK,CAAC,MAAM,CAAC,MAAgC;QAC3C,MAAM,SAAS,GAAG,OAAO,SAAS,KAAK,WAAW,CAAC;QACnD,IAAI,CAAC,SAAS,EAAE;YACd,OAAO,QAAQ,CAAC,KAAK,EAAE,CAAC;SACzB;QACD,MAAM,eAAe,GAAuB,oBAAoB,EAAE,CAAC;QACnE,OAAO,IAAI,CAAC,sBAAsB,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IAC9D,CAAC;IACD;;;;;;OAMG;IACK,sBAAsB,CAC5B,eAAmC,EACnC,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,QAAQ,CAAC,KAAK,EAAE,CAAC;SACzB;aAAM;YACL,OAAO,IAAI,QAAQ,CAAC,eAAe,CAAC,CAAC;SACtC;IACH,CAAC;CACF;AAED,8CAA8C;AAC9C,SAAS,oBAAoB;IAC3B,MAAM,cAAc,GAAuB,EAAE,CAAC;IAC9C,MAAM,aAAa,GAA+B,SAAiB;SAChE,aAAa,CAAC;IACjB,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 { diag } from '@opentelemetry/api';\nimport {\n Detector,\n Resource,\n ResourceDetectionConfig,\n} from '@opentelemetry/resources';\nimport { ResourceAttributes } 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 Detector {\n async detect(config?: ResourceDetectionConfig): Promise<Resource> {\n const isBrowser = typeof navigator !== 'undefined';\n if (!isBrowser) {\n return Resource.empty();\n }\n const browserResource: ResourceAttributes = 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: ResourceAttributes,\n _config?: ResourceDetectionConfig\n ) {\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 Resource.empty();\n } else {\n return new Resource(browserResource);\n }\n }\n}\n\n// Add Browser related attributes to resources\nfunction getBrowserAttributes(): ResourceAttributes {\n const browserAttribs: ResourceAttributes = {};\n const userAgentData: UserAgentData | undefined = (navigator as any)\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.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
|
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 SemantecConventions attribute when available\n BRANDS: 'browser.brands',\n MOBILE: 'browser.mobile',\n LANGUAGE: 'browser.language',\n USER_AGENT: 'browser.user_agent',\n};\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.35.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,QAAQ,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.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,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.35.0';\n"]}
|
|
@@ -39,7 +39,8 @@ class BrowserDetector {
|
|
|
39
39
|
* @returns The sanitized resource attributes.
|
|
40
40
|
*/
|
|
41
41
|
_getResourceAttributes(browserResource, _config) {
|
|
42
|
-
if (!browserResource[types_1.BROWSER_ATTRIBUTES.USER_AGENT] &&
|
|
42
|
+
if (!browserResource[types_1.BROWSER_ATTRIBUTES.USER_AGENT] &&
|
|
43
|
+
!browserResource[types_1.BROWSER_ATTRIBUTES.PLATFORM]) {
|
|
43
44
|
api_1.diag.debug('BrowserDetector failed: Unable to find required browser resources. ');
|
|
44
45
|
return resources_1.Resource.empty();
|
|
45
46
|
}
|
|
@@ -51,7 +52,8 @@ class BrowserDetector {
|
|
|
51
52
|
// Add Browser related attributes to resources
|
|
52
53
|
function getBrowserAttributes() {
|
|
53
54
|
const browserAttribs = {};
|
|
54
|
-
const userAgentData = navigator
|
|
55
|
+
const userAgentData = navigator
|
|
56
|
+
.userAgentData;
|
|
55
57
|
if (userAgentData) {
|
|
56
58
|
browserAttribs[types_1.BROWSER_ATTRIBUTES.PLATFORM] = userAgentData.platform;
|
|
57
59
|
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,4CAA0C;AAC1C,
|
|
1
|
+
{"version":3,"file":"BrowserDetector.js","sourceRoot":"","sources":["../../src/BrowserDetector.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAA0C;AAC1C,wDAIkC;AAElC,mCAA4D;AAE5D;;GAEG;AACH,MAAM,eAAe;IACnB,KAAK,CAAC,MAAM,CAAC,MAAgC;QAC3C,MAAM,SAAS,GAAG,OAAO,SAAS,KAAK,WAAW,CAAC;QACnD,IAAI,CAAC,SAAS,EAAE;YACd,OAAO,oB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E,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 { diag } from '@opentelemetry/api';\nimport {\n Detector,\n Resource,\n ResourceDetectionConfig,\n} from '@opentelemetry/resources';\nimport { ResourceAttributes } 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 Detector {\n async detect(config?: ResourceDetectionConfig): Promise<Resource> {\n const isBrowser = typeof navigator !== 'undefined';\n if (!isBrowser) {\n return Resource.empty();\n }\n const browserResource: ResourceAttributes = 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: ResourceAttributes,\n _config?: ResourceDetectionConfig\n ) {\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 Resource.empty();\n } else {\n return new Resource(browserResource);\n }\n }\n}\n\n// Add Browser related attributes to resources\nfunction getBrowserAttributes(): ResourceAttributes {\n const browserAttribs: ResourceAttributes = {};\n const userAgentData: UserAgentData | undefined = (navigator as any)\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.js
CHANGED
package/build/src/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AAqBa,QAAA,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
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AAqBa,QAAA,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 SemantecConventions 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/src/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.35.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/build/src/version.js
CHANGED
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,QAAQ,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.
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,QAAQ,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.35.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.35.0",
|
|
4
4
|
"description": "OpenTelemetry Resource Detector for Browser",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"module": "build/esm/index.js",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"repository": "open-telemetry/opentelemetry-js",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"prepublishOnly": "npm run compile",
|
|
12
|
-
"compile": "tsc --build tsconfig.
|
|
13
|
-
"clean": "tsc --build --clean tsconfig.
|
|
12
|
+
"compile": "tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
|
|
13
|
+
"clean": "tsc --build --clean tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
|
|
14
14
|
"lint": "eslint . --ext .ts",
|
|
15
15
|
"lint:fix": "eslint . --ext .ts --fix",
|
|
16
16
|
"test": "nyc ts-mocha -p tsconfig.json 'test/**/*.test.ts'",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"tdd:browser": "karma start",
|
|
20
20
|
"codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../",
|
|
21
21
|
"version": "node ../../../scripts/version-update.js",
|
|
22
|
-
"watch": "tsc --build --watch tsconfig.
|
|
22
|
+
"watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
|
|
23
23
|
"precompile": "lerna run version --scope $(npm pkg get name) --include-dependencies",
|
|
24
24
|
"prewatch": "npm run precompile",
|
|
25
25
|
"peer-api-check": "node ../../../scripts/peer-api-check.js"
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"codecov": "3.8.3",
|
|
62
62
|
"mocha": "10.0.0",
|
|
63
63
|
"nyc": "15.1.0",
|
|
64
|
-
"sinon": "
|
|
64
|
+
"sinon": "15.0.0",
|
|
65
65
|
"ts-loader": "8.4.0",
|
|
66
66
|
"ts-mocha": "10.0.0",
|
|
67
67
|
"typescript": "4.4.4"
|
|
@@ -70,9 +70,9 @@
|
|
|
70
70
|
"@opentelemetry/api": "^1.0.0"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@opentelemetry/resources": "1.
|
|
74
|
-
"@opentelemetry/semantic-conventions": "1.
|
|
73
|
+
"@opentelemetry/resources": "1.9.0",
|
|
74
|
+
"@opentelemetry/semantic-conventions": "1.9.0"
|
|
75
75
|
},
|
|
76
76
|
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/browser-detector",
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "08f597f3a3d71a4852b0afbba120af15ca038121"
|
|
78
78
|
}
|