From 6aaf2e4553467e7b45f53fcd679ee1e509229bb2 Mon Sep 17 00:00:00 2001 From: Alex Urbano Date: Wed, 18 May 2022 11:50:37 -0500 Subject: [PATCH 1/3] fix: appsflyer attribution --- packages/core/src/analytics.ts | 12 +++++++----- .../plugins/plugin-appsflyer/src/AppsflyerPlugin.tsx | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/core/src/analytics.ts b/packages/core/src/analytics.ts index 401c2ac24..31ea3b973 100644 --- a/packages/core/src/analytics.ts +++ b/packages/core/src/analytics.ts @@ -22,6 +22,7 @@ import { Context, DeepPartial, GroupTraits, + IntegrationSettings, JsonMap, PluginType, SegmentAPIIntegrations, @@ -351,20 +352,21 @@ export class SegmentClient { /** * Adds a new plugin to the currently loaded set. - * @param {{ plugin: Plugin, settings?: SegmentAPISettings }} Plugin to be added. Settings are optional if you want to force a configuration instead of the Segment Cloud received one + * @param {{ plugin: Plugin, settings?: IntegrationSettings }} Plugin to be added. Settings are optional if you want to force a configuration instead of the Segment Cloud received one */ - add({ + add

({ plugin, settings, }: { - plugin: Plugin; - settings?: Plugin extends DestinationPlugin ? SegmentAPISettings : never; + plugin: P; + settings?: P extends DestinationPlugin ? IntegrationSettings : never; + }) { // plugins can either be added immediately or // can be cached and added later during the next state update // this is to avoid adding plugins before network requests made as part of setup have resolved if (settings !== undefined && plugin.type === PluginType.destination) { - this.store.settings.add((plugin as DestinationPlugin).key, settings); + this.store.settings.add((plugin as unknown as DestinationPlugin).key, settings); } if (!this.store.isReady.get()) { diff --git a/packages/plugins/plugin-appsflyer/src/AppsflyerPlugin.tsx b/packages/plugins/plugin-appsflyer/src/AppsflyerPlugin.tsx index ac905f77b..4394ef283 100644 --- a/packages/plugins/plugin-appsflyer/src/AppsflyerPlugin.tsx +++ b/packages/plugins/plugin-appsflyer/src/AppsflyerPlugin.tsx @@ -85,7 +85,7 @@ export class AppsflyerPlugin extends DestinationPlugin { }, }; - if (is_first_launch === 'true') { + if (is_first_launch && JSON.parse(is_first_launch) === true) { if (af_status === 'Non-organic') { this.analytics?.track('Install Attributed', properties); } else { From 6e8d55274312c67efee0379a5a37f454814c768a Mon Sep 17 00:00:00 2001 From: Oscar Bazaldua <511911+oscb@users.noreply.github.com> Date: Thu, 19 May 2022 09:20:50 -0700 Subject: [PATCH 2/3] fix: remove truthy check on is_first_launch --- packages/plugins/plugin-appsflyer/src/AppsflyerPlugin.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/plugins/plugin-appsflyer/src/AppsflyerPlugin.tsx b/packages/plugins/plugin-appsflyer/src/AppsflyerPlugin.tsx index 4394ef283..c64fa354c 100644 --- a/packages/plugins/plugin-appsflyer/src/AppsflyerPlugin.tsx +++ b/packages/plugins/plugin-appsflyer/src/AppsflyerPlugin.tsx @@ -85,7 +85,7 @@ export class AppsflyerPlugin extends DestinationPlugin { }, }; - if (is_first_launch && JSON.parse(is_first_launch) === true) { + if (JSON.parse(is_first_launch) === true) { if (af_status === 'Non-organic') { this.analytics?.track('Install Attributed', properties); } else { From 12ddf09be1de27877d3c83b051f4006d42cadca2 Mon Sep 17 00:00:00 2001 From: Alex Urbano Date: Thu, 19 May 2022 11:42:48 -0500 Subject: [PATCH 3/3] fix: lint errors --- packages/core/src/analytics.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/core/src/analytics.ts b/packages/core/src/analytics.ts index 31ea3b973..ab1a744bd 100644 --- a/packages/core/src/analytics.ts +++ b/packages/core/src/analytics.ts @@ -26,7 +26,6 @@ import { JsonMap, PluginType, SegmentAPIIntegrations, - SegmentAPISettings, SegmentEvent, UpdateType, UserInfoState, @@ -360,13 +359,15 @@ export class SegmentClient { }: { plugin: P; settings?: P extends DestinationPlugin ? IntegrationSettings : never; - }) { // plugins can either be added immediately or // can be cached and added later during the next state update // this is to avoid adding plugins before network requests made as part of setup have resolved if (settings !== undefined && plugin.type === PluginType.destination) { - this.store.settings.add((plugin as unknown as DestinationPlugin).key, settings); + this.store.settings.add( + (plugin as unknown as DestinationPlugin).key, + settings + ); } if (!this.store.isReady.get()) {