adjust / web_sdk

40 stars 25 forks source link

Can't call https://app.adjust.com/session #29

Closed PVARS closed 2 years ago

PVARS commented 2 years ago

Why don't call /session after initialisation adjust package from

npm install @adjustcom/adjust-web-sdk --save

image image

alkismavridis commented 2 years ago

Is this issue really closed? I am also affected. I am sure that the call to Adjust.initSdk({...}) is performed. The appToken is not empty.

And still, I see no request being sent to https://app.adjust.com/session and I get the same log message that is shown on the screenshot. The message appears every time I call Adjust.trackEvent({...})

image

YaraMatkova commented 2 years ago

Hi @alkismavridis, this log mean that session request was sent but for some reason it was not successful. And until first session tracked the SDK can't send events because backend will reject them anyway. Could you please use Incognito mode to check result of session request at the Network tab of browser development tools and share it?

alkismavridis commented 2 years ago

Hi Yaroslavna. Thanks for the quick reply! I just tested this in incognito and got the same behaviour. I see no network activity to the /session endpoint. Actually, I see no traffic towards Adjust whatsoever.

alkismavridis commented 2 years ago

I am in running this from localhost, in case this makes a difference. Adjust version: 5.2.1 (installed by npm)

YaraMatkova commented 2 years ago

@alkismavridis it should work the same when testing with localhost. Just for me to be sure could you confirm that you open Network tab first and then load your web application so all the requests are caught? Also if there are a lot of requests you could apply filtering on Network tab.

alkismavridis commented 2 years ago

@YaroslavnaMatkova sure, I made sure that all requests are captured. And also applied filtering.

YaraMatkova commented 2 years ago

Hey Alkis, could you please share verbose logs from incognito browser session? If you see any errors in console those might be related to the SDK please let me know. Also could you share more info about your environment and browser? Does this behaviour reproduce in any other browser? Thank you!

alkismavridis commented 2 years ago

Good day Yaroslavna! So, I think I found some factor that changes the behaviour. All of the samples I will give you are in Incognito windows of Chromium.

When There is not an Indexed DB set by you (for example, after I delete it), I get the followign logs and a request to /session endpoint is indeed performed:

[adjust-sdk] 2022-03-17T09:23:16.461Z INFO:  Log level set to verbose
GlobalModule.ts:125 [PWA Builder] active service worker found, no need to register
fbevents.js:24 [Meta Pixel] - Invalid PixelID: null.
t @ fbevents.js:24
w @ fbevents.js:24
E @ fbevents.js:24
e @ fbevents.js:24
Y @ fbevents.js:27
X @ fbevents.js:27
ta @ fbevents.js:27
(anonymous) @ fbevents.js:27
(anonymous) @ fbevents.js:24
v @ fbevents.js:24
each @ fbevents.js:24
value @ fbevents.js:24
value @ fbevents.js:24
value @ fbevents.js:24
plugin @ fbevents.js:32
value @ fbevents.js:24
a.registerPlugin @ fbevents.js:27
(anonymous) @ fbevents.js:28
austria:60          GET https://www.googletagmanager.com/gtm.js?id= net::ERR_ABORTED 400
(anonymous) @ austria:60
(anonymous) @ austria:61
adjust-latest.js:2923 [adjust-sdk] 2022-03-17T09:23:16.592Z INFO:  Available storage is indexedDB
adjust-latest.js:2923 [adjust-sdk] 2022-03-17T09:23:16.606Z LOG:   Adjust SDK is starting with web_uuid set to 7cb5f72e-d613-4a55-ac04-d53cfdcbb228
adjust-latest.js:2923 [adjust-sdk] 2022-03-17T09:23:16.616Z LOG:   Trying request /session in 150ms
adjust-latest.js:2923 [adjust-sdk] 2022-03-17T09:23:16.774Z LOG:   REQUEST PARAMETERS:
adjust-latest.js:2923 [adjust-sdk] 2022-03-17T09:23:16.775Z LOG:   app_token         : bjm3rxxlm7eo
adjust-latest.js:2923 [adjust-sdk] 2022-03-17T09:23:16.776Z LOG:   environment       : production
adjust-latest.js:2923 [adjust-sdk] 2022-03-17T09:23:16.776Z LOG:   created_at        : 2022-03-17T10:23:16.609Z+0100
adjust-latest.js:2923 [adjust-sdk] 2022-03-17T09:23:16.777Z LOG:   sent_at           : 2022-03-17T10:23:16.772Z+0100
adjust-latest.js:2923 [adjust-sdk] 2022-03-17T09:23:16.777Z LOG:   web_uuid          : 7cb5f72e-d613-4a55-ac04-d53cfdcbb228
adjust-latest.js:2923 [adjust-sdk] 2022-03-17T09:23:16.777Z LOG:   platform          : web
adjust-latest.js:2923 [adjust-sdk] 2022-03-17T09:23:16.778Z LOG:   language          : en
adjust-latest.js:2923 [adjust-sdk] 2022-03-17T09:23:16.778Z LOG:   country           : us
adjust-latest.js:2923 [adjust-sdk] 2022-03-17T09:23:16.779Z LOG:   machine_type      : Linux x86_64
adjust-latest.js:2923 [adjust-sdk] 2022-03-17T09:23:16.779Z LOG:   queue_size        : 1
adjust-latest.js:2923 [adjust-sdk] 2022-03-17T09:23:16.779Z LOG:   attempts          : 1
adjust-latest.js:2923 [adjust-sdk] 2022-03-17T09:23:16.780Z LOG:   time_spent        : 0
adjust-latest.js:2923 [adjust-sdk] 2022-03-17T09:23:16.780Z LOG:   session_length    : 0
adjust-latest.js:2923 [adjust-sdk] 2022-03-17T09:23:16.781Z LOG:   session_count     : 1
adjust-latest.js:2923 [adjust-sdk] 2022-03-17T09:23:16.781Z LOG:   last_interval     : 0
adjust-latest.js:2923 [adjust-sdk] 2022-03-17T09:23:16.782Z LOG:   REQUEST HEADERS:
adjust-latest.js:2923 [adjust-sdk] 2022-03-17T09:23:16.783Z LOG:   Client-SDK     : js5.2.1
adjust-latest.js:2923 [adjust-sdk] 2022-03-17T09:23:16.783Z LOG:   Content-Type   : application/x-www-form-urlencoded
adjust-latest.js:7756          POST https://app.adjust.com/session 400 (Bad Request)
(anonymous) @ adjust-latest.js:7756
_buildXhr @ adjust-latest.js:7739
(anonymous) @ adjust-latest.js:7766
trySendRequest @ adjust-latest.js:7408
urlStrategyRetries @ adjust-latest.js:7423
_sendRequestWithUrlStrategyRetries @ adjust-latest.js:7765
(anonymous) @ adjust-latest.js:7853
Promise.then (async)
http @ adjust-latest.js:7852
(anonymous) @ adjust-latest.js:8449
setTimeout (async)
(anonymous) @ adjust-latest.js:8441
_request @ adjust-latest.js:8440
_preRequest @ adjust-latest.js:8415
_prepareRequest @ adjust-latest.js:8390
send @ adjust-latest.js:8606
_prepareToSend @ adjust-latest.js:9295
(anonymous) @ adjust-latest.js:9353
Promise.then (async)
run @ adjust-latest.js:9352
main_continue @ adjust-latest.js:11998
Promise.then (async)
_start @ adjust-latest.js:12095
(anonymous) @ adjust-latest.js:11635
Promise.then (async)
initSdk @ adjust-latest.js:11626
init @ AdjustTracker.ts:7
initTracking @ ExternalTracking.ts:19
(anonymous) @ GlobalModule.ts:16
(anonymous) @ main.esmodule.js:23519
(anonymous) @ main.esmodule.js:23520
adjust-latest.js:2923 [adjust-sdk] 2022-03-17T09:23:16.945Z LOG:   Request /session has been finished
adjust-latest.js:2923 [adjust-sdk] 2022-03-17T09:23:26.510Z LOG:   Running track event is delayed until Adjust SDK is up

Every subsequent attempt to refresh the page (as long as the Indexed DB is there) produces the following logs and no request to /session endpoint is attempted.

[adjust-sdk] 2022-03-17T09:26:28.973Z INFO:  Log level set to verbose
GlobalModule.ts:125 [PWA Builder] active service worker found, no need to register
austria:60          GET https://www.googletagmanager.com/gtm.js?id= net::ERR_ABORTED 400
(anonymous) @ austria:60
(anonymous) @ austria:61
adjust-latest.js:2923 [adjust-sdk] 2022-03-17T09:26:29.085Z INFO:  Available storage is indexedDB
adjust-latest.js:2923 [adjust-sdk] 2022-03-17T09:26:29.090Z LOG:   Adjust SDK is starting with web_uuid set to 7cb5f72e-d613-4a55-ac04-d53cfdcbb228
adjust-latest.js:2923 [adjust-sdk] 2022-03-17T09:26:39.027Z LOG:   Running track event is delayed until Adjust SDK is up

So question 1: can it be the case that you stop trying to contact /session endpoint after one failed attempt? Do you maybe store something in IndexedDB that causes that behaviour?

Question 2: Why does the request to /session fail in the first place? I get the following error in the response: Session failed (tracking disabled) (app_token:bjm3rxxlm7eo) (platform:web). Is there some setting we should do in Adjust Dashboard?

Thanks a lot!

YaraMatkova commented 2 years ago

Yes, after /session request finished the SDK won't send it again for some time, no matters was it successful or not.

Unfortunately it's not possible to enable Web Tracking in the Dashboard so you would need to contact your Adjust Account Manager or Customer Success Manager so that they can enable Web Tracking for you. Thank you for your understanding.

alkismavridis commented 2 years ago

Great Yaroslavna, it all makes sense now, I contacted your Solutions Consultant and we are waiting for the activation. One last question. When you say "for some time", how long that is?

alkismavridis commented 2 years ago

Hi there again. Your Solutions Consultant (Minh Biney) assured me that the web-tracking is now activated. But I still get the error response from the session endpoint: Session failed (tracking disabled) (app_token:bjm3rxxlm7eo) (platform:web).

Please help.

uerceg commented 2 years ago

Hi @alkismavridis

Can you retry again to send traffic from web SDK and let us know if it works for you or is the issue still present?

YaraMatkova commented 2 years ago

Hi Alkis!

Regarding your question. In the case when session request finished SDK doesn't send it again until session ended. Here is some information about sessions.

alkismavridis commented 2 years ago

@uerceg It works now, thanks. @YaroslavnaMatkova I see. Thanks!