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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zenstack-monorepo",
"version": "2.19.0",
"version": "2.19.1",
"description": "",
"scripts": {
"build": "pnpm -r --filter=\"!./packages/ide/*\" build",
Expand Down
2 changes: 1 addition & 1 deletion packages/ide/jetbrains/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
}

group = "dev.zenstack"
version = "2.19.0"
version = "2.19.1"

repositories {
mavenCentral()
Expand Down
2 changes: 1 addition & 1 deletion packages/ide/jetbrains/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jetbrains",
"version": "2.19.0",
"version": "2.19.1",
"displayName": "ZenStack JetBrains IDE Plugin",
"description": "ZenStack JetBrains IDE plugin",
"homepage": "https://zenstack.dev",
Expand Down
2 changes: 1 addition & 1 deletion packages/language/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenstackhq/language",
"version": "2.19.0",
"version": "2.19.1",
"displayName": "ZenStack modeling language compiler",
"description": "ZenStack modeling language compiler",
"homepage": "https://zenstack.dev",
Expand Down
2 changes: 1 addition & 1 deletion packages/misc/redwood/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/redwood",
"displayName": "ZenStack RedwoodJS Integration",
"version": "2.19.0",
"version": "2.19.1",
"description": "CLI and runtime for integrating ZenStack with RedwoodJS projects.",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/openapi/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/openapi",
"displayName": "ZenStack Plugin and Runtime for OpenAPI",
"version": "2.19.0",
"version": "2.19.1",
"description": "ZenStack plugin and runtime supporting OpenAPI",
"main": "index.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/swr/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/swr",
"displayName": "ZenStack plugin for generating SWR hooks",
"version": "2.19.0",
"version": "2.19.1",
"description": "ZenStack plugin for generating SWR hooks",
"main": "index.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/tanstack-query/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/tanstack-query",
"displayName": "ZenStack plugin for generating tanstack-query hooks",
"version": "2.19.0",
"version": "2.19.1",
"description": "ZenStack plugin for generating tanstack-query hooks",
"main": "index.js",
"exports": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/trpc/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/trpc",
"displayName": "ZenStack plugin for tRPC",
"version": "2.19.0",
"version": "2.19.1",
"description": "ZenStack plugin for tRPC",
"main": "index.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@zenstackhq/runtime",
"displayName": "ZenStack Runtime Library",
"version": "2.19.0",
"version": "2.19.1",
"description": "Runtime of ZenStack for both client-side and server-side environments.",
"repository": {
"type": "git",
Expand Down
19 changes: 19 additions & 0 deletions packages/schema/build/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@ const watch = process.argv.includes('--watch');
const minify = process.argv.includes('--minify');
const success = watch ? 'Watch build succeeded' : 'Build succeeded';
const fs = require('fs');
const path = require('path');

// Replace telemetry token in generated bundle files after building
function replaceTelemetryTokenInBundle() {
const telemetryToken = process.env.VSCODE_TELEMETRY_TRACKING_TOKEN;
if (!telemetryToken) {
console.error('Error: VSCODE_TELEMETRY_TRACKING_TOKEN environment variable is not set');
process.exit(1);
}
const file = 'bundle/extension.js';
let content = fs.readFileSync(file, 'utf-8');
content = content.replace('<VSCODE_TELEMETRY_TRACKING_TOKEN>', telemetryToken);
fs.writeFileSync(file, content, 'utf-8');
}

require('esbuild')
.build({
Expand All @@ -13,8 +27,13 @@ require('esbuild')
sourcemap: !minify,
minify,
})
.then(() => {
// Replace the token after building outputs
replaceTelemetryTokenInBundle();
})
.then(() => {
fs.cpSync('./src/res', 'bundle/res', { force: true, recursive: true });
fs.cpSync('./src/vscode/res', 'bundle/res', { force: true, recursive: true });
fs.cpSync('../language/syntaxes', 'bundle/syntaxes', { force: true, recursive: true });
})
.then(() => console.log(success))
Expand Down
18 changes: 17 additions & 1 deletion packages/schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"publisher": "zenstack",
"displayName": "ZenStack Language Tools",
"description": "FullStack enhancement for Prisma ORM: seamless integration from database to UI",
"version": "2.19.0",
"version": "2.19.1",
"author": {
"name": "ZenStack Team"
},
Expand Down Expand Up @@ -78,6 +78,11 @@
"command": "zenstack.preview-zmodel",
"when": "editorLangId == zmodel",
"group": "navigation"
},
{
"command": "zenstack.save-zmodel-documentation",
"when": "(activeWebviewPanelId == 'markdown.preview' || activeCustomEditorId == 'vscode.markdown.preview.editor') && zenstack.isMarkdownPreview == true",
"group": "navigation"
}
],
"commandPalette": [
Expand All @@ -99,6 +104,11 @@
"title": "ZenStack: Preview ZModel Documentation",
"icon": "$(preview)"
},
{
"command": "zenstack.save-zmodel-documentation",
"title": "ZenStack: Save ZModel Documentation",
"icon": "$(save)"
},
{
"command": "zenstack.clear-documentation-cache",
"title": "ZenStack: Clear Documentation Cache",
Expand All @@ -116,6 +126,12 @@
"key": "ctrl+shift+v",
"mac": "cmd+shift+v",
"when": "editorLangId == zmodel"
},
{
"command": "zenstack.save-zmodel-documentation",
"key": "ctrl+shift+s",
"mac": "cmd+shift+s",
"when": "(activeWebviewPanelId == 'markdown.preview' || activeCustomEditorId == 'vscode.markdown.preview.editor') && zenstack.isMarkdownPreview == true"
}
]
},
Expand Down
14 changes: 10 additions & 4 deletions packages/schema/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import * as vscode from 'vscode';
import * as path from 'path';

import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind } from 'vscode-languageclient/node';
import { AUTH_PROVIDER_ID, ZenStackAuthenticationProvider } from './zenstack-auth-provider';
import { DocumentationCache } from './documentation-cache';
import { ZModelPreview } from './zmodel-preview';
import { ReleaseNotesManager } from './release-notes-manager';
import { AUTH_PROVIDER_ID, ZenStackAuthenticationProvider } from './vscode/zenstack-auth-provider';
import { DocumentationCache } from './vscode/documentation-cache';
import { ZModelPreview } from './vscode/zmodel-preview';
import { ReleaseNotesManager } from './vscode/release-notes-manager';
import telemetry from './vscode/vscode-telemetry';

// Global variables
let client: LanguageClient;
Expand All @@ -19,13 +20,17 @@ export async function requireAuth(): Promise<vscode.AuthenticationSession | unde
if (!session) {
const signIn = 'Sign in';
const selection = await vscode.window.showWarningMessage('Please sign in to use this feature', signIn);
telemetry.track('extension:signin:show');
if (selection === signIn) {
telemetry.track('extension:signin:start');
try {
session = await vscode.authentication.getSession(AUTH_PROVIDER_ID, [], { createIfNone: true });
if (session) {
telemetry.track('extension:signin:complete');
vscode.window.showInformationMessage('ZenStack sign-in successful!');
}
} catch (e: unknown) {
telemetry.track('extension:signin:error', { error: e instanceof Error ? e.message : String(e) });
vscode.window.showErrorMessage(
'ZenStack sign-in failed: ' + (e instanceof Error ? e.message : String(e))
);
Expand All @@ -37,6 +42,7 @@ export async function requireAuth(): Promise<vscode.AuthenticationSession | unde

// This function is called when the extension is activated.
export function activate(context: vscode.ExtensionContext): void {
telemetry.track('extension:activate');
// Initialize and register the ZenStack authentication provider
context.subscriptions.push(new ZenStackAuthenticationProvider(context));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,16 @@ <h3>🚀 How to Use</h3>
<ol>
<li>Open your <code>.zmodel</code> file</li>
<li>
Click (<span class="codicon codicon-preview"></span>) in the editor toolbar, or simply press
Click (<span class="codicon codicon-preview"></span>) in the editor toolbar, or press
<code>Cmd&nbsp;+&nbsp;Shift&nbsp;+&nbsp;V</code> (Mac) or
<code>Ctrl&nbsp;+&nbsp;Shift&nbsp;+&nbsp;V</code> (Windows)
</li>
<li>Sign in with ZenStack (one-time setup)</li>
<li>Enjoy your AI-generated documentation</li>
<li>
Click (<span class="codicon codicon-save"></span>) in the preview toolbar to save the doc, or press
<code>Cmd&nbsp;+&nbsp;Shift&nbsp;+&nbsp;S</code> (Mac) or
<code>Ctrl&nbsp;+&nbsp;Shift&nbsp;+&nbsp;S</code> (Windows)
</li>
</ol>
</div>

Expand Down
75 changes: 75 additions & 0 deletions packages/schema/src/vscode/vscode-telemetry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { init, Mixpanel } from 'mixpanel';
import * as os from 'os';
import * as vscode from 'vscode';
import { getMachineId } from '../utils/machine-id-utils';
import { v5 as uuidv5 } from 'uuid';

export const VSCODE_TELEMETRY_TRACKING_TOKEN = '<VSCODE_TELEMETRY_TRACKING_TOKEN>';

export type TelemetryEvents =
| 'extension:activate'
| 'extension:zmodel-preview'
| 'extension:zmodel-save'
| 'extension:signin:show'
| 'extension:signin:start'
| 'extension:signin:error'
| 'extension:signin:complete';

export class VSCodeTelemetry {
private readonly mixpanel: Mixpanel | undefined;
private readonly deviceId = this.getDeviceId();
private readonly _os_type = os.type();
private readonly _os_release = os.release();
private readonly _os_arch = os.arch();
private readonly _os_version = os.version();
private readonly _os_platform = os.platform();
private readonly vscodeAppName = vscode.env.appName;
private readonly vscodeVersion = vscode.version;
private readonly vscodeAppHost = vscode.env.appHost;

constructor() {
if (vscode.env.isTelemetryEnabled) {
this.mixpanel = init(VSCODE_TELEMETRY_TRACKING_TOKEN, {
geolocate: true,
});
}
}

private getDeviceId() {
const hostId = getMachineId();
// namespace UUID for generating UUIDv5 from DNS 'zenstack.dev'
return uuidv5(hostId, '133cac15-3efb-50fa-b5fc-4b90e441e563');
}

track(event: TelemetryEvents, properties: Record<string, unknown> = {}) {
if (this.mixpanel) {
const payload = {
distinct_id: this.deviceId,
time: new Date(),
$os: this._os_type,
osType: this._os_type,
osRelease: this._os_release,
osPlatform: this._os_platform,
osArch: this._os_arch,
osVersion: this._os_version,
nodeVersion: process.version,
vscodeAppName: this.vscodeAppName,
vscodeVersion: this.vscodeVersion,
vscodeAppHost: this.vscodeAppHost,
...properties,
};
this.mixpanel.track(event, payload);
}
}

identify(userId: string) {
if (this.mixpanel) {
this.mixpanel.track('$identify', {
$identified_id: userId,
$anon_id: this.deviceId,
token: TELEMETRY_TRACKING_TOKEN,
});
}
}
}
export default new VSCodeTelemetry();
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as vscode from 'vscode';

import telemetry from './vscode-telemetry';
interface JWTClaims {
jti?: string;
sub?: string;
Expand Down Expand Up @@ -150,9 +150,6 @@ export class ZenStackAuthenticationProvider implements vscode.AuthenticationProv
}
);
}
private generateState(): string {
return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
}

// Handle authentication callback from ZenStack
public async handleAuthCallback(callbackUri: vscode.Uri): Promise<void> {
Expand Down Expand Up @@ -184,6 +181,7 @@ export class ZenStackAuthenticationProvider implements vscode.AuthenticationProv
try {
// Decode JWT to get claims
const claims = this.parseJWTClaims(accessToken);
telemetry.identify(claims.email!);
return {
id: claims.jti || Math.random().toString(36),
accessToken: accessToken,
Expand Down
Loading
Loading