monorepo icon indicating copy to clipboard operation
monorepo copied to clipboard

move `parseOrigin` from `@inlang/telemetry` to `@lix-js/client`

Open samuelstroschein opened this issue 7 months ago • 5 comments

Problem

@janfjohannes the parseOrigin function from @inlang/telemetry should likely move to lix

  • misplaced in @inlang/telemetry (which is supposed to be deprecated)
  • needed for several apps (ensures one origin)

https://github.com/opral/monorepo/blob/c8db6b71ba51d27ed94751958b21cde8882c11e9/inlang/source-code/telemetry/src/utilities/parseOrigin.ts

Proposal

  • [x] 1. Move the function to @lix-js/client and replace imports
  • [x] 2. parseOrigin should return undefined instead of "unknown" similar to #2079

samuelstroschein avatar Jan 22 '24 22:01 samuelstroschein

@samuelstroschein this was allready moved to lix a long time ago (thats how the "unknown" ended up in the lix api), just the imports have to be fixed and the code from telemetry removed.

janfjohannes avatar Jan 23 '24 12:01 janfjohannes

@janfjohannes parseOrigin doesn't exist on the repo API, nor is it exported from lix though.

context

  • getOrigin is not suited as parseOrigin replacement. parseOrigin acts as stripOriginFromMetadata (good rename!). two different use cases
  • stripOriginFromMetadata should be it's own exported function (no need to bloat repo.* API for this)
  • i want to use the function here https://github.com/opral/monorepo/blob/de481504d43f18bfcfbbf0a0729c139ba9f7b0e3/inlang/source-code/cli/src/commands/open/editor.ts#L30-L36

samuelstroschein avatar Jan 23 '24 14:01 samuelstroschein

@samuelstroschein sorry i dont unsderstand what the usecase is why getOrigin is no replacement of parseOrigin. the example you gave is exactly what getOrigin does if a m not mistaken.

janfjohannes avatar Jan 23 '24 15:01 janfjohannes

@janfjohannes does the following clarify the intent?

repo.getOrigin()

gets the unfiltered origin as stated in the repository. if we process it, it will become useless in envs where metadata such as keys are important.

stripMetadataFromRemote(origin)

removes metadata such as keys from a remote. needed to implement inlang open editor logic. see the test case below. the return value, stripped of metadata, is what is needed to open a repo from the cli with fink.

https://github.com/opral/monorepo/blob/de35c34d7c02736fa424f6c1187faef2c83798ff/inlang/source-code/telemetry/src/utilities/parseOrigin.test.ts#L63-L78


both use cases do not need safeHash. safehash can be removed from getOrigin

samuelstroschein avatar Jan 23 '24 15:01 samuelstroschein

Subscribing to this issue to get notified. VSC extension needs this functionality & a cleanup in this space too.

felixhaeberle avatar Feb 05 '24 12:02 felixhaeberle