2.0.23 • Published 2 years ago

@realeyes/environment-detector v2.0.23

Weekly downloads
49
License
Apache-2.0
Repository
github
Last release
2 years ago

Environment Detector

Installation

NPM version

$ npm i --save @realeyes/environment-detector

CDN version

The general format for the script URL is "https://codesdwncdn.realeyesit.com/environment-detector/release/{version}/environment-detector.js". You can specify which kinds of updates your app can accept using semver string in a following format:

  • x.y.z to load the exact version, for example: https://codesdwncdn.realeyesit.com/environment-detector/release/1.7.2/environment-detector.js
  • x.y to receive patch updates: https://codesdwncdn.realeyesit.com/environment-detector/release/1.7/environment-detector.js
  • x to receive minor updates: https://codesdwncdn.realeyesit.com/environment-detector/release/1/environment-detector.js
<script src="https://codesdwncdn.realeyesit.com/environment-detector/release/1/environment-detector.js"></script>

Self hosted

To create a self-hosted solution you will need to download the library archive https://codesdwncdn.realeyesit.com/environment-detector/release/1/environment-detector.zip. The archive contains the following files:

  • environment-detector.js - Detector library
  • environment-detector.min.js - Minified version
  • environment-detector.swf - Flash detector
  • index.html - Example page
  • log.gif - Tracking pixel

To use to detector you will need at least two files: environment-detector.js and environment-detector.swf. In this case you will need to provide an swf path when calling the detect() method.

<script src="https://example.com/environment-detector.js"></script>
<script>
Realeyesit.EnvironmentDetector.detect({ flash: { path: 'https://example.com/environment-detector.swf' } })
    .then(function (result) {
        // result will be an EnvironmentDetectionResult object
    });
</script>

API

The Realeyesit.EnvironmentDetector namespace contains one method: detect(). This method returns a Promise object that resolves with the EnvironmentDetectionResult object. This is the type definition for the EnvironmentDetectionResult:

{
  browser: {
    name: string,
    version: string,
  },
  platform: {
    type: string,
  },
  os: {
    name: string,
    version: string,
  },
  flash: ({
    version: string,
  }|null),
  webcams: Array.<string>,
  capabilities: Array.<string>
}
  • browser.name is a string like "Chrome" or "Firefox"
  • browser.version is a version string like "53.0"
  • platform.type is one of "tablet", "mobile" or "desktop"
  • os.name is a string like "windows" or "macos"
  • os.version is a version string like "10.11"
  • flash.version is a version string "\<major>.\<minor>.\<patch>.\<build>" format
  • webcams is an array of strings, for example ["USB Camera", "iSight"]
  • capabilities is an array of strings

Here is the list of capabilities we can detect:

{
    FLASH: 'flash',
    GET_USER_MEDIA: 'navigator.getUserMedia',
    MEDIA_RECORDER: 'MediaRecorder',
    WEBCAM: 'webcam',
    DOCUMENT_ALL: 'document.all',
    DOCUMENT_QUERY_SELECTOR: 'document.querySelector',
    HTTP: 'http',
    HTTPS: 'https',
}

The detect() method can receive an optional options object with the following type definition:

{
  flash: {
    path: string,
    testTimeout: number,
    containerId: string,
    minFlashVersion: string,
  }, // flash detection settings
  skip: Array.<string>, // you can pass an array of capabilities you don't want to check, for example ["flash"].
  logger: {
    path: string, // url of the tracking pixel
    disable: boolean, // pass true if you want to disable logging
  } // logger settings
}

Example usage

Realeyesit.EnvironmentDetector.detect()
    .then(function (result) {
        // result will be an EnvironmentDetectionResult object
    });

License

Copyright 2016 Realeyes OU.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

2.0.23-stage.9

2 years ago

2.0.23-stage.5

2 years ago

2.0.23-stage.3

2 years ago

2.0.23-stage.11

2 years ago

2.0.23-stage.10

2 years ago

2.0.24

3 years ago

2.0.23-stage.63

3 years ago

2.0.23

3 years ago

2.0.22

4 years ago

2.0.22-stage.3

4 years ago

2.0.22-stage.2

4 years ago

2.0.21

4 years ago

2.0.20

5 years ago

2.0.19

5 years ago

2.0.18

5 years ago

2.0.17

5 years ago

2.0.16

5 years ago

2.0.15

5 years ago

2.0.14

5 years ago

2.0.13

6 years ago

2.0.12

6 years ago

2.0.10

6 years ago

2.0.8

6 years ago

1.8.9

6 years ago

2.0.7

6 years ago

1.8.8

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.8.6

6 years ago

1.8.3

7 years ago

1.8.2

7 years ago

1.8.1

7 years ago

1.8.0

7 years ago

1.7.7

7 years ago

1.7.6

7 years ago

1.7.5

7 years ago

1.7.4

7 years ago

1.7.3

7 years ago

1.6.0

7 years ago

1.5.0

7 years ago

1.4.1

7 years ago

1.4.0

7 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.0

8 years ago

1.0.12

8 years ago

1.0.11

8 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago