They're both. They're selling a service to consumers, which they buy with their personal data. They then use that data to sell to advertisers in the form of better targeted ads.
They didn't even run ads for the first three years of their existence.
Are you saying they are bartering and not paying sales tax for their services and their customers personal data ?
I would argue that this is not totaly true. Everyone can advertise on Facebook (I did it myself without a company).