@point-api/js-sdk
Version:
Javascript SDK for Point API
66 lines • 2.55 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/** Class to keep track of api credentials and make requests to the custom suggestions api */
class InteractionsApiModule {
constructor(api) {
this.url = "/interactions";
this.api = api;
}
async pastedData(origin, data) {
await this.storeInteraction("pastedData", origin, { data });
}
async chosenSuggestion(responseId, origin, suggestion) {
await this.storeInteraction("chosenSuggestion", origin, { responseId, suggestion });
}
async draftDiscarded() {
await this.storeInteraction("draftDiscarded");
}
async emailSent(messageId) {
await this.storeInteraction("emailSent", undefined, { messageId });
}
async pointSearchOpened(trigger, origin) {
await this.storeInteraction("pointSearchOpened" + trigger, origin);
}
async pointSearchClosed(trigger, origin) {
await this.storeInteraction("pointSearchClosed" + trigger, origin);
}
async hotkeyCopied(trigger, origin) {
await this.storeInteraction("hotkeyCopied", origin, { trigger });
}
async hotkeyIconMoved(origin) {
await this.storeInteraction("hotkeyIconMoved", origin);
}
async tutorialOpened() {
await this.storeInteraction("tutorialOpened");
}
async tutorialStepViewed(step, stepText) {
await this.storeInteraction("tutorialStepViewed", undefined, { step, stepText });
}
async tutorialFinished() {
await this.storeInteraction("tutorialFinished");
}
async tutorialClosed(step) {
await this.storeInteraction("tutorialClosed", undefined, { step });
}
async pasteNotificationSave(origin, data) {
await this.storeInteraction("pasteNotificationSave", origin, { data });
}
async pasteNotificationDismiss(origin, data) {
await this.storeInteraction("pasteNotificationDismiss", origin, { data });
}
async showUseShortcutNotification(origin) {
await this.storeInteraction("showUseShortcutNotification", origin);
}
async storeInteraction(type, origin, data) {
await this.authFetch("POST", { type, origin, data });
}
/** Make authenticated request to interactions api */
async authFetch(method, data) {
const headers = {
"Content-Type": "application/json"
};
await this.api.authFetch(method, this.url, data, headers);
}
}
exports.default = InteractionsApiModule;
//# sourceMappingURL=interactions.js.map