Skip to content

Commit 478f596

Browse files
committed
source-appsflyer: move app_ids into document _meta fields
1 parent ec7dc44 commit 478f596

File tree

6 files changed

+73
-61
lines changed

6 files changed

+73
-61
lines changed

source-appsflyer/acmeCo/daily_geo_aggregate_report.schema.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,18 @@ $defs:
1515
description: Row ID of the Document, counting up from zero, or -1 if not known
1616
title: Row Id
1717
type: integer
18+
app_id:
19+
default: ''
20+
description: AppsFlyer App ID this row was fetched for
21+
title: App Id
22+
type: string
1823
title: Meta
1924
type: object
2025
additionalProperties: true
2126
properties:
2227
_meta:
2328
$ref: '#/$defs/Meta'
2429
description: Document metadata
25-
app_id:
26-
description: AppsFlyer App ID this row was fetched for
27-
title: App Id
28-
type: string
2930
Date:
3031
title: Date
3132
type: string
@@ -39,7 +40,6 @@ properties:
3940
title: Campaign (C)
4041
type: string
4142
required:
42-
- app_id
4343
- Date
4444
- Country
4545
- Media Source (pid)

source-appsflyer/acmeCo/flow.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ collections:
22
acmeCo/daily_geo_aggregate_report:
33
schema: daily_geo_aggregate_report.schema.yaml
44
key:
5-
- /app_id
5+
- /_meta/app_id
66
- /Date
77
- /Country
88
- /Media Source (pid)

source-appsflyer/config.yaml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
credentials:
22
credentials_title: Private App Credentials
33
access_token_sops: ENC[AES256_GCM,data:ZkesZ9lRtjF1t8pqbDS77qtZdMAqYwQpaj440sWV5NeOUks3IW3Qg48umz+hU9IhlPmK7knYRhd+6Bk7eY1l3PnWuPIQkpYcBHnWT6G+UJYdtp8dWz/P3JnvMZt0q08EWri23OxulMtkaVk9K+9cHHqbJvKCiCP+6gU36Jf+T+D03khTCrUhBbwGxubK3+Yx+qlt6EjKQ+IJ8umTM9O93Ppgk3bRVN3dDqbF+W68YfMxLWefktWiaptIfGNWBVAjfDx7f4ngddxEjdzT6yuiECmbiVWXJuU6nTyeVplxU5/sbGeneoWBuywi178e0INS6pt0CIhojAdCuvNad1Ye3St8enDeZq5Yu4VvIdqsIY4WRgA0GmimxFRtl5XzScbgvfbvAok91BC98l75MMQFOdWw6wLWZyf+VrzWSN9mqQbrjB9fg0p0AUNL6FZsZEDuyw3WpzJxARbDSYsYzI4mnosI7Czb/Ep45ou/rXrzjoJpiZwU1O6C5gQNGlXYBe6TafSOudmUtJ8c2CpQB/vYHYDWglslWueSfvQbtQivRPC7Pl/KhWMJ07KMJzsdzAgipjbTNcyjAoZTdRjwQal56LRSGp/swtLIBnlWo651nHhcDRlebMqf2/1/OLdIvJG8eCl8bPirKZyloO/nVNVkZ1tBiA81V+IQbawfvImsRZwUJINWFR1ussoSNg2z321j/R8=,iv:i8/dwVUNry5gCKe8SjaMi32NBJrmdzyy+9YeASg6HR4=,tag:dY9vL48vlumDS3r8VD28fA==,type:str]
4-
app_ids_sops: ENC[AES256_GCM,data:vXAJcwxmoBY+j8fEfFh/,iv:U3hJh+J/iQLxMiU8hertkbk9B0VlO2R0SYdg667fu2s=,tag:BWWhHF2kwsvFzhShtSfvLQ==,type:str]
5-
start_date: "2026-04-15T00:00:00Z"
4+
app_ids_sops: ENC[AES256_GCM,data:gmndTfAWMX2ghKjDBUtrqQ==,iv:lf2W1vINpzcgfbF7vrdaH7GWaeTK/rDtFLxNBldN+kk=,tag:QsLi+uHB+tVfJElt3TaMkg==,type:str]
5+
start_date: "2026-04-05T00:00:00Z"
66
sops:
7-
kms: []
87
gcp_kms:
98
- resource_id: projects/estuary-theatre/locations/us-central1/keyRings/connector-keyring/cryptoKeys/connector-repository
109
created_at: "2024-07-26T15:53:37Z"
1110
enc: CiQAdmEdwpmP0/Kcv6L1SnM3nPbsYLywIaUeOL1mz7cZjFUwWt0SSQD5lVw43Of1YI96anxUVo7d7ALi0DYnCNvxTHCgHX5ZeDBPlfXwLNpmYb6y3hJSsHG7NupwDQT/qIpUvlqQnq5IVkgJEFHPU1s=
12-
azure_kv: []
13-
hc_vault: []
14-
age: []
15-
lastmodified: "2026-04-17T20:56:07Z"
16-
mac: ENC[AES256_GCM,data:Yq78TmkHNZajFC6sXVuJwsY5JJyrOimd3xPikP8l2Wmy4aBCdJ9zAfwgoYcl6UNh8T624wsJIaC9HnPD5wlO5yyMT44NNxO6JlODHLSEzgp+CV9qOHKE/OrA4MCRiZiNbIk0xT8Wf9pixWtkfkm3JZKJGIDrd82xWxx13lXPyy4=,iv:CdGQ0lVrxjMAN0pUj8zKFu2aXAoSk9mW2t2mXHjUtBU=,tag:ulFF0z+vMu1pRKp6YDQ+Bg==,type:str]
17-
pgp: []
11+
lastmodified: "2026-04-17T22:00:16Z"
12+
mac: ENC[AES256_GCM,data:oUXiCPbmL84tL3+6Mz8rkI8tBVHlhUhEU4wI6QozsOJyKlrn+36p03S3Ykz617ocInPLMuAwR1ZMEUm5gOnU6+Grm39u9wC6SE+0GQhguV6lZ//wxr9U94yG9W43AgggnnQW6VUVpRvkkU0/zCQh+4C2NDGrUyqEL/0/OeBR+qY=,iv:Q/+saVbRXu2dwv+V05S9GTS8rwtM7oK3hZj2S9Y+IGI=,tag:xBx+hy788mOe27EwR94b8w==,type:str]
1813
encrypted_suffix: _sops
1914
version: 3.10.2

source-appsflyer/source_appsflyer/models.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,30 @@ class PullApiDocument(BaseDocument, metaclass=ABCMeta):
130130
# returned by AppsFlyer exactly (including spaces, case, and parentheses).
131131
key_fields: ClassVar[tuple[str, ...]]
132132

133-
app_id: str = Field(description="AppsFlyer App ID this row was fetched for")
133+
class Meta(BaseDocument.Meta):
134+
model_config = ConfigDict( # pyright: ignore[reportUnannotatedClassAttribute]
135+
validate_assignment=True
136+
)
137+
app_id: str = Field(
138+
description="AppsFlyer App ID this row was fetched for", default=""
139+
)
140+
141+
meta_: Meta = Field( # pyright: ignore[reportIncompatibleVariableOverride]
142+
default_factory=Meta,
143+
alias="_meta",
144+
description="Document metadata",
145+
)
134146

135147
@model_validator(mode="before")
136148
@classmethod
137149
def _inject_app_id(cls, data: Any, info: ValidationInfo) -> Any:
138-
if isinstance(data, dict) and info.context and "app_id" in info.context:
139-
return {**data, "app_id": info.context["app_id"]}
150+
if not isinstance(data, dict):
151+
return data
152+
if info.context and "app_id" in info.context:
153+
meta = data.get("_meta") or {}
154+
meta["app_id"] = info.context["app_id"]
155+
data["_meta"] = meta
156+
# return {**data, "app_id": info.context["app_id"]}
140157
return data
141158

142159
@classmethod

source-appsflyer/source_appsflyer/resources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def make_resource(
200200
) -> Resource[PullApiDocument, PullApiResourceConfig, ResourceState]:
201201
return Resource(
202202
name=doc_type.resource_name,
203-
key=["/app_id", *[f"/{f}" for f in doc_type.key_fields]],
203+
key=["/_meta/app_id", *[f"/{f}" for f in doc_type.key_fields]],
204204
model=doc_type,
205205
open=functools.partial(
206206
open_report_binding,

source-appsflyer/test.flow.yaml

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,116 +12,116 @@ captures:
1212
bindings:
1313
- resource:
1414
type: webhook
15-
name: re-attribution-in-app-event
15+
name: in-app-event
1616
match_rule:
17-
value: re-attribution-in-app-event
17+
value: in-app-event
1818
key: event_name
1919
type: body
20-
target: acmeCo/re-attribution-in-app-event
20+
target: acmeCo/in-app-event
2121
- resource:
2222
type: webhook
23-
name: install-in-app-event
23+
name: organic-install-in-app-event
2424
match_rule:
25-
value: install-in-app-event
25+
value: organic-install-in-app-event
2626
key: event_name
2727
type: body
28-
target: acmeCo/install-in-app-event
28+
target: acmeCo/organic-install-in-app-event
2929
- resource:
3030
type: webhook
31-
name: postback
31+
name: organic-reinstall
3232
match_rule:
33-
value: postback
33+
value: organic-reinstall
3434
key: event_name
3535
type: body
36-
target: acmeCo/postback
36+
target: acmeCo/organic-reinstall
3737
- resource:
3838
type: webhook
39-
name: organic-install-in-app-event
39+
name: organic-install
4040
match_rule:
41-
value: organic-install-in-app-event
41+
value: organic-install
4242
key: event_name
4343
type: body
44-
target: acmeCo/organic-install-in-app-event
44+
target: acmeCo/organic-install
4545
- resource:
4646
type: webhook
47-
name: reinstall
47+
name: re-download
4848
match_rule:
49-
value: reinstall
49+
value: re-download
5050
key: event_name
5151
type: body
52-
target: acmeCo/reinstall
52+
target: acmeCo/re-download
5353
- resource:
5454
type: webhook
55-
name: organic-reinstall
55+
name: re-attribution-in-app-event
5656
match_rule:
57-
value: organic-reinstall
57+
value: re-attribution-in-app-event
5858
key: event_name
5959
type: body
60-
target: acmeCo/organic-reinstall
60+
target: acmeCo/re-attribution-in-app-event
6161
- resource:
6262
type: webhook
63-
name: install
63+
name: re-attribution
6464
match_rule:
65-
value: install
65+
value: re-attribution
6666
key: event_name
6767
type: body
68-
target: acmeCo/install
68+
target: acmeCo/re-attribution
6969
- resource:
7070
type: webhook
71-
name: postbacks-copy
71+
name: install
7272
match_rule:
73-
value: postbacks-copy
73+
value: install
7474
key: event_name
7575
type: body
76-
target: acmeCo/postbacks-copy
76+
target: acmeCo/install
7777
- resource:
7878
type: webhook
79-
name: organic-install
79+
name: install-in-app-event
8080
match_rule:
81-
value: organic-install
81+
value: install-in-app-event
8282
key: event_name
8383
type: body
84-
target: acmeCo/organic-install
84+
target: acmeCo/install-in-app-event
8585
- resource:
8686
type: webhook
87-
name: re-engagement
87+
name: re-engagement-in-app-event
8888
match_rule:
89-
value: re-engagement
89+
value: re-engagement-in-app-event
9090
key: event_name
9191
type: body
92-
target: acmeCo/re-engagement
92+
target: acmeCo/re-engagement-in-app-event
9393
- resource:
9494
type: webhook
95-
name: re-engagement-in-app-event
95+
name: postback
9696
match_rule:
97-
value: re-engagement-in-app-event
97+
value: postback
9898
key: event_name
9999
type: body
100-
target: acmeCo/re-engagement-in-app-event
100+
target: acmeCo/postback
101101
- resource:
102102
type: webhook
103-
name: in-app-event
103+
name: reinstall
104104
match_rule:
105-
value: in-app-event
105+
value: reinstall
106106
key: event_name
107107
type: body
108-
target: acmeCo/in-app-event
108+
target: acmeCo/reinstall
109109
- resource:
110110
type: webhook
111-
name: re-attribution
111+
name: re-engagement
112112
match_rule:
113-
value: re-attribution
113+
value: re-engagement
114114
key: event_name
115115
type: body
116-
target: acmeCo/re-attribution
116+
target: acmeCo/re-engagement
117117
- resource:
118118
type: webhook
119-
name: re-download
119+
name: postbacks-copy
120120
match_rule:
121-
value: re-download
121+
value: postbacks-copy
122122
key: event_name
123123
type: body
124-
target: acmeCo/re-download
124+
target: acmeCo/postbacks-copy
125125
- resource:
126126
name: daily_geo_aggregate_report
127127
interval: PT4H

0 commit comments

Comments
 (0)