Skip to content

Commit

Permalink
feat: updated profile api's (#450)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jess6569 authored May 12, 2022
1 parent 5093024 commit 4582267
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"kissmetrics",
"segment",
"amplitude",
"baidu"
"baidu",
"pyze"
],
"ngPackage": {
"lib": {
Expand Down
8 changes: 4 additions & 4 deletions src/lib/providers/pyze/pyze.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ describe('Angulartics2Pyze', () => {
postCustomEventWithAttributes: jasmine.createSpy('postCustomEventWithAttributes'),
};
window.PyzeIdentity = PyzeIdentity = {
setUserIdentifier: jasmine.createSpy('setUserIdentifier'),
postTraits: jasmine.createSpy('postTraits'),
setUserProfile: jasmine.createSpy('setUserProfile'),
updateUserProfile: jasmine.createSpy('updateUserProfile'),
};

const provider: Angulartics2Pyze = TestBed.inject(Angulartics2Pyze);
Expand Down Expand Up @@ -73,7 +73,7 @@ describe('Angulartics2Pyze', () => {
fixture = createRoot(RootCmp);
angulartics2.setUsername.next('testId');
advance(fixture);
expect(PyzeIdentity.setUserIdentifier).toHaveBeenCalledWith('testId');
expect(PyzeIdentity.setUserProfile).toHaveBeenCalledWith('testId');
},
),
));
Expand All @@ -89,7 +89,7 @@ describe('Angulartics2Pyze', () => {
lastName: 'Lobo',
});
advance(fixture);
expect(PyzeIdentity.postTraits).toHaveBeenCalledWith({
expect(PyzeIdentity.updateUserProfile).toHaveBeenCalledWith({},{
userId: 'testId',
firstName: 'Jess',
lastName: 'Lobo',
Expand Down
12 changes: 6 additions & 6 deletions src/lib/providers/pyze/pyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ declare var PyzeIdentity: any;
@Injectable({ providedIn: 'root' })
export class Angulartics2Pyze {
constructor(private angulartics2: Angulartics2) {
this.angulartics2.setUsername.subscribe((x: string) => this.setUserId(x));
this.angulartics2.setUserProperties.subscribe(x => this.postTraits(x));
this.angulartics2.setUsername.subscribe((x: string) => this.setUserProfile(x));
this.angulartics2.setUserProperties.subscribe(x => this.updateUserProfile(x));
}

startTracking(): void {
Expand Down Expand Up @@ -42,19 +42,19 @@ export class Angulartics2Pyze {
}
}

setUserId(userId: string) {
setUserProfile(userId: string) {
try {
PyzeIdentity.setUserIdentifier(userId);
PyzeIdentity.setUserProfile(userId);
} catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
}
}
}

postTraits(properties: string) {
updateUserProfile(properties: string) {
try {
PyzeIdentity.postTraits(properties);
PyzeIdentity.updateUserProfile({},properties)
} catch (e) {
if (!(e instanceof ReferenceError)) {
throw e;
Expand Down

0 comments on commit 4582267

Please sign in to comment.