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