Skip to content

[Ampli Swift + CLI status]ampli status does not understand cross package calls #325

@dsaliberti

Description

@dsaliberti

Hi all
This issue is related to the CLI running ampli status on an iOS Swift project which has packages

Summary

My point is quite simple:

I create my strongly typed events and pass it to my own AnalyticsClient which finally calls ampli.track
But status CLI command fails because the ampli instance is not in the same file/package of the events.

Motivations

In more details:
In
packages/Feature/FeatureLogic
I call:
analyticsClient.logEvent(MyStronglyTypedEventViewed(params: vars))
where MyStronglyTypedEventViewed(params:) is from my tracking plan

and finally in:
packages/AnalyticsClient
I receive such call and pass it to Ampli instance track method

func logEvent(Event) {
  Ampli.instance.track(event)
}

But sadly it seems the instance has to be in the same file of the strongly typed events for the command ampli status to succeed.

The request

Could we consider that status could do what it does today OR requires at least one occurrence of <instance>.track(event:) wherever it is?

The workaround

Just in case someone runs into the same issue:
I had to add a comment mimicking the instance to make status happy:
So add this anywhere in the file of the strongly typed events

// Ampli.instance.

NB1: or however you're using your instance defined in your ampli.json
NB2: the dot . after the instance is required


Thanks @crleona 👍

Thank you
Danilo Aliberti

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions