Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions components/appsflyer/actions/get-event-types/get-event-types.mjs
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;
},
};
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",
],
},
},
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;
},
};
98 changes: 93 additions & 5 deletions components/appsflyer/appsflyer.app.mjs
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,
}));
},
},
},
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,
});
},
},
};
};
13 changes: 13 additions & 0 deletions components/appsflyer/common/constants.mjs
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,
};
7 changes: 5 additions & 2 deletions components/appsflyer/package.json
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": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.1.0"
}
}
}
87 changes: 87 additions & 0 deletions components/appsflyer/sources/common/webhook.mjs
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,
},
],
},
});
},
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,
),
},
});
},
},
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));
},
},
async run({ body }) {
this.http.respond({
status: 200,
});
this.processEvent(body);
},
};
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),
};
},
},
};
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),
};
},
},
};
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),
};
},
},
};
Loading
Loading