|
1 | | -# JavaScriptSDK |
2 | | -JavaScript Package to send TelemetryDeck signals |
| 1 | +# Telemetry Deck JavaScript SDK |
| 2 | + |
| 3 | +This package allows you to send signals to [TelemetryDeck](https://telemetrydeck.com) from your JavaScript code. |
| 4 | + |
| 5 | +It has no package dependencies and supports modern evergreen browsers which support [cryptography](https://caniuse.com/cryptography). |
| 6 | + |
| 7 | +Signals sent with this version of the SDK automatically send the following payload items: |
| 8 | + |
| 9 | +- url |
| 10 | +- useragent |
| 11 | +- locale |
| 12 | +- platform |
| 13 | + |
| 14 | +You can filter and show these values in the TelemetryDeck dashboard. |
| 15 | + |
| 16 | +Test Mode is currently not supported. |
| 17 | + |
| 18 | +## Usage |
| 19 | + |
| 20 | +### 📄 Usage via Script Tag |
| 21 | + |
| 22 | +For regular websites and to try out the code quickly, you can use [UNPKG](https://unpkg.com), a free CDN which allows you to load files from any npm package. |
| 23 | + |
| 24 | +Include the following snippet in your page header: |
| 25 | + |
| 26 | +```html |
| 27 | +<script src="https://unpkg.com/@telemtrydeck/sdk/dist/telemetrydeck.min.js"> |
| 28 | +``` |
| 29 | +
|
| 30 | +then include a script tag at the bottom of your page like this to send a signal once every time the page loads: |
| 31 | +
|
| 32 | +```html |
| 33 | +<script> |
| 34 | +signal( |
| 35 | + // required options to identify your app and the user |
| 36 | + { |
| 37 | + appID: 'YOUR_APP_ID', |
| 38 | + userIdentifier: 'ANONYMOUS', |
| 39 | + }, |
| 40 | + // optional: custom payload stored with the signal |
| 41 | + { |
| 42 | + route: 'some/page/path', |
| 43 | + } |
| 44 | +); |
| 45 | +</script> |
| 46 | +``` |
| 47 | + |
| 48 | +Please replace `YOUR_APP_ID` with the app ID you received from TelemetryDeck, and set a user identifier if possible. |
| 49 | + |
| 50 | +### 📦 Usage for applications that use a bundler (like Webpack, Rollup, …) |
| 51 | + |
| 52 | +After installing the package via NPM, use it like this: |
| 53 | + |
| 54 | +```js |
| 55 | +import { signal } from 'telemetry-deck'; |
| 56 | + |
| 57 | +// |
| 58 | +signal( |
| 59 | + // required options to identify your app and the user |
| 60 | + { |
| 61 | + appID: 'YOUR_APP_ID', |
| 62 | + userIdentifier: 'ANONYMOUS', |
| 63 | + }, |
| 64 | + // custom payload stored with the signal |
| 65 | + { |
| 66 | + route: 'some/page/path', |
| 67 | + } |
| 68 | +); |
| 69 | +``` |
| 70 | + |
| 71 | +Please replace `YOUR_APP_ID` with the app ID you received from TelemetryDeck. If you have any string that identifies your user, such as an email address, pass it into `userIdentifier` – it will be cryptographically anonymized with a hash function. |
| 72 | + |
| 73 | +If you want to pass optional parameters to the signal being sent, add them to the optional paylaod object. |
| 74 | + |
| 75 | +## More Info |
| 76 | + |
| 77 | +### 📱 You need an App ID |
| 78 | + |
| 79 | +Every application and website registered to TelemetryDeck has its own unique ID that we use to assign incoming signals to the correct app. To get started, create a new app in the TelemetryDeck UI and copy its ID. |
| 80 | + |
| 81 | +### 👤 Optional: User Identifiers |
| 82 | + |
| 83 | +TelemetryDeck can count users if you assign it a unique identifier for each user that doesn't change. This identifier can be any string that is unique to the user, such as their email address, or a randomly generated UUID. |
| 84 | + |
| 85 | +Feel free to use personally identifiable information as the user identifier: We use a cryptographically secure double-hasing process on client and server to make sure the data that arrives at our servers is anonymized and can not be traced back to individual users via their identifiers. A user's identifier is hashed inside the library, and then salted+hashed again on arrival at the server. This way the data is anonymized as defined by the GDPR and you don't have to ask for user consent for procesing or storing this data. |
| 86 | + |
| 87 | +### 🚛 Optional: Payload |
| 88 | + |
| 89 | +You can optionally attach an object with string values to the signal. This will allow you to filter and aggregate signal by these values in the dashboard. |
| 90 | + |
| 91 | +### 📚 Full Docs |
| 92 | + |
| 93 | +Go to [docs.telemetrydeck.com](https://docs.telemetrydeck.com) to see all documentation articles |
0 commit comments