@hyvor/design 1.1.21-beta.2 → 1.1.22-beta.1
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.
|
@@ -9,3 +9,4 @@ export { default as DocsImage } from './Docs/Content/DocsImage.svelte';
|
|
|
9
9
|
export { default as Footer } from './Footer/Footer.svelte';
|
|
10
10
|
export { default as FooterLinkList } from './Footer/FooterLinkList.svelte';
|
|
11
11
|
export { default as Document } from './Document/Document.svelte';
|
|
12
|
+
export { default as track } from './track/track.js';
|
package/dist/marketing/index.js
CHANGED
|
@@ -9,3 +9,4 @@ export { default as DocsImage } from './Docs/Content/DocsImage.svelte';
|
|
|
9
9
|
export { default as Footer } from './Footer/Footer.svelte';
|
|
10
10
|
export { default as FooterLinkList } from './Footer/FooterLinkList.svelte';
|
|
11
11
|
export { default as Document } from './Document/Document.svelte';
|
|
12
|
+
export { default as track } from './track/track.js';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface InitOptions {
|
|
2
|
+
forceTrack: boolean;
|
|
3
|
+
openPanelApiUrl?: string;
|
|
4
|
+
openPanelClientId?: string;
|
|
5
|
+
}
|
|
6
|
+
declare class Track {
|
|
7
|
+
private op;
|
|
8
|
+
private isProductionDomain;
|
|
9
|
+
init({ forceTrack, openPanelApiUrl, openPanelClientId }: InitOptions): void;
|
|
10
|
+
private checkOp;
|
|
11
|
+
context(properties: Record<string, any>): void;
|
|
12
|
+
event(name: string, properties?: Record<string, any>): void;
|
|
13
|
+
identify(profileId: string, props: {
|
|
14
|
+
name?: string;
|
|
15
|
+
avatar?: string;
|
|
16
|
+
properties?: Record<string, any>;
|
|
17
|
+
}): void;
|
|
18
|
+
logout(): void;
|
|
19
|
+
}
|
|
20
|
+
declare const track: Track;
|
|
21
|
+
export default track;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { OpenPanel } from '@openpanel/web';
|
|
2
|
+
class Track {
|
|
3
|
+
op;
|
|
4
|
+
isProductionDomain() {
|
|
5
|
+
const hostname = window.location.hostname;
|
|
6
|
+
return hostname === 'hyvor.com' || hostname.endsWith('.hyvor.com');
|
|
7
|
+
}
|
|
8
|
+
init({ forceTrack, openPanelApiUrl = 'https://op.hyvor.com/api', openPanelClientId = 'b11f6143-a6b0-4fa4-a86c-3969c01dbb1d' }) {
|
|
9
|
+
if (!forceTrack && !this.isProductionDomain()) {
|
|
10
|
+
console.log('Tracking is disabled in non-production domains.');
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
this.op = new OpenPanel({
|
|
14
|
+
apiUrl: openPanelApiUrl,
|
|
15
|
+
clientId: openPanelClientId,
|
|
16
|
+
trackScreenViews: true,
|
|
17
|
+
trackOutgoingLinks: true,
|
|
18
|
+
trackAttributes: true,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
checkOp() {
|
|
22
|
+
if (!this.op) {
|
|
23
|
+
throw new Error('OpenPanel is not initialized. Call track.init() first.');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// set global context
|
|
27
|
+
context(properties) {
|
|
28
|
+
this.checkOp();
|
|
29
|
+
this.op.setGlobalProperties(properties);
|
|
30
|
+
}
|
|
31
|
+
// log an event
|
|
32
|
+
event(name, properties) {
|
|
33
|
+
this.checkOp();
|
|
34
|
+
this.op.track(name, properties);
|
|
35
|
+
}
|
|
36
|
+
// identify user
|
|
37
|
+
identify(profileId, props) {
|
|
38
|
+
this.checkOp();
|
|
39
|
+
this.op.identify({
|
|
40
|
+
profileId: profileId,
|
|
41
|
+
firstName: props.name,
|
|
42
|
+
avatar: props.avatar,
|
|
43
|
+
properties: props.properties
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
// log out user (clear identity)
|
|
47
|
+
logout() {
|
|
48
|
+
this.checkOp();
|
|
49
|
+
this.op.clear();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const track = new Track();
|
|
53
|
+
export default track;
|
package/package.json
CHANGED
|
@@ -49,6 +49,8 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@fontsource/readex-pro": "^5.0.8",
|
|
51
51
|
"@hyvor/icons": "^1.1.1",
|
|
52
|
+
"@openpanel/sdk": "^1.0.0",
|
|
53
|
+
"@openpanel/web": "^1.0.1",
|
|
52
54
|
"deepmerge-ts": "^5.1.0",
|
|
53
55
|
"emojibase-data": "^16.0.3",
|
|
54
56
|
"highlight.js": "^11.9.0",
|
|
@@ -60,5 +62,5 @@
|
|
|
60
62
|
"publishConfig": {
|
|
61
63
|
"access": "public"
|
|
62
64
|
},
|
|
63
|
-
"version": "1.1.
|
|
65
|
+
"version": "1.1.22-beta.1"
|
|
64
66
|
}
|