Skip to content

Clipper Telemetry Fix #567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 17, 2024
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
51 changes: 45 additions & 6 deletions package-lock.json

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

27 changes: 14 additions & 13 deletions src/scripts/extensions/bookmarklet/inlineWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ export class InlineWorker extends ExtensionWorkerBase<any, any> {
let injectMessageHandlerThunk = () => { return new IFrameMessageHandler(() => parent); };
super(clientInfo, auth, new ClipperData(new LocalStorage()), uiMessageHandlerThunk, injectMessageHandlerThunk);

this.logger.setContextProperty(Log.Context.Custom.InPrivateBrowsing, Log.unknownValue);
this.logger.then(sessionLogger => sessionLogger.setContextProperty(Log.Context.Custom.InPrivateBrowsing, Log.unknownValue));

let invokeOptions = {
invokeMode: InvokeMode.Default
};
this.sendInvokeOptionsToInject(invokeOptions);

// The inline worker gets created after the UI was successfully inject, so we can safely log this here
this.logger.logUserFunnel(Log.Funnel.Label.Invoke);
this.logger.then(sessionLogger => sessionLogger.logUserFunnel(Log.Funnel.Label.Invoke));
this.logClipperInvoke({
invokeSource: InvokeSource.Bookmarklet
}, invokeOptions);
Expand Down Expand Up @@ -82,8 +82,8 @@ export class InlineWorker extends ExtensionWorkerBase<any, any> {
* authentication. Otherwise, it resolves with true if the redirect endpoint was hit as a result of a successful
* sign in attempt, and false if it was not hit (e.g., user manually closed the popup)
*/
protected doSignInAction(authType: AuthType): Promise<boolean> {
let usidQueryParamValue = this.getUserSessionIdQueryParamValue();
protected async doSignInAction(authType: AuthType): Promise<boolean> {
let usidQueryParamValue = await this.getUserSessionIdQueryParamValue();
let signInUrl = ClipperUrls.generateSignInUrl(this.clientInfo.get().clipperId, usidQueryParamValue, AuthType[authType]);

return this.launchPopupAndWaitForClose(signInUrl);
Expand All @@ -93,18 +93,19 @@ export class InlineWorker extends ExtensionWorkerBase<any, any> {
* Signs the user out
*/
protected doSignOutAction(authType: AuthType) {
let usidQueryParamValue = this.getUserSessionIdQueryParamValue();
let signOutUrl = ClipperUrls.generateSignOutUrl(this.clientInfo.get().clipperId, usidQueryParamValue, AuthType[authType]);

let iframe = document.createElement("iframe");
iframe.hidden = true;
iframe.style.display = "none";
iframe.src = signOutUrl;
document.body.appendChild(iframe);
this.getUserSessionIdQueryParamValue().then(usidQueryParamValue => {
let signOutUrl = ClipperUrls.generateSignOutUrl(this.clientInfo.get().clipperId, usidQueryParamValue, AuthType[authType]);

let iframe = document.createElement("iframe");
iframe.hidden = true;
iframe.style.display = "none";
iframe.src = signOutUrl;
document.body.appendChild(iframe);
});
}

private throwNotImplementedFailure(): any {
this.logger.logFailure(Log.Failure.Label.NotImplemented, Log.Failure.Type.Unexpected);
this.logger.then(sessionLogger => sessionLogger.logFailure(Log.Failure.Label.NotImplemented, Log.Failure.Type.Unexpected));
throw new Error("not implemented");
}
}
6 changes: 3 additions & 3 deletions src/scripts/extensions/extensionBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export abstract class ExtensionBase<TWorker extends ExtensionWorkerBase<TTab, TT
ExtensionBase.extensionId = StringUtils.generateGuid();

this.clipperData = clipperData;
this.clipperData.setLogger(this.logger);
this.clipperData.setLogger(Promise.resolve(this.logger));
this.auth = new AuthenticationHelper(this.clipperData, this.logger);
this.tooltip = new TooltipHelper(this.clipperData);

Expand Down Expand Up @@ -281,7 +281,7 @@ export abstract class ExtensionBase<TWorker extends ExtensionWorkerBase<TTab, TT
Promise.all([lastSeenTooltipTimeBase, numTimesTooltipHasBeenSeenBase]).then((values) => {
tooltipImpressionEvent.setCustomProperty(Log.PropertyName.Custom.LastSeenTooltipTime, values[0]);
tooltipImpressionEvent.setCustomProperty(Log.PropertyName.Custom.NumTimesTooltipHasBeenSeen, values[1]);
worker.getLogger().logEvent(tooltipImpressionEvent);
worker.getLogger().then(sessionLogger => sessionLogger.logEvent(tooltipImpressionEvent));
});
});
}
Expand All @@ -300,7 +300,7 @@ export abstract class ExtensionBase<TWorker extends ExtensionWorkerBase<TTab, TT
if (wasInvoked) {
let whatsNewImpressionEvent = new Log.Event.BaseEvent(Log.Event.Label.WhatsNewImpression);
whatsNewImpressionEvent.setCustomProperty(Log.PropertyName.Custom.FeatureEnabled, wasInvoked);
worker.getLogger().logEvent(whatsNewImpressionEvent);
worker.getLogger().then(sessionLogger => sessionLogger.logEvent(whatsNewImpressionEvent));

// We don't want to do this if the tooltip was not invoked (e.g., on about:blank) so we can show it at the next opportunity
this.updateLastSeenVersionInStorageToCurrent();
Expand Down
Loading