-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[Components] appsflyer - new components #17386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
components/appsflyer/actions/get-event-types/get-event-types.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import app from "../../appsflyer.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "appsflyer-get-event-types", | ||
| name: "Get Event Types", | ||
| description: "Returns a list of the available event types for the specified endpoint type. [See the documentation](https://dev.appsflyer.com/hc/reference/get_event-types-attributing-entity)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| attributingEntity: { | ||
| type: "string", | ||
| label: "Attributing Entity", | ||
| description: "The endpoint type.", | ||
| options: [ | ||
| "appsflyer", | ||
| "skadnetwork", | ||
| ], | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| app, | ||
| attributingEntity, | ||
| } = this; | ||
|
|
||
| const response = await app.getEventTypes({ | ||
| $, | ||
| attributingEntity, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully retrieved event types with request ID \`${response.request_id}\`.`); | ||
| return response; | ||
| }, | ||
| }; | ||
36 changes: 36 additions & 0 deletions
36
components/appsflyer/actions/get-message-fields/get-message-fields.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import app from "../../appsflyer.app.mjs"; | ||
|
|
||
| export default { | ||
| key: "appsflyer-get-message-fields", | ||
| name: "Get Message Fields", | ||
| description: "Returns a list of the available message fields for each platform. [See the documentation](https://dev.appsflyer.com/hc/reference/get_fields-platform)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| platform: { | ||
| type: "string", | ||
| label: "Platform", | ||
| description: "The platform to retrieve message fields for.", | ||
| options: [ | ||
| "ios", | ||
| "android", | ||
| "windowsphone", | ||
| ], | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| app, | ||
| platform, | ||
| } = this; | ||
|
|
||
| const response = await app.getMessageFields({ | ||
| $, | ||
| platform, | ||
| }); | ||
|
|
||
| $.export("$summary", `Successfully retrieved message fields with request ID \`${response.request_id}\`.`); | ||
| return response; | ||
| }, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,99 @@ | ||
| import { axios } from "@pipedream/platform"; | ||
| import constants from "./common/constants.mjs"; | ||
|
|
||
| export default { | ||
| type: "app", | ||
| app: "appsflyer", | ||
| propDefinitions: {}, | ||
| propDefinitions: { | ||
| appId: { | ||
| type: "string", | ||
| label: "App ID", | ||
| description: "Your AppsFlyer App ID (e.g. `com.my.app`).", | ||
| async options() { | ||
| const { data } = await this.listApps(); | ||
| return data.map(({ | ||
| id: value, | ||
| attributes: { name: label }, | ||
| }) => ({ | ||
| label, | ||
| value, | ||
| })); | ||
| }, | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| }, | ||
| methods: { | ||
| // this.$auth contains connected account data | ||
| authKeys() { | ||
| console.log(Object.keys(this.$auth)); | ||
| getUrl(path, baseUrl = constants.API.HQ1.BASE_URL) { | ||
| return `${baseUrl}${path}`; | ||
| }, | ||
| getHeaders() { | ||
| const { api_token: apiToken } = this.$auth; | ||
| return { | ||
| Authorization: `Bearer ${apiToken}`, | ||
| }; | ||
| }, | ||
| makeRequest({ | ||
| $ = this, path, baseUrl, ...args | ||
| } = {}) { | ||
| return axios($, { | ||
| ...args, | ||
| url: this.getUrl(path, baseUrl), | ||
| headers: this.getHeaders(), | ||
| }); | ||
| }, | ||
| post(args = {}) { | ||
| return this.makeRequest({ | ||
| method: "POST", | ||
| ...args, | ||
| }); | ||
| }, | ||
| put(args = {}) { | ||
| return this.makeRequest({ | ||
| method: "PUT", | ||
| ...args, | ||
| }); | ||
| }, | ||
| listApps(args = {}) { | ||
| return this.makeRequest({ | ||
| baseUrl: constants.API.HQ1.MNG_URL, | ||
| path: "/apps", | ||
| ...args, | ||
| }); | ||
| }, | ||
| getMessageFields({ | ||
| platform, ...args | ||
| } = {}) { | ||
| return this.makeRequest({ | ||
| baseUrl: constants.API.HQ1.PUSH_URL, | ||
| path: `/fields/${platform}`, | ||
| ...args, | ||
| }); | ||
| }, | ||
| getEventTypes({ | ||
| attributingEntity, ...args | ||
| } = {}) { | ||
| return this.makeRequest({ | ||
| baseUrl: constants.API.HQ1.PUSH_URL, | ||
| path: `/event-types/${attributingEntity}`, | ||
| ...args, | ||
| }); | ||
| }, | ||
| getPushApiConfiguration({ | ||
| appId, ...args | ||
| } = {}) { | ||
| return this.makeRequest({ | ||
| baseUrl: constants.API.HQ1.PUSH_URL, | ||
| path: `/app/${appId}`, | ||
| ...args, | ||
| }); | ||
| }, | ||
| updatePushApiConfiguration({ | ||
| appId, ...args | ||
| } = {}) { | ||
| return this.put({ | ||
| baseUrl: constants.API.HQ1.PUSH_URL, | ||
| path: `/app/${appId}`, | ||
| ...args, | ||
| }); | ||
| }, | ||
| }, | ||
| }; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| const HQ1_BASE_URL = "https://hq1.appsflyer.com"; | ||
|
|
||
| const API = { | ||
| HQ1: { | ||
| BASE_URL: HQ1_BASE_URL, | ||
| PUSH_URL: `${HQ1_BASE_URL}/api/pushapi/v1.0`, | ||
| MNG_URL: `${HQ1_BASE_URL}/api/mng`, | ||
| }, | ||
| }; | ||
|
|
||
| export default { | ||
| API, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "name": "@pipedream/appsflyer", | ||
| "version": "0.0.1", | ||
| "version": "0.1.0", | ||
| "description": "Pipedream AppsFlyer Components", | ||
| "main": "appsflyer.app.mjs", | ||
| "keywords": [ | ||
|
|
@@ -11,5 +11,8 @@ | |
| "author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "dependencies": { | ||
| "@pipedream/platform": "^3.1.0" | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| import { ConfigurationError } from "@pipedream/platform"; | ||
| import app from "../../appsflyer.app.mjs"; | ||
|
|
||
| export default { | ||
| props: { | ||
| app, | ||
| db: "$.service.db", | ||
| http: { | ||
| type: "$.interface.http", | ||
| customResponse: true, | ||
| }, | ||
| appId: { | ||
| propDefinition: [ | ||
| app, | ||
| "appId", | ||
| ], | ||
| }, | ||
| }, | ||
| hooks: { | ||
| async activate() { | ||
| const { | ||
| app, | ||
| appId, | ||
| http, | ||
| } = this; | ||
| const { endpoints = [] } = await app.getPushApiConfiguration({ | ||
| appId, | ||
| }); | ||
|
|
||
| await app.updatePushApiConfiguration({ | ||
| appId, | ||
| data: { | ||
| endpoints: [ | ||
| ...endpoints, | ||
| { | ||
| method: "POST", | ||
| url: http.endpoint, | ||
| event_types: this.getEventTypes(), | ||
| attributing_entity: "appsflyer", | ||
| enabled: true, | ||
| }, | ||
| ], | ||
| }, | ||
| }); | ||
| }, | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| async deactivate() { | ||
| const { | ||
| app, | ||
| appId, | ||
| http, | ||
| } = this; | ||
| const { endpoints = [] } = await app.getPushApiConfiguration({ | ||
| appId, | ||
| }); | ||
|
|
||
| await app.updatePushApiConfiguration({ | ||
| appId, | ||
| data: { | ||
| endpoints: endpoints.filter( | ||
| (endpoint) => endpoint.url !== http.endpoint, | ||
| ), | ||
| }, | ||
| }); | ||
| }, | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| methods: { | ||
| generateMeta() { | ||
| throw new ConfigurationError("generateMeta is not implemented"); | ||
| }, | ||
| getEventTypes() { | ||
| throw new ConfigurationError("getEventTypes is not implemented"); | ||
| }, | ||
| processEvent(event) { | ||
| if (this.appId && event.app_id !== this.appId) { | ||
| return; | ||
| } | ||
|
|
||
| this.$emit(event, this.generateMeta(event)); | ||
| }, | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| async run({ body }) { | ||
| this.http.respond({ | ||
| status: 200, | ||
| }); | ||
| this.processEvent(body); | ||
| }, | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
29 changes: 29 additions & 0 deletions
29
components/appsflyer/sources/new-in-app-event-instant/new-in-app-event-instant.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import common from "../common/webhook.mjs"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| key: "appsflyer-new-in-app-event-instant", | ||
| name: "New In-App Event (Instant)", | ||
| description: "Emit new event when an in-app event is recorded, such as a purchase or level completion. [See docs here](https://dev.appsflyer.com/hc/reference/push-api-v2)", | ||
| version: "0.0.1", | ||
| type: "source", | ||
| dedupe: "unique", | ||
| methods: { | ||
| ...common.methods, | ||
| getEventTypes() { | ||
| return [ | ||
| "install-in-app-event", | ||
| "organic-install-in-app-event", | ||
| "re-engagement-in-app-event", | ||
| "re-attribution-in-app-event", | ||
| ]; | ||
| }, | ||
| generateMeta(event) { | ||
| return { | ||
| summary: `New In-App Event ${event.event_name}`, | ||
| id: event.event_id, | ||
| ts: Date.parse(event.event_time), | ||
| }; | ||
| }, | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| }; | ||
27 changes: 27 additions & 0 deletions
27
components/appsflyer/sources/new-install-instant/new-install-instant.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import common from "../common/webhook.mjs"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| key: "appsflyer-new-install-instant", | ||
| name: "New Install (Instant)", | ||
| description: "Emit new event when a user installs an app tracked by AppsFlyer. [See docs here](https://dev.appsflyer.com/hc/reference/push-api-v2)", | ||
| version: "0.0.1", | ||
| type: "source", | ||
| dedupe: "unique", | ||
| methods: { | ||
| ...common.methods, | ||
| getEventTypes() { | ||
| return [ | ||
| "install", | ||
| "organic-install", | ||
| ]; | ||
| }, | ||
| generateMeta(event) { | ||
| return { | ||
| summary: `New Install ${event.app_id}`, | ||
| id: event.event_id, | ||
| ts: Date.parse(event.event_time), | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
| }, | ||
| }, | ||
| }; | ||
26 changes: 26 additions & 0 deletions
26
components/appsflyer/sources/new-uninstall-instant/new-uninstall-instant.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import common from "../common/webhook.mjs"; | ||
|
|
||
| export default { | ||
| ...common, | ||
| key: "appsflyer-new-uninstall-instant", | ||
| name: "New Uninstall (Instant)", | ||
| description: "Emit new event when a user uninstalls an app tracked by AppsFlyer. [See docs here](https://dev.appsflyer.com/hc/reference/push-api-v2)", | ||
| version: "0.0.1", | ||
| type: "source", | ||
| dedupe: "unique", | ||
| methods: { | ||
| ...common.methods, | ||
| getEventTypes() { | ||
| return [ | ||
| "uninstall", | ||
| ]; | ||
| }, | ||
| generateMeta(event) { | ||
| return { | ||
| summary: `New Uninstall ${event.app_id}`, | ||
| id: event.event_id, | ||
| ts: Date.parse(event.event_time), | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
| }, | ||
| }, | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.