@sankhyalabs/core 4.9.1 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/classes/OnboardingUtils.md +126 -0
- package/.docs/modules.md +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/OnboardingUtils.d.ts +17 -0
- package/dist/utils/OnboardingUtils.js +41 -0
- package/dist/utils/OnboardingUtils.js.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +3 -2
- package/src/utils/OnboardingUtils.ts +46 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
[@sankhyalabs/core](../README.md) / [Exports](../modules.md) / OnboardingUtils
|
|
2
|
+
|
|
3
|
+
# Class: OnboardingUtils
|
|
4
|
+
|
|
5
|
+
## Table of contents
|
|
6
|
+
|
|
7
|
+
### Constructors
|
|
8
|
+
|
|
9
|
+
- [constructor](OnboardingUtils.md#constructor)
|
|
10
|
+
|
|
11
|
+
### Properties
|
|
12
|
+
|
|
13
|
+
- [USER\_GUIDE\_TAG\_ID](OnboardingUtils.md#user_guide_tag_id)
|
|
14
|
+
- [instance](OnboardingUtils.md#instance)
|
|
15
|
+
|
|
16
|
+
### Methods
|
|
17
|
+
|
|
18
|
+
- [init](OnboardingUtils.md#init)
|
|
19
|
+
- [injectScript](OnboardingUtils.md#injectscript)
|
|
20
|
+
- [register](OnboardingUtils.md#register)
|
|
21
|
+
- [getInstance](OnboardingUtils.md#getinstance)
|
|
22
|
+
|
|
23
|
+
## Constructors
|
|
24
|
+
|
|
25
|
+
### constructor
|
|
26
|
+
|
|
27
|
+
• `Private` **new OnboardingUtils**()
|
|
28
|
+
|
|
29
|
+
#### Defined in
|
|
30
|
+
|
|
31
|
+
src/utils/OnboardingUtils.ts:5
|
|
32
|
+
|
|
33
|
+
## Properties
|
|
34
|
+
|
|
35
|
+
### USER\_GUIDE\_TAG\_ID
|
|
36
|
+
|
|
37
|
+
▪ `Static` `Private` `Readonly` **USER\_GUIDE\_TAG\_ID**: ``"userGuideSnippet"``
|
|
38
|
+
|
|
39
|
+
#### Defined in
|
|
40
|
+
|
|
41
|
+
src/utils/OnboardingUtils.ts:2
|
|
42
|
+
|
|
43
|
+
___
|
|
44
|
+
|
|
45
|
+
### instance
|
|
46
|
+
|
|
47
|
+
▪ `Static` `Private` **instance**: [`OnboardingUtils`](OnboardingUtils.md)
|
|
48
|
+
|
|
49
|
+
#### Defined in
|
|
50
|
+
|
|
51
|
+
src/utils/OnboardingUtils.ts:3
|
|
52
|
+
|
|
53
|
+
## Methods
|
|
54
|
+
|
|
55
|
+
### init
|
|
56
|
+
|
|
57
|
+
▸ **init**(`apiKey`, `ctx`): `Promise`<`void`\>
|
|
58
|
+
|
|
59
|
+
#### Parameters
|
|
60
|
+
|
|
61
|
+
| Name | Type |
|
|
62
|
+
| :------ | :------ |
|
|
63
|
+
| `apiKey` | `string` |
|
|
64
|
+
| `ctx` | `EnvironmentContext` |
|
|
65
|
+
|
|
66
|
+
#### Returns
|
|
67
|
+
|
|
68
|
+
`Promise`<`void`\>
|
|
69
|
+
|
|
70
|
+
#### Defined in
|
|
71
|
+
|
|
72
|
+
src/utils/OnboardingUtils.ts:14
|
|
73
|
+
|
|
74
|
+
___
|
|
75
|
+
|
|
76
|
+
### injectScript
|
|
77
|
+
|
|
78
|
+
▸ `Private` **injectScript**(`apiKey`): `void`
|
|
79
|
+
|
|
80
|
+
#### Parameters
|
|
81
|
+
|
|
82
|
+
| Name | Type |
|
|
83
|
+
| :------ | :------ |
|
|
84
|
+
| `apiKey` | `string` |
|
|
85
|
+
|
|
86
|
+
#### Returns
|
|
87
|
+
|
|
88
|
+
`void`
|
|
89
|
+
|
|
90
|
+
#### Defined in
|
|
91
|
+
|
|
92
|
+
src/utils/OnboardingUtils.ts:23
|
|
93
|
+
|
|
94
|
+
___
|
|
95
|
+
|
|
96
|
+
### register
|
|
97
|
+
|
|
98
|
+
▸ `Private` **register**(`ctx`): `void`
|
|
99
|
+
|
|
100
|
+
#### Parameters
|
|
101
|
+
|
|
102
|
+
| Name | Type |
|
|
103
|
+
| :------ | :------ |
|
|
104
|
+
| `ctx` | `EnvironmentContext` |
|
|
105
|
+
|
|
106
|
+
#### Returns
|
|
107
|
+
|
|
108
|
+
`void`
|
|
109
|
+
|
|
110
|
+
#### Defined in
|
|
111
|
+
|
|
112
|
+
src/utils/OnboardingUtils.ts:34
|
|
113
|
+
|
|
114
|
+
___
|
|
115
|
+
|
|
116
|
+
### getInstance
|
|
117
|
+
|
|
118
|
+
▸ `Static` **getInstance**(): [`OnboardingUtils`](OnboardingUtils.md)
|
|
119
|
+
|
|
120
|
+
#### Returns
|
|
121
|
+
|
|
122
|
+
[`OnboardingUtils`](OnboardingUtils.md)
|
|
123
|
+
|
|
124
|
+
#### Defined in
|
|
125
|
+
|
|
126
|
+
src/utils/OnboardingUtils.ts:7
|
package/.docs/modules.md
CHANGED
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
- [MaskFormatter](classes/MaskFormatter-1.md)
|
|
38
38
|
- [NumberUtils](classes/NumberUtils.md)
|
|
39
39
|
- [ObjectUtils](classes/ObjectUtils.md)
|
|
40
|
+
- [OnboardingUtils](classes/OnboardingUtils.md)
|
|
40
41
|
- [ReadyUtil](classes/ReadyUtil.md)
|
|
41
42
|
- [RequestMetadata](classes/RequestMetadata.md)
|
|
42
43
|
- [SelectionInfo](classes/SelectionInfo.md)
|
package/dist/index.d.ts
CHANGED
|
@@ -28,4 +28,5 @@ import { UserAgentUtils } from "./utils/UserAgentUtils/index.js";
|
|
|
28
28
|
import { JSUtils } from "./utils/JSUtils.js";
|
|
29
29
|
import { DataUnitStorage } from "./dataunit/DataUnitStorage.js";
|
|
30
30
|
import VersionUtils from './utils/VersionUtils.js';
|
|
31
|
-
|
|
31
|
+
import { OnboardingUtils } from "./utils/OnboardingUtils.js";
|
|
32
|
+
export { StringUtils, MaskFormatter, NumberUtils, FloatingManager, DateUtils, ArrayUtils, TimeFormatter, SkwHttpProvider, HttpProvider, RequestMetadata, AuthorizedServiceCaller, DataUnit, DataUnitStorage, Record, SavedRecord, DataType, UnitMetadata, FieldDescriptor, UserInterface, DependencyType, ChildDescriptor, ChildLink, DataUnitAction, Action, Change, Sort, Filter, ChangeOperation, DUActionInterceptor, ApplicationContext, WaitingChange, PageRequest, QuickFilter, ReadyUtil, ObjectUtils, WarningException, WaitingChangeException, ErrorException, ErrorTracking, ExecutionContext, PaginationInfo, SortingProvider, SortMode, LoadDataRequest, LoadDataResponse, SelectionInfo, SelectionMode, ElementIDUtils, IElementIDInfo, UserAgentUtils, JSUtils, VersionUtils, OnboardingUtils };
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,7 @@ import { UserAgentUtils } from "./utils/UserAgentUtils/index.js";
|
|
|
25
25
|
import { JSUtils } from "./utils/JSUtils.js";
|
|
26
26
|
import { DataUnitStorage } from "./dataunit/DataUnitStorage.js";
|
|
27
27
|
import VersionUtils from './utils/VersionUtils.js';
|
|
28
|
+
import { OnboardingUtils } from "./utils/OnboardingUtils.js";
|
|
28
29
|
/*Classes públicas no pacote*/
|
|
29
|
-
export { StringUtils, MaskFormatter, NumberUtils, FloatingManager, DateUtils, ArrayUtils, TimeFormatter, SkwHttpProvider, HttpProvider, RequestMetadata, AuthorizedServiceCaller, DataUnit, DataUnitStorage, DataType, UserInterface, DependencyType, DataUnitAction, Action, Change, ChangeOperation, ApplicationContext, ReadyUtil, ObjectUtils, WarningException, WaitingChangeException, ErrorException, ErrorTracking, SortMode, SelectionInfo, SelectionMode, ElementIDUtils, UserAgentUtils, JSUtils, VersionUtils };
|
|
30
|
+
export { StringUtils, MaskFormatter, NumberUtils, FloatingManager, DateUtils, ArrayUtils, TimeFormatter, SkwHttpProvider, HttpProvider, RequestMetadata, AuthorizedServiceCaller, DataUnit, DataUnitStorage, DataType, UserInterface, DependencyType, DataUnitAction, Action, Change, ChangeOperation, ApplicationContext, ReadyUtil, ObjectUtils, WarningException, WaitingChangeException, ErrorException, ErrorTracking, SortMode, SelectionInfo, SelectionMode, ElementIDUtils, UserAgentUtils, JSUtils, VersionUtils, OnboardingUtils };
|
|
30
31
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,eAAe,MAAM,yBAAyB,CAAC;AACtD,OAAO,SAAS,MAAM,sBAAsB,CAAC;AAC7C,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,QAAQ,EAAE,EAAsB,MAAM,EAAE,eAAe,EAAgE,aAAa,EAAE,aAAa,EAAC,MAAM,wBAAwB,CAAC;AAC1L,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAiC,aAAa,EAAQ,QAAQ,EAA2B,cAAc,EAA8B,MAAM,qCAAqC,CAAC;AACxL,OAAO,EAAE,cAAc,EAAE,MAAM,EAAoB,MAAM,2CAA2C,CAAC;AACrG,OAAO,kBAAkB,MAAM,+BAA+B,CAAC;AAC/D,OAAO,SAAS,MAAM,sBAAsB,CAAC;AAC7C,OAAO,WAAW,MAAM,wBAAwB,CAAC;AACjD,OAAO,gBAAgB,MAAM,kCAAkC,CAAC;AAChE,OAAO,sBAAsB,MAAM,wCAAwC,CAAC;AAC5E,OAAO,cAAc,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAI1D,OAAO,EAAE,cAAc,EAAkB,MAAM,2BAA2B,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,YAAY,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,eAAe,MAAM,yBAAyB,CAAC;AACtD,OAAO,SAAS,MAAM,sBAAsB,CAAC;AAC7C,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,QAAQ,EAAE,EAAsB,MAAM,EAAE,eAAe,EAAgE,aAAa,EAAE,aAAa,EAAC,MAAM,wBAAwB,CAAC;AAC1L,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAiC,aAAa,EAAQ,QAAQ,EAA2B,cAAc,EAA8B,MAAM,qCAAqC,CAAC;AACxL,OAAO,EAAE,cAAc,EAAE,MAAM,EAAoB,MAAM,2CAA2C,CAAC;AACrG,OAAO,kBAAkB,MAAM,+BAA+B,CAAC;AAC/D,OAAO,SAAS,MAAM,sBAAsB,CAAC;AAC7C,OAAO,WAAW,MAAM,wBAAwB,CAAC;AACjD,OAAO,gBAAgB,MAAM,kCAAkC,CAAC;AAChE,OAAO,sBAAsB,MAAM,wCAAwC,CAAC;AAC5E,OAAO,cAAc,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAI1D,OAAO,EAAE,cAAc,EAAkB,MAAM,2BAA2B,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,YAAY,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAE,eAAe,EAAC,MAAM,4BAA4B,CAAC;AAE5D,8BAA8B;AAC9B,OAAO,EACH,WAAW,EACX,aAAa,EACb,WAAW,EACX,eAAe,EACf,SAAS,EACT,UAAU,EACV,aAAa,EACb,eAAe,EACf,YAAY,EACZ,eAAe,EACf,uBAAuB,EACvB,QAAQ,EACR,eAAe,EAGf,QAAQ,EAGR,aAAa,EACb,cAAc,EAGd,cAAc,EACd,MAAM,EACN,MAAM,EAGN,eAAe,EAEf,kBAAkB,EAIlB,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,sBAAsB,EACtB,cAAc,EACd,aAAa,EAIb,QAAQ,EAGR,aAAa,EACb,aAAa,EACb,cAAc,EAEd,cAAc,EACd,OAAO,EACP,YAAY,EACZ,eAAe,EAClB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare class OnboardingUtils {
|
|
2
|
+
private static readonly USER_GUIDE_TAG_ID;
|
|
3
|
+
private static instance;
|
|
4
|
+
private constructor();
|
|
5
|
+
static getInstance(): OnboardingUtils;
|
|
6
|
+
init(apiKey: string, ctx: EnvironmentContext): Promise<void>;
|
|
7
|
+
private injectScript;
|
|
8
|
+
private register;
|
|
9
|
+
}
|
|
10
|
+
export declare class EnvironmentContext {
|
|
11
|
+
userID: string;
|
|
12
|
+
userName: string;
|
|
13
|
+
partnerName: string;
|
|
14
|
+
sysVersion: string;
|
|
15
|
+
environment: string;
|
|
16
|
+
clientGaId: string;
|
|
17
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export class OnboardingUtils {
|
|
2
|
+
constructor() { }
|
|
3
|
+
static getInstance() {
|
|
4
|
+
if (this.instance == null) {
|
|
5
|
+
this.instance = new OnboardingUtils();
|
|
6
|
+
}
|
|
7
|
+
return this.instance;
|
|
8
|
+
}
|
|
9
|
+
init(apiKey, ctx) {
|
|
10
|
+
if (!apiKey) {
|
|
11
|
+
return Promise.resolve();
|
|
12
|
+
}
|
|
13
|
+
this.injectScript(apiKey);
|
|
14
|
+
this.register(ctx);
|
|
15
|
+
return Promise.resolve();
|
|
16
|
+
}
|
|
17
|
+
injectScript(apiKey) {
|
|
18
|
+
if (window.document.head.querySelector(`script#${OnboardingUtils.USER_GUIDE_TAG_ID}`)) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const scriptEl = document.createElement('script');
|
|
22
|
+
scriptEl.setAttribute("id", OnboardingUtils.USER_GUIDE_TAG_ID);
|
|
23
|
+
scriptEl.innerText = `(function(g,u,i,d,e,s){g[e]=g[e]||[];var f=u.getElementsByTagName(i)[0];var k=u.createElement(i);k.async=true;k.src='https://static.userguiding.com/media/user-guiding-'+s+'-embedded.js';f.parentNode.insertBefore(k,f);if(g[d])return;var ug=g[d]={q:[]};ug.c=function(n){return function(){ug.q.push([n,arguments])};};var m=['previewGuide','finishPreview','track','identify','hideChecklist','launchChecklist'];for(var j=0;j<m.length;j+=1){ug[m[j]]=ug.c(m[j]);}})(window,document,'script','userGuiding','userGuidingLayer','${apiKey}');`;
|
|
24
|
+
window.document.head.appendChild(scriptEl);
|
|
25
|
+
}
|
|
26
|
+
register(ctx) {
|
|
27
|
+
window.userGuiding.identify(`${ctx.userID}-${ctx.userName}-${ctx.clientGaId}`, ctx);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
OnboardingUtils.USER_GUIDE_TAG_ID = "userGuideSnippet";
|
|
31
|
+
export class EnvironmentContext {
|
|
32
|
+
constructor() {
|
|
33
|
+
this.userID = "";
|
|
34
|
+
this.userName = "";
|
|
35
|
+
this.partnerName = "";
|
|
36
|
+
this.sysVersion = "";
|
|
37
|
+
this.environment = "";
|
|
38
|
+
this.clientGaId = "";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=OnboardingUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OnboardingUtils.js","sourceRoot":"","sources":["../../src/utils/OnboardingUtils.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,eAAe;IAIxB,gBAAsB,CAAC;IAEhB,MAAM,CAAC,WAAW;QACrB,IAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,EAAC;YACrB,IAAI,CAAC,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC;SACzC;QACD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAEM,IAAI,CAAC,MAAc,EAAE,GAAuB;QAC/C,IAAG,CAAC,MAAM,EAAC;YACP,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;SAC5B;QACD,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QAC1B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACnB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;IAEO,YAAY,CAAC,MAAc;QAC/B,IAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,eAAe,CAAC,iBAAiB,EAAE,CAAC,EAAC;YACjF,OAAO;SACV;QAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAClD,QAAQ,CAAC,YAAY,CAAC,IAAI,EAAE,eAAe,CAAC,iBAAiB,CAAC,CAAC;QAC/D,QAAQ,CAAC,SAAS,GAAG,ygBAAygB,MAAM,KAAK,CAAC;QAC1iB,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC;IAEO,QAAQ,CAAC,GAAuB;QACnC,MAAc,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,UAAU,EAAE,EAAE,GAAG,CAAC,CAAC;IACjG,CAAC;;AAlCuB,iCAAiB,GAAG,kBAAkB,CAAC;AAqCnE,MAAM,OAAO,kBAAkB;IAA/B;QACK,WAAM,GAAW,EAAE,CAAC;QACpB,aAAQ,GAAW,EAAE,CAAC;QACtB,gBAAW,GAAW,EAAE,CAAC;QACzB,eAAU,GAAW,EAAE,CAAC;QACxB,gBAAW,GAAW,EAAE,CAAC;QACzB,eAAU,GAAW,EAAE,CAAC;IAC7B,CAAC;CAAA"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -28,7 +28,7 @@ import { UserAgentUtils } from "./utils/UserAgentUtils/index.js";
|
|
|
28
28
|
import { JSUtils } from "./utils/JSUtils.js";
|
|
29
29
|
import { DataUnitStorage } from "./dataunit/DataUnitStorage.js";
|
|
30
30
|
import VersionUtils from './utils/VersionUtils.js'
|
|
31
|
-
|
|
31
|
+
import { OnboardingUtils} from "./utils/OnboardingUtils.js";
|
|
32
32
|
|
|
33
33
|
/*Classes públicas no pacote*/
|
|
34
34
|
export {
|
|
@@ -83,5 +83,6 @@ export {
|
|
|
83
83
|
IElementIDInfo,
|
|
84
84
|
UserAgentUtils,
|
|
85
85
|
JSUtils,
|
|
86
|
-
VersionUtils
|
|
86
|
+
VersionUtils,
|
|
87
|
+
OnboardingUtils
|
|
87
88
|
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export class OnboardingUtils {
|
|
2
|
+
private static readonly USER_GUIDE_TAG_ID = "userGuideSnippet";
|
|
3
|
+
private static instance: OnboardingUtils;
|
|
4
|
+
|
|
5
|
+
private constructor(){}
|
|
6
|
+
|
|
7
|
+
public static getInstance(): OnboardingUtils {
|
|
8
|
+
if(this.instance == null){
|
|
9
|
+
this.instance = new OnboardingUtils();
|
|
10
|
+
}
|
|
11
|
+
return this.instance;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public init(apiKey: string, ctx: EnvironmentContext): Promise<void> {
|
|
15
|
+
if(!apiKey){
|
|
16
|
+
return Promise.resolve();
|
|
17
|
+
}
|
|
18
|
+
this.injectScript(apiKey);
|
|
19
|
+
this.register(ctx);
|
|
20
|
+
return Promise.resolve();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
private injectScript(apiKey: string){
|
|
24
|
+
if(window.document.head.querySelector(`script#${OnboardingUtils.USER_GUIDE_TAG_ID}`)){
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const scriptEl = document.createElement('script');
|
|
29
|
+
scriptEl.setAttribute("id", OnboardingUtils.USER_GUIDE_TAG_ID);
|
|
30
|
+
scriptEl.innerText = `(function(g,u,i,d,e,s){g[e]=g[e]||[];var f=u.getElementsByTagName(i)[0];var k=u.createElement(i);k.async=true;k.src='https://static.userguiding.com/media/user-guiding-'+s+'-embedded.js';f.parentNode.insertBefore(k,f);if(g[d])return;var ug=g[d]={q:[]};ug.c=function(n){return function(){ug.q.push([n,arguments])};};var m=['previewGuide','finishPreview','track','identify','hideChecklist','launchChecklist'];for(var j=0;j<m.length;j+=1){ug[m[j]]=ug.c(m[j]);}})(window,document,'script','userGuiding','userGuidingLayer','${apiKey}');`;
|
|
31
|
+
window.document.head.appendChild(scriptEl);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
private register(ctx: EnvironmentContext){
|
|
35
|
+
(window as any).userGuiding.identify(`${ctx.userID}-${ctx.userName}-${ctx.clientGaId}`, ctx);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export class EnvironmentContext {
|
|
40
|
+
userID: string = "";
|
|
41
|
+
userName: string = "";
|
|
42
|
+
partnerName: string = "";
|
|
43
|
+
sysVersion: string = "";
|
|
44
|
+
environment: string = "";
|
|
45
|
+
clientGaId: string = "";
|
|
46
|
+
}
|