smartlook-client
Advanced tools
Comparing version 7.0.2 to 8.0.0
declare const _default: { | ||
init: (key: string, params?: { | ||
region?: "eu" | "us" | undefined; | ||
version?: "nextgen" | "legacy" | undefined; | ||
cookies?: boolean | undefined; | ||
relayProxyUrl?: string | undefined; | ||
} | undefined) => boolean; | ||
@@ -7,0 +7,0 @@ identify: (userId: string | number, props: { |
@@ -14,5 +14,18 @@ "use strict"; | ||
}; | ||
var _a = params !== null && params !== void 0 ? params : {}, _b = _a.region, region = _b === void 0 ? 'eu' : _b, _c = _a.version, version = _c === void 0 ? 'nextgen' : _c, _d = _a.cookies, cookies = _d === void 0 ? true : _d; | ||
var _a = params !== null && params !== void 0 ? params : {}, _b = _a.region, region = _b === void 0 ? 'eu' : _b, _c = _a.cookies, cookies = _c === void 0 ? true : _c, relayProxyUrl = _a.relayProxyUrl; | ||
w.smartlook.api = []; | ||
w.smartlook('init', key, { region: region, cookies: cookies }); | ||
var initParams = { region: region, cookies: cookies }; | ||
var src = 'https://web-sdk.smartlook.com/recorder.js'; | ||
if (relayProxyUrl) { | ||
try { | ||
var constructedUrl = new URL('/recorder.js', relayProxyUrl); | ||
initParams.host = constructedUrl.host; | ||
src = constructedUrl.toString(); | ||
} | ||
catch (e) { | ||
console.error('Smartlook init param `relayProxyUrl` is not valid. Please provide full url like `https://my-proxy-domain.com/`.'); | ||
return false; | ||
} | ||
} | ||
w.smartlook('init', key, initParams); | ||
var head = window.document.getElementsByTagName('head')[0]; | ||
@@ -23,4 +36,3 @@ var script = window.document.createElement('script'); | ||
script.crossOrigin = 'anonymous'; | ||
script.src = | ||
version === 'nextgen' ? 'https://web-sdk.smartlook.com/recorder.js' : 'https://rec.smartlook.com/recorder.js'; | ||
script.src = src; | ||
head.appendChild(script); | ||
@@ -27,0 +39,0 @@ return true; |
30
index.ts
@@ -9,6 +9,8 @@ type SmartlookWindow = Window & { smartlook?: any } | ||
* @param key Project key from project settings | ||
* @param params Not required parameters, default region is 'eu', default version is 'nextgen' | ||
* and storing metadata in cookies is enabled by default | ||
* @param params Not required parameters | ||
* default region is 'eu' | ||
* metadata in cookies is enabled by default | ||
* relayProxyUrl is used together with https://help.smartlook.com/en/articles/6120645-smartlook-relay-proxy and should be full url with protocol e.g. https://my-proxy-domain.com/ | ||
*/ | ||
init: function (key: string, params?: { region?: 'eu' | 'us'; version?: 'nextgen' | 'legacy', cookies?: boolean }): boolean { | ||
init: function (key: string, params?: { region?: 'eu' | 'us'; cookies?: boolean; relayProxyUrl?: string }): boolean { | ||
const w = window as SmartlookWindow | ||
@@ -23,7 +25,22 @@ if (w.smartlook) { | ||
const { region = 'eu', version = 'nextgen', cookies = true } = params ?? {} | ||
const { region = 'eu', cookies = true, relayProxyUrl } = params ?? {} | ||
w.smartlook.api = [] | ||
w.smartlook('init', key, { region, cookies }) | ||
const initParams: { region?: string, cookies?: boolean, host?: string } = { region, cookies } | ||
let src = 'https://web-sdk.smartlook.com/recorder.js' | ||
if (relayProxyUrl) { | ||
try { | ||
const constructedUrl = new URL('/recorder.js', relayProxyUrl) | ||
initParams.host = constructedUrl.host | ||
src = constructedUrl.toString() | ||
} catch (e) { | ||
console.error('Smartlook init param `relayProxyUrl` is not valid. Please provide full url like `https://my-proxy-domain.com/`.') | ||
return false | ||
} | ||
} | ||
w.smartlook('init', key, initParams) | ||
const head = window.document.getElementsByTagName('head')[0] | ||
@@ -34,4 +51,3 @@ const script = window.document.createElement('script') | ||
script.crossOrigin = 'anonymous' | ||
script.src = | ||
version === 'nextgen' ? 'https://web-sdk.smartlook.com/recorder.js' : 'https://rec.smartlook.com/recorder.js' | ||
script.src = src | ||
head.appendChild(script) | ||
@@ -38,0 +54,0 @@ |
{ | ||
"name": "smartlook-client", | ||
"version": "7.0.2", | ||
"version": "8.0.0", | ||
"description": "Official Smartlook client for easy frontend integration.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -25,5 +25,40 @@ # Smartlook-client | ||
init(string key) | ||
init(string key, params?: { region?: 'eu' | 'us', version?: 'legacy' | 'nextgen', cookies?: boolean }) | ||
init(string key, params?: { region?: 'eu' | 'us', cookies?: boolean, relayProxyUrl?: string }) | ||
``` | ||
Required parameters: | ||
* key: | ||
* Obtained in application at project settings | ||
Optional parameters: | ||
* region: | ||
* supported values: | ||
* `'eu'` | ||
* `'us'` | ||
* example: | ||
* `smartlookClient.init('xxxxx', { region: 'us' })` | ||
* description | ||
* Region where data will be captured and stored | ||
* **Do not change** unless told by your sales manager | ||
* cookies: | ||
* supported values: | ||
* `true` | ||
* `false` | ||
* example: | ||
* `smartlookClient.init('xxxxx', { cookies: false })` | ||
* description | ||
* Use false if you do not want to store recording metadata in cookies | ||
* Note that disabling cookies with block the ability to connect visitors between domain and its subdomains. | ||
* Read more at https://help.smartlook.com/en/articles/6064963-cookies-in-smartlook | ||
* relayProxyUrl: | ||
* supported values: | ||
* full URL of self-hosted relay proxy | ||
* e.g. `'https://my-proxy-domain.com/'` | ||
* example | ||
* `smartlookClient.init('xxxxx', { relayProxyUrl: 'https://my-proxy-domain.com/' })` | ||
* description: | ||
* Read more about relay proxy at https://help.smartlook.com/en/articles/6120645-smartlook-relay-proxy and https://github.com/smartlook/smartlook-relay-proxy | ||
--- | ||
``` | ||
@@ -149,2 +184,2 @@ track(string eventName, object<key:value> props) | ||
For more info visit https://www.smartlook.com/docs/api.html | ||
For more info visit https://web.developer.smartlook.com/reference/getting-started-with-your-api |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22775
431
184