@seeka-labs/cli-apps 1.1.11 → 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.
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/init-templates/aws-lambda/src/lib/services/index.ts +1 -1
- package/dist/init-templates/azure-function/package.json +2 -2
- package/dist/init-templates/azure-function/src/functions/pollingExample.ts +1 -1
- package/dist/init-templates/azure-function/src/functions/seekaAppWebhook.ts +11 -5
- package/dist/init-templates/azure-function/src/lib/jobs/index.ts +1 -1
- package/dist/init-templates/browser/package.json +1 -1
- package/dist/init-templates/browser/src/plugin/index.ts +1 -109
- package/dist/init-templates/netlify-function/src/api/example-job-background/index.ts +2 -2
- package/dist/init-templates/netlify-function/src/api/polling-example-job-scheduled/index.ts +1 -1
- package/dist/init-templates/netlify-function/src/api/seeka-app-webhook/index.ts +9 -3
- package/package.json +1 -1
|
@@ -31,7 +31,7 @@ export const stopServices = async (logger: Logger) => {
|
|
|
31
31
|
logger.profile('service.redis.disconnect')
|
|
32
32
|
await disconnect();
|
|
33
33
|
logger.profile('service.redis.disconnect')
|
|
34
|
-
logger.
|
|
34
|
+
logger.debug(`Redis disconnected - ${process.env.REDIS_CONNECTION_HOST}`)
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
catch (err) {
|
|
@@ -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"
|
|
@@ -18,7 +18,7 @@ export async function pollingExample(myTimer: Timer, context: InvocationContext)
|
|
|
18
18
|
const logger = backgroundJobLogger(jobNames.pollingExample, undefined, context);
|
|
19
19
|
|
|
20
20
|
logger.profile(`job.${jobNames.pollingExample}`)
|
|
21
|
-
logger.
|
|
21
|
+
logger.debug('Received request to trigger scheduled job');
|
|
22
22
|
|
|
23
23
|
await startServices(logger);
|
|
24
24
|
|
|
@@ -185,11 +185,17 @@ const onInstallation = async (payload: SeekaAppInstalledWebhookPayload, logger:
|
|
|
185
185
|
installationSettings: payload.content?.installationSettings || {}
|
|
186
186
|
}, logger)
|
|
187
187
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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
|
}
|
|
@@ -49,6 +49,6 @@ export const triggerBackgroundJobWithQueue = async (queueClient: QueueClient, co
|
|
|
49
49
|
throw new Error(`Failed to trigger background job: ${response.errorCode}`);
|
|
50
50
|
}
|
|
51
51
|
else {
|
|
52
|
-
logger.
|
|
52
|
+
logger.debug("Background job triggered", { body, messageId: response.messageId, context })
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -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.
|
|
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 {
|
|
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
|
}
|
|
@@ -21,7 +21,7 @@ export default async (req: Request, context: Context) => {
|
|
|
21
21
|
await startServices(logger);
|
|
22
22
|
|
|
23
23
|
if (process.env.SEEKA_DEBUG_ENABLED === 'true') {
|
|
24
|
-
logger.
|
|
24
|
+
logger.debug('Received request to trigger background job', { body, headers: req.headers });
|
|
25
25
|
}
|
|
26
26
|
else {
|
|
27
27
|
logger.verbose('Received request to trigger background job', { body });
|
|
@@ -48,5 +48,5 @@ export default async (req: Request, context: Context) => {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
const doWork = async (context: BackgroundJobRequestContext, logger: Logger) => {
|
|
51
|
-
logger.
|
|
51
|
+
logger.debug('Ran background job')
|
|
52
52
|
}
|
|
@@ -17,7 +17,7 @@ export default async (req: Request, context: Context) => {
|
|
|
17
17
|
|
|
18
18
|
logger.profile(`job.${jobNames.examplePollingScheduledJob}`)
|
|
19
19
|
if (process.env.SEEKA_DEBUG_ENABLED === 'true') {
|
|
20
|
-
logger.
|
|
20
|
+
logger.debug('Received request to trigger scheduled job', { headers: req.headers, next_run });
|
|
21
21
|
}
|
|
22
22
|
else {
|
|
23
23
|
logger.verbose('Received request to trigger scheduled job', { next_run });
|
|
@@ -149,9 +149,15 @@ const onInstallation = async (payload: SeekaAppInstalledWebhookPayload, logger:
|
|
|
149
149
|
}, logger)
|
|
150
150
|
|
|
151
151
|
// Trigger a sync for the installation
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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
|
}
|