-
Notifications
You must be signed in to change notification settings - Fork 306
Expand file tree
/
Copy pathindex.ts
More file actions
75 lines (69 loc) · 2.5 KB
/
index.ts
File metadata and controls
75 lines (69 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/* eslint-disable @typescript-eslint/no-explicit-any */
import { DestinationDefinition, defaultValues } from '@segment/actions-core'
import type { Settings } from './generated-types'
import sendSchemaToInspector from './sendSchemaToInspector'
import { Environment } from './constants'
const destination: DestinationDefinition<Settings> = {
name: 'Avo Inspector v2',
slug: 'actions-avo-v2',
mode: 'cloud',
authentication: {
scheme: 'custom',
fields: {
apiKey: {
label: 'Avo Inspector API Key',
description: 'Avo Inspector API Key can be found in the Inspector setup page on your source in Avo.',
type: 'string',
required: true
},
publicEncryptionKey: {
label: 'Avo Inspector Public Encryption Key',
description:
'Optional. Enables verification of the property values against your Tracking Plan (e.g. allowed values, regex patterns, min/max constraints). Values are end-to-end encrypted and Avo can not decrypt them. Read more: https://www.avo.app/docs/inspector/connect-inspector-to-segment#property-value-validation-optional',
type: 'string',
required: false
},
env: {
label: 'Environment',
description: 'Avo Inspector Environment',
type: 'string',
choices: Object.values(Environment).map((environment) => ({ label: environment, value: environment })),
default: Environment.PROD,
required: true
},
appVersionPropertyName: {
label: 'App Version Property',
description:
'If you send a custom event property on all events that contains the app version, please enter the name of that property here (e.g. “app_version”). If you do not have a custom event property for the app version, please leave this field empty.',
type: 'string',
required: false
}
},
testAuthentication: (request, { settings }) => {
const { apiKey } = settings
const resp = request(`https://api.avo.app/auth/inspector/validate`, {
method: 'post',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
apiKey
})
})
return resp
}
},
presets: [
{
name: 'Track Schema From Event',
subscribe: 'type = "track"',
partnerAction: 'sendSchemaToInspector',
mapping: defaultValues(sendSchemaToInspector.fields),
type: 'automatic'
}
],
actions: {
sendSchemaToInspector
}
}
export default destination