🚀 Big News:Socket Has Acquired Secure Annex.Learn More
Socket
Book a DemoSign in
Socket

@opentelemetry/opentelemetry-browser-detector

Package Overview
Dependencies
Maintainers
2
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@opentelemetry/opentelemetry-browser-detector - npm Package Compare versions

Comparing version
0.34.0
to
0.35.0
+5
-3
build/esm/BrowserDetector.js

@@ -53,3 +53,3 @@ /*

import { diag } from '@opentelemetry/api';
import { Resource } from '@opentelemetry/resources';
import { Resource, } from '@opentelemetry/resources';
import { BROWSER_ATTRIBUTES } from './types';

@@ -83,3 +83,4 @@ /**

BrowserDetector.prototype._getResourceAttributes = function (browserResource, _config) {
if (!browserResource[BROWSER_ATTRIBUTES.USER_AGENT] && !browserResource[BROWSER_ATTRIBUTES.PLATFORM]) {
if (!browserResource[BROWSER_ATTRIBUTES.USER_AGENT] &&
!browserResource[BROWSER_ATTRIBUTES.PLATFORM]) {
diag.debug('BrowserDetector failed: Unable to find required browser resources. ');

@@ -97,3 +98,4 @@ return Resource.empty();

var browserAttribs = {};
var userAgentData = navigator.userAgentData;
var userAgentData = navigator
.userAgentData;
if (userAgentData) {

@@ -100,0 +102,0 @@ browserAttribs[BROWSER_ATTRIBUTES.PLATFORM] = userAgentData.platform;

@@ -1,1 +0,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,EAAY,QAAQ,EAA2B,MAAM,0BAA0B,CAAC;AAEvF,OAAO,EAAE,kBAAkB,EAAiB,MAAM,SAAS,CAAC;AAE5D;;GAEG;AACH;IAAA;IA+BA,CAAC;IA9BO,gCAAM,GAAZ,UAAa,MAAgC;;;;gBACrC,SAAS,GAAG,OAAO,S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AAS,CAAC,QAAQ,CAAC;IAC/D,OAAO,cAAc,CAAC;AACxB,CAAC;AAGD,MAAM,CAAC,IAAM,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 { Detector, Resource, ResourceDetectionConfig } 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] && !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).userAgentData;\n if (userAgentData) {\n browserAttribs[BROWSER_ATTRIBUTES.PLATFORM] = userAgentData.platform;\n browserAttribs[BROWSER_ATTRIBUTES.BRANDS] = userAgentData.brands.map(b => `${b.brand} ${b.version}`);\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\n\nexport const browserDetector = new BrowserDetector();\n"]}
{"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;gBACK,eAAe,GAAuB,oBAAoB,EAAE,CAAC;gBACnE,sBAAO,IAAI,CAAC,sBAAsB,CAAC,eAAe,EAAE,MAAM,CAAC,EAAC;;;KAC7D;IACD;;;;;;OAMG;IACK,gDAAsB,GAA9B,UACE,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;IACH,sBAAC;AAAD,CAAC,AAhCD,IAgCC;AAED,8CAA8C;AAC9C,SAAS,oBAAoB;IAC3B,IAAM,cAAc,GAAuB,EAAE,CAAC;IAC9C,IAAM,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,UAAA,CAAC,IAAI,OAAG,CAAC,CAAC,KAAK,SAAI,CAAC,CAAC,OAAS,EAAzB,CAAyB,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,IAAM,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"]}

@@ -6,4 +6,4 @@ export var BROWSER_ATTRIBUTES = {

LANGUAGE: 'browser.language',
USER_AGENT: 'browser.user_agent'
USER_AGENT: 'browser.user_agent',
};
//# sourceMappingURL=types.js.map

@@ -1,1 +0,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"]}
{"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"]}

@@ -1,2 +0,2 @@

export declare const VERSION = "0.34.0";
export declare const VERSION = "0.35.0";
//# sourceMappingURL=version.d.ts.map

@@ -17,3 +17,3 @@ /*

// this is autogenerated file, see scripts/version-update.js
export var VERSION = '0.34.0';
export var VERSION = '0.35.0';
//# sourceMappingURL=version.js.map

@@ -1,1 +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.34.0';\n"]}
{"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"]}

@@ -17,3 +17,3 @@ /*

import { diag } from '@opentelemetry/api';
import { Resource } from '@opentelemetry/resources';
import { Resource, } from '@opentelemetry/resources';
import { BROWSER_ATTRIBUTES } from './types';

@@ -40,3 +40,4 @@ /**

_getResourceAttributes(browserResource, _config) {
if (!browserResource[BROWSER_ATTRIBUTES.USER_AGENT] && !browserResource[BROWSER_ATTRIBUTES.PLATFORM]) {
if (!browserResource[BROWSER_ATTRIBUTES.USER_AGENT] &&
!browserResource[BROWSER_ATTRIBUTES.PLATFORM]) {
diag.debug('BrowserDetector failed: Unable to find required browser resources. ');

@@ -53,3 +54,4 @@ return Resource.empty();

const browserAttribs = {};
const userAgentData = navigator.userAgentData;
const userAgentData = navigator
.userAgentData;
if (userAgentData) {

@@ -56,0 +58,0 @@ browserAttribs[BROWSER_ATTRIBUTES.PLATFORM] = userAgentData.platform;

@@ -1,1 +0,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,EAAY,QAAQ,EAA2B,MAAM,0BAA0B,CAAC;AAEvF,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,WA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B,CAAC;AAGD,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 { Detector, Resource, ResourceDetectionConfig } 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] && !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).userAgentData;\n if (userAgentData) {\n browserAttribs[BROWSER_ATTRIBUTES.PLATFORM] = userAgentData.platform;\n browserAttribs[BROWSER_ATTRIBUTES.BRANDS] = userAgentData.brands.map(b => `${b.brand} ${b.version}`);\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\n\nexport const browserDetector = new BrowserDetector();\n"]}
{"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"]}

@@ -6,4 +6,4 @@ export const BROWSER_ATTRIBUTES = {

LANGUAGE: 'browser.language',
USER_AGENT: 'browser.user_agent'
USER_AGENT: 'browser.user_agent',
};
//# sourceMappingURL=types.js.map

@@ -1,1 +0,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"]}
{"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 +0,2 @@

export declare const VERSION = "0.34.0";
export declare const VERSION = "0.35.0";
//# sourceMappingURL=version.d.ts.map

@@ -17,3 +17,3 @@ /*

// this is autogenerated file, see scripts/version-update.js
export const VERSION = '0.34.0';
export const VERSION = '0.35.0';
//# sourceMappingURL=version.js.map

@@ -1,1 +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.34.0';\n"]}
{"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"]}

@@ -42,3 +42,4 @@ "use strict";

_getResourceAttributes(browserResource, _config) {
if (!browserResource[types_1.BROWSER_ATTRIBUTES.USER_AGENT] && !browserResource[types_1.BROWSER_ATTRIBUTES.PLATFORM]) {
if (!browserResource[types_1.BROWSER_ATTRIBUTES.USER_AGENT] &&
!browserResource[types_1.BROWSER_ATTRIBUTES.PLATFORM]) {
api_1.diag.debug('BrowserDetector failed: Unable to find required browser resources. ');

@@ -55,3 +56,4 @@ return resources_1.Resource.empty();

const browserAttribs = {};
const userAgentData = navigator.userAgentData;
const userAgentData = navigator
.userAgentData;
if (userAgentData) {

@@ -58,0 +60,0 @@ browserAttribs[types_1.BROWSER_ATTRIBUTES.PLATFORM] = userAgentData.platform;

@@ -1,1 +0,1 @@

{"version":3,"file":"BrowserDetector.js","sourceRoot":"","sources":["../../src/BrowserDetector.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,4CAA0C;AAC1C,wDAAuF;AAEvF,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,oBAAQ,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,0BAAkB,CAAC,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC,0BAAkB,CAAC,QAAQ,CAAC,EAChG;YACA,UAAI,CAAC,KAAK,CACR,qEAAqE,CACtE,CAAC;YACF,OAAO,oBAAQ,CAAC,KAAK,EAAE,CAAC;SACzB;aAAM;YACL,OAAO,IAAI,oBAAQ,CAAC,eAAe,CAAC,CAAC;SACtC;IACH,CAAC;CACF;AAED,8CAA8C;AAC9C,SAAS,oBAAoB;IAC3B,MAAM,cAAc,GAAwB,EAAE,CAAC;IAC/C,MAAM,aAAa,GAAgC,SAAiB,CAAC,aAAa,CAAC;IACnF,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,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;QACrG,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,GAAC,SAAS,CAAC,QAAQ,CAAC;IAC/D,OAAO,cAAc,CAAC;AACxB,CAAC;AAGY,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 { diag } from '@opentelemetry/api';\nimport { Detector, Resource, ResourceDetectionConfig } 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] && !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).userAgentData;\n if (userAgentData) {\n browserAttribs[BROWSER_ATTRIBUTES.PLATFORM] = userAgentData.platform;\n browserAttribs[BROWSER_ATTRIBUTES.BRANDS] = userAgentData.brands.map(b => `${b.brand} ${b.version}`);\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\n\nexport const browserDetector = new BrowserDetector();\n"]}
{"version":3,"file":"BrowserDetector.js","sourceRoot":"","sources":["../../src/Br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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 { 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"]}

@@ -9,4 +9,4 @@ "use strict";

LANGUAGE: 'browser.language',
USER_AGENT: 'browser.user_agent'
USER_AGENT: 'browser.user_agent',
};
//# sourceMappingURL=types.js.map

@@ -1,1 +0,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"]}
{"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"]}

@@ -1,2 +0,2 @@

export declare const VERSION = "0.34.0";
export declare const VERSION = "0.35.0";
//# sourceMappingURL=version.d.ts.map

@@ -20,3 +20,3 @@ "use strict";

// this is autogenerated file, see scripts/version-update.js
exports.VERSION = '0.34.0';
exports.VERSION = '0.35.0';
//# sourceMappingURL=version.js.map

@@ -1,1 +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.34.0';\n"]}
{"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"]}
{
"name": "@opentelemetry/opentelemetry-browser-detector",
"version": "0.34.0",
"version": "0.35.0",
"description": "OpenTelemetry Resource Detector for Browser",

@@ -12,4 +12,4 @@ "main": "build/src/index.js",

"prepublishOnly": "npm run compile",
"compile": "tsc --build tsconfig.all.json",
"clean": "tsc --build --clean tsconfig.all.json",
"compile": "tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
"clean": "tsc --build --clean tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
"lint": "eslint . --ext .ts",

@@ -23,3 +23,3 @@ "lint:fix": "eslint . --ext .ts --fix",

"version": "node ../../../scripts/version-update.js",
"watch": "tsc --build --watch tsconfig.all.json",
"watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
"precompile": "lerna run version --scope $(npm pkg get name) --include-dependencies",

@@ -66,3 +66,3 @@ "prewatch": "npm run precompile",

"nyc": "15.1.0",
"sinon": "14.0.0",
"sinon": "15.0.0",
"ts-loader": "8.4.0",

@@ -76,7 +76,7 @@ "ts-mocha": "10.0.0",

"dependencies": {
"@opentelemetry/resources": "1.8.0",
"@opentelemetry/semantic-conventions": "1.8.0"
"@opentelemetry/resources": "1.9.0",
"@opentelemetry/semantic-conventions": "1.9.0"
},
"homepage": "https://github.com/open-telemetry/opentelemetry-js/tree/main/experimental/packages/browser-detector",
"gitHead": "7972edf6659fb6e0d5928a5cf7a35f26683e168f"
"gitHead": "08f597f3a3d71a4852b0afbba120af15ca038121"
}