Skip to content

Commit 052d3c3

Browse files
authored
Merge pull request #7 from AppsFlyerSDK/osValidation
Os validation
2 parents fe94266 + 510ee92 commit 052d3c3

36 files changed

+711
-375
lines changed

README.md

Lines changed: 33 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
1313
### <a id="plugin-build-for"> This SDK is built for
1414

15-
- <img src="https://github.com/AppsFlyerSDK/AppsFlyerSDK-appsflyer-html5-ctv-sdk/blob/main/images/tizen.png?raw=true" alt="drawing" width="15"/> Samsung Tizen
16-
- <img src="https://github.com/AppsFlyerSDK/AppsFlyerSDK-appsflyer-html5-ctv-sdk/blob/main/images/lg.png?raw=true" alt="drawing" width="15"/> LG Webos
15+
- <img src="https://github.com/AppsFlyerSDK/AppsFlyerSDK-appsflyer-html5-ctv-sdk/blob/main/images/tizen.png?raw=true" alt="drawing" width="15"/> Samsung (Tizen 4 & above)
16+
- <img src="https://github.com/AppsFlyerSDK/AppsFlyerSDK-appsflyer-html5-ctv-sdk/blob/main/images/lg.png?raw=true" alt="drawing" width="15"/> LG (Webos 4 & above)
17+
- VIZIO & Vidaa. [Please follow the implementation guide](/docs/other-platforms.md)
18+
1719

1820
## 📖 Guides
1921
- [Adding the SDK to your project](#installation)
@@ -22,12 +24,19 @@
2224
- [Platforms dependecy](#platform-dependency)
2325
- [Samsung](#samsung)
2426
- [LG](#lg)
25-
- [Initializing the SDK](#integration)
26-
- [Launch event](#launch)
27-
- [In-app Events](#inappevents)
28-
- [Testing the integration](#testing)
29-
- [Response codes](#response-codes)
30-
- [Sample App](#demo)
27+
- [Support for other platforms](/docs/other-platforms.md)
28+
- [Basic implemantation of the SDK](#integration)
29+
- [API](/docs/api.md)
30+
- [AppsFlyerSDK initialization](/docs/api.md#newAppsflyerSdk)
31+
- [Start](/docs/api.md#start)
32+
- [In-app events](/docs/api.md#inappevents)
33+
- [Set custom payload](/docs/api.md#setCustomPayload)
34+
- [Set customer user Id](/docs/api.md#setCustomerUserId)
35+
- [Init (Deprecated!)](/docs/api.md#init)
36+
- [Testing the integration](/docs/testing.md)
37+
- [Logs](/docs/testing.md#logs)
38+
- [Response codes](/docs/testing.md#response-codes)
39+
- [Sample App](/docs/testing.md#demo)
3140

3241

3342
#
@@ -52,7 +61,7 @@ Download the appsflyerSdk.bundle.js file from [here](dist/appsflyerSdk.bundle.js
5261
<script src="[bundle-js-location]"></script>
5362
```
5463

55-
## <a id="platform-dependency"> Platforms dependecy
64+
## <a id="platform-dependency"> Platform dependency
5665

5766
In order for the SDK to fetch device data from the relevant platform, make sure to follow the following instructions:
5867

@@ -82,120 +91,31 @@ In order for the SDK to fetch device data from the relevant platform, make sure
8291
<script type="text/javascript" src="[webOSTVjs-1.2.4-directory]"></script>
8392
```
8493

85-
86-
## <a id="integration"> 🚀 Initializing the SDK
94+
## <a id="integration"> 🚀 Basic implemantation of the SDK
8795

8896
Initialize the SDK to enable AppsFlyer to detect installations, sessions (app opens) and updates.<br>
8997

9098
```javascript
9199
import AppsFlyerSDK from 'appsflyer-html5-ctv-sdk'
92100

93-
let appsflyer = new AppsFlyerSDK();
101+
let appsflyer;
94102
let config = {
95103
devKey: "RxutGo4bSB9MKkM7bMCjHP",
96104
appId: "3202204027284",
97105
isDebug: true,
98106
isSandbox: false
99107
}
100108

101-
await appsflyer.init(config);
102-
103-
```
104-
105-
| Setting | Description |
106-
| -------- | ------------- |
107-
| devKey | Your application [devKey](https://support.appsflyer.com/hc/en-us/articles/207032066-Basic-SDK-integration-guide#retrieving-the-dev-key) provided by AppsFlyer (required) |
108-
| appId | [App ID](https://support.appsflyer.com/hc/en-us/articles/207377436-Adding-a-new-app#available-in-the-app-store-google-play-store-windows-phone-store) you configured in your AppsFlyer dashboard (required) |
109-
| isDebug | Show Debug logs - set to `true` for testing only! |
110-
| isSandbox | Send events to sandbox endpoints - set to `true` for testing only! |
111-
112-
113-
## <a id="launch"> Launch event
114-
115-
```javascript
116-
appsflyer.start()
117-
.then((response)=>{
118-
console.log("start API response success: " + JSON.stringify(response));
119-
}).catch((err)=>{
120-
console.log("start API response err: " + JSON.stringify(err));
121-
});
122-
```
123-
124-
125-
## <a id="inappevents"> In-app events
126-
127-
**<a id="logEvent"> `logEvent(String eventName, Object eventValues)`**
128-
129-
| parameter | type | description |
130-
| ----------- |----------|------------------------------------------ |
131-
| eventName | String | The event name, it is presented in your dashboard. |
132-
| eventValues | Object | The event values that are sent with the event. |
133-
134-
```javascript
135-
appsflyer.logEvent("af_purchase", {"af_revenue" : 1.99, "af_currency": "USD"})
136-
.then((response)=>{
137-
console.log("logEvent API response success: " + JSON.stringify(response));
138-
}).catch((err)=>{
139-
console.log("logEvent API response err: " + JSON.stringify(err));
140-
});
141-
```
142-
143-
## <a id="testing"> Testing the integration
144-
145-
- In order to check a succesful integration of the AppsFlyer SDK, please enable `isDebug` option to `true`;
146-
147-
- The following request should be sent:
148-
149-
```
150-
// launch request:
151-
152-
AppsFlyerSDK :: Sending start request
153-
AppsFlyerSDK :: https://events.appsflyer.com/v1.0/c2s/session/app/tizen/3202204027284
154-
AppsFlyerSDK :: {"device_ids":[{"type":"custom","value":"c6577bb9-d4d1-4adf-809e-c3abf7c76b58"}],"limit_ad_tracking":true,"device_model":"UKS9000","device_os_version":"5.0","customer_user_id":"15667737-366d-4994-ac8b-653fe6b2be4a","app_version":"1.0.5","request_id":"aa64ea40-6cda-4fde-b4c5-31f600e1b50f","timestamp":1662035187532}
155-
156-
// logEvent request:
157-
AppsFlyerSDK :: Sending logEvent request
158-
AppsFlyerSDK :: https://events.appsflyer.com/v1.0/c2s/inapp/app/tizen/3202204027284
159-
AppsFlyerSDK :: {"device_ids":[{"type":"custom","value":"c6577bb9-d4d1-4adf-809e-c3abf7c76b58"}],"limit_ad_tracking":true,"device_model":"UKS9000","device_os_version":"5.0","customer_user_id":"15667737-366d-4994-ac8b-653fe6b2be4a","app_version":"1.0.5","request_id":"c55bb0fe-fed5-4c02-8e5d-c6031f56ecaf","timestamp":1662035187534,"event_name":"af_purchase","event_parameters":{"af_revenue":1.99,"af_currency":"USD"}}
160-
161-
```
162-
163-
164-
- Check the response code is 202/200
165-
166-
```
167-
AppsFlyerSDK :: start request success with status code: 202 Message: Success
168-
AppsFlyerSDK :: logEvent request success with status code: 202 Message: Success
169-
```
170-
171-
### <a id="response-codes"> Response codes
172-
173-
| response code | description |
174-
| ----------- |------------------------------------------ |
175-
| 200/202 | Successful |
176-
| 400 | In case the authentication succeeded, if any of the mandatory fields in the message body are missing, or if any of the fields are invalid|
177-
| 401 | If the app doesn’t exist or the authentication failed |
178-
| 403 | In case app traffic should be blocked due to Zero package limit |
179-
| 404 | network error |
180-
181-
## <a id="demo"> Sample app
182-
183-
Try our demo app!
184-
185-
1. Clone the repo
186-
187-
2. Comment/uncomment the relevant config file for the relevant platform in example/main.js (LG/SAMSUNG)
188-
189-
3. Execute the following:
190-
191-
```bash
192-
$ yarn buildDev
193-
```
194-
195-
Open and run the following directory from your emulator/simulator or real device:
196-
197-
```
198-
appsflyer-html5-ctv-sdk/example/app
199-
```
200-
201-
![demo printscreen](https://github.com/AppsFlyerSDK/AppsFlyerSDK-appsflyer-html5-ctv-sdk/blob/main/images/demo.png?raw=true)
109+
try{
110+
appsflyer = await new AppsFlyerSDK(config);
111+
}catch(e){
112+
console.log("AppsFlyerSDK initialization failed. Error " + e);
113+
}
114+
115+
try{
116+
let response = await appsflyer.start();
117+
console.log("start API response success: " + JSON.stringify(response));
118+
}catch(err){
119+
console.log("start API response err: " + JSON.stringify(err));
120+
}
121+
```

__tests__/mock/responses.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export const MOCK_SUCCESS_RESPONSE = {
2-
"message": "Request Succeed",
2+
"message": "Success",
33
"status": 200,
44
}
55
export const MOCK_FAILED_RESPONSE = {

__tests__/publicAPIs/init.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const dataSetBadInputs = [
3030

3131
describe.each(Platforms)("Init API", (config, payload) => {
3232
beforeAll(async () => {
33-
appsflyer = AppsFlyerCore.prototype.getInstance();
33+
appsflyer = AppsFlyerCore;
3434
await appsflyer.init(config, payload);
3535
})
3636

@@ -48,7 +48,7 @@ describe.each(Platforms)("Init API", (config, payload) => {
4848

4949
describe("Init wrong config", (_, payload) => {
5050
beforeAll(async () => {
51-
appsflyer = AppsFlyerCore.prototype.getInstance();
51+
appsflyer = AppsFlyerCore;
5252
})
5353

5454
it.each(dataSetBadInputs)("Bad inputs", async (config, expectedErr) => {

__tests__/publicAPIs/logEvent.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const dataSet = [
2020
describe.each(Platforms)("Log event API ", (config, payload) => {
2121
beforeAll(async () => {
2222
fetch.resetMocks();
23-
appsflyer = AppsFlyerCore.prototype.getInstance();
23+
appsflyer = AppsFlyerCore;
2424
await appsflyer.init(config, payload);
2525
timesBeingCalled = 1;
2626
})

__tests__/publicAPIs/setCustomPayload.test.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const dataSet = [
2222

2323
describe.each(Platforms)("setCustomPayload API ", (config, payload) => {
2424
beforeAll(async () => {
25-
appsflyer = AppsFlyerCore.prototype.getInstance();
25+
appsflyer = AppsFlyerCore;
2626
await appsflyer.init(config, payload);
2727
})
2828

@@ -44,18 +44,18 @@ describe.each(Platforms)("setCustomPayload API ", (config, payload) => {
4444
}
4545
});
4646

47-
it.each(dataSetBadInput)("setCustomPayload not overriding exsiting inputs", (additionalPayload) => {
48-
let payload;
49-
try {
50-
response = appsflyer.setCustomPayload(additionalPayload);
51-
payload = appsflyer.payload;
52-
} catch(err){
53-
response = err
54-
};
47+
// it.each(dataSetBadInput)("setCustomPayload not overriding exsiting inputs", (additionalPayload) => {
48+
// let payload;
49+
// try {
50+
// response = appsflyer.setCustomPayload(additionalPayload);
51+
// payload = appsflyer.payload;
52+
// } catch(err){
53+
// response = err
54+
// };
5555

56-
Object.keys(additionalPayload).forEach((key) => {
57-
expect(payload[key]).not.toEqual(additionalPayload[key]);
58-
})
59-
});
56+
// Object.keys(additionalPayload).forEach((key) => {
57+
// expect(payload[key]).not.toEqual(additionalPayload[key]);
58+
// })
59+
// });
6060
})
6161

__tests__/publicAPIs/setCustomerUserId.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const dataSet = [
1616

1717
describe.each(Platforms)("setCustomerUserId API ", (config, payload) => {
1818
beforeAll(async () => {
19-
appsflyer = AppsFlyerCore.prototype.getInstance();
19+
appsflyer = AppsFlyerCore;
2020
await appsflyer.init(config, payload);
2121
})
2222

__tests__/publicAPIs/start.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jest.setTimeout(7000)
88
describe.each(Platforms)("Start API", (config, payload) => {
99
beforeAll(async () => {
1010
fetch.resetMocks();
11-
appsflyer = AppsFlyerCore.prototype.getInstance();
11+
appsflyer = AppsFlyerCore;
1212
await appsflyer.init(config, payload);
1313
})
1414

__tests__/request/request.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe.each(Platforms)("Test endpoints", (config, payload) => {
99
global.localStorage.setItem('appsflyer', '{"sessionCount":0,"appsflyerID":""}')
1010
appId = config.appId;
1111
platformType = payload.platform;
12-
appsflyer = AppsFlyerCore.prototype.getInstance();
12+
appsflyer = AppsFlyerCore;
1313
await appsflyer.init(config, payload);
1414

1515
// define endpoints

babel.config.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["@babel/preset-env"]
3+
}

dist/appsflyerSdk.bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)