The contract carries an annual cap hit of $2.8 million.
Heinen, 24, had 11 goals and 34 points in 77 games last season. He added two goals and eight points in 24 post-season games.
The Langley, B.C. native was originally a fourth-round pick by the Bruins in 2014. He was a restricted free agent who was scheduled to have an arbitration hearing with the Bruins in August before this contract was signed.