amplitude / amplitude/ampli-examples

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

Aperta
#325 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Java
Stelle
12
Fork
12
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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

```swift
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 `.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

```swift
// 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

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.