@asiyst/sdk 0.1.18 → 0.1.19
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/dist/index.cjs +61 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +61 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -71,7 +71,7 @@ var ALL_ACTION_KINDS = [
|
|
|
71
71
|
// src/core/constants.ts
|
|
72
72
|
function resolveSdkVersion() {
|
|
73
73
|
{
|
|
74
|
-
return "0.1.
|
|
74
|
+
return "0.1.18";
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
var SDK_VERSION = resolveSdkVersion();
|
|
@@ -559,18 +559,33 @@ var CloudClient = class {
|
|
|
559
559
|
return this.inFlightToken;
|
|
560
560
|
}
|
|
561
561
|
async fetchConfig() {
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
562
|
+
try {
|
|
563
|
+
const response = await this.runtimeRequest({
|
|
564
|
+
path: `/projects/${encodeURIComponent(this.projectId)}/avatar`,
|
|
565
|
+
method: "GET",
|
|
566
|
+
idempotent: true
|
|
567
|
+
});
|
|
568
|
+
if (response.ok && response.data) {
|
|
569
|
+
return normalizeProjectConfig(response.data.config ?? response.data);
|
|
570
|
+
}
|
|
571
|
+
} catch {
|
|
569
572
|
}
|
|
570
|
-
|
|
571
|
-
|
|
573
|
+
try {
|
|
574
|
+
const res = await fetch(`https://asiyst.com/api/v1/runtime/avatar?projectId=${encodeURIComponent(this.projectId)}&publicKey=${encodeURIComponent(this.publicKey)}`, {
|
|
575
|
+
headers: { Accept: "application/json" }
|
|
576
|
+
});
|
|
577
|
+
if (res.ok) {
|
|
578
|
+
const body = await res.json();
|
|
579
|
+
if (body?.avatar) {
|
|
580
|
+
return normalizeProjectConfig({
|
|
581
|
+
avatarName: body.avatar.name,
|
|
582
|
+
avatarId: body.avatar.avatarId
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
} catch {
|
|
572
587
|
}
|
|
573
|
-
return normalizeProjectConfig(
|
|
588
|
+
return normalizeProjectConfig({});
|
|
574
589
|
}
|
|
575
590
|
async heartbeat(metadata) {
|
|
576
591
|
const response = await this.runtimeRequest({
|
|
@@ -668,6 +683,33 @@ var CloudClient = class {
|
|
|
668
683
|
async sendAnalytics(events) {
|
|
669
684
|
await this.safePost("/analytics", { events });
|
|
670
685
|
}
|
|
686
|
+
async sendTelemetryEvent(eventType, metadata = {}) {
|
|
687
|
+
try {
|
|
688
|
+
const origin = typeof window !== "undefined" ? window.location.origin : void 0;
|
|
689
|
+
const installationId = this.runtimeAuth ? this.runtimeAuth.options?.installationId : void 0;
|
|
690
|
+
const payload = {
|
|
691
|
+
projectId: this.projectId,
|
|
692
|
+
publicKey: this.publicKey,
|
|
693
|
+
eventType,
|
|
694
|
+
installationId,
|
|
695
|
+
origin,
|
|
696
|
+
metadata: {
|
|
697
|
+
...metadata,
|
|
698
|
+
sdkVersion: SDK_VERSION
|
|
699
|
+
}
|
|
700
|
+
};
|
|
701
|
+
await fetch("https://asiyst.com/api/v1/events", {
|
|
702
|
+
method: "POST",
|
|
703
|
+
headers: {
|
|
704
|
+
"Content-Type": "application/json",
|
|
705
|
+
Accept: "application/json",
|
|
706
|
+
"x-asiyst-public-key": this.publicKey
|
|
707
|
+
},
|
|
708
|
+
body: JSON.stringify(payload)
|
|
709
|
+
});
|
|
710
|
+
} catch {
|
|
711
|
+
}
|
|
712
|
+
}
|
|
671
713
|
async sendTaskUpdate(taskId, status, stepId) {
|
|
672
714
|
await this.safePost(`/tasks/${encodeURIComponent(taskId)}/events`, {
|
|
673
715
|
status,
|
|
@@ -2951,6 +2993,14 @@ var AsiystRuntime = class {
|
|
|
2951
2993
|
}
|
|
2952
2994
|
}
|
|
2953
2995
|
this.events.emit("asiyst:ready", { projectId: this.options.projectId, configVersion: cfg.version });
|
|
2996
|
+
void this.cloud.sendTelemetryEvent("avatar_runtime_initialized", {
|
|
2997
|
+
avatarId: this.options.avatarId ?? cfg.avatarName,
|
|
2998
|
+
avatarName: cfg.avatarName
|
|
2999
|
+
});
|
|
3000
|
+
void this.cloud.sendTelemetryEvent("avatar_asset_loaded", {
|
|
3001
|
+
avatarId: this.options.avatarId ?? cfg.avatarName,
|
|
3002
|
+
avatarName: cfg.avatarName
|
|
3003
|
+
});
|
|
2954
3004
|
}
|
|
2955
3005
|
getConnectionStatus() {
|
|
2956
3006
|
return this.connectionStatus;
|