Skip to content

Commit

Permalink
feat: record API
Browse files Browse the repository at this point in the history
  • Loading branch information
amertak committed Mar 31, 2022
1 parent 7f4f873 commit 9fd7c5d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 58 deletions.
10 changes: 7 additions & 3 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ declare const _default: {
[key: string]: string | number | boolean;
}) => boolean;
disable: () => boolean;
consentForms: (consent: string | false) => boolean;
consentIP: (consent: string | false) => boolean;
consentAPI: (consent: string | false) => boolean;
record: (params: {
forms?: boolean;
ips?: boolean;
numbers?: boolean;
emails?: boolean;
api?: boolean;
}) => boolean;
getData: (callback: () => void) => boolean;
restart: () => boolean;
pause: () => boolean;
Expand Down
22 changes: 2 additions & 20 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 20 additions & 34 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,31 +74,19 @@ export default {
w.smartlook('disable')
return true
},
consentForms: function (consent: string | false): boolean {
record: function (params: {
forms?: boolean
ips?: boolean
numbers?: boolean
emails?: boolean
api?: boolean
}): boolean {
const w = window as SmartlookWindow
if (!w.smartlook) {
console.warn(SL_NOT_INITIALIZED)
return false
}
w.smartlook('consentForms', consent)
return true
},
consentIP: function (consent: string | false): boolean {
const w = window as SmartlookWindow
if (!w.smartlook) {
console.warn(SL_NOT_INITIALIZED)
return false
}
w.smartlook('consentIP', consent)
return true
},
consentAPI: function (consent: string | false): boolean {
const w = window as SmartlookWindow
if (!w.smartlook) {
console.warn(SL_NOT_INITIALIZED)
return false
}
w.smartlook('consentAPI', consent)
w.smartlook('record', params)
return true
},
getData: function (callback: () => void): boolean {
Expand Down Expand Up @@ -168,30 +156,28 @@ export default {
const w = window as SmartlookWindow
return !!w.smartlook
},
get playUrl(): string | undefined {
const w = window as SmartlookWindow
get playUrl(): string | undefined {
const w = window as SmartlookWindow
return w.smartlook.playUrl
},
get sessionId(): string | undefined {
const w = window as SmartlookWindow
get sessionId(): string | undefined {
const w = window as SmartlookWindow
return w.smartlook.sessionId
},
get visitorId(): string | undefined {
const w = window as SmartlookWindow
get visitorId(): string | undefined {
const w = window as SmartlookWindow
return w.smartlook.visitorId
},
get recordId(): string | undefined {
const w = window as SmartlookWindow
get recordId(): string | undefined {
const w = window as SmartlookWindow
return w.smartlook.recordId
},
get key(): string | undefined {
const w = window as SmartlookWindow
get key(): string | undefined {
const w = window as SmartlookWindow
return w.smartlook.key
},
get version(): string | undefined {
const w = window as SmartlookWindow
get version(): string | undefined {
const w = window as SmartlookWindow
return w.smartlook.version
},
}


0 comments on commit 9fd7c5d

Please sign in to comment.