@seeka-labs/cli-apps 1.1.12 → 1.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,12 +11,12 @@
11
11
  },
12
12
  "scripts": {
13
13
  "lint": "eslint",
14
- "build": "tsc",
14
+ "build": "<packageManagerRunPrefix> clean && tsc",
15
15
  "watch": "tsc -w",
16
16
  "test": "yarn jest",
17
17
  "clean": "<packageManagerRunPrefix> rimraf dist",
18
18
  "prestart": "<packageManagerRunPrefix> clean && <packageManagerRunPrefix> build",
19
- "dev": "func start --port 7072",
19
+ "dev": "<packageManagerRunPrefix> build && func start --port 7072",
20
20
  "tunnel": "node scripts/ngrok.js seeka-app-example-name-localdev",
21
21
  "deploy": "<packageManagerRunPrefix> clean && <packageManagerRunPrefix> build && func azure functionapp publish seeka-app-example-name --no-build --javascript",
22
22
  "dev:queue:create": "node scripts/dev-queue-setup.js sample-queue-name"
@@ -185,11 +185,17 @@ const onInstallation = async (payload: SeekaAppInstalledWebhookPayload, logger:
185
185
  installationSettings: payload.content?.installationSettings || {}
186
186
  }, logger)
187
187
 
188
- await triggerBackgroundJob(queueNames.queueItemExampleQueueName, {
189
- ...payload.context,
190
- causationId: payload.causationId,
191
- correlationId: payload.requestId
192
- }, logger)
188
+ try {
189
+ await triggerBackgroundJob(queueNames.queueItemExampleQueueName, {
190
+ ...payload.context,
191
+ causationId: payload.causationId,
192
+ correlationId: payload.requestId
193
+ }, logger)
194
+ }
195
+ catch (err) {
196
+ await deleteInstallation(installation.applicationInstallId, logger)
197
+ return 'Failed to complete install';
198
+ }
193
199
 
194
200
  return null;
195
201
  }
@@ -17,7 +17,7 @@
17
17
  "watch": "yarn clean && node ./scripts/esbuild/build-browser-plugin.mjs seeka-app-example-name SampleAppConvergeSdkPlugin dev watch"
18
18
  },
19
19
  "dependencies": {
20
- "@seeka-labs/converge": "^1.7.2"
20
+ "@seeka-labs/converge": "^1.7.23"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/jest": "^29.5.4",
@@ -5,7 +5,7 @@ import {
5
5
  TrackingActivityNames, getActivityName
6
6
  } from '@seeka-labs/converge';
7
7
 
8
- import type { EnrichSeekaProfileFromSampleAppRequest, ISampleAppBrowserSdkPluginConfig } from '../../../lib/browser/models'
8
+ import type { ISampleAppBrowserSdkPluginConfig } from '../../../lib/browser/models'
9
9
 
10
10
  import { version, dependencies } from '../../package.json';
11
11
 
@@ -41,117 +41,9 @@ export class SampleAppConvergeSdkPlugin implements IConvergePlugin<ISampleAppBro
41
41
  config: ISampleAppBrowserSdkPluginConfig;
42
42
 
43
43
  async init(_params: any): Promise<void> {
44
- window.addEventListener('message', async (event) => {
45
- if (event.origin === 'https://calendly.com') {
46
- await this.handleSampleAppEvent(event);
47
- }
48
- })
49
-
50
44
  checkSdkAndPluginVersion(dependencies['@seeka-labs/converge'], this.sdk, this.name)
51
45
  }
52
46
 
53
- private async handleSampleAppEvent(event: any) {
54
- const eventType = event.data.event;
55
- if (!eventType || eventType.indexOf('calendly.') !== 0) return;
56
-
57
- this.sdk.debug.verbose("SampleApp event received", { eventType, event })
58
- switch (eventType) {
59
- case 'calendly.date_and_time_selected':
60
- break;
61
- case 'calendly.event_type_viewed':
62
- break;
63
- case 'calendly.event_scheduled':
64
- {
65
- let activityName: TrackingActivityNames;
66
- let activityNameCustom: string = '';
67
-
68
- if (this.config?.eventBookedEventName) {
69
- activityName = getActivityName(this.config.eventBookedEventName);
70
- if (activityName === TrackingActivityNames.Custom) {
71
- activityNameCustom = this.config.eventBookedEventName;
72
- }
73
- }
74
- else {
75
- activityName = TrackingActivityNames.Custom;
76
- activityNameCustom = 'SampleAppInviteCreated';
77
- }
78
-
79
- const activityId = this.getEventId(event.data.payload)
80
- const eventId = event.data.payload.event.uri.split('/').splice(-1)[0];
81
-
82
- switch (activityName) {
83
- case TrackingActivityNames.Custom: {
84
- await this.sdk.track.custom(activityNameCustom, {
85
- activityIdentifier: activityId,
86
- contentId: eventId
87
- });
88
- break;
89
- }
90
- default: {
91
- await this.sdk.track.activity(activityName, {
92
- activityIdentifier: activityId,
93
- contentId: eventId
94
- });
95
- break;
96
- }
97
- }
98
-
99
- await this.sendAttendeeToApp(event.data.payload);
100
-
101
- break;
102
- }
103
- }
104
- }
105
-
106
- private async sendAttendeeToApp(payload: any): Promise<void> {
107
- try {
108
- const eventId = payload.event.uri
109
- const inviteeId = payload.invitee.uri;
110
-
111
- const beaconUrl = `${this.config.appUrl}/api/profile/enrich`;
112
-
113
- // if (navigator.sendBeacon && !navigator.sendBeacon(beaconUrl, JSON.stringify(beaconPayload))) {
114
- // this.sdk.debug.warn('Failed to send attendee to SampleApp app')
115
- // }
116
- // else {
117
- const res = await fetch(beaconUrl, {
118
- method: 'POST',
119
- keepalive: true,
120
- mode: 'cors',
121
- credentials: 'omit',
122
- headers: {
123
- 'Content-Type': 'application/json',
124
- },
125
- body: JSON.stringify({
126
- appId: this.config.appId,
127
- appInstallId: this.config.appInstallId,
128
- event: eventId,
129
- invitee: inviteeId,
130
- seekaPersonId: this.sdk.identity.personId,
131
- } as EnrichSeekaProfileFromSampleAppRequest)
132
- })
133
- if (!res.ok) {
134
- this.sdk.debug.error('Failed to send attendee to SampleApp app')
135
- }
136
- // }
137
- }
138
- catch (err) {
139
- this.sdk.debug.error('Failed to send attendee to SampleApp app', err)
140
- }
141
- }
142
-
143
- // Should match Seeka developer app for dedupe
144
- private getEventId(payload: any) {
145
- const eventId = payload.event.uri.split('/').splice(-1)[0];
146
- const inviteeId = this.getInviteeId(payload);
147
-
148
- return `calendly_${eventId}_invite_${inviteeId}_created`
149
- }
150
-
151
- private getInviteeId(payload: any) {
152
- return payload.invitee.uri.split('/').splice(-1)[0];
153
- }
154
-
155
47
  isLoaded(): boolean {
156
48
  return true;
157
49
  }
@@ -149,9 +149,15 @@ const onInstallation = async (payload: SeekaAppInstalledWebhookPayload, logger:
149
149
  }, logger)
150
150
 
151
151
  // Trigger a sync for the installation
152
- await triggerBackgroundJob(jobNames.exampleBackgroundJob, {
153
- ...payload.context
154
- }, logger)
152
+ try {
153
+ await triggerBackgroundJob(jobNames.exampleBackgroundJob, {
154
+ ...payload.context
155
+ }, logger)
156
+ }
157
+ catch (err) {
158
+ await deleteInstallation(installation.applicationInstallId, logger)
159
+ return 'Failed to complete install';
160
+ }
155
161
 
156
162
  return null;
157
163
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seeka-labs/cli-apps",
3
- "version": "1.1.12",
3
+ "version": "1.1.13",
4
4
  "description": "Seeka - Apps CLI",
5
5
  "author": "SEEKA <platform@seeka.co>",
6
6
  "license": "MIT",