Skip to content

Fix: Integrations map in segment event. #153

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
14 changes: 11 additions & 3 deletions packages/core/lib/analytics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Analytics with ClientMethods {
addPlugin(segmentDestination);
}

if(config.token != null) {
if (config.token != null) {
_platformPlugins.add(InjectToken(config.token!));
}

Expand Down Expand Up @@ -212,12 +212,20 @@ class Analytics with ClientMethods {

@override
Future track(String event, {Map<String, dynamic>? properties}) async {
await _process(TrackEvent(event, properties: properties ?? {}));
await _process(TrackEvent(
event,
properties: properties ?? {},
integrations: _state.integrations.state,
));
}

@override
Future screen(String name, {Map<String, dynamic>? properties}) async {
final event = ScreenEvent(name, properties: properties ?? {});
final event = ScreenEvent(
name,
properties: properties ?? {},
integrations: _state.integrations.state,
);

await _process(event);
}
Expand Down
25 changes: 22 additions & 3 deletions packages/core/lib/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ abstract class RawEvent with JSONSerialisable {
@JsonKey(name: "_metadata")
DestinationMetadata? metadata;

RawEvent(this.type, {this.anonymousId, this.userId});
RawEvent(
this.type, {
this.anonymousId,
this.userId,
this.integrations,
});
}

@JsonSerializable(explicitToJson: true)
Expand All @@ -79,7 +84,14 @@ class TrackEvent extends RawEvent {
String event;
Map<String, dynamic>? properties;

TrackEvent(this.event, {this.properties}) : super(EventType.track);
TrackEvent(
this.event, {
this.properties,
Map<String, dynamic>? integrations,
}) : super(
EventType.track,
integrations: integrations,
);

factory TrackEvent.fromJson(Map<String, dynamic> json) =>
_$TrackEventFromJson(json);
Expand Down Expand Up @@ -131,7 +143,14 @@ class ScreenEvent extends RawEvent {
String name;
Map<String, dynamic>? properties;

ScreenEvent(this.name, {this.properties}) : super(EventType.screen);
ScreenEvent(
this.name, {
this.properties,
Map<String, dynamic>? integrations,
}) : super(
EventType.screen,
integrations: integrations,
);

factory ScreenEvent.fromJson(Map<String, dynamic> json) =>
_$ScreenEventFromJson(json);
Expand Down
243 changes: 89 additions & 154 deletions packages/core/lib/event.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading