Skip to content

Commit

Permalink
Publish st-client-lib and reuse as dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
ashevchuk-ecw committed Mar 4, 2024
1 parent ae974b5 commit 087727d
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 25 deletions.
4 changes: 4 additions & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"allowedCommonJsDependencies": [
"statsig",
"statsig-js"
],
"assets": [
"src/favicon.ico",
"src/assets"
Expand Down
23 changes: 19 additions & 4 deletions package-lock.json

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

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.0.0",
"scripts": {
"ng": "ng",
"postinstall": "ngcc --properties es2020 browser module main",
"start": "ng serve",
"build": "ng build st-client-lib && ng build",
"watch": "ng build --watch --configuration development",
Expand All @@ -19,7 +20,8 @@
"@angular/platform-browser-dynamic": "^14.2.0",
"@angular/router": "^14.2.0",
"rxjs": "~7.5.0",
"statsig-js": "^4.49.0",
"st-client-lib": "0.0.3",
"statsig-js": "^4.48.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
},
Expand Down
2 changes: 1 addition & 1 deletion projects/st-client-lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "st-client-lib",
"version": "0.0.1",
"version": "0.0.3",
"peerDependencies": {
"@angular/common": "^14.2.0",
"@angular/core": "^14.2.0",
Expand Down
13 changes: 6 additions & 7 deletions projects/st-client-lib/src/lib/st-client-lib.service.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { Injectable } from '@angular/core';
import Statsig, { DynamicConfig } from 'statsig-js';
import { DynamicConfig } from 'statsig-js';
import * as StatsigRoot from 'statsig-js'

@Injectable({
providedIn: 'root'
})
export class StClientLibService {

constructor() { }

public async statsigInit(key: string): Promise<void> {
Statsig.initialize(
public async statsigInit(key: string): Promise<void> {
StatsigRoot.default.initialize(
key,
{
appVersion: '42',
Expand All @@ -26,10 +25,10 @@ export class StClientLibService {
}

public isFeatureEnabled(key: string): boolean {
return Statsig.checkGate(key);
return StatsigRoot.default.checkGate(key);
}

public getExperiment(experimentName: string): DynamicConfig {
return Statsig.getExperiment(experimentName);;
return StatsigRoot.default.getExperiment(experimentName);;
}
}
4 changes: 3 additions & 1 deletion projects/st-client-lib/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
"declaration": true,
"declarationMap": true,
"inlineSources": true,
"allowSyntheticDefaultImports": true,
"types": []
},
"exclude": [
"src/test.ts",
"**/*.spec.ts"
]
],
"include": ["**/*.ts"]
}
3 changes: 2 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component } from '@angular/core';
import { StService } from './statsig.service';
import { StClientLibService } from 'st-client-lib';


@Component({
selector: 'app-root',
templateUrl: './app.component.html',
Expand All @@ -22,7 +23,7 @@ export class AppComponent {
}

public async initDepsStatsig() {
await this.depsStatsigService.statsigInit('');
await this.depsStatsigService.statsigInit('client-C1rOhOyc5O1TqQIpY3MCp5wCtjfxlXMsUvQSTnKqPi4');
}

public getDepsExperiment(experimentName: string) {
Expand Down
9 changes: 5 additions & 4 deletions src/app/statsig.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Injectable } from '@angular/core';
import Statsig, { DynamicConfig } from 'statsig-js';
import * as Statsig from 'statsig-js';
import { DynamicConfig } from 'statsig-js';

@Injectable({
providedIn: 'root'
Expand All @@ -9,7 +10,7 @@ export class StService {
constructor() { }

public async statsigInit(): Promise<void> {
Statsig.initialize(
Statsig.default.initialize(
'client-C1rOhOyc5O1TqQIpY3MCp5wCtjfxlXMsUvQSTnKqPi4',
{
appVersion: '42',
Expand All @@ -26,10 +27,10 @@ export class StService {
}

public isFeatureEnabled(key: string): boolean {
return Statsig.checkGate(key);
return Statsig.default.checkGate(key);
}

public getExperiment(experimentName: string): DynamicConfig {
return Statsig.getExperiment(experimentName);;
return Statsig.default.getExperiment(experimentName);;
}
}
11 changes: 5 additions & 6 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "es2020",
"paths": {
"st-client-lib": [
"dist/st-client-lib"
]
},
"module": "es2020",
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"allowSyntheticDefaultImports": true,
"module": "esnext",
"lib": [
"es2020",
"dom"
Expand Down

0 comments on commit 087727d

Please sign in to comment.