Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ static/key-file.json
.npmrc
/.claude
/playwright-report
/test-results
/test-results
.agent
6 changes: 5 additions & 1 deletion src/common/services/translate.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import { Dictionary } from "../types/general.type";

import proxy from "./proxy.service";
import { functionProvider } from "@modular-rest/client";
import { functionProvider, authentication } from "@modular-rest/client";
import {
Chunk,
LanguageLearningData,
Expand Down Expand Up @@ -132,6 +132,8 @@ export class TranslateService {
targetLanguage: this.languageTitle,
phrase: text,
context: context || "",
// For the server-side translation_requested analytics event.
userId: authentication.user?.id,
},
});

Expand Down Expand Up @@ -169,6 +171,8 @@ export class TranslateService {
targetLanguage: this.languageTitle,
phrase: text,
context: context || "",
// For the server-side translation_requested analytics event.
userId: authentication.user?.id,
},
});

Expand Down
2 changes: 1 addition & 1 deletion src/console-crane/components/Definition.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export default defineComponent({
});
});

analytic.track("Definition translated");
analytic.track("definition_translated");
},
},
});
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function start() {
.then((_) => {
registerGlobalEvents();
})
.catch((_) => analytic.track("Error on initiating"));
.catch((_) => analytic.track("extension_init-failed"));
}

//
Expand Down
4 changes: 4 additions & 0 deletions src/popup/views/LoginView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ import {
StoreUserTokenMessage,
} from "../../common/types/messaging";
import { sendMessage, sendMessageToTabs } from "../../common/helper/massage";
import { analytic } from "../../plugins/mixpanel";
import { get } from "../helper/http";
import { joinToBaseUrl } from "../../common/helper/url";
import {
Expand Down Expand Up @@ -240,6 +241,9 @@ async function handleTokenLogin(token: string) {
await sendMessage(message);
sendMessageToTabs(message);
await loginWithLastSession();
// Fired only on an explicit login from this view β€” session restores on
// startup do not pass through here.
analytic.track("user_logged-in");
}

function launchWebAuthFlow(authURL) {
Expand Down
2 changes: 1 addition & 1 deletion src/subtitle/_support-template/components/Subtitle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export default defineComponent({
hoveredWord(value) {
if (value.length) {
this.translateWord(value);
analytic.track("Word hovered", { word: value });
analytic.track("phrase_hovered", { word: value });
}
},
},
Expand Down
7 changes: 7 additions & 0 deletions src/subtitle/components/specific/Word.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ function onMouseLeave(e: MouseEvent) {
}

function OpenWordDetail() {
analytic.track("phrase_clicked", {
word:
markerStore.words.length > 1
? markerStore.selectedPhrase
: props.modelValue,
platform: window.location.hostname,
});
if (markerStore.words.length > 1) {
emitOpen({
page: "word-detail",
Expand Down
1 change: 1 addition & 0 deletions tests/nibble-surface.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ vi.mock("../src/nibble/composables/useTextSelection", async () => {
// the child stub doesn't trigger a real fetch chain just by importing.
vi.mock("@modular-rest/client", () => ({
functionProvider: { run: vi.fn() },
authentication: { user: { id: "test-user-id" } },
}));

import NibbleSurface from "../src/nibble/components/NibbleSurface.vue";
Expand Down
1 change: 1 addition & 0 deletions tests/selection-popup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { createTestingPinia } from "@pinia/testing";
// network layer so a stray click in another test can't fire a real request.
vi.mock("@modular-rest/client", () => ({
functionProvider: { run: vi.fn() },
authentication: { user: { id: "test-user-id" } },
}));

import SelectionPopup from "../src/nibble/components/SelectionPopup.vue";
Expand Down
3 changes: 3 additions & 0 deletions tests/translate.service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ vi.mock("@modular-rest/client", () => ({
functionProvider: {
run: vi.fn(),
},
// translate.service reads authentication.user?.id to attach a userId for the
// server-side translation_requested event.
authentication: { user: { id: "test-user-id" } },
}));

import { TranslateService } from "../src/common/services/translate.service";
Expand Down
Loading