Web Quickstart
The Web SDK is currently in Closed Beta testing. The public API and internal operations are subject to change while it is tested with qualified partners and in different web-technology environments.
Requirements
Browsers
- Chrome
- Firefox
- Safari
- Edge
- IE11
Nodejs
- 6.12+
- requires an isomorphic fetch polyfill (eg: node-fetch)
1. Installing the SDK
Add the supplied lmgSDK.js
file to your repository
The file is a Universal Module Definition so it can be used two ways:
a) Run-time
<!-- HTML -->
<script src="/vendor/lmgSDK.js"></script>
Exposes window.loopmediagroup.Client
constructor
b) Compile-time
const Client = require('./vendor/lmgSDK').Client;
2. Initialization
Create an Integration Write Key
Create a new Integration for your app in the Property you're working with, and use the Integration Write Key to initialize the SDK (below).
See Enabling SDK Integrations for more details.
Initialize the SDK
The SDK must be initialized first thing, before calling any other methods.
const lmgClient = new Client(
INTEGRATION_WRITE_KEY,
{
useGeolocation: false,
logLevel: 'Debug'
}
);
Configuration
Parameter | Type | Default | Use |
---|---|---|---|
useGeoLocation | boolean | true | Should we ask the browser for the user's physical location? |
useWindow | boolean | true | Set to false when running in a node environment |
fetch | Function | window.fetch | Fetch implementation to use for http requests. Required if running in nodejs |
logLevel | string | 'Warning' | Level of events to log to the console. |
LogLevel Values
Value | Meaning |
---|---|
'Verbose' | Fine-grained information events. Used for debugging and should never be displayed in production. |
'Info' | Course application information that may be useful for debugging or in production logs. |
'Warning' | Non-critical errors that were recovered from or have few major problems. |
3.Testing your integration
Run app. You should see following message in your log:
[RefreshOrCreateSession] Completed successfully
Note: This will only be logged when logLevel
is set to 'Debug' or 'Verbose'