@fluid-topics/ft-reader-context 2.0.19 → 2.0.21
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.
|
@@ -59,5 +59,6 @@ export declare class FtReaderStateManager {
|
|
|
59
59
|
onMapAttachmentsUpdate(): void;
|
|
60
60
|
getRelativeDocumentUrlForLocale(uiLocale: string): Promise<string | undefined>;
|
|
61
61
|
private sendDocumentOnDemandTranslateEvent;
|
|
62
|
+
private sendTopicAiTranslateEvent;
|
|
62
63
|
private parseLanguageToAnalyticsFormat;
|
|
63
64
|
}
|
|
@@ -266,6 +266,7 @@ export class FtReaderStateManager {
|
|
|
266
266
|
var _a, _b;
|
|
267
267
|
const translationSettings = this.getTranslationSettings();
|
|
268
268
|
if (translationSettings) {
|
|
269
|
+
this.sendTopicAiTranslateEvent(translationSettings.destinationLanguage, tocNode);
|
|
269
270
|
return (_a = this.service) === null || _a === void 0 ? void 0 : _a.getTranslatedTopicContent(tocNode, translationSettings).then((translationContent) => {
|
|
270
271
|
if (translationContent.isTranslationError) {
|
|
271
272
|
this.setTranslationError(true);
|
|
@@ -331,6 +332,43 @@ export class FtReaderStateManager {
|
|
|
331
332
|
console.warn("Failed to send on-demand document translate event:", error);
|
|
332
333
|
}
|
|
333
334
|
}
|
|
335
|
+
sendTopicAiTranslateEvent(destinationLanguage, tocNode) {
|
|
336
|
+
const { editorMode, apiIntegrationIdentifier, apiIntegrationAppVersion } = ftAppInfoStore.getState();
|
|
337
|
+
const state = this.store.getState();
|
|
338
|
+
const map = state.map;
|
|
339
|
+
const profileId = state.translation.profileId;
|
|
340
|
+
if (editorMode || !map || !apiIntegrationIdentifier || !apiIntegrationAppVersion || !profileId) {
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
try {
|
|
344
|
+
const breadcrumb = this.buildBreadcrumb(tocNode.tocId);
|
|
345
|
+
if (!breadcrumb) {
|
|
346
|
+
console.warn("Failed to build breadcrumb for topic ai translate event");
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
const document = this.analyticsEventsService.convertMapToAnalyticsDocument(map);
|
|
350
|
+
this.analyticsEventsService.sendTopicAiTranslateEvent({
|
|
351
|
+
name: "TOPIC__AI_TRANSLATE",
|
|
352
|
+
offline: false,
|
|
353
|
+
appName: apiIntegrationIdentifier,
|
|
354
|
+
appVersion: apiIntegrationAppVersion,
|
|
355
|
+
translationOrigin: FtAnalyticsTranslationOrigin.AI,
|
|
356
|
+
sourceLanguage: this.parseLanguageToAnalyticsFormat(map.lang),
|
|
357
|
+
destinationLanguage: this.parseLanguageToAnalyticsFormat(destinationLanguage),
|
|
358
|
+
breadcrumb: breadcrumb.map((item) => ({
|
|
359
|
+
tocId: item.tocId,
|
|
360
|
+
title: item.title,
|
|
361
|
+
mapId: map.id,
|
|
362
|
+
mapTitle: map.title,
|
|
363
|
+
})),
|
|
364
|
+
document,
|
|
365
|
+
profileId,
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
catch (error) {
|
|
369
|
+
console.warn("Failed to send topic ai translate event:", error);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
334
372
|
parseLanguageToAnalyticsFormat(languageString) {
|
|
335
373
|
if (!languageString) {
|
|
336
374
|
return undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-reader-context",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.21",
|
|
4
4
|
"description": "Context block for integrated reader components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lit"
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@fluid-topics/ft-app-context": "2.0.
|
|
23
|
-
"@fluid-topics/ft-wc-utils": "2.0.
|
|
22
|
+
"@fluid-topics/ft-app-context": "2.0.21",
|
|
23
|
+
"@fluid-topics/ft-wc-utils": "2.0.21",
|
|
24
24
|
"@reduxjs/toolkit": "^1.6.2",
|
|
25
25
|
"lit": "3.1.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@fluid-topics/public-api": "1.0.
|
|
28
|
+
"@fluid-topics/public-api": "1.0.121"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "3daf4c51496f7b8ef227e5e7e0ed0a03bfbbb9fc"
|
|
31
31
|
}
|