demoway-sdk
Advanced tools
Comparing version 0.4.7 to 0.4.8
@@ -5,6 +5,16 @@ import type { ISDKService } from './lib/service-host'; | ||
export interface ISDKAttributes { | ||
userId?: string; | ||
username?: string; | ||
userInfo?: IUserInfo; | ||
[key: string]: unknown; | ||
} | ||
export interface IUserInfo { | ||
openId?: string; | ||
userName?: string; | ||
nickName?: string; | ||
email?: string; | ||
company?: { | ||
id?: string; | ||
name: string; | ||
}; | ||
[key: string]: unknown; | ||
} | ||
export interface ISDKInitializeOptions { | ||
@@ -14,3 +24,3 @@ appId: string; | ||
zIndex?: number; | ||
attributes?: ISDKAttributes; | ||
userInfo?: IUserInfo; | ||
} | ||
@@ -17,0 +27,0 @@ export declare const SERVICE_ENDPOINT: string; |
@@ -1,4 +0,4 @@ | ||
import { firstValueFrom as l, fromEvent as d, map as s, bufferCount as E, filter as m, noop as I } from "rxjs"; | ||
import { firstValueFrom as d, fromEvent as E, map as s, bufferCount as I, filter as m, noop as u } from "rxjs"; | ||
import g from "auto-bind"; | ||
class u { | ||
class p { | ||
constructor(e) { | ||
@@ -11,10 +11,10 @@ this.delegate = e, g(this); | ||
openDemoDialog(e, o) { | ||
return this.delegate.then((r) => r.openDemoDialog(e, o)); | ||
return this.delegate.then((n) => n.openDemoDialog(e, o)); | ||
} | ||
} | ||
const i = "DEMOWAY_SDK_INITIALIZED", p = "demoway-sdk-initialize"; | ||
function f(t) { | ||
const i = "DEMOWAY_SDK_INITIALIZED", f = "demoway-sdk-initialize"; | ||
function h(t) { | ||
return typeof localStorage == "object" ? localStorage.getItem(t) : null; | ||
} | ||
const D = "MIAOLU_SERVICE_ENDPOINT", S = f(D) || "https://s.demoway.co/sdk/sdk-service/index.js"; | ||
const D = "MIAOLU_SERVICE_ENDPOINT", S = h(D) || "https://s.demoway.co/sdk/sdk-service/index.js"; | ||
function a() { | ||
@@ -26,5 +26,5 @@ throw new Error("sdk is not initialized"); | ||
enableRecord: a | ||
}), n = new u(c), N = n.openDemoDialog, _ = n.enableRecord; | ||
}), r = new p(c), _ = r.openDemoDialog, b = r.enableRecord; | ||
typeof sessionStorage == "object" && sessionStorage.setItem(i, "false"); | ||
function b(t) { | ||
function k(t) { | ||
if (!t.accessToken) | ||
@@ -34,4 +34,4 @@ throw new Error("Invalid token"); | ||
throw new Error("Missing appId"); | ||
if (n.delegate !== c) | ||
return n.delegate.then(() => n); | ||
if (r.delegate !== c) | ||
return r.delegate.then(() => r); | ||
if (sessionStorage.getItem(i) === "true") | ||
@@ -42,12 +42,16 @@ throw new Error("Multiple sdk detected"); | ||
S | ||
).then((o) => (sessionStorage.setItem(i, "true"), o.initialize(t))).then((o) => (window.dispatchEvent(new CustomEvent(p)), o)); | ||
return n.delegate = e, e.then(() => n); | ||
).then((o) => { | ||
sessionStorage.setItem(i, "true"); | ||
const { userInfo: n, ...l } = t; | ||
return o.initialize({ ...l, attributes: { userInfo: n } }); | ||
}).then((o) => (window.dispatchEvent(new CustomEvent(f)), o)); | ||
return r.delegate = e, e.then(() => r); | ||
} | ||
function k(t, e, o) { | ||
return l( | ||
d(t, "click").pipe( | ||
function v(t, e, o) { | ||
return d( | ||
E(t, "click").pipe( | ||
s(() => Date.now()), | ||
E(e), | ||
m((r) => r[r.length - 1] - r[0] < o), | ||
s(I) | ||
I(e), | ||
m((n) => n[n.length - 1] - n[0] < o), | ||
s(u) | ||
) | ||
@@ -58,6 +62,6 @@ ); | ||
S as SERVICE_ENDPOINT, | ||
_ as enableRecord, | ||
b as initialize, | ||
N as openDemoDialog, | ||
k as rageClick | ||
b as enableRecord, | ||
k as initialize, | ||
_ as openDemoDialog, | ||
v as rageClick | ||
}; |
{ | ||
"name": "demoway-sdk", | ||
"version": "0.4.7", | ||
"version": "0.4.8", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -34,3 +34,12 @@ # Demoway SDK | ||
initialize({ | ||
accessToken: '', // getting from DemoWay dashboard | ||
accessToken: '', // getting from your DemoWay dashboard | ||
appId: '', // getting from your DemoWay dashboard | ||
attributes: { | ||
userId: '', // the user id or openid of the user in your system, you can get the user‘s data from DemoWay by API via this userId | ||
userName: '', | ||
nickName: '', // the nick name of the user in your system, will display in your DemoWay dashboard | ||
anyOtherAttributes1: '', // any other attributes you want to provide, will display in your DemoWay dashboard | ||
anyOtherAttributes2: '', | ||
anyOtherAttributes3: '', | ||
}, | ||
}) | ||
@@ -51,2 +60,11 @@ /** | ||
accessToken: '', // getting from DemoWay dashboard | ||
appId: '', // getting from DemoWay dashboard | ||
attributes: { | ||
userId: '', // the user id or openid of the user in your system, you can get the user‘s data from DemoWay by API via this userId | ||
userName: '', | ||
nickName: '', // the nick name of the user in your system, will display in your DemoWay dashboard | ||
anyOtherAttributes1: '', // any other attributes you want to provide, will display in your DemoWay dashboard | ||
anyOtherAttributes2: '', | ||
anyOtherAttributes3: '', | ||
}, | ||
}); | ||
@@ -53,0 +71,0 @@ |
Sorry, the diff of this file is not supported yet
11358
137
128