@hyvor/design 1.1.22-beta.1 → 1.1.22
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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { track } from '../../marketing/index.js';
|
|
1
2
|
import { writable } from 'svelte/store';
|
|
2
3
|
let instance = '';
|
|
3
4
|
let product = 'core';
|
|
@@ -28,6 +29,12 @@ export function initBar() {
|
|
|
28
29
|
if (lastUnreadTime === null) {
|
|
29
30
|
UnreadUpdatesTimeLocalStorage.setNow();
|
|
30
31
|
}
|
|
32
|
+
if (data.user && track.ready()) {
|
|
33
|
+
track.identify(data.user.id.toString(), {
|
|
34
|
+
name: data.user.name ?? undefined,
|
|
35
|
+
avatar: data.user.picture_url ?? undefined,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
31
38
|
})
|
|
32
39
|
.catch((error) => {
|
|
33
40
|
console.error('Error:', error);
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
interface InitOptions {
|
|
2
|
-
forceTrack
|
|
2
|
+
forceTrack?: boolean;
|
|
3
3
|
openPanelApiUrl?: string;
|
|
4
4
|
openPanelClientId?: string;
|
|
5
|
+
context?: Record<string, any>;
|
|
5
6
|
}
|
|
6
7
|
declare class Track {
|
|
7
8
|
private op;
|
|
8
9
|
private isProductionDomain;
|
|
9
|
-
init({ forceTrack, openPanelApiUrl, openPanelClientId }
|
|
10
|
+
init({ forceTrack, openPanelApiUrl, openPanelClientId, context }?: InitOptions): void;
|
|
10
11
|
private checkOp;
|
|
12
|
+
ready(): boolean;
|
|
11
13
|
context(properties: Record<string, any>): void;
|
|
12
14
|
event(name: string, properties?: Record<string, any>): void;
|
|
13
15
|
identify(profileId: string, props: {
|
|
@@ -5,7 +5,7 @@ class Track {
|
|
|
5
5
|
const hostname = window.location.hostname;
|
|
6
6
|
return hostname === 'hyvor.com' || hostname.endsWith('.hyvor.com');
|
|
7
7
|
}
|
|
8
|
-
init({ forceTrack, openPanelApiUrl = 'https://op.hyvor.com/api', openPanelClientId = 'b11f6143-a6b0-4fa4-a86c-3969c01dbb1d' }) {
|
|
8
|
+
init({ forceTrack = false, openPanelApiUrl = 'https://op.hyvor.com/api', openPanelClientId = 'b11f6143-a6b0-4fa4-a86c-3969c01dbb1d', context = {} } = {}) {
|
|
9
9
|
if (!forceTrack && !this.isProductionDomain()) {
|
|
10
10
|
console.log('Tracking is disabled in non-production domains.');
|
|
11
11
|
return;
|
|
@@ -17,12 +17,18 @@ class Track {
|
|
|
17
17
|
trackOutgoingLinks: true,
|
|
18
18
|
trackAttributes: true,
|
|
19
19
|
});
|
|
20
|
+
if (Object.keys(context).length > 0) {
|
|
21
|
+
this.op.setGlobalProperties(context);
|
|
22
|
+
}
|
|
20
23
|
}
|
|
21
24
|
checkOp() {
|
|
22
25
|
if (!this.op) {
|
|
23
26
|
throw new Error('OpenPanel is not initialized. Call track.init() first.');
|
|
24
27
|
}
|
|
25
28
|
}
|
|
29
|
+
ready() {
|
|
30
|
+
return this.op !== undefined;
|
|
31
|
+
}
|
|
26
32
|
// set global context
|
|
27
33
|
context(properties) {
|
|
28
34
|
this.checkOp();
|
package/package.json
CHANGED