Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 4eb1f5a

Browse files
cleanup
1 parent eb9e07a commit 4eb1f5a

File tree

5 files changed

+68
-62
lines changed

5 files changed

+68
-62
lines changed

.travis.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
branches:
22
only:
33
- master
4+
45
matrix:
56
include:
67
- stage: "Lint"
78
language: node_js
89
os: linux
910
node_js: "8"
1011
script: "npm run ci.tslint"
11-
- stage: "Webpack"
12+
- stage: "WebPack"
1213
os: osx
1314
env:
14-
- Webpack="iOS"
15-
osx_image: xcode10
15+
- WebPack="iOS"
16+
osx_image: xcode10.0
1617
language: node_js
1718
node_js: "8"
1819
jdk: oraclejdk8
@@ -23,13 +24,13 @@ matrix:
2324
- language: android
2425
os: linux
2526
env:
26-
- Webpack="Android"
27+
- WebPack="Android"
2728
jdk: oraclejdk8
28-
before_install: nvm install stable
29+
before_install: nvm install 8
2930
script: travis_wait travis_retry tns build android --bundle
3031
- stage: "Build"
3132
env:
32-
- BuildAndroid="26"
33+
- BuildAndroid="28"
3334
language: android
3435
os: linux
3536
jdk: oraclejdk8
@@ -40,7 +41,7 @@ matrix:
4041
env:
4142
- BuildiOS="12"
4243
- Xcode="10.0"
43-
osx_image: xcode10
44+
osx_image: xcode10.0
4445
language: node_js
4546
node_js: "8"
4647
jdk: oraclejdk8
@@ -57,6 +58,7 @@ android:
5758
- build-tools-28.0.3
5859
- android-28
5960
- extra-android-m2repository
61+
- sys-img-armeabi-v7a-android-21
6062

6163
before_install:
6264
- sudo pip install --upgrade pip

demo/app/main-page.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
<Button row="31" col="0" text="collection on" tap="{{ doEnableAnalytics }}" class="button button-analytics"/>
177177
<Button row="31" col="1" text="collection off" tap="{{ doDisableAnalytics }}" class="button button-analytics"/>
178178

179-
<Button row="32" col="0" text="log event" tap="{{ doLogAnalyticsEvent }}" class="button button-analytics"/>
179+
<Button row="32" col="0" text="log events" tap="{{ doLogAnalyticsEvents }}" class="button button-analytics"/>
180180
<Button row="32" col="1" text="set user property" tap="{{ doSetAnalyticsUserProperty }}" class="button button-analytics"/>
181181

182182
<Button row="33" col="0" text="set Screen A" tap="{{ doSetScreenNameA }}" class="button button-analytics"/>

demo/app/main-view-model.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ export class HelloWorldModel extends Observable {
477477
});
478478
}
479479

480-
public doLogAnalyticsEvent(): void {
480+
public doLogAnalyticsEvents(): void {
481481
firebase.analytics.logEvent({
482482
// see https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html
483483
key: "add_to_cart",
@@ -517,31 +517,29 @@ export class HelloWorldModel extends Observable {
517517
value: [
518518
{
519519
parameters: [
520-
{ key: "item_id", value: "id of item", type: LogComplexEventTypeParameter.STRING},
520+
{key: "item_id", value: "id of item", type: LogComplexEventTypeParameter.STRING},
521521
{key: "item_name", value: "name of item", type: LogComplexEventTypeParameter.STRING},
522522
{key: "item_category", value: "category", type: LogComplexEventTypeParameter.STRING},
523523
{key: "item_variant", value: "variant", type: LogComplexEventTypeParameter.STRING},
524524
{key: "item_brand", value: "name of item brand", type: LogComplexEventTypeParameter.STRING},
525-
{key: "price", value: 1 , type: LogComplexEventTypeParameter.DOUBLE},
526-
{key: "item_list", value: "name of list" , type: LogComplexEventTypeParameter.STRING },
527-
{key: "index", value: 1 , type: LogComplexEventTypeParameter.INT}
528-
525+
{key: "price", value: 1, type: LogComplexEventTypeParameter.DOUBLE},
526+
{key: "item_list", value: "name of list", type: LogComplexEventTypeParameter.STRING},
527+
{key: "index", value: 1, type: LogComplexEventTypeParameter.INT}
529528
]
530529
},
531530
{
532531
parameters: [
533-
{ key: "item_id", value: "id of item", type: LogComplexEventTypeParameter.STRING},
532+
{key: "item_id", value: "id of item", type: LogComplexEventTypeParameter.STRING},
534533
{key: "item_name", value: "name of item", type: LogComplexEventTypeParameter.STRING},
535534
{key: "item_category", value: "category", type: LogComplexEventTypeParameter.STRING},
536535
{key: "item_variant", value: "variant", type: LogComplexEventTypeParameter.STRING},
537536
{key: "item_brand", value: "name of item brand", type: LogComplexEventTypeParameter.STRING},
538-
{key: "price", value: 1 , type: LogComplexEventTypeParameter.DOUBLE},
539-
{key: "item_list", value: "name of list" , type: LogComplexEventTypeParameter.STRING },
540-
{key: "index", value: 2 , type: LogComplexEventTypeParameter.INT}
541-
537+
{key: "price", value: 1, type: LogComplexEventTypeParameter.DOUBLE},
538+
{key: "item_list", value: "name of list", type: LogComplexEventTypeParameter.STRING},
539+
{key: "index", value: 2, type: LogComplexEventTypeParameter.INT}
542540
]
543541
}
544-
]
542+
]
545543
}]
546544
});
547545

@@ -1805,4 +1803,4 @@ export class HelloWorldModel extends Observable {
18051803
okButtonText: "Okay"
18061804
});
18071805
}
1808-
}
1806+
}

src/analytics/analytics.android.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import * as appModule from "tns-core-modules/application";
2-
import { LogEventOptions, SetScreenNameOptions, SetUserPropertyOptions, LogComplexEventOptions, LogComplexEventParameter } from "./analytics";
3-
import { LogComplexEventTypeParameter } from "../firebase";
2+
import {
3+
LogEventOptions,
4+
SetScreenNameOptions,
5+
SetUserPropertyOptions,
6+
LogComplexEventOptions,
7+
LogComplexEventParameter
8+
} from "./analytics";
49

510
declare const com: any;
611

@@ -54,23 +59,18 @@ function buildBundle(params: Array<LogComplexEventParameter>): android.os.Bundle
5459
const param = params[p];
5560
if (param.value !== undefined) {
5661
if (param.type === "string") {
57-
bundle.putString(param.key, param.value);
62+
bundle.putString(param.key, param.value);
5863
} else if (param.type === "double") {
5964
bundle.putDouble(param.key, param.value);
60-
}
61-
else if (param.type === "float") {
65+
} else if (param.type === "float") {
6266
bundle.putFloat(param.key, param.value);
63-
}
64-
else if (param.type === "int") {
67+
} else if (param.type === "int") {
6568
bundle.putInt(param.key, param.value);
66-
}
67-
else if (param.type === "long") {
69+
} else if (param.type === "long") {
6870
bundle.putLong(param.key, param.value);
69-
}
70-
else if (param.type === "boolean") {
71+
} else if (param.type === "boolean") {
7172
bundle.putBoolean(param.key, param.value);
72-
}
73-
else if (param.type === "array") {
73+
} else if (param.type === "array") {
7474
bundle.putParcelableArrayList(param.key, getArrayList(param.value));
7575
}
7676
// bundle.putString(param.key, param.value);

src/analytics/analytics.ios.ts

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { LogEventOptions, SetScreenNameOptions, SetUserPropertyOptions, LogComplexEventOptions, LogComplexEventParameter } from "./analytics";
1+
import {
2+
LogEventOptions,
3+
SetScreenNameOptions,
4+
SetUserPropertyOptions,
5+
LogComplexEventOptions
6+
} from "./analytics";
27

38
export function logEvent(options: LogEventOptions): Promise<void> {
49
return new Promise<void>((resolve, reject) => {
@@ -27,6 +32,7 @@ export function logEvent(options: LogEventOptions): Promise<void> {
2732
}
2833
});
2934
}
35+
3036
/*
3137
function getArrayList(array: Array<LogComplexEventOptions>): Array<NSMutableDictionary<string, any>> {
3238
let returnArray: Array<NSMutableDictionary<string, any>> = new Array();
@@ -112,40 +118,40 @@ export function logComplexEvent(options: LogComplexEventOptions): Promise<void>
112118

113119

114120
export function logComplexEvent(options: LogComplexEventOptions): Promise<void> {
115-
return new Promise<void>((resolve, reject) => {
116-
try {
117-
const dic: any = NSMutableDictionary.new();
118-
if (options.parameters !== undefined) {
119-
for (let p in options.parameters) {
120-
const param = options.parameters[p];
121-
if (param.type === "array" && param.value !== undefined ) {
122-
const listArray = new Array();
123-
for (let val in param.value) {
124-
const value = param.value[val];
125-
if (value.parameters !== undefined) {
126-
const dicTemp: any = NSMutableDictionary.new();
127-
for (let i in value.parameters) {
128-
const item = value.parameters[i];
129-
if (item.type !== "array" && item.value !== undefined && item.key !== undefined ) {
130-
dicTemp.setObjectForKey(item.value, item.key);
131-
}
121+
return new Promise<void>((resolve, reject) => {
122+
try {
123+
const dic: any = NSMutableDictionary.new();
124+
if (options.parameters !== undefined) {
125+
for (let p in options.parameters) {
126+
const param = options.parameters[p];
127+
if (param.type === "array" && param.value !== undefined) {
128+
const listArray = new Array();
129+
for (let val in param.value) {
130+
const value = param.value[val];
131+
if (value.parameters !== undefined) {
132+
const dicTemp: any = NSMutableDictionary.new();
133+
for (let i in value.parameters) {
134+
const item = value.parameters[i];
135+
if (item.type !== "array" && item.value !== undefined && item.key !== undefined) {
136+
dicTemp.setObjectForKey(item.value, item.key);
132137
}
133-
listArray.push(dicTemp);
134138
}
139+
listArray.push(dicTemp);
135140
}
136-
dic.setObjectForKey(listArray, param.key);
137-
} else if (param.type === "string" || param.type === "double" || param.type === "float" || param.type === "int" || param.type === "long" || param.type === "boolean") {
138-
dic.setObjectForKey(param.value, param.key);
139141
}
142+
dic.setObjectForKey(listArray, param.key);
143+
} else if (param.type === "string" || param.type === "double" || param.type === "float" || param.type === "int" || param.type === "long" || param.type === "boolean") {
144+
dic.setObjectForKey(param.value, param.key);
140145
}
141146
}
142-
FIRAnalytics.logEventWithNameParameters(options.key, dic);
143-
resolve();
144-
} catch (ex) {
145-
console.log("Error in firebase.analytics.logEvent: " + ex);
146-
reject(ex);
147147
}
148-
});
148+
FIRAnalytics.logEventWithNameParameters(options.key, dic);
149+
resolve();
150+
} catch (ex) {
151+
console.log("Error in firebase.analytics.logEvent: " + ex);
152+
reject(ex);
153+
}
154+
});
149155
}
150156

151157

0 commit comments

Comments
 (0)