Skip to content
Draft
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
93 changes: 87 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1650,6 +1650,12 @@
"description": "Disable SSL certificate verification (for development only)",
"scope": "application"
},
"deepnote.telemetry.enabled": {
"type": "boolean",
"default": true,
"description": "Enable anonymous usage telemetry to help improve Deepnote for VS Code.",
"scope": "application"
},
"deepnote.snapshots.enabled": {
"type": "boolean",
"default": true,
Expand Down Expand Up @@ -2725,6 +2731,7 @@
"pidtree": "^0.6.0",
"plotly.js-dist": "^3.0.1",
"portfinder": "^1.0.25",
"posthog-node": "^4.18.0",
"re-resizable": "^6.5.5",
"react": "^16.5.2",
"react-data-grid": "^6.0.2-0",
Expand Down
1 change: 1 addition & 0 deletions src/extension.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export function deactivate(): Thenable<void> {
// Make sure to shutdown anybody who needs it.
if (activatedServiceContainer) {
const registry = activatedServiceContainer.get<IAsyncDisposableRegistry>(IAsyncDisposableRegistry);

if (registry) {
return registry.dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import { IPythonApiProvider } from '../../../platform/api/types';
import { STANDARD_OUTPUT_CHANNEL } from '../../../platform/common/constants';
import { getDisplayPath } from '../../../platform/common/platform/fs-paths.node';
import { ITelemetryService } from '../../../platform/analytics/types';
import { IDisposableRegistry, IOutputChannel } from '../../../platform/common/types';
import { createDeepnoteServerConfigHandle } from '../../../platform/deepnote/deepnoteServerUtils.node';
import { DeepnoteToolkitMissingError } from '../../../platform/errors/deepnoteKernelErrors';
Expand Down Expand Up @@ -52,7 +53,8 @@ export class DeepnoteEnvironmentsView implements Disposable {
@inject(IDeepnoteNotebookEnvironmentMapper)
private readonly notebookEnvironmentMapper: IDeepnoteNotebookEnvironmentMapper,
@inject(IKernelProvider) private readonly kernelProvider: IKernelProvider,
@inject(IOutputChannel) @named(STANDARD_OUTPUT_CHANNEL) private readonly outputChannel: IOutputChannel
@inject(IOutputChannel) @named(STANDARD_OUTPUT_CHANNEL) private readonly outputChannel: IOutputChannel,
@inject(ITelemetryService) private readonly analytics: ITelemetryService
) {
// Create tree data provider

Expand Down Expand Up @@ -193,6 +195,14 @@ export class DeepnoteEnvironmentsView implements Disposable {
const config = await this.environmentManager.createEnvironment(options, token);
logger.info(`Created environment: ${config.id} (${config.name})`);

this.analytics.trackEvent({
eventName: 'create_environment',
properties: {
hasDescription: !!options.description,
hasPackages: !!options.packages?.length
}
});

void window.showInformationMessage(
l10n.t('Environment "{0}" created successfully!', config.name)
);
Expand Down Expand Up @@ -314,6 +324,7 @@ export class DeepnoteEnvironmentsView implements Disposable {
}
);

this.analytics.trackEvent({ eventName: 'delete_environment' });
void window.showInformationMessage(l10n.t('Environment "{0}" deleted', config.name));
} catch (error) {
logger.error('Failed to delete environment', error);
Expand Down Expand Up @@ -483,6 +494,7 @@ export class DeepnoteEnvironmentsView implements Disposable {
}
);

this.analytics.trackEvent({ eventName: 'select_environment' });
void window.showInformationMessage(l10n.t('Environment switched successfully'));
} catch (error) {
if (error instanceof DeepnoteToolkitMissingError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { CancellationToken, Disposable, NotebookDocument, ProgressOptions, Uri }
import { DeepnoteEnvironmentsView } from './deepnoteEnvironmentsView.node';
import { IDeepnoteEnvironmentManager, IDeepnoteKernelAutoSelector, IDeepnoteNotebookEnvironmentMapper } from '../types';
import { IPythonApiProvider } from '../../../platform/api/types';
import { ITelemetryService } from '../../../platform/analytics/types';
import { IDisposableRegistry, IOutputChannel } from '../../../platform/common/types';
import { IKernelProvider } from '../../../kernels/types';
import { DeepnoteEnvironment } from './deepnoteEnvironment';
Expand All @@ -25,6 +26,7 @@ suite('DeepnoteEnvironmentsView', () => {
let mockNotebookEnvironmentMapper: IDeepnoteNotebookEnvironmentMapper;
let mockKernelProvider: IKernelProvider;
let mockOutputChannel: IOutputChannel;
let mockTelemetryService: ITelemetryService;
let disposables: Disposable[] = [];
let pythonEnvironments: PythonExtension['environments'];

Expand All @@ -43,6 +45,7 @@ suite('DeepnoteEnvironmentsView', () => {
mockNotebookEnvironmentMapper = mock<IDeepnoteNotebookEnvironmentMapper>();
mockKernelProvider = mock<IKernelProvider>();
mockOutputChannel = mock<IOutputChannel>();
mockTelemetryService = mock<ITelemetryService>();

// Mock onDidChangeEnvironments to return a disposable event
when(mockConfigManager.onDidChangeEnvironments).thenReturn((_listener: () => void) => {
Expand All @@ -61,7 +64,8 @@ suite('DeepnoteEnvironmentsView', () => {
instance(mockKernelAutoSelector),
instance(mockNotebookEnvironmentMapper),
instance(mockKernelProvider),
instance(mockOutputChannel)
instance(mockOutputChannel),
instance(mockTelemetryService)
);
});

Expand Down
9 changes: 8 additions & 1 deletion src/notebooks/deepnote/deepnoteActivationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { inject, injectable, optional } from 'inversify';
import { commands, l10n, workspace, window, type Disposable, type NotebookDocumentContentOptions } from 'vscode';

import { IExtensionSyncActivationService } from '../../platform/activation/types';
import { ITelemetryService } from '../../platform/analytics/types';
import { IExtensionContext } from '../../platform/common/types';
import { ILogger } from '../../platform/logging/types';
import { IDeepnoteNotebookManager } from '../types';
Expand Down Expand Up @@ -34,6 +35,7 @@ export class DeepnoteActivationService implements IExtensionSyncActivationServic
@inject(IDeepnoteNotebookManager) private readonly notebookManager: IDeepnoteNotebookManager,
@inject(IIntegrationManager) integrationManager: IIntegrationManager,
@inject(ILogger) private readonly logger: ILogger,
@inject(ITelemetryService) private readonly analytics: ITelemetryService,
@inject(SnapshotService) @optional() private readonly snapshotService?: SnapshotService
) {
this.integrationManager = integrationManager;
Expand All @@ -45,7 +47,12 @@ export class DeepnoteActivationService implements IExtensionSyncActivationServic
*/
public activate() {
this.serializer = new DeepnoteNotebookSerializer(this.notebookManager, this.snapshotService);
this.explorerView = new DeepnoteExplorerView(this.extensionContext, this.notebookManager, this.logger);
this.explorerView = new DeepnoteExplorerView(
this.extensionContext,
this.notebookManager,
this.logger,
this.analytics
);
this.editProtection = new DeepnoteInputBlockEditProtection(this.logger);
this.snapshotsEnabled = this.isSnapshotsEnabled();

Expand Down
30 changes: 24 additions & 6 deletions src/notebooks/deepnote/deepnoteActivationService.unit.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { assert } from 'chai';
import { anything, verify, when } from 'ts-mockito';
import { anything, instance, mock, verify, when } from 'ts-mockito';

import { ITelemetryService } from '../../platform/analytics/types';
import { DeepnoteActivationService } from './deepnoteActivationService';
import { DeepnoteNotebookManager } from './deepnoteNotebookManager';
import { IExtensionContext } from '../../platform/common/types';
Expand All @@ -25,6 +26,7 @@ suite('DeepnoteActivationService', () => {
let manager: DeepnoteNotebookManager;
let mockIntegrationManager: IIntegrationManager;
let mockLogger: ILogger;
let mockAnalytics: ITelemetryService;

setup(() => {
mockExtensionContext = {
Expand All @@ -38,11 +40,13 @@ suite('DeepnoteActivationService', () => {
}
};
mockLogger = createMockLogger();
mockAnalytics = instance(mock<ITelemetryService>());
activationService = new DeepnoteActivationService(
mockExtensionContext,
manager,
mockIntegrationManager,
mockLogger
mockLogger,
mockAnalytics
);
});

Expand Down Expand Up @@ -103,6 +107,7 @@ suite('DeepnoteActivationService', () => {
manager,
mockIntegrationManager,
mockLogger,
mockAnalytics,
mockSnapshotService
);

Expand Down Expand Up @@ -150,6 +155,7 @@ suite('DeepnoteActivationService', () => {
manager,
mockIntegrationManager,
mockLogger,
mockAnalytics,
mockSnapshotService
);

Expand Down Expand Up @@ -206,8 +212,20 @@ suite('DeepnoteActivationService', () => {
};
const mockLogger1 = createMockLogger();
const mockLogger2 = createMockLogger();
const service1 = new DeepnoteActivationService(context1, manager1, mockIntegrationManager1, mockLogger1);
const service2 = new DeepnoteActivationService(context2, manager2, mockIntegrationManager2, mockLogger2);
const service1 = new DeepnoteActivationService(
context1,
manager1,
mockIntegrationManager1,
mockLogger1,
mockAnalytics
);
const service2 = new DeepnoteActivationService(
context2,
manager2,
mockIntegrationManager2,
mockLogger2,
mockAnalytics
);

// Verify each service has its own context
assert.strictEqual((service1 as any).extensionContext, context1);
Expand Down Expand Up @@ -244,8 +262,8 @@ suite('DeepnoteActivationService', () => {
};
const mockLogger3 = createMockLogger();
const mockLogger4 = createMockLogger();
new DeepnoteActivationService(context1, manager1, mockIntegrationManager1, mockLogger3);
new DeepnoteActivationService(context2, manager2, mockIntegrationManager2, mockLogger4);
new DeepnoteActivationService(context1, manager1, mockIntegrationManager1, mockLogger3, mockAnalytics);
new DeepnoteActivationService(context2, manager2, mockIntegrationManager2, mockLogger4, mockAnalytics);

assert.strictEqual(context1.subscriptions.length, 0);
assert.strictEqual(context2.subscriptions.length, 1);
Expand Down
Loading
Loading