Skip to content

Commit 0795135

Browse files
2785 - Amplitude component added
1 parent a05acdd commit 0795135

File tree

18 files changed

+2461
-0
lines changed

18 files changed

+2461
-0
lines changed
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
---
2+
title: "Amplitude"
3+
description: "Build better products by turning your user data into meaningful insights, using Amplitude's digital analytics platform and experimentation tools."
4+
---
5+
6+
7+
Categories: Analytics
8+
9+
10+
Type: amplitude/v1
11+
12+
<hr />
13+
14+
15+
16+
## Connections
17+
18+
Version: 1
19+
20+
21+
### custom
22+
23+
#### Properties
24+
25+
| Name | Label | Type | Description | Required |
26+
|:---------------:|:--------------:|:------------:|:-------------------:|:--------:|
27+
| api_key | API Key | STRING | `The API key for the Amplitude project` | true |
28+
| region | Region | STRING <details> <summary> Options </summary> api2, api.eu </details> | `Environment region you wish to access the API in.` | true |
29+
30+
31+
32+
33+
34+
<hr />
35+
36+
37+
38+
## Actions
39+
40+
41+
### Create Attribution Event
42+
Name: createAttributionEvent
43+
44+
`Creates attribution event using Attribution API.`
45+
46+
#### Properties
47+
48+
| Name | Label | Type | Description | Required |
49+
|:---------------:|:--------------:|:------------:|:-------------------:|:--------:|
50+
| event_type | Event Type | STRING | `The event info. Prefix with brackets [YOUR COMPANY].` | true |
51+
| platform | Platform | STRING <details> <summary> Options </summary> ios, android </details> | `Platform which the event will occur on.` | true |
52+
| identifier | Identifier | OBJECT <details> <summary> Properties </summary> &#123;STRING\(key), STRING\(value)&#125; </details> | `Identifier of the platform.` | true |
53+
| user_properties | User Properties | ARRAY <details> <summary> Items </summary> [&#123;STRING\(key), STRING\(value)&#125;\($property)] </details> | `A dictionary of attribution properties prefixed with brackets [YOUR COMPANY].` | false |
54+
55+
#### Example JSON Structure
56+
```json
57+
{
58+
"label" : "Create Attribution Event",
59+
"name" : "createAttributionEvent",
60+
"parameters" : {
61+
"event_type" : "",
62+
"platform" : "",
63+
"identifier" : {
64+
"key" : "",
65+
"value" : ""
66+
},
67+
"user_properties" : [ {
68+
"key" : "",
69+
"value" : ""
70+
} ]
71+
},
72+
"type" : "amplitude/v1/createAttributionEvent"
73+
}
74+
```
75+
76+
#### Output
77+
78+
79+
80+
Type: STRING
81+
82+
83+
84+
85+
86+
87+
88+
89+
### Create or Update User
90+
Name: createOrUpdateUser
91+
92+
`Creates or updates user without sending an event.`
93+
94+
#### Properties
95+
96+
| Name | Label | Type | Description | Required |
97+
|:---------------:|:--------------:|:------------:|:-------------------:|:--------:|
98+
| id | ID | STRING <details> <summary> Options </summary> user_id, device_id </details> | `Choose to create or update a user or a device.` | true |
99+
| device_id | Device ID | STRING | `A device specific identifier, such as the Identifier for Vendor (IDFV) on iOS.` | true |
100+
| user_id | User ID | STRING | `Unique user ID specified by you. If you send a request with a user ID that's not in the Amplitude system, new user will be created (e.g. email address).` | true |
101+
| user_properties | User Properties | ARRAY <details> <summary> Items </summary> [&#123;STRING\(key), STRING\(value)&#125;\($property)] </details> | `A dictionary of attribution properties prefixed with brackets [YOUR COMPANY].` | false |
102+
| platform | Platform | STRING | `The platform that's sending the data.` | false |
103+
| os_name | Operating System Name | STRING | `The mobile operating system or browser the user is on.` | false |
104+
| device_brand | Device Brand | STRING | `The device brand the user is on.` | false |
105+
| carrier | Carrier | STRING | `The carrier of the device the user is on.` | false |
106+
| country | Country | STRING | `The country the user is in.` | false |
107+
| city | City | STRING | `The city the user is in.` | false |
108+
| dma | Designated Market Area | STRING | `The Designated Market Area of the user.` | false |
109+
| language | Language | STRING | `The language the user has set.` | false |
110+
111+
#### Example JSON Structure
112+
```json
113+
{
114+
"label" : "Create or Update User",
115+
"name" : "createOrUpdateUser",
116+
"parameters" : {
117+
"id" : "",
118+
"device_id" : "",
119+
"user_id" : "",
120+
"user_properties" : [ {
121+
"key" : "",
122+
"value" : ""
123+
} ],
124+
"platform" : "",
125+
"os_name" : "",
126+
"device_brand" : "",
127+
"carrier" : "",
128+
"country" : "",
129+
"city" : "",
130+
"dma" : "",
131+
"language" : ""
132+
},
133+
"type" : "amplitude/v1/createOrUpdateUser"
134+
}
135+
```
136+
137+
#### Output
138+
139+
140+
141+
Type: STRING
142+
143+
144+
145+
146+
147+
148+
149+
150+
151+
152+
<hr />
153+
154+
# Additional instructions
155+
<hr />
156+

server/apps/server-app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ dependencies {
154154
implementation(project(":server:libs:modules:components:ai:vectorstore:weaviate"))
155155
implementation(project(":server:libs:modules:components:airtable"))
156156
implementation(project(":server:libs:modules:components:aitable"))
157+
implementation(project(":server:libs:modules:components:amplitude"))
157158
implementation(project(":server:libs:modules:components:apify"))
158159
implementation(project(":server:libs:modules:components:apollo"))
159160
implementation(project(":server:libs:modules:components:app-event"))

server/ee/apps/worker-app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ dependencies {
9898
implementation(project(":server:libs:modules:components:ai:vectorstore:weaviate"))
9999
implementation(project(":server:libs:modules:components:airtable"))
100100
implementation(project(":server:libs:modules:components:aitable"))
101+
implementation(project(":server:libs:modules:components:amplitude"))
101102
implementation(project(":server:libs:modules:components:apify"))
102103
implementation(project(":server:libs:modules:components:apollo"))
103104
implementation(project(":server:libs:modules:components:app-event"))
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
version="1.0"
2+
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright 2025 ByteChef
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.bytechef.component.amplitude;
18+
19+
import static com.bytechef.component.definition.ComponentDsl.component;
20+
import static com.bytechef.component.definition.ComponentDsl.tool;
21+
22+
import com.bytechef.component.ComponentHandler;
23+
import com.bytechef.component.amplitude.action.AmplitudeCreateAttributionEventAction;
24+
import com.bytechef.component.amplitude.action.AmplitudeCreateOrUpdateUserAction;
25+
import com.bytechef.component.amplitude.connection.AmplitudeConnection;
26+
import com.bytechef.component.definition.ComponentCategory;
27+
import com.bytechef.component.definition.ComponentDefinition;
28+
import com.google.auto.service.AutoService;
29+
30+
/**
31+
* @author Nikolina Spehar
32+
*/
33+
@AutoService(ComponentHandler.class)
34+
public class AmplitudeComponentHandler implements ComponentHandler {
35+
36+
private static final ComponentDefinition COMPONENT_DEFINITION = component("amplitude")
37+
.title("Amplitude")
38+
.description(
39+
"Build better products by turning your user data into meaningful insights, using Amplitude's digital " +
40+
"analytics platform and experimentation tools.")
41+
.icon("path:assets/amplitude.svg")
42+
.categories(ComponentCategory.ANALYTICS)
43+
.connection(AmplitudeConnection.CONNECTION_DEFINITION)
44+
.actions(
45+
AmplitudeCreateAttributionEventAction.ACTION_DEFINITION,
46+
AmplitudeCreateOrUpdateUserAction.ACTION_DEFINITION)
47+
.clusterElements(
48+
tool(AmplitudeCreateAttributionEventAction.ACTION_DEFINITION),
49+
tool(AmplitudeCreateOrUpdateUserAction.ACTION_DEFINITION));
50+
51+
@Override
52+
public ComponentDefinition getDefinition() {
53+
return COMPONENT_DEFINITION;
54+
}
55+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/*
2+
* Copyright 2025 ByteChef
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.bytechef.component.amplitude.action;
18+
19+
import static com.bytechef.component.amplitude.constant.AmplitudeConstants.API_KEY;
20+
import static com.bytechef.component.amplitude.constant.AmplitudeConstants.EVENT;
21+
import static com.bytechef.component.amplitude.constant.AmplitudeConstants.EVENT_TYPE;
22+
import static com.bytechef.component.amplitude.constant.AmplitudeConstants.IDENTIFIER;
23+
import static com.bytechef.component.amplitude.constant.AmplitudeConstants.KEY;
24+
import static com.bytechef.component.amplitude.constant.AmplitudeConstants.PLATFORM;
25+
import static com.bytechef.component.amplitude.constant.AmplitudeConstants.USER_PROPERTIES_OBJECT;
26+
import static com.bytechef.component.amplitude.constant.AmplitudeConstants.VALUE;
27+
import static com.bytechef.component.amplitude.util.AmplitudeUtils.getEventJson;
28+
import static com.bytechef.component.definition.ComponentDsl.action;
29+
import static com.bytechef.component.definition.ComponentDsl.object;
30+
import static com.bytechef.component.definition.ComponentDsl.option;
31+
import static com.bytechef.component.definition.ComponentDsl.outputSchema;
32+
import static com.bytechef.component.definition.ComponentDsl.string;
33+
import static com.bytechef.component.definition.Context.Http.responseType;
34+
35+
import com.bytechef.component.amplitude.util.AmplitudeUtils;
36+
import com.bytechef.component.definition.ComponentDsl.ModifiableActionDefinition;
37+
import com.bytechef.component.definition.Context;
38+
import com.bytechef.component.definition.Context.Http.ResponseType;
39+
import com.bytechef.component.definition.OptionsDataSource.ActionOptionsFunction;
40+
import com.bytechef.component.definition.Parameters;
41+
import com.bytechef.component.definition.TypeReference;
42+
43+
/**
44+
* @author Nikolina Spehar
45+
*/
46+
public class AmplitudeCreateAttributionEventAction {
47+
48+
public static final ModifiableActionDefinition ACTION_DEFINITION = action("createAttributionEvent")
49+
.title("Create Attribution Event")
50+
.description("Creates attribution event using Attribution API.")
51+
.properties(
52+
string(EVENT_TYPE)
53+
.label("Event Type")
54+
.description("The event info. Prefix with brackets [YOUR COMPANY].")
55+
.required(true),
56+
string(PLATFORM)
57+
.label("Platform")
58+
.description("Platform which the event will occur on.")
59+
.options(
60+
option("iOS", "ios"),
61+
option("Android", "android"))
62+
.required(true),
63+
object(IDENTIFIER)
64+
.label("Identifier")
65+
.description("Identifier of the platform.")
66+
.required(true)
67+
.properties(
68+
string(KEY)
69+
.label("Identifier Key")
70+
.description("For iOS input the Identifier for Advertiser or the Identifier for Vendor." +
71+
"For Android input the Google ADID or App Set ID")
72+
.options((ActionOptionsFunction<String>) AmplitudeUtils::getIdentifierKeyOptions)
73+
.optionsLookupDependsOn(PLATFORM)
74+
.required(true),
75+
string(VALUE)
76+
.label("Identifier Value")
77+
.description("Value of selected identifier.")
78+
.required(true)),
79+
USER_PROPERTIES_OBJECT)
80+
.output(
81+
outputSchema(
82+
string()
83+
.description("Response message")))
84+
.perform(AmplitudeCreateAttributionEventAction::perform);
85+
86+
private AmplitudeCreateAttributionEventAction() {
87+
}
88+
89+
public static String perform(Parameters inputParameters, Parameters connectionParameters, Context context) {
90+
91+
return context.http(http -> http.post("/attribution"))
92+
.configuration(responseType(ResponseType.TEXT))
93+
.queryParameters(
94+
API_KEY, connectionParameters.getRequiredString(API_KEY),
95+
EVENT, getEventJson(inputParameters, context))
96+
.execute()
97+
.getBody(new TypeReference<>() {});
98+
}
99+
}

0 commit comments

Comments
 (0)